提交 5b013786 编写于 作者: C CyrusNajmabadi

Remove unnecessary subclassing for a CodeFixProvider.

上级 0721df49
......@@ -3,7 +3,7 @@
using System;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.CodeFixes.FullyQualify;
using Microsoft.CodeAnalysis.CodeFixes.NamingStyles;
using Microsoft.CodeAnalysis.CSharp.Diagnostics.NamingStyles;
using Microsoft.CodeAnalysis.Diagnostics;
using Roslyn.Test.Utilities;
......@@ -14,7 +14,9 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics.NamingStyle
public partial class NamingStylesTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest
{
internal override Tuple<DiagnosticAnalyzer, CodeFixProvider> CreateDiagnosticProviderAndFixer(Workspace workspace) =>
new Tuple<DiagnosticAnalyzer, CodeFixProvider>(new CSharpNamingStyleDiagnosticAnalyzer(), new CSharpNamingStyleCodeFixProvider());
new Tuple<DiagnosticAnalyzer, CodeFixProvider>(
new CSharpNamingStyleDiagnosticAnalyzer(),
new NamingStyleCodeFixProvider());
[WpfFact, Trait(Traits.Feature, Traits.Features.NamingStyle)]
public async Task TestPascalCaseClass_CorrectName()
......
......@@ -111,7 +111,6 @@
<Compile Include="CodeFixes\Iterator\CSharpAddYieldCodeFixProvider.cs" />
<Compile Include="CodeFixes\Iterator\CSharpChangeToIEnumerableCodeFixProvider.cs" />
<Compile Include="QualifyMemberAccess\CSharpQualifyMemberAccessCodeFixProvider.cs" />
<Compile Include="CodeFixes\NamingStyles\CSharpNamingStyleCodeFixProvider.cs" />
<Compile Include="CodeFixes\RemoveUnnecessaryCast\RemoveUnnecessaryCastCodeFixProvider.RemoveUnnecessaryCastFixAllProvider.cs" />
<Compile Include="CodeFixes\RemoveUnnecessaryCast\RemoveUnnecessaryCastCodeFixProvider.cs" />
<Compile Include="RemoveUnnecessaryImports\CSharpRemoveUnnecessaryImportsCodeFixProvider.cs" />
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Composition;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CodeFixes.NamingStyles;
namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.FullyQualify
{
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.ApplyNamingStyle), Shared]
internal class CSharpNamingStyleCodeFixProvider : AbstractNamingStyleCodeFixProvider
{
}
}
......@@ -2,6 +2,7 @@
using System;
using System.Collections.Immutable;
using System.Composition;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
......@@ -14,12 +15,12 @@
namespace Microsoft.CodeAnalysis.CodeFixes.NamingStyles
{
internal abstract class AbstractNamingStyleCodeFixProvider : CodeFixProvider
[ExportCodeFixProvider(LanguageNames.CSharp, LanguageNames.VisualBasic,
Name = PredefinedCodeFixProviderNames.ApplyNamingStyle), Shared]
internal class NamingStyleCodeFixProvider : CodeFixProvider
{
public override ImmutableArray<string> FixableDiagnosticIds
{
get { return ImmutableArray.Create(IDEDiagnosticIds.NamingRuleId); }
}
public override ImmutableArray<string> FixableDiagnosticIds { get; }
= ImmutableArray.Create(IDEDiagnosticIds.NamingRuleId);
public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
{
......@@ -47,8 +48,8 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
symbol,
fixedName,
await document.GetOptionsAsync(c).ConfigureAwait(false),
c).ConfigureAwait(false),
nameof(AbstractNamingStyleCodeFixProvider)),
c).ConfigureAwait(false),
nameof(NamingStyleCodeFixProvider)),
diagnostic);
}
}
......@@ -61,4 +62,4 @@ public FixNameCodeAction(string title, Func<CancellationToken, Task<Solution>> c
}
}
}
}
}
\ No newline at end of file
......@@ -110,7 +110,6 @@
<Compile Include="CodeFixes\IncorrectFunctionReturnType\IncorrectFunctionReturnTypeCodeFixProvider.vb" />
<Compile Include="CodeFixes\MoveToTopOfFile\MoveToTopOfFileCodeFixProvider.MoveToLineCodeAction.vb" />
<Compile Include="CodeFixes\MoveToTopOfFile\MoveToTopOfFileCodeFixProvider.vb" />
<Compile Include="CodeFixes\NamingStyles\VisualBasicNamingStyleCodeFixProvider.vb" />
<Compile Include="CodeFixes\OverloadBase\OverloadBaseCodeFixProvider.AddOverloads.vb" />
<Compile Include="CodeFixes\OverloadBase\OverloadBaseCodeFixProvider.vb" />
<Compile Include="Structure\Providers\CollectionInitializerStructureProvider.vb" />
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports System.Composition
Imports Microsoft.CodeAnalysis.CodeFixes
Imports Microsoft.CodeAnalysis.CodeFixes.NamingStyles
Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.NamingStyles
<ExportCodeFixProvider(LanguageNames.VisualBasic, Name:=PredefinedCodeFixProviderNames.ApplyNamingStyle), [Shared]>
Friend Class VisualBasicNamingStyleCodeFixProvider
Inherits AbstractNamingStyleCodeFixProvider
End Class
End Namespace
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册