[HN Gopher] CSharpRepl: C# REPL with syntax highlighting and int...
___________________________________________________________________
CSharpRepl: C# REPL with syntax highlighting and intellisense
Author : aragonite
Score : 114 points
Date : 2024-05-23 21:47 UTC (1 days ago)
(HTM) web link (fuqua.io)
(TXT) w3m dump (fuqua.io)
| waldrews wrote:
| How does it compare with LinqPad, polyglot notebooks, csi.exe?
| aragonite wrote:
| The author has some comments on this on GitHub:
|
| https://github.com/waf/CSharpRepl?tab=readme-ov-file#compari...
|
| Even though it's not as feature-rich as linqpad's Dump()
| method, personally I find the ability to pretty print any
| object ("detailed view"[1]) by pressing ctrl+enter really
| convenient. E.g. try typing in new
| Uri("https://news.ycombinator.com")
|
| (without semicolon), then pressing ctrl+enter.
|
| [1] https://github.com/waf/CSharpRepl?tab=readme-ov-
| file#:~:text...
| ammo1662 wrote:
| There is an alternative of LinqPad. It does not have a lot of
| features, but it is good enough for testing code snippets.
|
| https://github.com/roslynpad/roslynpad
| xnorswap wrote:
| When it comes to C# REPLs I absolutely adore LinqPad, although
| recently it's felt like I've had to buy licenses for it
| increasingly often which I've found annoying.
|
| If any other REPL can get to a point where it can rival LinqPad
| in functionality then it'll be an absolute winner.
|
| The key features linqpad has that I'd need from any
| replacement:
|
| * Securely store secrets
|
| Util.GetPassword prompts the user for the password if it's not
| in it's store. Leverages the windows user credential store.
|
| * Keeps the process running
|
| This is absolutely key, it keeps alive the process even after
| the script has finished, so you can easily attach a debugger /
| profiler to it when the script isn't running, then start the
| script again. It also means you can use
| AppDomain.CurrentDomain.SetData to cache expensive setup if
| you're trying to profile something.
|
| * Quickly switch between expression / statements / program mode
|
| It'll intelligently work out if you've written a single
| expression vs multi-line statements, and you can switch to
| "program" and it'll wrap what you've done so far in a Main
| stub.
|
| * Easily define default App.Config files, default namespaces,
| default nuget packages.
|
| After finally getting a fiddly setup working, there's a "Use as
| default for new queries" button which is very convenient. Also
| the "clone query" functionality is similarly useful for copying
| not just the C# text but all the background namespace
| declarations, references, config, etc.
|
| And that's about it. I barely use the database connection and
| exploration side, but I do use it daily for hooking into DLLs
| to quickly test changes to our internal projects.
| stanac wrote:
| RoslynPad support user input with `Console.ReadLine()`, but
| that's about it. For me personally it does everything I need
| for scripting C#. For anything more serous I usually create
| full program and a bat/sh file to execute it in a
| conveniently.
| hnrodey wrote:
| Great to see LINQPad getting some love. Wish it had a fully
| functional trial so outsiders can see the real thing before
| paying. Otherwise, the free version is crippled and boring.
|
| Made this video to show LINQPad and getting OAuth tokens from
| the Spotify api.
|
| https://www.youtube.com/watch?v=g2C1SXfTHXI&t=30s
| pjmlp wrote:
| Looks quite nice, specially since VSCode lacks interactive panes.
| jayd16 wrote:
| I think you can run C# in the debug console while debugging, at
| least.
| groone wrote:
| VSCode has plugin for polyglot notebooks
| https://code.visualstudio.com/docs/languages/polyglot
| classified wrote:
| Is it capable of UTF-8? I couldn't for the life of me get the F#
| REPL to read UTF-8.
| Pathogen-David wrote:
| It doesn't change the output encoding by default, but if you
| manually set it to UTF8 it works. (IE: Console.OutputEncoding =
| System.Text.Encoding.UTF8;)
|
| That might be all you need to fix the F# REPL too.
| yau8edq12i wrote:
| What do you mean? With dotnet fsi? I just tried it and it reads
| UTF8 just fine, at least in windows terminal.
| aragonite wrote:
| If you mean problems having to do with assigning "..."u8 UTF-8
| string literals to variables, there's this workaround:
|
| https://github.com/waf/CSharpRepl/issues/318#issuecomment-21...
| DeathArrow wrote:
| There's also LinqPad.
| dgan wrote:
| Can't stop reading it as "shrapnel", especially with
| "intellisense" just below
| spicyusername wrote:
| I just started learning C# while tinkering with Monogame.
|
| It's a really nice language to use, I'm quite surprised.
| pjc50 wrote:
| C# is an absolutely excellent language, and continues to
| gradually improve.
|
| Because I had to check this myself: Monogame is not tied to
| mono! It claims to support dotnet 8, so it looks suitably
| current and maintained.
|
| It is annoying that Microsoft had their own perfectly adequate
| game framework which they binned at one of the transitions
| https://en.wikipedia.org/wiki/Microsoft_XNA
| ClimaxGravely wrote:
| monogame is pretty much the continuation of XNA although they
| have added more stuff.
|
| There is another framework called FNA that I've not used
| personally but I've heard it tries to match XNA exactly while
| monogame is a bit more forward looking. So FNA is good for
| porting forward your older XNA games.
| utensil4778 wrote:
| C# was my first language so I am biased, but it continues to be
| my favorite language out of any I've tried.
| doodpants wrote:
| As someone who first learned to program in the early 80's, C#
| is far from my first language. But it is my favorite as well!
| hoofedear wrote:
| C# is really an awesome language, it's come such a long way. I
| know it used to be a pain and not very cross-platform friendly,
| but nowadays it's a dream. Shoutout to Rider as the best IDE
| for it lol
| tiptup300 wrote:
| I've done C# for a while and I really love what can be done
| with DI & reflection for cool cross cutting abilities.
|
| I want to branch out to native stuff like C++ & Rust for memory
| management stuff, but they don't seem to come close in terms of
| the reflection abilities or probably the function is there, but
| just a nightmare to work with.
|
| Anybody have any thoughts/opinions?
| mhh__ wrote:
| The core is very good, the OOP aspects can be really quite
| poor.
|
| Let me write a function without 50 tokens of boilerplate!
| jayd16 wrote:
| You just need to put them in a static class to act as a name
| space. What is the big deal?
| metaltyphoon wrote:
| Love C# but public static implicit operator
| ClassA(ClassB b)
|
| Is very verbose. There are probably worse offenders. C#
| devs also love to add access modifiers even when its not
| needed. For example, private for anything that is meant to
| be private or the suffix `Async` even though you don't have
| a sync version of a method.
| jayd16 wrote:
| The private keyword is needed because the default access
| is public to the same assembly. Usually that's very
| different from private.
|
| As for the implicit cast, two extra tokens in an uncommon
| case doesn't seem so bad when you consider all the nice
| common things like var, the lambda syntax, initializers,
| pattern matching, LINQ, delegates, etc. etc.
| neonsunset wrote:
| Default visibility for type members is private, default
| visibility for no-nested types is internal.
|
| The comment tries to make a strawman as you don't define
| implicit cast operators that often, its length is just
| fine.
| mhh__ wrote:
| 1. It's very long winded.
|
| 2. It encourages everyone to think about nouns rather
| verbs.
| neonsunset wrote:
| Can you make an example of "poor"?
| munchler wrote:
| Give F# a try as well if you have some time. It's even better,
| and can do anything C# can do!
___________________________________________________________________
(page generated 2024-05-24 23:02 UTC)