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.96k stars 4.02k forks source link

Clicking 'rerun generator' prevent future edits into the regular text buffer. #74032

Open stephentoub opened 3 months ago

stephentoub commented 3 months ago

Roslyn recently switched to using "balanced" for source generators, which means it only runs source generators on save/build. This is bad for both developers working on source generators and developers demo'ing source generators, which frequently involves having the dynamically generated source open in a window:

Image

"balanced" should factor in whether such a window is open and ensure that generator is run. Very few developers not in these scenarios will have such windows open (and if they do and they hit perf issues, the workaround is easy: don't do that), and "balanced" is a terrible default for these scenarios.

stephentoub commented 3 months ago

Oh, and in the above example, after I press "Rerun generator", I'm no longer able to edit the source on the left in Program.cs... attempts to type in that window are just ignored.

Version 17.11.0 Preview 3.0 [35009.13.main]

CyrusNajmabadi commented 3 months ago

Duple of https://github.com/dotnet/roslyn/issues/74031. I beat you by one minute :)

CyrusNajmabadi commented 3 months ago

Note; workround for demo'ers currently is to switch to automatic mode here:

image

Def interested in this idea. Will roll this and other feedback we get here into tweaks around what counts as 'balanced'.

Note (@arkalyanms) this is why its' good it's not called "manual", as this is a demonstration of how it's much more about a heuristic on what cadence to run these. Not explicitly in response to a user explicitly invoking it.

stephentoub commented 3 months ago

Duple of #74031. I beat you by one minute :)

What about this part? https://github.com/dotnet/roslyn/issues/74032#issuecomment-2174008558

CyrusNajmabadi commented 3 months ago

reactivating to use this issue to track that broken behavior. We'll have two issues on this. The strict bug about focus/editing capture. And the request for better 'balanced' behavior.

JakeYallop commented 3 months ago

@CyrusNajmabadi - Should this issue still be closed? I've just ran into this issue myself, based on the conversation above it seems like it has been left closed by mistake.

CyrusNajmabadi commented 3 months ago

Weird. I thought this was reactivated. Have been having issues with the app not persisting changes