-
Notifications
You must be signed in to change notification settings - Fork 0
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
Allow keywords as property names in components #32
Comments
Couldn't we internally use @ nanes and add an @ sign to the variables when we resolve double curly braces? |
I believe contents within {{ }} is directly evaluated, so that would require a different set up. |
It won't work for expressions. I would suggest limiting variable names to valid c# variable names then, excluding names beginning with underscores as they are used internally already. |
We could just substitute reserved keywords with something else like |
Currently if you try to name a property that resembles a C# keyword like "class" or "checked", a syntax error will occur within the template engine.
A potential solution, which keeps the component's interface the same for the users of the component is to prefix variable names with
@
behind the scenes when a property is part of a C# keyword. To use the property inside the component, the component author must refer to the component as@Name
everywhere.Example:
Here is a list of all keywords in C#: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/
The contextual keywords will probably work without any special treatment, but might want to fully test that first. I can see contextual keywords being a problem inside expressions where they are actually available.
The text was updated successfully, but these errors were encountered: