-
-
Notifications
You must be signed in to change notification settings - Fork 107
Description
While attempting to convert a Java file, JavaToCSharp crashed while parsing the following method parameter
Structure structstruct is a keyword in C#, but not in Java. As such, JavaToCSharp.Declarations.MethodDeclarationVisitor.VisitInternal was crashing here
var paramSyntax = SyntaxFactory.Parameter(
attributeLists: [],
modifiers: modifiers,
type: TypeHelper.ConvertTypeSyntax(type, arrayLevel),
identifier: SyntaxFactory.ParseToken(identifier),
@default: null);on the basis that the value passed to the identifier parameter was invalid. SyntaxFactory.ParseToken will produce a token of type SyntaxKind.StructKeyword in response to parsing struct rather than a simple identifier token. Earlier in VisitInternal the method TypeHelper.EscapeIdentifier is called, which prepends @ to several types of keywords. Not all keywords are listed here however, so I have updated the list to specify all standard keywords as defined here. There are additional contextual keywords in C# but these should not apply for the purposes of escaping an identifier.