Move IDE0078 codefix to Analyzers#60378
Conversation
| <Compile Include="$(MSBuildThisFileDirectory)ConvertTypeOfToNameOf\CSharpConvertTypeOfToNameOfCodeFixProvider.cs" /> | ||
| <Compile Include="$(MSBuildThisFileDirectory)ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.cs" /> | ||
| <Compile Include="$(MSBuildThisFileDirectory)ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs" /> | ||
| <Compile Include="$(MSBuildThisFileDirectory)CSharpUsePatternCombinatorsCodeFixProvider.cs" /> |
There was a problem hiding this comment.
I am wondering if we should add ExportCodeFixProviderAttribute and DiagnosticAnalyzerAttribute to Banned APIs in Features layer, with a recommendation message in the diagnostic to move the analyzer/fixer down to the shared layer, when possible. For cases where this is not possible due to analyzer/fixer using a public API not available in a shipped Roslyn version, one would be expected to add a source suppression, with a reference to a tracking issue to perform the move later when the public API does become available (similar to the issue closed by this PR).
What do you thing @Youssef1313?
There was a problem hiding this comment.
Btw, I don't recall whether or not the BannedApiAnalyzer flags banned attribute constructors :-)
There was a problem hiding this comment.
@mavasani There are too many codefixes there (in Features) anyway. Banning the attribute (if possible) and suppressing all of the warnings is going to be noisy. I may look into moving more codefixes later. Then fix BannedApiAnalyzer if needed and use it.
| { | ||
| var semanticModel = p.Target.SemanticModel; | ||
| Debug.Assert(semanticModel != null); | ||
| RoslynDebug.Assert(semanticModel != null); |
There was a problem hiding this comment.
Debug.Assert isn't annotated for netstandard2.0. Used RoslynDebug instead of null-suppression with !.
|
|
||
| #if !CODE_STYLE // 'CodeActionPriority' is not a public API, hence not supported in CodeStyle layer. | ||
| internal override CodeActionPriority Priority => CodeActionPriority.Low; | ||
| #endif |
There was a problem hiding this comment.
how does this work in vs @mavasani ? do we pick up the CodeStyle fixer? Or do we pick up the one from Features?
There was a problem hiding this comment.
We prefer the fixer and analyzer from NuGet package over the one from VSIX
There was a problem hiding this comment.
Btw is there a specific reason for marking this as low priority?

Closes #45569