@@ -608,6 +608,43 @@ public void Test_ObservableProperty_ModelWithCultureAwarePropertyName()
608
608
CollectionAssert . AreEqual ( new [ ] { nameof ( model . InputFolder ) } , propertyNames ) ;
609
609
}
610
610
611
+ // See https://github.com/CommunityToolkit/dotnet/issues/242
612
+ [ TestMethod ]
613
+ public void Test_ObservableProperty_ModelWithAlsoBroadcastChangeAndDisplayAttributeLast ( )
614
+ {
615
+ IMessenger messenger = new StrongReferenceMessenger ( ) ;
616
+ ModelWithAlsoBroadcastChangeAndDisplayAttributeLast model = new ( messenger ) ;
617
+
618
+ List < string ? > propertyNames = new ( ) ;
619
+
620
+ model . PropertyChanged += ( s , e ) => propertyNames . Add ( e . PropertyName ) ;
621
+
622
+ object newValue = new ( ) ;
623
+ bool isMessageReceived = false ;
624
+
625
+ messenger . Register < Test_ObservablePropertyAttribute , PropertyChangedMessage < object > > ( this , ( r , m ) =>
626
+ {
627
+ if ( m . Sender != model )
628
+ {
629
+ Assert . Fail ( ) ;
630
+ }
631
+
632
+ if ( m . NewValue != newValue )
633
+ {
634
+ Assert . Fail ( ) ;
635
+ }
636
+
637
+ isMessageReceived = true ;
638
+ } ) ;
639
+
640
+ model . SomeProperty = newValue ;
641
+
642
+ Assert . AreEqual ( model . SomeProperty , newValue ) ;
643
+ Assert . IsTrue ( isMessageReceived ) ;
644
+
645
+ CollectionAssert . AreEqual ( new [ ] { nameof ( model . SomeProperty ) } , propertyNames ) ;
646
+ }
647
+
611
648
public abstract partial class BaseViewModel : ObservableObject
612
649
{
613
650
public string ? Content { get ; set ; }
@@ -991,4 +1028,13 @@ partial class ModelWithCultureAwarePropertyName
991
1028
[ ObservableProperty ]
992
1029
private int _inputFolder ;
993
1030
}
1031
+
1032
+ [ ObservableRecipient ]
1033
+ public sealed partial class ModelWithAlsoBroadcastChangeAndDisplayAttributeLast : ObservableValidator
1034
+ {
1035
+ [ ObservableProperty ]
1036
+ [ AlsoBroadcastChange ]
1037
+ [ Display ( Name = "Foo bar baz" ) ]
1038
+ private object ? _someProperty ;
1039
+ }
994
1040
}
0 commit comments