-
Notifications
You must be signed in to change notification settings - Fork 226
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
Make UtilityAnalyzerBase stateless by removing properties #6902
Make UtilityAnalyzerBase stateless by removing properties #6902
Conversation
protected bool IsAnalyzerEnabled { get; set; } | ||
protected bool IgnoreHeaderComments { get; set; } | ||
protected virtual bool AnalyzeGeneratedCode { get; set; } | ||
protected virtual bool AnalyzeTestProjects => true; | ||
protected string OutPath { get; set; } | ||
protected bool IsTestProject { get; set; } | ||
protected override bool EnableConcurrentExecution => false; |
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.
Like with the OutPath
property, the mutable state is the root cause that prevents ConcurrentExecution (to be fair: ConcurrentExecution would also work without this change, but it is tough to see why that is the case. With this change, it is evident that it works, and it is no longer possible to break it).
The PR moves the state into its own type, which is now captured in RegisterCompilationStartAction
for the compilation. The new Parameters struct is readonly
now and passed to all methods that need it to make decisions.
f6f146e
to
9cd9199
Compare
This is slowly getting out of sync. I suggest to close this and link it to the issue so the ideas can be reused once it will be actively worked on. |
fe11931
to
2fb6add
Compare
2fb6add
to
1eff4f2
Compare
1eff4f2
to
2807592
Compare
There is also
Concurrent collections: click here |
350813c
to
1283458
Compare
85a78f4
to
d9589fd
Compare
We need to open a cleanup issue for this PR because the |
Kudos, SonarCloud Quality Gate passed! |
Kudos, SonarCloud Quality Gate passed! |
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.
LGTM!
Pre-condition for #6674
Analyzer should be stateless. This PR removes the properties from UtilityAnalyzerBase and captures them in
RegisterCompilationStartAction
per compilation.After this change,
EnableConcurrentExecution
can be set to true (and alsovar treeMessages = new List<TMessage>();
needs to be changed tovar treeMessages = new ConcurrentStack<TMessage>();
of course).