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

Write CA1824 as non-compilation-end #6873

Merged
merged 2 commits into from
Oct 11, 2023

Conversation

Youssef1313
Copy link
Member

The intent of this change is two things:

  1. Avoid analyzing more attributes if we already found a matching attribute.
  2. Having this analyzer not be a compilation end analyzer.

@mavasani @sharwell Do you think it's worth changing this analyzer to not be non-compilation-end (which will make it available in IDE live diagnostics)?

Is there a better than what I did here?

@Youssef1313 Youssef1313 marked this pull request as ready for review August 20, 2023 09:52
@Youssef1313 Youssef1313 requested a review from a team as a code owner August 20, 2023 09:52
@codecov
Copy link

codecov bot commented Aug 20, 2023

Codecov Report

Merging #6873 (2073e40) into main (3587540) will increase coverage by 0.00%.
The diff coverage is 98.11%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6873   +/-   ##
=======================================
  Coverage   96.39%   96.39%           
=======================================
  Files        1403     1403           
  Lines      330977   331006   +29     
  Branches    10890    10892    +2     
=======================================
+ Hits       319055   319085   +30     
+ Misses       9188     9187    -1     
  Partials     2734     2734           

data.ApplicationSyntaxReference?.GetSyntax(context.CancellationToken) is { } attributeSyntax)
{
// we have the attribute but its doing it wrong.
context.ReportDiagnostic(attributeSyntax.CreateDiagnostic(Rule));
Copy link
Member

@sharwell sharwell Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❗ This diagnostic (the one with a specific location) should always be reported. It can set alreadyReportedDiagnostic to true, but it should not return without reporting if alreadyReportedDiagnostic was already true.

Edit: It cannot set alreadyReportedDiagnostic to true because it would destabilize the no-location reporting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diagnostic with location will always be reported if we find a source assembly attribute here, otherwise a no-location diagnostic will always be reported - I believe the logic here is deterministic because data is computed at CompilationStart and does not alter during subsequent callbacks.

@mavasani
Copy link
Contributor

mavasani commented Oct 3, 2023

@sharwell I can merge once you are happy with the PR, thanks!

@mavasani
Copy link
Contributor

Merging this PR - feel free to create a follow-up PR for any follow-up changes.

@mavasani mavasani merged commit 35bb41b into dotnet:main Oct 11, 2023
11 checks passed
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.

3 participants