daver32/InterfaceGenerator

Keyword parameter identifiers don't get escaped

Closed this issue · 1 comments

Hey,

while testing this source generator with another one I noticed an issue with some generated parameter names.
Methods that use keywords such as long as identifiers don't get properly prefixed with @ in the generated interface.

Example:

public void VoidMethodWithKeywordParam(long @long)

results in:

void VoidMethodWithKeywordParam(long long); // CS1001 Identifier expected

but should be:

void VoidMethodWithKeywordParam(long @long);

This should be the line where param.Name needs to be checked and sometimes prefixed.

writer.Write("{0} {1}", param.Type, param.Name);

e. g. AutoRest is handling these identifiers like this:
1. Writing the identifier.
2. Checking for C# keywords

Thanks for the heads up, I've just added this in v1.0.8