提交 cbb6ea21 编写于 作者: K Kevin Pilch-Bisson

Merge pull request #1767 from kentcb/Issue1766

Treat System.Void as the absence of a type.

Fixes #1766.
......@@ -132,7 +132,7 @@ public SyntaxNode MethodDeclaration(IMethodSymbol method, IEnumerable<SyntaxNode
var decl = MethodDeclaration(
method.Name,
parameters: method.Parameters.Select(p => ParameterDeclaration(p)),
returnType: TypeExpression(method.ReturnType),
returnType: method.ReturnType.IsSystemVoid() ? null : TypeExpression(method.ReturnType),
accessibility: method.DeclaredAccessibility,
modifiers: DeclarationModifiers.From(method),
statements: statements);
......
......@@ -697,6 +697,22 @@ End Function</x>.Value)
End Sub</x>.Value)
End Sub
<Fact>
Public Sub MethodDeclarationCanRoundTrip()
Dim tree = VisualBasicSyntaxTree.ParseText(
<x>
Public Sub Test()
End Sub</x>.Value)
Dim compilation = VisualBasicCompilation.Create("AssemblyName", syntaxTrees:={tree})
Dim model = compilation.GetSemanticModel(tree)
Dim node = tree.GetRoot().DescendantNodes().First()
Dim symbol = CType(model.GetDeclaredSymbol(node), IMethodSymbol)
VerifySyntax(Of MethodBlockSyntax)(
_g.MethodDeclaration(symbol),
<x>Public Sub Test()
End Sub</x>.Value)
End Sub
<Fact>
Public Sub TestPropertyDeclarations()
VerifySyntax(Of PropertyStatementSyntax)(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册