Johan Appelgren
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
24 additions and
1 deletions
-
src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs
-
tests/Avalonia.Markup.UnitTests/Parsers/ExpressionObserverBuilderTests_AttachedProperty.cs
|
|
|
@ -257,8 +257,10 @@ namespace Avalonia.Markup.Parsers |
|
|
|
} |
|
|
|
|
|
|
|
result = ParseBeforeMember(ref r, nodes); |
|
|
|
if (result == State.AttachedProperty) |
|
|
|
result = ParseAttachedProperty(ref r, nodes); |
|
|
|
|
|
|
|
if(r.Peek == '[') |
|
|
|
if (r.Peek == '[') |
|
|
|
{ |
|
|
|
result = ParseIndexer(ref r, nodes); |
|
|
|
} |
|
|
|
|
|
|
|
@ -65,6 +65,22 @@ namespace Avalonia.Markup.UnitTests.Parsers |
|
|
|
Assert.Null(((IAvaloniaObjectDebug)data).GetPropertyChangedSubscribers()); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task Should_Get_Chained_Attached_Property_Value_With_TypeCast() |
|
|
|
{ |
|
|
|
var expected = new Class1(); |
|
|
|
|
|
|
|
var data = new Class1(); |
|
|
|
data.SetValue(Owner.SomethingProperty, new Class1() { Next = expected }); |
|
|
|
|
|
|
|
var target = Build(data, "((Class1)(Owner.Something)).Next", typeResolver: (ns, name) => name == "Class1" ? typeof(Class1) : _typeResolver(ns, name)); |
|
|
|
var result = await target.Take(1); |
|
|
|
|
|
|
|
Assert.Equal(expected, result); |
|
|
|
|
|
|
|
Assert.Null(((IAvaloniaObjectDebug)data).GetPropertyChangedSubscribers()); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Should_Track_Simple_Attached_Value() |
|
|
|
{ |
|
|
|
@ -159,6 +175,11 @@ namespace Avalonia.Markup.UnitTests.Parsers |
|
|
|
"Foo", |
|
|
|
typeof(Owner), |
|
|
|
defaultValue: "foo"); |
|
|
|
|
|
|
|
public static readonly AttachedProperty<AvaloniaObject> SomethingProperty = |
|
|
|
AvaloniaProperty.RegisterAttached<Class1, AvaloniaObject>( |
|
|
|
"Something", |
|
|
|
typeof(Owner)); |
|
|
|
} |
|
|
|
|
|
|
|
private class Class1 : AvaloniaObject |
|
|
|
|