-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Fixed Selector.ValidateNestingSelector not calling overrides when iterating up through parent selectors #19947
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
base: master
Are you sure you want to change the base?
Fixed Selector.ValidateNestingSelector not calling overrides when iterating up through parent selectors #19947
Conversation
…rating up through parent selectors Changed ValidateNestingSelector to call recursively, walking up the hierarchy of parent selectors. This means function overrides are taken into account when walking up the tree. Now if a selector has an OrSelector as its parent, it doesn't throw an exception.
ecffbba to
317df98
Compare
|
You can test this PR using the following package version. |
|
As mentioned in #19943 (comment), this isn't a valid syntax in XAML right now. We don't even support parenthesis, e.g. Like Max, I'm not against it (we can enable that syntax in XAML later), this should still be kept in mind. |
| { | ||
| _selectorString = _parent.ToString(owner) + " > "; | ||
| _selectorString = _parent is OrSelector ? | ||
| $"({_parent.ToString(owner)}) > " : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: all selectors have been modified to add parenthesis around OrSelector, why not add this directly to OrSelector.ToString()? You could add an internal override taking a flag to avoid adding parenthesis around an OrSelector being placed at the root level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could do that if you want. I'd still have to change all of the other selectors to check if it's an OrSelector and to invoke the internal override with the extra parameter. Just to be clear, the idea is that parenthesis are redundant when the OrSelector is the only selector.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant is to have a method like internal virtual string ToString(Style owner, bool hasChild) on Selector and just call that with hasChild: true in every child selector without checking for the parent. Then override it in OrSelector to add the parenthesis according to hasChild.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
2e477b3 to
e8906d3
Compare
|
You can test this PR using the following package version. |
What does the pull request do?
Suggested fix for #19943
What is the current behavior?
Explained in #19943
What is the updated/expected behavior with this PR?
Explained in #19943
How was the solution implemented (if it's not obvious)?
Changed ValidateNestingSelector to call recursively, walking up the hierarchy of parent selectors. This means function overrides are taken into account when walking up the tree. Now if a leaf selector has an OrSelector as its parent, it doesn't throw an exception.
Checklist
Breaking changes
Should not break anything.
Fixed issues
Fixes #19943