@@ -546,6 +546,29 @@ public void Test_ObservableProperty_InheritedMembersAsAttributeTargets()
546
546
CollectionAssert . AreEqual ( new [ ] { model . DoSomethingCommand , model . ManualCommand } , canExecuteChangedArgs ) ;
547
547
}
548
548
549
+ // See https://github.com/CommunityToolkit/dotnet/issues/224
550
+ [ TestMethod ]
551
+ public void Test_ObservableProperty_WithinGenericTypeWithMultipleTypeParameters ( )
552
+ {
553
+ ModelWithMultipleGenericParameters < int , string > model = new ( ) ;
554
+
555
+ List < string ? > propertyNames = new ( ) ;
556
+
557
+ model . PropertyChanged += ( s , e ) => propertyNames . Add ( e . PropertyName ) ;
558
+
559
+ model . Value = true ;
560
+ model . TValue = 42 ;
561
+ model . UValue = "Hello" ;
562
+ model . List = new List < int > ( ) { 420 } ;
563
+
564
+ Assert . AreEqual ( model . Value , true ) ;
565
+ Assert . AreEqual ( model . TValue , 42 ) ;
566
+ Assert . AreEqual ( model . UValue , "Hello" ) ;
567
+ CollectionAssert . AreEqual ( new [ ] { 420 } , model . List ) ;
568
+
569
+ CollectionAssert . AreEqual ( new [ ] { nameof ( model . Value ) , nameof ( model . TValue ) , nameof ( model . UValue ) , nameof ( model . List ) } , propertyNames ) ;
570
+ }
571
+
549
572
public abstract partial class BaseViewModel : ObservableObject
550
573
{
551
574
public string ? Content { get ; set ; }
@@ -889,4 +912,24 @@ public class Bar<T>
889
912
}
890
913
}
891
914
#endif
915
+
916
+ interface IValueHolder
917
+ {
918
+ public bool Value { get ; }
919
+ }
920
+
921
+ partial class ModelWithMultipleGenericParameters < T , U > : ObservableObject , IValueHolder
922
+ {
923
+ [ ObservableProperty ]
924
+ private bool value ;
925
+
926
+ [ ObservableProperty ]
927
+ private T tValue ;
928
+
929
+ [ ObservableProperty ]
930
+ private U uValue ;
931
+
932
+ [ ObservableProperty ]
933
+ private List < T > list ;
934
+ }
892
935
}
0 commit comments