Closed PawelGerr closed 1 year ago
From your description, it's not clear that there is a compiler issue as opposed to an issue somewhere else.
I suggest you build with the binary log options (-bl
) and confirm whether the correct files are passed to the compiler. If they are but the compiler is not processing them correctly then feel free to re-open this issue.
I'd same issue here. People on c# discord said you must use Testing to develop source generators to do not keep first generation even if you build it again. Otherwise you will need reload VS.
Does it a bug, or a feature? I thought every time you do build the source generator restart, and do the new build, not the first one.
Since 7.0.200 the CLI behaves incorrect on build (
dotnet build --no-incremental --force
). If the source generator is referenced via project reference by another (console) project then CLI seem to keep using the source generator from the very first build. I can change the code generation as often as I want but the changes are not reflected in the generated code. Even if I delete obj and bin folders, still, the thedotnet build --no-incremental --force
doesn't pick up the current state of the source generator.If I lock the SDK with global.json to 7.0.103 or 7.0.104, then everything is working correctly.
Does the build server (.NET Host), which keeps running in the background after a build, caches the source generator and doesn't invalidate the cache? If I kill the host, then a rebuild works as expected, once.
Version Used: Issue arises when building with SDKs 7.0.200 and 7.0.202. No issues with older versions and with 7.0.103 and 7.0.104
I was able to reproduce the issue on 2 different machines (win-10 x64). One of them was a non-dev PC, so it wasn't poluted with SDKs and stuff like mine.
Steps to Reproduce
Project 1
SourceGen.csproj
DemoSourceGenerator.cs
Project 2
ConsoleApp.csproj
Program.cs
dotnet build
. There should be no errors.public class Test
butpublic class Test2
.dotnet build --no-incremental --force
Expected Behavior: The compiler raises an error in Program.cs because there is no class
new Test();
Actual Behavior: No error