Roslyn: Missing FixAll support for bunch of IDE CodeFixProviders

Created on 2 Dec 2017  路  6Comments  路  Source: dotnet/roslyn

Version Used: Roslyn master

Steps to Reproduce:

  1. Move Roslyn to latest analyzers: https://www.nuget.org/packages/Microsoft.Net.RoslynDiagnostics/2.6.0-beta1 by changing MicrosoftNetRoslynDiagnosticsVersion over here to 2.6.0-beta1. If this value is already greater than equals 2.6.0-beta1, then search for source suppressions for RS1016.
  2. Build solution

Expected Behavior:
No RS1016 diagnostics (CodeFixProviders should override GetFixAllProvider).

Actual Behavior:

Severity    Code    Description Project File    Line    Suppression State   Detail Description
Warning RS1016  'GenerateEndConstructCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support. BasicFeatures   c:\roslyn\src\Features\VisualBasic\Portable\CodeFixes\GenerateEndConstruct\GenerateEndConstructCodeFixProvider.vb   16  Active
Warning RS1016  'GenerateEventCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support.    BasicFeatures   c:\roslyn\src\Features\VisualBasic\Portable\CodeFixes\GenerateEvent\GenerateEventCodeFixProvider.CodeAction.vb  8   Active  A CodeFixProvider should provide FixAll support to enable users to fix multiple instances of the underlying diagnostic with a single code fix. See documenation at https://github.com/dotnet/roslyn/blob/master/docs/analyzers/FixAllProvider.md for further details.
Warning RS1016  'HideBaseCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support. CSharpFeatures  c:\roslyn\src\Features\CSharp\Portable\CodeFixes\HideBase\HideBaseCodeFixProvider.AddNewKeywordAction.cs    12  Active
Warning RS1016  'AbstractAddImportCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support.    Features    c:\roslyn\src\Features\Core\Portable\AddImport\CodeActions\AssemblyReferenceCodeAction.cs   13  Active
Warning RS1016  'AbstractAddPackageCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support.   Features    c:\roslyn\src\Features\Core\Portable\AddPackage\AbstractAddPackageCodeFixProvider.cs    16  Active
Warning RS1016  'AbstractAddParameterCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support. Features    c:\roslyn\src\Features\Core\Portable\AddParameter\AbstractAddParameterCodeFixProvider.cs    22  Active
Warning RS1016  'AbstractGenerateMemberCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support.   Features    c:\roslyn\src\Features\Core\Portable\CodeFixes\GenerateMember\AbstractGenerateMemberCodeFixProvider.cs  15  Active
Warning RS1016  'AbstractIteratorCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support. Features    c:\roslyn\src\Features\Core\Portable\CodeFixes\Iterator\AbstractIteratorCodeFixProvider.cs  12  Active
Warning RS1016  'NamingStyleCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support.  Features    c:\roslyn\src\Features\Core\Portable\CodeFixes\NamingStyle\AbstractNamingStyleCodeFixProvider.cs    22  Active
Warning RS1016  'AbstractResolveConflictMarkerCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support.    Features    c:\roslyn\src\Features\Core\Portable\ConflictMarkerResolution\AbstractConflictMarkerCodeFixProvider.cs  14  Active
Warning RS1016  'AbstractFullyQualifyCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support. Features    c:\roslyn\src\Features\Core\Portable\FullyQualify\AbstractFullyQualifyCodeFixProvider.cs    18  Active
Warning RS1016  'AbstractSpellCheckCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support.   Features    c:\roslyn\src\Features\Core\Portable\SpellCheck\AbstractSpellCheckCodeFixProvider.cs    15  Active
Warning RS1016  'AbstractUpgradeProjectCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support.   Features    c:\roslyn\src\Features\Core\Portable\UpgradeProject\AbstractUpgradeProjectCodeFixProvider.cs    15  Active
3 - Working Area-IDE Bug

All 6 comments

Many of these don't really make sense for 'fix all'. They're intended to be used in a more interactive manner where users need to decide what the right fix is.

Yes, I agree. The recommendation from the analyzer is to still always override GetFixAllProvider method and return null to explicitly state this intent. Otherwise, it is not clear if this was an oversight causing missing FixAll support or intentional design.

@CyrusNajmabadi Yes, I brought that point up when RS1016 was originally proposed. I agree with @mavasani that these cases should still be explicit.

That works for me. Thanks!

Suppressing these violations and unblocking build of core projects leads to following additional 8 RS1016 violations for VB:

Severity    Code    Description Project File    Line    Suppression State
Warning RS1016  'CorrectNextControlVariableCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support.   BasicFeatures   c:\roslyn\src\Features\VisualBasic\Portable\CodeFixes\CorrectNextControlVariable\CorrectNextControlVariableCodeFixProvider.CodeAction.vb    8   N/A
Warning RS1016  'GenerateEndConstructCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support. BasicFeatures   c:\roslyn\src\Features\VisualBasic\Portable\CodeFixes\GenerateEndConstruct\GenerateEndConstructCodeFixProvider.vb   16  N/A
Warning RS1016  'GenerateEventCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support.    BasicFeatures   c:\roslyn\src\Features\VisualBasic\Portable\CodeFixes\GenerateEvent\GenerateEventCodeFixProvider.CodeAction.vb  8   N/A
Warning RS1016  'IncorrectExitContinueCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support.    BasicFeatures   c:\roslyn\src\Features\VisualBasic\Portable\CodeFixes\IncorrectExitContinue\IncorrectExitContinueCodeFixProvider.AddKeywordCodeAction.vb    9   N/A
Warning RS1016  'IncorrectFunctionReturnTypeCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support.  BasicFeatures   c:\roslyn\src\Features\VisualBasic\Portable\CodeFixes\IncorrectFunctionReturnType\IncorrectFunctionReturnTypeCodeFixProvider.vb 16  N/A
Warning RS1016  'InsertMissingCastCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support.    BasicFeatures   c:\roslyn\src\Features\VisualBasic\Portable\CodeFixes\InsertMissingCast\InsertMissingCastCodeFixProvider.CodeAction.vb  8   N/A
Warning RS1016  'MoveToTopOfFileCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support.  BasicFeatures   c:\roslyn\src\Features\VisualBasic\Portable\CodeFixes\MoveToTopOfFile\MoveToTopOfFileCodeFixProvider.MoveToLineCodeAction.vb    8   N/A
Warning RS1016  'OverloadBaseCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support. BasicFeatures   c:\roslyn\src\Features\VisualBasic\Portable\CodeFixes\OverloadBase\OverloadBaseCodeFixProvider.AddOverloads.vb  11  N/A

Noticed one more in latest snapshot:

Severity    Code    Description Project File    Line    Suppression State
Warning RS1016  'HideBaseCodeFixProvider' registers one or more code fixes, but does not override the method 'CodeFixProvider.GetFixAllProvider'. Override this method and provide a non-null FixAllProvider for FixAll support, potentially 'WellKnownFixAllProviders.BatchFixer', or 'null' to explicitly disable FixAll support. CSharpFeatures  c:\roslyn\src\Features\CSharp\Portable\CodeFixes\HideBase\HideBaseCodeFixProvider.cs    14  Active
Was this page helpful?
0 / 5 - 0 ratings