提交 ea42a2b0 编写于 作者: M Martin Strecker

Allow fixing VBs explicit interface implementations.

上级 36bcb451
......@@ -22,12 +22,15 @@ protected override bool SupportsReadOnlyProperties(Compilation compilation)
protected override bool SupportsPropertyInitializer(Compilation compilation)
=> ((CSharpCompilation)compilation).LanguageVersion >= LanguageVersion.CSharp6;
protected override bool CanExplicitInterfaceImplementationsBeFixed()
=> false;
protected override void AnalyzeCompilationUnit(
SemanticModelAnalysisContext context, SyntaxNode root, List<AnalysisResult> analysisResults)
=> AnalyzeMembers(context, ((CompilationUnitSyntax)root).Members, analysisResults);
private void AnalyzeMembers(
SemanticModelAnalysisContext context,
SemanticModelAnalysisContext context,
SyntaxList<MemberDeclarationSyntax> members,
List<AnalysisResult> analysisResults)
{
......
......@@ -21,6 +21,10 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UseAutoProperty
Return DirectCast(compilation, VisualBasicCompilation).LanguageVersion >= LanguageVersion.VisualBasic10
End Function
Protected Overrides Function CanExplicitInterfaceImplementationsBeFixed() As Boolean
Return True
End Function
Protected Overrides Sub AnalyzeCompilationUnit(context As SemanticModelAnalysisContext, root As SyntaxNode, analysisResults As List(Of AnalysisResult))
AnalyzeMembers(context, DirectCast(root, CompilationUnitSyntax).Members, analysisResults)
End Sub
......
......@@ -557,7 +557,7 @@ End Class")
<WorkItem(23735, "https://github.com/dotnet/roslyn/issues/23735")>
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseAutoProperty)>
Public Async Function ExplicitInterfaceImplementation() As Task
Await TestMissingInRegularAndScriptAsync("
Await TestInRegularAndScriptAsync("
Namespace RoslynSandbox
Public Interface IFoo
ReadOnly Property Bar() As Object
......@@ -579,6 +579,23 @@ Namespace RoslynSandbox
End Sub
End Class
End Namespace
",
"
Namespace RoslynSandbox
Public Interface IFoo
ReadOnly Property Bar() As Object
End Interface
Friend Class Foo
Implements IFoo
Private ReadOnly Property Bar() As Object Implements IFoo.Bar
Public Sub New(bar As Object)
Me.Bar = bar
End Sub
End Class
End Namespace
")
End Function
End Class
......
......@@ -31,6 +31,7 @@ protected AbstractUseAutoPropertyAnalyzer()
protected abstract void AnalyzeCompilationUnit(SemanticModelAnalysisContext context, SyntaxNode root, List<AnalysisResult> analysisResults);
protected abstract bool SupportsReadOnlyProperties(Compilation compilation);
protected abstract bool SupportsPropertyInitializer(Compilation compilation);
protected abstract bool CanExplicitInterfaceImplementationsBeFixed();
protected abstract TExpression GetFieldInitializer(TVariableDeclarator variable, CancellationToken cancellationToken);
protected abstract TExpression GetGetterExpression(IMethodSymbol getMethod, CancellationToken cancellationToken);
protected abstract TExpression GetSetterExpression(IMethodSymbol setMethod, SemanticModel semanticModel, CancellationToken cancellationToken);
......@@ -113,7 +114,7 @@ protected void AnalyzeProperty(SemanticModelAnalysisContext context, TPropertyDe
return;
}
if (property.ExplicitInterfaceImplementations.Length != 0)
if (!CanExplicitInterfaceImplementationsBeFixed() && property.ExplicitInterfaceImplementations.Length != 0)
{
return;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册