-
Notifications
You must be signed in to change notification settings - Fork 468
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
Add MakeTypesInternalAnalyzer #6820
Conversation
Codecov Report
@@ Coverage Diff @@
## main #6820 +/- ##
========================================
Coverage 96.42% 96.43%
========================================
Files 1401 1408 +7
Lines 334973 335687 +714
Branches 11072 11081 +9
========================================
+ Hits 322997 323704 +707
- Misses 9193 9198 +5
- Partials 2783 2785 +2 |
src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/MakeTypesInternal.cs
Outdated
Show resolved
Hide resolved
compilationStartContext.RegisterSyntaxNodeAction(AnalyzeTypeDeclaration, TypeKinds); | ||
compilationStartContext.RegisterSyntaxNodeAction(AnalyzeEnumDeclaration, EnumKind); |
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.
delegate declaration as well?
...NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/MakeTypesInternal.Fixer.cs
Outdated
Show resolved
Hide resolved
@Youssef1313 I have addressed your feedback. |
LGTM from a quick glance. One suggestion: Analyzers that operate/bail out based on project output kind should probably be configurable to allow end users to override the applicable output kinds, we added such an option for CA2007: https://github.com/dotnet/roslyn-analyzers/blob/main/docs/Analyzer%20Configuration.md#analyzed-output-kinds |
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.
Thank you @CollinAlpert, left a few comments, overall looks good.
...zers/CSharp/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpMakeTypesInternal.Fixer.cs
Outdated
Show resolved
Hide resolved
...zers/CSharp/Microsoft.CodeQuality.Analyzers/Maintainability/CSharpMakeTypesInternal.Fixer.cs
Outdated
Show resolved
Hide resolved
...etAnalyzers/Core/Microsoft.CodeQuality.Analyzers/MicrosoftCodeQualityAnalyzersResources.resx
Outdated
Show resolved
Hide resolved
...etAnalyzers/Core/Microsoft.CodeQuality.Analyzers/MicrosoftCodeQualityAnalyzersResources.resx
Outdated
Show resolved
Hide resolved
...etAnalyzers/Core/Microsoft.CodeQuality.Analyzers/MicrosoftCodeQualityAnalyzersResources.resx
Outdated
Show resolved
Hide resolved
...etAnalyzers/Core/Microsoft.CodeQuality.Analyzers/MicrosoftCodeQualityAnalyzersResources.resx
Outdated
Show resolved
Hide resolved
...nalyzers/UnitTests/Microsoft.CodeQuality.Analyzers/Maintainability/MakeTypesInternalTests.cs
Show resolved
Hide resolved
# Conflicts: # src/NetAnalyzers/Core/AnalyzerReleases.Unshipped.md # src/NetAnalyzers/Microsoft.CodeAnalysis.NetAnalyzers.md # src/NetAnalyzers/RulesMissingDocumentation.md
src/NetAnalyzers/Core/Microsoft.CodeQuality.Analyzers/Maintainability/MakeTypesInternal.cs
Outdated
Show resolved
Hide resolved
SyntaxTree? firstSyntaxTree; | ||
if (compilation.Options.OutputKind is not (OutputKind.ConsoleApplication or OutputKind.WindowsApplication or OutputKind.WindowsRuntimeApplication) | ||
|| (firstSyntaxTree = context.Compilation.SyntaxTrees.FirstOrDefault()) is null | ||
|| !context.Options.GetOutputKindsOption(Rule, firstSyntaxTree, compilation).Contains(compilation.Options.OutputKind)) |
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.
Thanks for making OutputKind configurable, though looks with the current logic only OutputKind.ConsoleApplication, OutputKind.WindowsApplication or OutputKind.WindowsRuntimeApplication
are configurable, there is no way to enable the rule for OutputKind.DynamicallyLinkedLibrary
. I think if it is giving an option to configure, all should be configurable, what you think @CollinAlpert @stephentoub?
Also please add the rule into Configurable Rules
list in https://github.com/dotnet/roslyn-analyzers/blob/main/docs/Analyzer%20Configuration.md#analyzed-output-kinds
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.
I agree, it is better to make all OutputKind
s configurable.
...etAnalyzers/Core/Microsoft.CodeQuality.Analyzers/MicrosoftCodeQualityAnalyzersResources.resx
Outdated
Show resolved
Hide resolved
...etAnalyzers/Core/Microsoft.CodeQuality.Analyzers/MicrosoftCodeQualityAnalyzersResources.resx
Outdated
Show resolved
Hide resolved
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.
I left a couple suggestions for the resource file.
...etAnalyzers/Core/Microsoft.CodeQuality.Analyzers/MicrosoftCodeQualityAnalyzersResources.resx
Outdated
Show resolved
Hide resolved
...etAnalyzers/Core/Microsoft.CodeQuality.Analyzers/MicrosoftCodeQualityAnalyzersResources.resx
Outdated
Show resolved
Hide resolved
Great, thank you @gewarren! |
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.
Looks great to me, thank you @CollinAlpert!
Fixes dotnet/runtime#78388