Is there a way, in .net, to detect if a word is a keyword in a given .net language?
I am using a fairly simple code generator for this project, and I would like to start automating it. Right now I do each one by hand, so fixing any issues that arise is pretty easy. However, once this starts happening automatically I am going to need a way to detect if a word I need to use as an identifier is a keyword. I can still use it, I just need to quote it properly.
I know that I can simply quote everything I generate, but I would like to keep the generated code pretty 🙂
An example of the kind of things I need to quote:
vb: Public [Class] As String = 'CLASS' c#: public String @class = 'CLASS';
Perhaps you’re looking for
IsValidIdentifieror
CreateEscapedIdentifierFor example:
Seems like it wouldn’t be too hard to extend/use this facility to meet your needs.