Skip to content
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

Chars restriction for PropertyPath #2621

Closed
FoggyFinder opened this issue Jun 5, 2019 · 3 comments
Closed

Chars restriction for PropertyPath #2621

FoggyFinder opened this issue Jun 5, 2019 · 3 comments
Labels

Comments

@FoggyFinder
Copy link
Contributor

Currently there are next restrictions to the symbols:

        private static bool IsValidIdentifierChar(char c)
        {
            if (IsValidIdentifierStart(c))
            {
                return true;
            }
            else
            {
                var cat = CharUnicodeInfo.GetUnicodeCategory(c);
                return cat == UnicodeCategory.NonSpacingMark ||
                       cat == UnicodeCategory.SpacingCombiningMark ||
                       cat == UnicodeCategory.ConnectorPunctuation ||
                       cat == UnicodeCategory.Format ||
                       cat == UnicodeCategory.DecimalDigitNumber;
            }
        }

Source

These constraints are definitely more strict than WPF has. For example, UnicodeCategory.DashPunctuation is valid for WPF.

@grokys
Copy link
Member

grokys commented Jun 5, 2019

Why would you need to use a dash in a property path? Is there anywhere a dash is valid in a .NET property name?

Also by allowing dashes, we'd be ruling out the future possibility for allowing mathematical expressions in a binding.

@FoggyFinder
Copy link
Contributor Author

Is there anywhere a dash is valid in a .NET property name?

I don't think so. Not sure although.

Anyway, properties with dashes might be exposed as helper properties in some libraries.
For example, in Gjallarhorn.Bindable:

    let getErrorsPropertyName propertyName =
        propertyName + "-" + "Errors"
    let getValidPropertyName propertyName =
        propertyName + "-" + "IsValid"

Source

So it won't work for Avalonia as for WPF.

If dashes won't be allowed in principle then I'll open issue there to discuss how to handle it better. I just want to be sure that it is intentional restriction and not bug or something.

@FoggyFinder
Copy link
Contributor Author

Closing this one since that not a bug and last reply was long ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants