kekekeks / XamlX

General purpose pluggable XAML compiler with no runtime dependencies.
MIT License
319 stars 55 forks source link

Don't allow adding to lists from attributes. #85

Closed grokys closed 1 year ago

grokys commented 1 year ago

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 https://github.com/AvaloniaUI/Avalonia/issues/10946