Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source generator does not work in .Net 8 #310

Open
plavoie-nms opened this issue Feb 6, 2024 · 1 comment
Open

Source generator does not work in .Net 8 #310

plavoie-nms opened this issue Feb 6, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@plavoie-nms
Copy link

Can't make the source generator works with my project. So, I downloaded the sources of refitter, opened the test solution, updated the NuGet packages, unloaded all the projects other than Net8, deleted the Generated folder, built the project and nothing, the project does not compile because the generated classes are not there. If I try the same thing with Net7, the classes are generated. There is zero output from the source generator.

@plavoie-nms plavoie-nms added the bug Something isn't working label Feb 6, 2024
@christianhelle
Copy link
Owner

@plavoie-nms Thanks for taking the time to report this and the investigative steps you have taken.

I use this primarily for .NET 8.0 projects and have it running on several systems. I'm running on against v0.9.6

The source generator is a bit limited in the sense that it generates physical files so if there are any dependencies on those files in the project then the build will fail, the first time around. After building once, the generated files should appear and the build should work again

I just tested this with building using the .NET CLI and also from Visual Studio 2022. Visual Studio 2022 has a bit of magic to it as it can detect changes to the file and will execute the source generator in the background.

have you tried shutting down the .NET Build Servers -> dotnet build-server shutdown? I found this to be a necessary trick when developing source generators. I ran into situations now and then where the source generator just stopped working, and it wouldn't work again until I shut down the .NET Build Servers

SourceGenerator.-.Visual.Studio.Code.2024-02-06.21-57-24.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants