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

Ensure that we register to analyze generated code for MakeFieldReadO… #52726

Merged
merged 2 commits into from
Apr 19, 2021

Conversation

mavasani
Copy link
Contributor

…nly analyzer

Fixes #50925
Note that we only pass in the Analyze flag, not the ReportDiagnostics flag, so that fields defined in generated code are not flagged.

…nly analyzer

Fixes dotnet#50925
Note that we only pass in the `Analyze` flag, not the `ReportDiagnostics` flag, so that fields defined in generated code are not flagged.
@mavasani mavasani requested a review from a team April 19, 2021 09:14
@mavasani mavasani changed the title Ensure that we register to analyzer generated code for MakeFieldReadO… Ensure that we register to analyze generated code for MakeFieldReadO… Apr 19, 2021
@@ -65,10 +65,12 @@ protected AbstractBuiltInCodeStyleDiagnosticAnalyzer(ImmutableArray<DiagnosticDe
customTags: DiagnosticCustomTags.Create(isUnnecessary, isConfigurable, enforceOnBuild));
#pragma warning restore RS0030 // Do not used banned APIs

// Code style analyzers should not run on generated code, unless explicitly required by the analyzer.
Copy link
Member

Choose a reason for hiding this comment

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

Might be better as a doc comment. Probably also extend the statement to say it should either be None or Analyze, but not ReportDiagnostic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably also extend the statement to say it should either be None or Analyze, but not ReportDiagnostic?

Hmm, I did not want to be so pedantic given we may have some analyzer that also wants to report on generated code? I can actually make this simple by just making this a bool property though, which may make the purpose more explicit.

@mavasani mavasani enabled auto-merge April 19, 2021 11:27
@mavasani mavasani merged commit 3fd808a into dotnet:main Apr 19, 2021
@ghost ghost added this to the Next milestone Apr 19, 2021
@mavasani mavasani deleted the FixGeneratedCodeIssue branch April 19, 2021 19:28
@dibarbet dibarbet modified the milestones: Next, 16.10.P3 Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IDE0044 suggests making field readonly when generated code writes to it
5 participants