提交 8ecb8817 编写于 作者: D Darren Blaby

Add Codefix provider to resolve issue #3437 and a CodeFix provider for C# for warning CS0108

上级 ed79f538
...@@ -256,6 +256,7 @@ ...@@ -256,6 +256,7 @@
<Compile Include="Diagnostics\GenerateType\GenerateTypeTests.cs" /> <Compile Include="Diagnostics\GenerateType\GenerateTypeTests.cs" />
<Compile Include="Diagnostics\GenerateType\GenerateTypeTests_Dialog.cs" /> <Compile Include="Diagnostics\GenerateType\GenerateTypeTests_Dialog.cs" />
<Compile Include="Diagnostics\GenerateVariable\GenerateVariableTests.cs" /> <Compile Include="Diagnostics\GenerateVariable\GenerateVariableTests.cs" />
<Compile Include="Diagnostics\HideBase\HideBaseTests.cs" />
<Compile Include="Diagnostics\ImplementAbstractClass\ImplementAbstractClassTests.cs" /> <Compile Include="Diagnostics\ImplementAbstractClass\ImplementAbstractClassTests.cs" />
<Compile Include="Diagnostics\ImplementAbstractClass\ImplementAbstractClassTests_FixAllTests.cs" /> <Compile Include="Diagnostics\ImplementAbstractClass\ImplementAbstractClassTests_FixAllTests.cs" />
<Compile Include="Diagnostics\ImplementInterface\ImplementInterfaceTests_FixAllTests.cs" /> <Compile Include="Diagnostics\ImplementInterface\ImplementInterfaceTests_FixAllTests.cs" />
......
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.CodeFixes.HideBase;
using Microsoft.CodeAnalysis.Diagnostics;
using System;
using Xunit;
using Roslyn.Test.Utilities;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics.HideBase
{
public class HideBaseTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest
{
internal override Tuple<DiagnosticAnalyzer, CodeFixProvider> CreateDiagnosticProviderAndFixer(Workspace workspace)
{
return Tuple.Create<DiagnosticAnalyzer, CodeFixProvider>(null, new HideBaseCodeFixProvider());
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddNew)]
public void TestAddNewToProperty()
{
Test(
@"class Application
{
public static Application Current { get; }
}
class App : Application
{
[|public static App Current|] { get; set; }
}",
@"class Application
{
public static Application Current { get; }
}
class App : Application
{
public static new App Current { get; set; }
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddNew)]
public void TestAddNewToMethod()
{
Test(
@"class Application
{
public static void Method()
{
}
}
class App : Application
{
[|public static void Method()
{
}|]
}",
@"class Application
{
public static void Method()
{
}
}
class App : Application
{
public static new void Method()
{
}
}");
}
[Fact,Trait(Traits.Feature,Traits.Features.CodeActionsAddNew)]
public void TestAddNewToMember()
{
Test(
@"class Application
{
public string Test;
}
class App : Application
{
[|public int Test;|]
}",
@"class Application
{
public string Test;
}
class App : Application
{
public new int Test;
}");
}
}
}
...@@ -34,14 +34,14 @@ public void TestNoCyclesInFixProviders() ...@@ -34,14 +34,14 @@ public void TestNoCyclesInFixProviders()
// ExtensionOrderer.Order() will not throw even if cycle is detected. However, it will // ExtensionOrderer.Order() will not throw even if cycle is detected. However, it will
// break the cycle and the resulting order will end up being unpredictable. // break the cycle and the resulting order will end up being unpredictable.
var actualOrder = ExtensionOrderer.Order(csharpProviders).ToArray(); var actualOrder = ExtensionOrderer.Order(csharpProviders).ToArray();
Assert.Equal(20, actualOrder.Length); Assert.Equal(21, actualOrder.Length);
Assert.Equal(PredefinedCodeFixProviderNames.AddUsingOrImport, actualOrder[0].Metadata.Name); Assert.Equal(PredefinedCodeFixProviderNames.AddUsingOrImport, actualOrder[0].Metadata.Name);
Assert.Equal(PredefinedCodeFixProviderNames.RenameTracking, actualOrder[1].Metadata.Name); Assert.Equal(PredefinedCodeFixProviderNames.RenameTracking, actualOrder[1].Metadata.Name);
var vbProviders = providersPerLanguage[LanguageNames.VisualBasic]; var vbProviders = providersPerLanguage[LanguageNames.VisualBasic];
Assert.DoesNotThrow(() => ExtensionOrderer.CheckForCycles(vbProviders)); Assert.DoesNotThrow(() => ExtensionOrderer.CheckForCycles(vbProviders));
actualOrder = ExtensionOrderer.Order(vbProviders).ToArray(); actualOrder = ExtensionOrderer.Order(vbProviders).ToArray();
Assert.Equal(28, actualOrder.Length); Assert.Equal(29, actualOrder.Length);
Assert.Equal(PredefinedCodeFixProviderNames.AddUsingOrImport, actualOrder[0].Metadata.Name); Assert.Equal(PredefinedCodeFixProviderNames.AddUsingOrImport, actualOrder[0].Metadata.Name);
Assert.Equal(PredefinedCodeFixProviderNames.RenameTracking, actualOrder[1].Metadata.Name); Assert.Equal(PredefinedCodeFixProviderNames.RenameTracking, actualOrder[1].Metadata.Name);
} }
......
...@@ -124,6 +124,8 @@ public static class Features ...@@ -124,6 +124,8 @@ public static class Features
public const string Venus = "Venus"; public const string Venus = "Venus";
public const string VsLanguageBlock = "VsLanguageBlock"; public const string VsLanguageBlock = "VsLanguageBlock";
public const string XmlTagCompletion = "XmlTagCompletion"; public const string XmlTagCompletion = "XmlTagCompletion";
public const string CodeActionsAddOverload = "CodeActions.AddOverloads";
public const string CodeActionsAddNew = "CodeActions.AddNew";
} }
} }
} }
...@@ -235,6 +235,7 @@ ...@@ -235,6 +235,7 @@
<Compile Include="Diagnostics\ImplementInterface\ImplementInterfaceTests.vb" /> <Compile Include="Diagnostics\ImplementInterface\ImplementInterfaceTests.vb" />
<Compile Include="Diagnostics\InsertMissingCast\InsertMissingCastTests.vb" /> <Compile Include="Diagnostics\InsertMissingCast\InsertMissingCastTests.vb" />
<Compile Include="Diagnostics\MoveToTopOfFile\MoveToTopOfFileTests.vb" /> <Compile Include="Diagnostics\MoveToTopOfFile\MoveToTopOfFileTests.vb" />
<Compile Include="Diagnostics\OverloadBase\OverloadBaseTests.vb" />
<Compile Include="Diagnostics\RemoveUnnecessaryCast\RemoveUnnecessaryCastTests.vb" /> <Compile Include="Diagnostics\RemoveUnnecessaryCast\RemoveUnnecessaryCastTests.vb" />
<Compile Include="Diagnostics\RemoveUnnecessaryCast\RemoveUnnecessaryCastTests_FixAllTests.vb" /> <Compile Include="Diagnostics\RemoveUnnecessaryCast\RemoveUnnecessaryCastTests_FixAllTests.vb" />
<Compile Include="Diagnostics\RemoveUnnecessaryImports\RemoveUnnecessaryImportsTests.vb" /> <Compile Include="Diagnostics\RemoveUnnecessaryImports\RemoveUnnecessaryImportsTests.vb" />
......
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.CodeFixes
Imports Microsoft.CodeAnalysis.Diagnostics
Imports Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics
Imports Microsoft.CodeAnalysis.VisualBasic.CodeFixes.OverloadBase
Imports Microsoft.CodeAnalysis.VisualBasic.Diagnostics
Public Class OverloadBaseTests
Inherits AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest
Friend Overrides Function CreateDiagnosticProviderAndFixer(workspace As Workspace) As Tuple(Of DiagnosticAnalyzer, CodeFixProvider)
Return Tuple.Create(Of DiagnosticAnalyzer, CodeFixProvider)(Nothing, New OverloadBaseCodeFixProvider())
End Function
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddOverload)>
Public Sub TestAddOverloadsToProperty()
Test(
NewLines("Class Application \n Shared Property Current As Application \n End Class \n Class App : Inherits Application \n [|Shared Property Current As App|] \n End Class"),
NewLines("Class Application \n Shared Property Current As Application \n End Class \n Class App : Inherits Application \n Overloads Shared Property Current As App \n End Class"))
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddOverload)>
Public Sub TestAddOverloadsToFunction()
Test(
NewLines("Class Application \n Shared Function Test() As Integer \n Return 1 \n End Function \n End Class \n Class App : Inherits Application \n [|Shared Function Test() As Integer \n Return 2 \n End Function|] \n End Class"),
NewLines("Class Application \n Shared Function Test() As Integer \n Return 1 \n End Function \n End Class \n Class App : Inherits Application \n Overloads Shared Function Test() As Integer \n Return 2 \n End Function \n End Class"))
End Sub
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsAddOverload)>
Public Sub TestAddOverloadsToSub()
Test(
NewLines("Class Application \n Shared Sub Test() \n End Sub \n End Class \n Class App : Inherits Application \n [|Shared Sub Test() \n End Sub|] \n End Class"),
NewLines("Class Application \n Shared Sub Test() \n End Sub \n End Class \n Class App : Inherits Application \n Overloads Shared Sub Test() \n End Sub \n End Class"))
End Sub
End Class
...@@ -99,6 +99,8 @@ ...@@ -99,6 +99,8 @@
<Compile Include="CodeFixes\GenerateMethod\GenerateMethodCodeFixProvider.cs" /> <Compile Include="CodeFixes\GenerateMethod\GenerateMethodCodeFixProvider.cs" />
<Compile Include="CodeFixes\GenerateType\GenerateTypeCodeFixProvider.cs" /> <Compile Include="CodeFixes\GenerateType\GenerateTypeCodeFixProvider.cs" />
<Compile Include="CodeFixes\GenerateVariable\GenerateVariableCodeFixProvider.cs" /> <Compile Include="CodeFixes\GenerateVariable\GenerateVariableCodeFixProvider.cs" />
<Compile Include="CodeFixes\HideBase\HideBaseCodeFixProvider.AddNewKeywordAction.cs" />
<Compile Include="CodeFixes\HideBase\HideBaseCodeFixProvider.cs" />
<Compile Include="CodeFixes\ImplementAbstractClass\ImplementAbstractClassCodeFixProvider.cs" /> <Compile Include="CodeFixes\ImplementAbstractClass\ImplementAbstractClassCodeFixProvider.cs" />
<Compile Include="CodeFixes\ImplementInterface\ImplementInterfaceCodeFixProvider.cs" /> <Compile Include="CodeFixes\ImplementInterface\ImplementInterfaceCodeFixProvider.cs" />
<Compile Include="CodeFixes\Iterator\CSharpAddYieldCodeFixProvider.cs" /> <Compile Include="CodeFixes\Iterator\CSharpAddYieldCodeFixProvider.cs" />
...@@ -384,6 +386,7 @@ ...@@ -384,6 +386,7 @@
<PublicAPI Include="PublicAPI.Shipped.txt" /> <PublicAPI Include="PublicAPI.Shipped.txt" />
<PublicAPI Include="PublicAPI.Unshipped.txt" /> <PublicAPI Include="PublicAPI.Unshipped.txt" />
</ItemGroup> </ItemGroup>
<ItemGroup />
<Import Project="..\..\..\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems" Label="Shared" /> <Import Project="..\..\..\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems" Label="Shared" />
<ImportGroup Label="Targets"> <ImportGroup Label="Targets">
<Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" /> <Import Project="..\..\..\..\build\Targets\VSL.Imports.targets" />
......
...@@ -376,6 +376,15 @@ internal class CSharpFeaturesResources { ...@@ -376,6 +376,15 @@ internal class CSharpFeaturesResources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Hide base member.
/// </summary>
internal static string HideBase {
get {
return ResourceManager.GetString("HideBase", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Implement Abstract Class. /// Looks up a localized string similar to Implement Abstract Class.
/// </summary> /// </summary>
......
...@@ -437,4 +437,7 @@ ...@@ -437,4 +437,7 @@
<data name="ERR_NameNotInContext" xml:space="preserve"> <data name="ERR_NameNotInContext" xml:space="preserve">
<value>The name '{0}' does not exist in the current context.</value> <value>The name '{0}' does not exist in the current context.</value>
</data> </data>
<data name="HideBase" xml:space="preserve">
<value>Hide base member</value>
</data>
</root> </root>
\ No newline at end of file
// 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.Threading.Tasks;
using System.Threading;
using Microsoft.CodeAnalysis.Formatting;
namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.HideBase
{
internal partial class HideBaseCodeFixProvider
{
private class AddNewKeywordAction : CodeActions.CodeAction
{
private Document _document;
private SyntaxNode _node;
private SyntaxNode _newNode;
public override string Title
{
get
{
return CSharpFeaturesResources.HideBase;
}
}
public AddNewKeywordAction(Document document, SyntaxNode node, SyntaxNode newNode)
{
_document = document;
_node = node;
_newNode = newNode;
}
protected override async Task<Document> GetChangedDocumentAsync(CancellationToken cancellationToken)
{
var root = await _document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var newRoot = root.ReplaceNode(_node, _newNode);
var newDocument = await Formatter.FormatAsync(_document.WithSyntaxRoot(newRoot)).ConfigureAwait(false);
return newDocument;
}
}
}
}
// 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 Microsoft.CodeAnalysis.CodeFixes;
using System.Composition;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using System.Threading;
using Microsoft.CodeAnalysis.CodeCleanup;
using Microsoft.CodeAnalysis.Shared.Extensions;
using System.Diagnostics;
namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.HideBase
{
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AddNew), Shared]
internal partial class HideBaseCodeFixProvider : CodeFixProvider
{
internal const string CS0108 = "CS0108"; // 'SomeClass.SomeMember' hides inherited member 'SomeClass.SomeMember'. Use the new keyword if hiding was intended.
public override ImmutableArray<string> FixableDiagnosticIds
{
get
{
return ImmutableArray.Create(CS0108);
}
}
public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
{
var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
var diagnostic = context.Diagnostics.First();
var diagnosticSpan = diagnostic.Location.SourceSpan;
var token = root.FindToken(diagnosticSpan.Start);
SyntaxNode originalNode = token.GetAncestor<PropertyDeclarationSyntax>();
if (originalNode == null)
{
originalNode = token.GetAncestor<MethodDeclarationSyntax>();
}
if(originalNode == null)
{
originalNode = token.GetAncestor<FieldDeclarationSyntax>();
}
if(originalNode == null)
{
return;
}
var newNode = GetNewNode(context.Document, originalNode, context.CancellationToken);
if (newNode == null)
{
return;
}
context.RegisterCodeFix(new AddNewKeywordAction(context.Document, originalNode, newNode), context.Diagnostics);
}
private SyntaxNode GetNewNode(Document document, SyntaxNode node, CancellationToken cancellationToken)
{
SyntaxNode newNode = null;
var propertyStatement = node as PropertyDeclarationSyntax;
if (propertyStatement != null)
{
newNode = propertyStatement.AddModifiers(SyntaxFactory.Token(SyntaxTriviaList.Empty, SyntaxKind.NewKeyword, SyntaxTriviaList.Create(SyntaxFactory.Whitespace(" ")))) as SyntaxNode;
}
var methodStatement = node as MethodDeclarationSyntax;
if (methodStatement != null)
{
newNode = methodStatement.AddModifiers(SyntaxFactory.Token(SyntaxTriviaList.Empty, SyntaxKind.NewKeyword, SyntaxTriviaList.Create(SyntaxFactory.Whitespace(" "))));
}
var fieldDeclaration = node as FieldDeclarationSyntax;
if (fieldDeclaration != null)
{
newNode = fieldDeclaration.AddModifiers(SyntaxFactory.Token(SyntaxTriviaList.Empty, SyntaxKind.NewKeyword, SyntaxTriviaList.Create(SyntaxFactory.Whitespace(" "))));
}
var cleanupService = document.GetLanguageService<ICodeCleanerService>();
if (cleanupService != null && newNode != null)
{
newNode = cleanupService.Cleanup(newNode, new[] { newNode.Span }, document.Project.Solution.Workspace, cleanupService.GetDefaultProviders(), cancellationToken);
}
return newNode;
}
}
}
...@@ -34,5 +34,7 @@ internal static class PredefinedCodeFixProviderNames ...@@ -34,5 +34,7 @@ internal static class PredefinedCodeFixProviderNames
public const string SimplifyNames = "Simplify Names"; public const string SimplifyNames = "Simplify Names";
public const string SpellCheck = "Spell Check"; public const string SpellCheck = "Spell Check";
public const string Suppression = "Suppression"; public const string Suppression = "Suppression";
public const string AddOverloads = "Add Overloads to member";
public const string AddNew = "Add new keyword to member";
} }
} }
...@@ -150,6 +150,8 @@ ...@@ -150,6 +150,8 @@
<Compile Include="CodeFixes\IncorrectFunctionReturnType\IncorrectFunctionReturnTypeCodeFixProvider.vb" /> <Compile Include="CodeFixes\IncorrectFunctionReturnType\IncorrectFunctionReturnTypeCodeFixProvider.vb" />
<Compile Include="CodeFixes\MoveToTopOfFile\MoveToTopOfFileCodeFixProvider.MoveToLineCodeAction.vb" /> <Compile Include="CodeFixes\MoveToTopOfFile\MoveToTopOfFileCodeFixProvider.MoveToLineCodeAction.vb" />
<Compile Include="CodeFixes\MoveToTopOfFile\MoveToTopOfFileCodeFixProvider.vb" /> <Compile Include="CodeFixes\MoveToTopOfFile\MoveToTopOfFileCodeFixProvider.vb" />
<Compile Include="CodeFixes\OverloadBase\OverloadBaseCodeFixProvider.AddOverloads.vb" />
<Compile Include="CodeFixes\OverloadBase\OverloadBaseCodeFixProvider.vb" />
<Compile Include="CodeFixes\RemoveUnnecessaryCast\RemoveUnnecessaryCastCodeFixProvider.RemoveUnnecessaryCastFixAllProvider.vb" /> <Compile Include="CodeFixes\RemoveUnnecessaryCast\RemoveUnnecessaryCastCodeFixProvider.RemoveUnnecessaryCastFixAllProvider.vb" />
<Compile Include="CodeFixes\RemoveUnnecessaryCast\RemoveUnnecessaryCastCodeFixProvider.Rewriter.vb" /> <Compile Include="CodeFixes\RemoveUnnecessaryCast\RemoveUnnecessaryCastCodeFixProvider.Rewriter.vb" />
<Compile Include="CodeFixes\RemoveUnnecessaryCast\RemoveUnnecessaryCastCodeFixProvider.vb" /> <Compile Include="CodeFixes\RemoveUnnecessaryCast\RemoveUnnecessaryCastCodeFixProvider.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.Threading
Imports Microsoft.CodeAnalysis.CodeActions
Imports Microsoft.CodeAnalysis.Formatting
Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.OverloadBase
Partial Friend Class OverloadBaseCodeFixProvider
Private Class AddOverloadsKeywordAction
Inherits CodeAction
Private ReadOnly _document As Document
Private ReadOnly _node As SyntaxNode
Private ReadOnly _newNode As SyntaxNode
Public Overrides ReadOnly Property Title As String
Get
Return VBFeaturesResources.AddOverloadsKeyword
End Get
End Property
Public Overrides ReadOnly Property EquivalenceKey As String
Get
Return VBFeaturesResources.AddOverloadsKeyword
End Get
End Property
Public Sub New(document As Document, node As SyntaxNode, newNode As SyntaxNode)
_document = document
_node = node
_newNode = newNode
End Sub
Protected Overrides Async Function GetChangedDocumentAsync(cancellationToken As CancellationToken) As Task(Of Document)
Dim root = Await _document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(False)
Dim newRoot = root.ReplaceNode(_node, _newNode)
Dim newDocument = Await Formatter.FormatAsync(_document.WithSyntaxRoot(newRoot), cancellationToken:=cancellationToken).ConfigureAwait(False)
Return newDocument
End Function
End Class
End Class
End Namespace
' 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.Collections.Immutable
Imports System.Composition
Imports System.Threading
Imports Microsoft.CodeAnalysis.CodeCleanup
Imports Microsoft.CodeAnalysis.CodeFixes
Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
Namespace Microsoft.CodeAnalysis.VisualBasic.CodeFixes.OverloadBase
<ExportCodeFixProvider(LanguageNames.VisualBasic, Name:=PredefinedCodeFixProviderNames.AddOverloads), [Shared]>
Partial Friend Class OverloadBaseCodeFixProvider
Inherits CodeFixProvider
Friend Const BC40003 As String = "BC40003" ' '{0} '{1}' shadows an overloadable member declared in the base class '{2}'. If you want to overload the base method, this method must be declared 'Overloads'.
Public Overrides ReadOnly Property FixableDiagnosticIds As ImmutableArray(Of String)
Get
Return ImmutableArray.Create(BC40003)
End Get
End Property
Public NotOverridable Overrides Async Function RegisterCodeFixesAsync(context As CodeFixContext) As Task
Dim root = Await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(False)
Dim diagnostic = context.Diagnostics.First()
Dim diagnosticSpan = diagnostic.Location.SourceSpan
Dim token = root.FindToken(diagnosticSpan.Start)
If TypeOf token.Parent IsNot PropertyStatementSyntax AndAlso TypeOf token.Parent IsNot MethodStatementSyntax Then
Return
End If
Dim newNode = GetNewNode(context.Document, token.Parent, context.CancellationToken)
context.RegisterCodeFix(New AddOverloadsKeywordAction(context.Document, token.Parent, newNode), context.Diagnostics)
End Function
Private Function GetNewNode(document As Document, node As SyntaxNode, cancellationToken As CancellationToken) As SyntaxNode
Dim newNode As SyntaxNode = Nothing
Dim propertyStatement = TryCast(node, PropertyStatementSyntax)
If propertyStatement IsNot Nothing Then
newNode = propertyStatement.AddModifiers(SyntaxFactory.Token(SyntaxKind.OverloadsKeyword))
End If
Dim methodStatement = TryCast(node, MethodStatementSyntax)
If methodStatement IsNot Nothing Then
newNode = methodStatement.AddModifiers(SyntaxFactory.Token(SyntaxKind.OverloadsKeyword))
End If
Dim cleanupService = document.GetLanguageService(Of ICodeCleanerService)
If cleanupService IsNot Nothing AndAlso newNode IsNot Nothing Then
newNode = cleanupService.Cleanup(newNode, {newNode.Span}, document.Project.Solution.Workspace, cleanupService.GetDefaultProviders(), cancellationToken)
End If
Return newNode
End Function
End Class
End Namespace
\ No newline at end of file
...@@ -70,6 +70,15 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.VBFeaturesResources ...@@ -70,6 +70,15 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.VBFeaturesResources
End Get End Get
End Property End Property
'''<summary>
''' Looks up a localized string similar to Add Overloads.
'''</summary>
Friend ReadOnly Property AddOverloadsKeyword() As String
Get
Return ResourceManager.GetString("AddOverloadsKeyword", resourceCulture)
End Get
End Property
'''<summary> '''<summary>
''' Looks up a localized string similar to Creates a delegate procedure instance that references the specified procedure. ''' Looks up a localized string similar to Creates a delegate procedure instance that references the specified procedure.
'''AddressOf &lt;procedureName&gt;. '''AddressOf &lt;procedureName&gt;.
......
...@@ -1207,4 +1207,7 @@ Sub(&lt;parameterList&gt;) &lt;statement&gt;</value> ...@@ -1207,4 +1207,7 @@ Sub(&lt;parameterList&gt;) &lt;statement&gt;</value>
<data name="ERR_UndefinedType1" xml:space="preserve"> <data name="ERR_UndefinedType1" xml:space="preserve">
<value>Type '{0}' is not defined.</value> <value>Type '{0}' is not defined.</value>
</data> </data>
<data name="AddOverloadsKeyword" xml:space="preserve">
<value>Add Overloads</value>
</data>
</root> </root>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册