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

Misc improvements #270

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Youssef1313
Copy link
Contributor

No description provided.

Comment on lines -37 to -40
if (ReportDiagnosticsOnGeneratedCode)
{
context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics);
}
Copy link
Contributor Author

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.

@SergeyTeplyakov
Copy link
Owner

I would love to get the understanding of the rationale of the change before accepting a refactoring.

@SergeyTeplyakov
Copy link
Owner

And TBH misc refactorings with 13 changed files and no description is not really friendly PR to accept :)

@Youssef1313
Copy link
Contributor Author

@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);
Copy link
Contributor Author

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)
Copy link
Contributor Author

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);
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants