@@ -608,6 +608,43 @@ public void Test_ObservableProperty_ModelWithCultureAwarePropertyName()
608608 CollectionAssert . AreEqual ( new [ ] { nameof ( model . InputFolder ) } , propertyNames ) ;
609609 }
610610
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+
611648 public abstract partial class BaseViewModel : ObservableObject
612649 {
613650 public string ? Content { get ; set ; }
@@ -991,4 +1028,13 @@ partial class ModelWithCultureAwarePropertyName
9911028 [ ObservableProperty ]
9921029 private int _inputFolder ;
9931030 }
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+ }
9941040}
0 commit comments