-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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 generated syntax trees should report IsGenerated #49326
Comments
Will this impact the way the compiler raises diagnostics for generated code? I can imagine there are a set of compiler checks we'd want to be ignored for generated code to simplify code-generators (eg: style analyzers) where there are others that we would want to be honored (obsolete, nullable annotations). cc @AaronRobinsonMSFT |
Each analyzer can choose whether it needs to analyze generated code or not via the roslyn/src/Compilers/Core/Portable/DiagnosticAnalyzer/DiagnosticAnalysisContext.cs Lines 214 to 219 in f52afd9
Today all analyzers that come with the SDK that are required for code correctness (for example security analyzers) look at generated code. |
💭 It seems desirable to continue requiring source generators to emit the |
Looking at dotnet/runtime#53275, the change is appending the How many different ways are source generators supposed to mark their files as "generated"? So far I see:
What are the recommendations for |
@sharwell Is the following the appropriate way to add the comment? SyntaxFactory.Comment("<auto-generated/>").ToString() |
@AaronRobinsonMSFT |
@chsienki can you fill out the API proposal template for this? |
Added #56810 to track the API |
We should add
GeneratedKind.SourceGenerator
and have any syntax trees added by a generator return this value.We should also update the original
bool
version of the property to report true for this value.The text was updated successfully, but these errors were encountered: