-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specify name for a property #220
Comments
We have a dictionary of characters that must not occur in an identifier: XmlSchemaClassGenerator/XmlSchemaClassGenerator/NamingExtensions.cs Lines 12 to 77 in e0d6119
+ is in that dictionary so it gets replaced by Plus but although - is also invalid it gets replaced with _ in a separate step. And because _ by itself is again invalid it gets prepended with Item . The reason we're replacing - with _ and not Minus (or Dash ) is that - occurs frequently as a word separator. I think it might be best to make this a special case so that the exact string "-" is replaced by "Minus" .
|
@florin141 Couldn't you do this by implementing your own NamingProvider? |
Mmm, I'm not sure how to do that. But I'll have a closer look at the code soon and I'll try that. Any idea where I could start? |
Make a copy of this: https://github.com/mganss/XmlSchemaClassGenerator/blob/master/XmlSchemaClassGenerator/NamingProvider.cs Rename it and supply it as NamingProvider. But you need to generate stuff programatically then (See https://github.com/mganss/XmlSchemaClassGenerator/#usage -> Last part: "For use from code" ) |
Consider this:
The generated c# code is this:
As you can see, 'Plus' name is a perfect name for the symbol '+', but 'Item_' not so much for the symbol '-'.
Is there any way I could override that behaviour and say something like, for 'SignType' if you encounter an enumeration with value="-", change the name of the property to 'Minus'?
The text was updated successfully, but these errors were encountered: