Skip to content
This repository has been archived by the owner. It is now read-only.

Commit 91c0c8c

Browse files
Use switch for readability - matches style of VisitExitStatement
1 parent 64a8c60 commit 91c0c8c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

RefactoringEssentials/CSharp/Converter/MethodBodyVisitor.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,20 @@ public override SyntaxList<StatementSyntax> DefaultVisit(SyntaxNode node)
3434

3535
public override SyntaxList<StatementSyntax> VisitStopOrEndStatement(VBSyntax.StopOrEndStatementSyntax node)
3636
{
37-
var cSharpEquivalent = node.StopOrEndKeyword.IsKind(VBasic.SyntaxKind.StopKeyword) ? "System.Diagnostics.Debugger.Break();"
38-
: node.StopOrEndKeyword.IsKind(VBasic.SyntaxKind.EndKeyword) ? "System.Environment.Exit(0);"
39-
: throw new NotImplementedException(node.StopOrEndKeyword.Kind() + " not implemented!");
40-
return SingleStatement(SyntaxFactory.ParseStatement(cSharpEquivalent));
37+
return SingleStatement(SyntaxFactory.ParseStatement(GetCSharpEquivalentStatementText(node)));
38+
}
39+
40+
private static string GetCSharpEquivalentStatementText(VBSyntax.StopOrEndStatementSyntax node)
41+
{
42+
switch (VBasic.VisualBasicExtensions.Kind(node.StopOrEndKeyword))
43+
{
44+
case VBasic.SyntaxKind.StopKeyword:
45+
return "System.Diagnostics.Debugger.Break();";
46+
case VBasic.SyntaxKind.EndKeyword:
47+
return "System.Environment.Exit(0);";
48+
default:
49+
throw new NotImplementedException(node.StopOrEndKeyword.Kind() + " not implemented!");
50+
}
4151
}
4252

4353
public override SyntaxList<StatementSyntax> VisitLocalDeclarationStatement(VBSyntax.LocalDeclarationStatementSyntax node)

0 commit comments

Comments
 (0)