dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.99k stars 4.03k forks source link

Turn the C# interactive window into a complete playground #51480

Open vsfeedback opened 3 years ago

vsfeedback commented 3 years ago

This issue has been moved from a ticket on Developer Community.


Migrated from Visual Studio IDE UserVoice forum

I recently found out about the C# interactive window, which is a very nice tool to test and run small code blocks (like LINQPad). One of the nuisances of C# is it's rigidity when it comes to running/debugging small pieces of code. The interactive window solves this partially with the functionality "Initialize interactive with project". My question is "Can the C# interactive window be turned into a complete playground?".

This means that: -The interactive window can also immediately debug the code you are running -Running the code via the interactive window will also execute the complete build process (optionally) e.g. JSON setting files are also copied to the output directory and are also being read -The "Initialize Interactive with Project" also should load the config file

If this is implemented, the C# interactive window should be more visible and get a more prominent role in Visual studio. If this is all possible, I think using and playing around C# will become way more attractive. The IDE will become way more dynamic, flexible and easy to debug.


Original Comments

Fiona Niu[MSFT] on 10/15/2018, 02:09 AM:

Thank you for taking the time to provide your suggestion. We will do some preliminary checks to make sure we can proceed further. You will hear from us in about five business days on our next steps.

Kendra Havens [MSFT] on 10/31/2018, 10:17 AM:

Your suggestion has been queued up for prioritization. Feature suggestions are prioritized based on the value to our broader developer community and the product roadmap. We may not be able to pursue this one immediately, but we will continue to monitor it up to 90 days for community input.

André Silva de Jesus on 10/15/2019, 00:49 PM:

The C# Interactive Window is definitely in need of some work. It's still using .NET Framework instead of Core, which is absurd; it doesn't support interruption of execution, so if you do something that ends up looping forever, you'll have to restart the IDE, which is absurd again; it still doesn't support nuget; it doesn't support unloading of references; the add reference auto-complete has some issues.

All these need addressing, however this window has seen low to none work from the team since it was first created.

Liam Corrigan on 1/23/2020, 01:22 PM:

Probably a not a great sign when Microsoft Product Managers blog how awesome .NET (Core) is in Jupyter instead of Visual Studio 2019 for interactive/script development. Instead of finding a Visual Studio road map that spoke of C# interactive, I found this: net-core-with-juypter-notebooks

I love Jupyter, but really need a full IDE with Interactive support and using VSCode is not an option for our group.

Jack Bowley on 8/21/2020, 01:19 PM:

Just want to add some support for this. Appreciate there are likely good reasons, but it's a bit galling to have the ability to interactively debug typescript in visual studio code but not c# in visual studio. Even the ability to interactively query objects already visible in autos and locals would improve experience significantly.

Matthew Puglisi on 8/27/2020, 01:23 PM:

Great News! They already have it! The Immediate window is intended for use in the context of a debugging session only. You need to use the "C# Interactive" window for this Python REPL (Read Evaluation Print Loop)-like experience. You'll find it under View / Other Windows / C# Interactive (near the bottom). Cheers! :D

C# Interactive Menu Item

C# Interactive Window

P.S. Don't judge me for my orange cursor. ;P

Jack Bowley on 8/27/2020, 01:45 PM:

I hope I'm missing something but there is no way to stop at a break-point and the interact with the objects shown in autos or locals using C# interactive. I can see the #r & #load functions but don't think they'll do what i'm describing. Here's a https://stackoverflow.com/questions/7898123/getting-debugger-context-in-c-sharp-interactive

However, I've just found out I can use the immediate window for mostly what i'm after. Well I never...

Matthew Puglisi on 8/27/2020, 03:12 PM:

Oh I'm terribly sorry, I seem to have misunderstood your question. Still not sure I completely understand, and yes the Immediate Window is probably what you're after, but the problem with that is that the debug symbols are only available at runtime. Although, since those symbols are compiled into a pdb file, I suppose it might be theoretically possible to get what you want? Bah, I'm out of my depth here so I'll let the experts speak on that, haha. Cheers!

Franklin Lee on 11/23/2020, 05:04 PM:

After loading the project in Interactive, go to Debug > "Attach to Process", and attach to "InteractiveHost.exe". I was able to set a breakpoint in the editor and have it break during an Interactive command.

Source: https://stackoverflow.com/a/43106951

Sam King on 1/25/2021, 00:19 PM:

Franklin Lee How sad is that that the tool is already capable of working with the debugger but Microsoft has not been willing to take the tiny amount of effort it to do it automatically for all these years?

shaggygi commented 3 years ago

I really hope this will be added as I've asked for this many years. Hope to have the ability to debug and add NuGet packages.

JakeRadMSFT commented 3 years ago

Hey All! You can now try out the Notebook Editor Preview in Visual Studio!

Blog Post: https://devblogs.microsoft.com/dotnet/ml-net-and-model-builder-october-updates/ Install: https://marketplace.visualstudio.com/items?itemName=MLNET.notebook

shaggygi commented 3 years ago

Thanks @JakeRadMSFT. Installing and trying now. One thing I noticed is the links are a little confusing. It appears the blog and the Notebook extension are related to ML.NET. However, the notebook (similar to C# Interactive) should be a generic "playground" and not really specific to ML.NET... that's what made the beginnings of C# Interactive so great.

I have a question/issue to ask soon about how to do something in the notebook. The link at the bottom of the Notebook extension routes you to the machine-learning repo. Do we need to create issues in that repo or is there another one we should be using?

Thanks again for the heads up on related links/news from this week. 👍

JakeRadMSFT commented 3 years ago

"However, the notebook (similar to C# Interactive) should be a generic "playground" and not really specific to ML.NET... that's what made the beginnings of C# Interactive so great."

@shaggygi Totally! It is a generic playground. Let us know how you want to use a playground and if the Notebook Editor is missing anything! It's been designed generically but the feature of automatically generating notebooks from ML.NET Model Builder and being able to open them in Visual Studio is our first/primary user story for our 0.1.0 version of the Notebook Editor.

We're still figuring out where issues will live but for now we're happy to take any feedback/issues in the machine learning repo.

shaggygi commented 3 years ago

Thanks @JakeRadMSFT Created an issue here.

MgSam commented 2 years ago

Notebook support is nice, but I don't think it's a replacement whatsoever for what C# Interactive should be. C# Interactive needs:

These seem trivial to do, as the functionality already exists. It seems like it's simply a matter of wiring up defaults in Visual Studio.

jonsequitur commented 2 years ago

.NET Interactive also supports building REPLs and there's been some discussion of taking the capabilities in notebooks (visualizations, NuGet support, remotability, extensibility, support for other languages like SQL and JavaScript) and using these to enhance the C# Interactive and F# Interactive windows. You can try out an experiment in what that might look like with dotnet-repl.

An open issue to discuss stronger project integration for .NET Interactive (which would apply to both REPL and notebook form factors) is here: https://github.com/dotnet/interactive/issues/890.

amine-aboufirass commented 1 year ago

@jonsequitur that discussion mentions nothing about attaching a dotnet interactive window to a visual studio debugging session. Has there been any progress on that? It seems this is a highly desirable feature