diff --git a/tests/Avalonia.LeakTests/ExpressionObserverTests.cs b/tests/Avalonia.LeakTests/ExpressionObserverTests.cs index 3dbc62424f..d0f892bebb 100644 --- a/tests/Avalonia.LeakTests/ExpressionObserverTests.cs +++ b/tests/Avalonia.LeakTests/ExpressionObserverTests.cs @@ -71,6 +71,28 @@ namespace Avalonia.LeakTests Assert.Equal(0, memory.GetObjects(where => where.Type.Is()).ObjectsCount)); } + [Fact] + public void Should_Not_Keep_Source_Alive_MethodBinding() + { + Func run = () => + { + var source = new { Foo = new MethodBound() }; + var target = new ExpressionObserver(source, "Foo.A"); + target.Subscribe(_ => { }); + return target; + }; + + var result = run(); + + dotMemory.Check(memory => + Assert.Equal(0, memory.GetObjects(where => where.Type.Is()).ObjectsCount)); + } + + private class MethodBound + { + public void A() { } + } + private class NonIntegerIndexer : NotifyingBase { private readonly Dictionary _storage = new Dictionary();