@@ -747,6 +747,119 @@ await CSharpAnalyzerWithLanguageVersionTest<WinRTGeneratedBindableCustomProperty
747
747
editorconfig : [ ( "_MvvmToolkitIsUsingWindowsRuntimePack" , true ) ] ) ;
748
748
}
749
749
750
+ [ TestMethod ]
751
+ public async Task WinRTGeneratedBindableCustomPropertyWithBasesMemberAnalyzer_TargetingWindows_NotIncluded_DoesNotWarn ( )
752
+ {
753
+ const string source = """
754
+ using System;
755
+ using CommunityToolkit.Mvvm.ComponentModel;
756
+ using CommunityToolkit.Mvvm.Input;
757
+ using WinRT;
758
+
759
+ namespace MyApp
760
+ {
761
+ [GeneratedBindableCustomProperty(["Name"], [])]
762
+ public partial class SampleViewModel : ObservableObject
763
+ {
764
+ [ObservableProperty]
765
+ private string name;
766
+
767
+ [RelayCommand]
768
+ private void DoStuff()
769
+ {
770
+ }
771
+ }
772
+ }
773
+
774
+ namespace WinRT
775
+ {
776
+ public class GeneratedBindableCustomPropertyAttribute(string[] a, string[] b) : Attribute
777
+ {
778
+ }
779
+ }
780
+ """ ;
781
+
782
+ await CSharpAnalyzerWithLanguageVersionTest < WinRTGeneratedBindableCustomPropertyWithBasesMemberAnalyzer > . VerifyAnalyzerAsync (
783
+ source ,
784
+ LanguageVersion . CSharp12 ,
785
+ editorconfig : [ ( "_MvvmToolkitIsUsingWindowsRuntimePack" , true ) ] ) ;
786
+ }
787
+
788
+ [ TestMethod ]
789
+ public async Task WinRTGeneratedBindableCustomPropertyWithBasesMemberAnalyzer_TargetingWindows_BaseType_Field_NotIncluded_DoesNotWarn ( )
790
+ {
791
+ const string source = """
792
+ using System;
793
+ using CommunityToolkit.Mvvm.ComponentModel;
794
+ using WinRT;
795
+
796
+ namespace MyApp
797
+ {
798
+ [GeneratedBindableCustomProperty(["OtherName"], [])]
799
+ public partial class SampleViewModel : BaseViewModel
800
+ {
801
+ }
802
+
803
+ public partial class BaseViewModel : ObservableObject
804
+ {
805
+ [ObservableProperty]
806
+ private string name;
807
+ }
808
+ }
809
+
810
+ namespace WinRT
811
+ {
812
+ public class GeneratedBindableCustomPropertyAttribute(string[] a, string[] b) : Attribute
813
+ {
814
+ }
815
+ }
816
+ """ ;
817
+
818
+ await CSharpAnalyzerWithLanguageVersionTest < WinRTGeneratedBindableCustomPropertyWithBasesMemberAnalyzer > . VerifyAnalyzerAsync (
819
+ source ,
820
+ LanguageVersion . CSharp12 ,
821
+ editorconfig : [ ( "_MvvmToolkitIsUsingWindowsRuntimePack" , true ) ] ) ;
822
+ }
823
+
824
+ [ TestMethod ]
825
+ public async Task WinRTGeneratedBindableCustomPropertyWithBasesMemberAnalyzer_TargetingWindows_BaseType_Method_NotIncluded_DoesNotWarn ( )
826
+ {
827
+ const string source = """
828
+ using System;
829
+ using CommunityToolkit.Mvvm.ComponentModel;
830
+ using CommunityToolkit.Mvvm.Input;
831
+ using WinRT;
832
+
833
+ namespace MyApp
834
+ {
835
+ [GeneratedBindableCustomProperty(["OtherMethod"], [])]
836
+ public partial class SampleViewModel : BaseViewModel
837
+ {
838
+ }
839
+
840
+ public partial class BaseViewModel : ObservableObject
841
+ {
842
+ [RelayCommand]
843
+ private void DoStuff()
844
+ {
845
+ }
846
+ }
847
+ }
848
+
849
+ namespace WinRT
850
+ {
851
+ public class GeneratedBindableCustomPropertyAttribute(string[] a, string[] b) : Attribute
852
+ {
853
+ }
854
+ }
855
+ """ ;
856
+
857
+ await CSharpAnalyzerWithLanguageVersionTest < WinRTGeneratedBindableCustomPropertyWithBasesMemberAnalyzer > . VerifyAnalyzerAsync (
858
+ source ,
859
+ LanguageVersion . CSharp12 ,
860
+ editorconfig : [ ( "_MvvmToolkitIsUsingWindowsRuntimePack" , true ) ] ) ;
861
+ }
862
+
750
863
[ TestMethod ]
751
864
public async Task WinRTGeneratedBindableCustomPropertyWithBasesMemberAnalyzer_TargetingWindows_BaseType_Field_Warns ( )
752
865
{
@@ -781,6 +894,42 @@ await CSharpAnalyzerWithLanguageVersionTest<WinRTGeneratedBindableCustomProperty
781
894
editorconfig : [ ( "_MvvmToolkitIsUsingWindowsRuntimePack" , true ) ] ) ;
782
895
}
783
896
897
+ [ TestMethod ]
898
+ public async Task WinRTGeneratedBindableCustomPropertyWithBasesMemberAnalyzer_TargetingWindows_BaseType_Field_Included_Warns ( )
899
+ {
900
+ const string source = """
901
+ using System;
902
+ using CommunityToolkit.Mvvm.ComponentModel;
903
+ using WinRT;
904
+
905
+ namespace MyApp
906
+ {
907
+ [GeneratedBindableCustomProperty(["Name"], [])]
908
+ public partial class {|MVVMTK0047:SampleViewModel|} : BaseViewModel
909
+ {
910
+ }
911
+
912
+ public partial class BaseViewModel : ObservableObject
913
+ {
914
+ [ObservableProperty]
915
+ private string name;
916
+ }
917
+ }
918
+
919
+ namespace WinRT
920
+ {
921
+ public class GeneratedBindableCustomPropertyAttribute(string[] a, string[] b) : Attribute
922
+ {
923
+ }
924
+ }
925
+ """ ;
926
+
927
+ await CSharpAnalyzerWithLanguageVersionTest < WinRTGeneratedBindableCustomPropertyWithBasesMemberAnalyzer > . VerifyAnalyzerAsync (
928
+ source ,
929
+ LanguageVersion . CSharp12 ,
930
+ editorconfig : [ ( "_MvvmToolkitIsUsingWindowsRuntimePack" , true ) ] ) ;
931
+ }
932
+
784
933
[ TestMethod ]
785
934
public async Task WinRTGeneratedBindableCustomPropertyWithBasesMemberAnalyzer_TargetingWindows_BaseType_Method_Warns ( )
786
935
{
@@ -818,6 +967,45 @@ await CSharpAnalyzerWithLanguageVersionTest<WinRTGeneratedBindableCustomProperty
818
967
editorconfig : [ ( "_MvvmToolkitIsUsingWindowsRuntimePack" , true ) ] ) ;
819
968
}
820
969
970
+ [ TestMethod ]
971
+ public async Task WinRTGeneratedBindableCustomPropertyWithBasesMemberAnalyzer_TargetingWindows_BaseType_Method_Included_Warns ( )
972
+ {
973
+ const string source = """
974
+ using System;
975
+ using CommunityToolkit.Mvvm.ComponentModel;
976
+ using CommunityToolkit.Mvvm.Input;
977
+ using WinRT;
978
+
979
+ namespace MyApp
980
+ {
981
+ [GeneratedBindableCustomProperty(["DoStuffCommand"], [])]
982
+ public partial class {|MVVMTK0048:SampleViewModel|} : BaseViewModel
983
+ {
984
+ }
985
+
986
+ public partial class BaseViewModel : ObservableObject
987
+ {
988
+ [RelayCommand]
989
+ private void DoStuff()
990
+ {
991
+ }
992
+ }
993
+ }
994
+
995
+ namespace WinRT
996
+ {
997
+ public class GeneratedBindableCustomPropertyAttribute(string[] a, string[] b) : Attribute
998
+ {
999
+ }
1000
+ }
1001
+ """ ;
1002
+
1003
+ await CSharpAnalyzerWithLanguageVersionTest < WinRTGeneratedBindableCustomPropertyWithBasesMemberAnalyzer > . VerifyAnalyzerAsync (
1004
+ source ,
1005
+ LanguageVersion . CSharp12 ,
1006
+ editorconfig : [ ( "_MvvmToolkitIsUsingWindowsRuntimePack" , true ) ] ) ;
1007
+ }
1008
+
821
1009
[ TestMethod ]
822
1010
public async Task InvalidPartialPropertyLevelObservablePropertyAttributeAnalyzer_OnValidProperty_DoesNotWarn ( )
823
1011
{
0 commit comments