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

Incremental Generators documentation is missing information about project setup (and more) #75798

Open
samtun opened this issue Nov 7, 2024 · 0 comments
Labels
Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@samtun
Copy link

samtun commented Nov 7, 2024

I was searching the web for SourceGenerators and came across the Incremental Generators which seem to replace the SourceGenerators.

https://github.com/dotnet/roslyn/blob/main/docs/features/incremental-generators.md
https://github.com/dotnet/roslyn/blob/main/docs/features/incremental-generators.cookbook.md

I found it exceedingly hard to create a working generator project with a consumer project that uses the generated code in VS. Thinking of developers that have not yet worked with generators before I guess the main problem is that this documentation only provides information about the in depth logic that can be used once a generator is all setup (Pipeline, IncrementalValuesProvider, creating a NuGet package, ...), but it misses the important part of how to actually setup the project for the generator and how to reference the generator project in a consumer project to use the generated code.

I would love to see the documentation to be accessible for new developers that have not worked with SourceGenerators / have no prior knowledge on the subject.

Information I'd like to see to improve this:

  • How should the Generator csproj look like?
  • What's the minimum of properties and references I need?
  • How do I reference the project correctly in my consumer project?
  • How can I debug my generator?

Information sources that can help improve the documentation:

VS needs to be restarted when generating code

I found multiple issues that gave me ideas on what might be the issue. Looks like VS has a pretty long standing issue with generated code.
#49249 #48083
After this ordeal I tried the same project in Rider and it does not have any of these issues. Would be great to have a sentence in the documentation about restarting VS after generating code until that issue is fixed.

A comment on an issue currently is the best "getting started" documentation

After reading a lot of issues and blogs online I also found this comment in one of the previously mentioned issues: #49249 (comment) which was the best source for the kind of information I was lacking and I'd strongly recommend including most, if not all of this information in the documentation,

A random text on github is the documentation for debugging a generator

Also regarding debugging the generator I randomly found this text on github which works wonderfully https://github.com/JoanComasFdz/dotnet-how-to-debug-source-generator-vs2022 - which I also propose to include in the documentation somehow.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

1 participant