|
11 | 11 | using System.Runtime.CompilerServices;
|
12 | 12 | using System.Threading.Tasks;
|
13 | 13 | using CommunityToolkit.Mvvm.ComponentModel;
|
| 14 | +using CommunityToolkit.Mvvm.ExternalAssembly; |
14 | 15 | using CommunityToolkit.Mvvm.Input;
|
15 | 16 | using CommunityToolkit.Mvvm.Messaging;
|
16 | 17 | using CommunityToolkit.Mvvm.Messaging.Messages;
|
@@ -569,6 +570,27 @@ public void Test_ObservableProperty_WithinGenericTypeWithMultipleTypeParameters(
|
569 | 570 | CollectionAssert.AreEqual(new[] { nameof(model.Value), nameof(model.TValue), nameof(model.UValue), nameof(model.List) }, propertyNames);
|
570 | 571 | }
|
571 | 572 |
|
| 573 | + // See https://github.com/CommunityToolkit/dotnet/issues/222 |
| 574 | + [TestMethod] |
| 575 | + public void Test_ObservableProperty_WithBaseViewModelWithObservableObjectAttributeInAnotherAssembly() |
| 576 | + { |
| 577 | + ModelWithObservablePropertyAndBaseClassInAnotherAssembly model = new(); |
| 578 | + |
| 579 | + List<string?> propertyNames = new(); |
| 580 | + |
| 581 | + model.PropertyChanged += (s, e) => propertyNames.Add(e.PropertyName); |
| 582 | + |
| 583 | + Assert.AreEqual(model.OtherProperty, "Ok"); |
| 584 | + |
| 585 | + model.MyProperty = "A"; |
| 586 | + model.OtherProperty = "B"; |
| 587 | + |
| 588 | + Assert.AreEqual(model.MyProperty, "A"); |
| 589 | + Assert.AreEqual(model.OtherProperty, "B"); |
| 590 | + |
| 591 | + CollectionAssert.AreEqual(new[] { nameof(model.MyProperty), nameof(model.OtherProperty) }, propertyNames); |
| 592 | + } |
| 593 | + |
572 | 594 | public abstract partial class BaseViewModel : ObservableObject
|
573 | 595 | {
|
574 | 596 | public string? Content { get; set; }
|
@@ -913,6 +935,17 @@ public class Bar<T>
|
913 | 935 | }
|
914 | 936 | #endif
|
915 | 937 |
|
| 938 | + partial class ModelWithObservablePropertyAndBaseClassInAnotherAssembly : ModelWithObservableObjectAttribute |
| 939 | + { |
| 940 | + [ObservableProperty] |
| 941 | + private string? _otherProperty; |
| 942 | + |
| 943 | + public ModelWithObservablePropertyAndBaseClassInAnotherAssembly() |
| 944 | + { |
| 945 | + OtherProperty = "Ok"; |
| 946 | + } |
| 947 | + } |
| 948 | + |
916 | 949 | interface IValueHolder
|
917 | 950 | {
|
918 | 951 | public bool Value { get; }
|
|
0 commit comments