Convert VB's implicit empty argument lists using a simple heuristic
This commit is contained in:
Родитель
5a637b8453
Коммит
66297755cc
|
@ -827,7 +827,17 @@ namespace RefactoringEssentials.CSharp.Converter
|
|||
return SyntaxFactory.AliasQualifiedName((IdentifierNameSyntax) left, simpleNameSyntax);
|
||||
}
|
||||
else
|
||||
return SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, left, simpleNameSyntax);
|
||||
{
|
||||
var memberAccessExpressionSyntax = SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, left, simpleNameSyntax);
|
||||
if (semanticModel.GetSymbolInfo(node).Symbol is IMethodSymbol methodSymbol && methodSymbol.ReturnType.Equals(semanticModel.GetTypeInfo(node).ConvertedType))
|
||||
{
|
||||
return SyntaxFactory.InvocationExpression(memberAccessExpressionSyntax, SyntaxFactory.ArgumentList());
|
||||
}
|
||||
else
|
||||
{
|
||||
return memberAccessExpressionSyntax;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override CSharpSyntaxNode VisitConditionalAccessExpression(VBSyntax.ConditionalAccessExpressionSyntax node)
|
||||
|
|
|
@ -64,6 +64,26 @@ class TestClass
|
|||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmptyArgumentLists()
|
||||
{
|
||||
TestConversionVisualBasicToCSharp(@"Class TestClass
|
||||
Private Sub TestMethod()
|
||||
Dim str = (New ThreadStaticAttribute).ToString
|
||||
End Sub
|
||||
End Class", @"using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
class TestClass
|
||||
{
|
||||
private void TestMethod()
|
||||
{
|
||||
var str = (new ThreadStaticAttribute()).ToString();
|
||||
}
|
||||
}");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StringConcatenationAssignment()
|
||||
|
|
Загрузка…
Ссылка в новой задаче