2

One thing I really love about languages such as Python is that if you have a piece of code you'd like to try out, you can just open the interactive shell and do it in seconds.

Is there a Visual Studio add-in that does the same for C#?

Basically what I'm looking for is something that opens up a window or tab with a text editor (preferably with code completion, because VS does it so nicely) and a button that runs the code and displays the output. Extra points for convenience features such as displaying complex output in a user-friendly way (think Firebug's console.log), automatically referencing all the assemblies the current project references, etc.

I tried googling for a while, but either I fail at coming up with good keywords, or no-one has made an add-in like this. If there really is none, I'm considering making one myself.

Matti Virkkunen
  • 63,558
  • 9
  • 127
  • 159

3 Answers3

4

LinqPad will execute C# snippets as well as LINQ. Nice except that autocompletion is not included in the free version. Of course you can write statements in VS with autocompletion, then copy/paste them into Linqpad.

Joe
  • 122,218
  • 32
  • 205
  • 338
3

I don't know about an add-in for VS but anytime I want to try something quickly (and don't want to fire up VS and create a console app) I use Snippet Compiler. It gets the job done as far as quickly testing methods and what not. I usually use it for things like testing a regex or trying out random datetime formatters. You can add references to other assemblies and it does provide some degree of intellisense.

Matt Dearing
  • 9,286
  • 1
  • 23
  • 25
  • This looks very promising. I might even be able to semi-integrate this into VS by creating a macro that launches it with some parameters for references etc, if it supports it. Hold on while I give it a spin. – Matti Virkkunen May 14 '10 at 21:00
  • I guess this is the closest I can get without writing a whole VS add-in. Even though it's not exactly what I was looking for, it's pretty close, and I can always write that macro I thought about. Thanks! – Matti Virkkunen May 14 '10 at 21:24
1

I have a test.vcproj project sitting around with a test.cpp file which I paste code into. It's the best I could come up with.

sbi
  • 219,715
  • 46
  • 258
  • 445
  • same here. Another method, somewhat quicker but less versatile is a commandline compile; I have a few bat files like 'compile_and_run.bat' taking a single file as argument. – stijn May 14 '10 at 21:14