-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
ThisAssembly.Strings: If resource name is not a valid code identifier, compilation fails #83
Comments
Some quick notes:
|
I guess more than just checking whether the identifier is valid, you'd actually want it to generate code but turn the identifier into a valid one by replacing invalid chars with underscores, say... |
@viceroypenguin perhaps this could also use the sanitization you applied to resource class names? |
Yeah, I encountered this while working on Resources; I just got lazy and avoided it for now... 🙂. I would expect the code to work the same here. Could copy/paste or extract to common .cs file. The regex is doing the bulk of the work, so copy/paste would probably be fine. |
This method could be used to generate a valid identifier : it replaces any invalid identifier by '', removes redundant '', and prefixes the identifier by '_' if not valid :
As for now, all we can do is change all the files' name, but that's not always easy. |
Thanks for the suggestion @PhenX. Would you like to send a PR? 🙏 |
If a resx file contains an entry with an invalid code identifier (like a number), the generated code will not compile, and the error is quite cryptic too.
We should validate that the name are valid C# identifiers and skip (probably warn too if they aren't?)
The text was updated successfully, but these errors were encountered: