Closed stephentoub closed 1 year ago
Tagging subscribers to this area: @dotnet/area-meta See info in area-owners.md if you want to be subscribed.
Author: | stephentoub |
---|---|
Assignees: | - |
Labels: | `area-Meta`, `code-analyzer`, `code-fixer` |
Milestone: | - |
Looks good as proposed.
Given concerns with some of the templates (e.g. WinForms creating the skeleton for a new form type being default) we're recommending this analyzer be opt-in. But we're probably easily convinced that it should be something else.
Category: Maintainability (?) Visibility: None (off by default; might be nice if trimmer-style scenarios can flip it on by default)
The proposal is to add an analyzer/fixer that runs when a compilation's OutputKind is ConsoleApplication or WindowsApplication and that flags all public types, recommending they instead be made internal.
Could the analyzer run when the output binary contains runnable entry-point?
Should this consider the OutputKind WindowsRuntimeApplication
as well?
I see a lot of the newly added analyzers are opt-in.
How do I as a developer enable them, and more importantly, find which ones to enable? Basically, is there an easily digestible list somewhere?
I remember seeing a few good ones being added, so I worry that I'll forget about them and not benefit from them!
You can add an .editorconfig
file to your solution and then select the severity of the rules you would like. For example:
dotnet_diagnostic.CA1018.severity = warning
I assume it will also be enabled by setting <AnalysisLevel>latest-all</AnalysisLevel>
?
I assume it will also be enabled by setting
<AnalysisLevel>latest-all</AnalysisLevel>
?
Indeed, that is correct.
Various analyzers only pay attention to internal/private types and members, as changes to public API is visible. For example, analyzers/fixers that find and remove dead code, or that recommend types without derivations be sealed. Applications, rather than libraries, however, typically aren't referenced, and public types/members are likely mistakes, such that if the mistakes are corrected and the types/members have their visibility changed to internal/private, then other analyzers can start making recommendations for them.
The proposal is to add an analyzer/fixer that runs when a compilation's OutputKind is ConsoleApplication or WindowsApplication and that flags all public types, recommending they instead be made internal.