-
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
Expose IsGeneratedCode boolean property on diagnostic analyzer contexts #63447
Conversation
Closes dotnet#7578 Based on the recent feature requests in allowing more fine grained generated code analysis, we have decided to initially expose a boolean IsGeneratedCode property on each of the analysis contexts. Note that this flag indicates if the callback symbol/node/operation/tree is considered generated code or not based on compiler's internal heuristics for analyzer execution. This flag helps the analyzers that only want to analyze certain kinds of generated code to narrow down their custom fine grained generated code analysis to only those callbacks that have this flag set to true.
In the Razor scenario, you might have "generated platform code" and "generated code from user code" in the same method, right? Something like: <h1>@MyMethod()</h1> might turn into (extreme pseudocode, sorry if I've totally botched what Razor actually does) void RenderTemplate()
{
#line hidden
Render("<h1>");
#line 1,5 Index.cshtml
Model.MyMethod();
#line hidden
Render("</h1>");
} This kind of thing is not handled in this PR, right? Is there any expectation to handle it eventually? |
Yes, that is correct. This PR is not changing semantics, just exposing a public API for an existing |
@dotnet/roslyn-compiler for another review |
@dotnet/roslyn-compiler for second review |
1 similar comment
@dotnet/roslyn-compiler for second review |
Merging this PR as the underlying public API has been approved by the compiler team in #7578 (comment). I'll address any further feedback with a follow-up PR. |
Closes #7578
Based on the recent feature requests in allowing more fine grained generated code analysis, we have decided to initially expose a boolean IsGeneratedCode property on each of the analysis contexts. Note that this flag indicates if the callback symbol/node/operation/tree is considered generated code or not based on compiler's internal heuristics for analyzer execution. This flag helps the analyzers that only want to analyze certain kinds of generated code to narrow down their custom fine grained generated code analysis to only those callbacks that have this flag set to true.