-
Notifications
You must be signed in to change notification settings - Fork 45
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
Misc improvements #270
base: master
Are you sure you want to change the base?
Misc improvements #270
Conversation
if (ReportDiagnosticsOnGeneratedCode) | ||
{ | ||
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Analyze | ReportDiagnostics is already the default. So, currently ReportDiagnosticsOnGeneratedCode
is broken. This wasn't observed because there are actually no analyzers that overrides this property to return false. So, it was always true.
I would love to get the understanding of the rationale of the change before accepting a refactoring. |
And TBH misc refactorings with 13 changed files and no description is not really friendly PR to accept :) |
@SergeyTeplyakov Yes, sorry. It is related to this comment (#266 (comment)) Let me know if you want me to expand more than that |
{ | ||
if (returnType == null) | ||
{ | ||
return false; | ||
} | ||
|
||
var (taskType, taskOfTType, valueTaskOfTType) = GetTaskTypes(compilation); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code path was repeatedly called, and GetTaskTypes
would call compilation.GetTypeByMetadataName
. For performance, it's recommended to do this call once, in compilation start (i.e, using RegisterCompilationStartAction
).
So, instead of passing Compilation
here, the symbols calculated in compilation start should be passed. Then, I needed to "group" all task symbols in TaskTypesInfo
instead of passing multiple parameters here.
var compilation = context.Compilation; | ||
|
||
var configureAwaitConfig = ConfigureAwaitConfiguration.TryGetConfigureAwait(context.Compilation); | ||
if (configureAwaitConfig != ConfigureAwait.UseConfigureAwaitFalse) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All callbacks are checking for this. So, we can actually check it once in compilation start, and not register any action at all when not needed.
|
||
var yieldAwaitable = compilation.GetTypeByMetadataName(typeof(YieldAwaitable).FullName); | ||
|
||
context.RegisterOperationAction(context => AnalyzeAwaitOperation(context, configureAwaitMethods, yieldAwaitable), OperationKind.Await); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched from syntax to operation.
At the end, GetOperation
is called anyways.
No description provided.