Skip to content

Commit a3a8e65

Browse files
Fix more predefined type name parsing
1 parent 21e1599 commit a3a8e65

4 files changed

Lines changed: 9 additions & 21 deletions

File tree

CodeConverter/CSharp/DeclarationNodeVisitor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ public override async Task<CSharpSyntaxNode> VisitEventStatement(VBSyntax.EventS
11451145
var delegateDecl = SyntaxFactory.DelegateDeclaration(
11461146
SyntaxFactory.List<AttributeListSyntax>(),
11471147
modifiers,
1148-
SyntaxFactory.ParseTypeName("void"),
1148+
SyntaxFactory.PredefinedType(SyntaxFactory.Token(CSSyntaxKind.VoidKeyword)),
11491149
delegateName,
11501150
null,
11511151
(ParameterListSyntax) await node.ParameterList.AcceptAsync(_triviaConvertingExpressionVisitor) ?? SyntaxFactory.ParameterList(),
@@ -1258,7 +1258,7 @@ public override async Task<CSharpSyntaxNode> VisitDeclareStatement(VBSyntax.Decl
12581258
var attributeLists = (await CommonConversions.ConvertAttributesAsync(node.AttributeLists)).Add(dllImportAttributeList);
12591259

12601260
var modifiers = CommonConversions.ConvertModifiers(node, node.Modifiers).Add(SyntaxFactory.Token(Microsoft.CodeAnalysis.CSharp.SyntaxKind.StaticKeyword)).Add(SyntaxFactory.Token(Microsoft.CodeAnalysis.CSharp.SyntaxKind.ExternKeyword));
1261-
var returnType = (TypeSyntax) await (node.AsClause?.Type).AcceptAsync(_triviaConvertingExpressionVisitor) ?? SyntaxFactory.ParseTypeName("void");
1261+
var returnType = (TypeSyntax) await (node.AsClause?.Type).AcceptAsync(_triviaConvertingExpressionVisitor) ?? SyntaxFactory.PredefinedType(SyntaxFactory.Token(CSSyntaxKind.VoidKeyword));
12621262
var parameterListSyntax = (ParameterListSyntax) await (node.ParameterList).AcceptAsync(_triviaConvertingExpressionVisitor) ??
12631263
SyntaxFactory.ParameterList();
12641264

Tests/CSharp/MemberTests/EventMemberTests.cs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ public void RaisingFlour()
4343
{
4444
OnCakeChange?.Invoke();
4545
}
46-
}
47-
1 target compilation errors:
48-
CS1547: Keyword 'void' cannot be used in this context");
46+
}");
4947
}
5048

5149
[Fact]
@@ -150,9 +148,7 @@ public static void PrintTestMessage2()
150148
public static void PrintTestMessage3()
151149
{
152150
}
153-
}
154-
1 target compilation errors:
155-
CS1547: Keyword 'void' cannot be used in this context");
151+
}");
156152
}
157153

158154
[Fact]
@@ -207,8 +203,6 @@ public void EventClassInstance_TestEvent()
207203
{
208204
}
209205
}
210-
1 target compilation errors:
211-
CS1547: Keyword 'void' cannot be used in this context
212206
");
213207
}
214208

@@ -352,9 +346,7 @@ public partial class ShouldNotGainConstructor
352346
{
353347
}
354348
1 source compilation errors:
355-
BC30516: Overload resolution failed because no accessible 'New' accepts this number of arguments.
356-
1 target compilation errors:
357-
CS1547: Keyword 'void' cannot be used in this context", hasLineCommentConversionIssue: true);//TODO: Improve comment mapping for events
349+
BC30516: Overload resolution failed because no accessible 'New' accepts this number of arguments.", hasLineCommentConversionIssue: true);//TODO: Improve comment mapping for events
358350
}
359351

360352
[Fact]
@@ -483,9 +475,7 @@ public void PrintTestMessage2()
483475
public void PrintTestMessage3()
484476
{
485477
}
486-
}
487-
1 target compilation errors:
488-
CS1547: Keyword 'void' cannot be used in this context", hasLineCommentConversionIssue: true);//TODO: Improve comment mapping for events
478+
}", hasLineCommentConversionIssue: true);//TODO: Improve comment mapping for events
489479
}
490480

491481
[Fact]

Tests/CSharp/StatementTests/StatementTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,9 +1180,7 @@ public static void Main()
11801180
Thread.Sleep(1000);
11811181
}
11821182
}
1183-
}
1184-
1 target compilation errors:
1185-
CS1547: Keyword 'void' cannot be used in this context");
1183+
}");
11861184
}
11871185

11881186
[Fact]

Tests/TestData/MultiFileCharacterization/VBToCSResults/ConvertWholeSolution/ConsoleApp4/My Project/MyNamespace.Static.2.Designer.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)