Skip to content

Conversation

@grokys
Copy link
Collaborator

@grokys grokys commented Apr 13, 2023

Collection syntax in XAML should only be supported when setting property values using property element syntax and not attribute syntax.

Adds a property to XamlAstXamlPropertyValueNode to indicate whether the property value came from an attribute, and a property to PropertySetterBinderParameters to indicate whether a setter can be used from an attribute.

The AdderSetters set PropertySetterBinderParameters.AllowAttributeSyntax to false, which disallows their usage from attribute XamlAstXamlPropertyValueNodes.

Updated the unit tests to ensure that markup extensions cannot now be used to add items to read-only collections (but can be used to assign lists to read-write collection properties).

Required for AvaloniaUI/Avalonia#10946

[Collection syntax](https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/xaml-syntax-in-detail?view=netframeworkdesktop-4.8#collection-syntax)
in XAML should only be supported when setting property values using property element syntax and not attribute syntax.

Adds a property to `XamlAstXamlPropertyValueNode` to indicate whether the property value came from an attribute,
and a property to `PropertySetterBinderParameters` to indicate whether a setter can be used from an attribute.

The `AdderSetter`s set `PropertySetterBinderParameters.AllowAttributeSyntax` to false, which disallows their usage
from attribute `XamlAstXamlPropertyValueNode`s.
@grokys grokys marked this pull request as draft April 13, 2023 09:22
@grokys grokys marked this pull request as ready for review April 13, 2023 10:43
@kekekeks kekekeks enabled auto-merge April 13, 2023 14:41
grokys added a commit to AvaloniaUI/Avalonia that referenced this pull request Apr 13, 2023
Depends on kekekeks/XamlX#85: this PR disallows invoking "collection behavior" for property setters when using attribute syntax.

Required adding a `Flyout.FlyoutPresenterClasses` setter. This property was previously buggy without the setter (see #10946 (comment)). Added tests for setting classes that I put in place when investigating this.

Fixes #10946
@kekekeks kekekeks merged commit 0e5aedc into kekekeks:master Apr 13, 2023
@grokys grokys deleted the fixes/10946-no-list-add-from-attributes branch April 13, 2023 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants