dotnet / interactive

.NET Interactive combines the power of .NET with many other languages to create notebooks, REPLs, and embedded coding experiences. Share code, explore data, write, and learn across your apps in ways you couldn't before.
MIT License
2.9k stars 389 forks source link

Support Source Generators in Notebooks #1786

Open JasonBock opened 2 years ago

JasonBock commented 2 years ago

Is your feature request related to a problem? Please describe. It's not a problem, just something I'd like to see work in a notebook.

Describe the solution you'd like I noticed that if I reference a NuGet package in a notebook where that package contains source generators, the generators won't execute. Therefore, I can't use the package as intended. I'd like to be able to demo/document source generator packages using a notebook, so hopefully this will be supported in the future.

Note: @jonsequitur mentioned I should add this as an issue, so....here it is :)

Describe alternatives you've considered No alternatives.

LittleLittleCloud commented 1 year ago

Any update on this issue?

alexyakunin commented 1 week ago

Also curious.

jonsequitur commented 1 week ago

The compilation model for C# Script is different enough that source generators as currently designed won't work.

But at the same time, the use cases for source generation within a notebook might also be a little different as well. One example is generating classes from data in memory. The experimental #!linqify magic command (i.e. LINQ to CSV) offers one example.

Image

The code for this is actually pretty simple and might offer some ideas for a different approach to source generation.