@@ -2049,6 +2049,111 @@ await CSharpAnalyzerWithLanguageVersionTest<WinRTRelayCommandIsNotGeneratedBinda
2049
2049
editorconfig : [ ( "_MvvmToolkitIsUsingWindowsRuntimePack" , true ) ] ) ;
2050
2050
}
2051
2051
2052
+ [ TestMethod ]
2053
+ public async Task WinRTRelayCommandIsNotGeneratedBindableCustomPropertyCompatibleAnalyzer_TargetingWindows_NotIncluded1_DoesNotWarn ( )
2054
+ {
2055
+ const string source = """
2056
+ using System;
2057
+ using CommunityToolkit.Mvvm.ComponentModel;
2058
+ using CommunityToolkit.Mvvm.Input;
2059
+ using WinRT;
2060
+
2061
+ namespace MyApp
2062
+ {
2063
+ [GeneratedBindableCustomProperty([], [])]
2064
+ public partial class SampleViewModel : ObservableObject
2065
+ {
2066
+ [RelayCommand]
2067
+ private void DoStuff()
2068
+ {
2069
+ }
2070
+ }
2071
+ }
2072
+
2073
+ namespace WinRT
2074
+ {
2075
+ public class GeneratedBindableCustomPropertyAttribute(string[] a, string[] b) : Attribute
2076
+ {
2077
+ }
2078
+ }
2079
+ """ ;
2080
+
2081
+ await CSharpAnalyzerWithLanguageVersionTest < WinRTRelayCommandIsNotGeneratedBindableCustomPropertyCompatibleAnalyzer > . VerifyAnalyzerAsync (
2082
+ source ,
2083
+ LanguageVersion . CSharp12 ,
2084
+ editorconfig : [ ( "_MvvmToolkitIsUsingWindowsRuntimePack" , true ) ] ) ;
2085
+ }
2086
+
2087
+ [ TestMethod ]
2088
+ public async Task WinRTRelayCommandIsNotGeneratedBindableCustomPropertyCompatibleAnalyzer_TargetingWindows_NotIncluded2_DoesNotWarn ( )
2089
+ {
2090
+ const string source = """
2091
+ using System;
2092
+ using CommunityToolkit.Mvvm.ComponentModel;
2093
+ using CommunityToolkit.Mvvm.Input;
2094
+ using WinRT;
2095
+
2096
+ namespace MyApp
2097
+ {
2098
+ [GeneratedBindableCustomProperty(["OtherCommand"], [])]
2099
+ public partial class SampleViewModel : ObservableObject
2100
+ {
2101
+ [RelayCommand]
2102
+ private void DoStuff()
2103
+ {
2104
+ }
2105
+ }
2106
+ }
2107
+
2108
+ namespace WinRT
2109
+ {
2110
+ public class GeneratedBindableCustomPropertyAttribute(string[] a, string[] b) : Attribute
2111
+ {
2112
+ }
2113
+ }
2114
+ """ ;
2115
+
2116
+ await CSharpAnalyzerWithLanguageVersionTest < WinRTRelayCommandIsNotGeneratedBindableCustomPropertyCompatibleAnalyzer > . VerifyAnalyzerAsync (
2117
+ source ,
2118
+ LanguageVersion . CSharp12 ,
2119
+ editorconfig : [ ( "_MvvmToolkitIsUsingWindowsRuntimePack" , true ) ] ) ;
2120
+ }
2121
+
2122
+ [ TestMethod ]
2123
+ public async Task WinRTRelayCommandIsNotGeneratedBindableCustomPropertyCompatibleAnalyzer_TargetingWindows_NotIncluded3_DoesNotWarn ( )
2124
+ {
2125
+ const string source = """
2126
+ using System;
2127
+ using CommunityToolkit.Mvvm.ComponentModel;
2128
+ using CommunityToolkit.Mvvm.Input;
2129
+ using WinRT;
2130
+
2131
+ namespace MyApp
2132
+ {
2133
+ [GeneratedBindableCustomProperty(["OtherCommand"], ["DoStuffCommand"])]
2134
+ public partial class SampleViewModel : ObservableObject
2135
+ {
2136
+ [RelayCommand]
2137
+ private void DoStuff()
2138
+ {
2139
+ }
2140
+ }
2141
+ }
2142
+
2143
+ namespace WinRT
2144
+ {
2145
+ public class GeneratedBindableCustomPropertyAttribute(string[] a, string[] b) : Attribute
2146
+ {
2147
+ }
2148
+ }
2149
+ """ ;
2150
+
2151
+ await CSharpAnalyzerWithLanguageVersionTest < WinRTRelayCommandIsNotGeneratedBindableCustomPropertyCompatibleAnalyzer > . VerifyAnalyzerAsync (
2152
+ source ,
2153
+ LanguageVersion . CSharp12 ,
2154
+ editorconfig : [ ( "_MvvmToolkitIsUsingWindowsRuntimePack" , true ) ] ) ;
2155
+ }
2156
+
2052
2157
[ TestMethod ]
2053
2158
public async Task WinRTRelayCommandIsNotGeneratedBindableCustomPropertyCompatibleAnalyzer_TargetingWindows_Bindable_Warns ( )
2054
2159
{
@@ -2084,6 +2189,76 @@ await CSharpAnalyzerWithLanguageVersionTest<WinRTRelayCommandIsNotGeneratedBinda
2084
2189
editorconfig : [ ( "_MvvmToolkitIsUsingWindowsRuntimePack" , true ) ] ) ;
2085
2190
}
2086
2191
2192
+ [ TestMethod ]
2193
+ public async Task WinRTRelayCommandIsNotGeneratedBindableCustomPropertyCompatibleAnalyzer_TargetingWindows_Bindable_Included1_Warns ( )
2194
+ {
2195
+ const string source = """
2196
+ using System;
2197
+ using CommunityToolkit.Mvvm.ComponentModel;
2198
+ using CommunityToolkit.Mvvm.Input;
2199
+ using WinRT;
2200
+
2201
+ namespace MyApp
2202
+ {
2203
+ [GeneratedBindableCustomProperty(["DoStuffCommand"], [])]
2204
+ public partial class SampleViewModel : ObservableObject
2205
+ {
2206
+ [RelayCommand]
2207
+ private void {|MVVMTK0046:DoStuff|}()
2208
+ {
2209
+ }
2210
+ }
2211
+ }
2212
+
2213
+ namespace WinRT
2214
+ {
2215
+ public class GeneratedBindableCustomPropertyAttribute(string[] a, string[] b) : Attribute
2216
+ {
2217
+ }
2218
+ }
2219
+ """ ;
2220
+
2221
+ await CSharpAnalyzerWithLanguageVersionTest < WinRTRelayCommandIsNotGeneratedBindableCustomPropertyCompatibleAnalyzer > . VerifyAnalyzerAsync (
2222
+ source ,
2223
+ LanguageVersion . CSharp12 ,
2224
+ editorconfig : [ ( "_MvvmToolkitIsUsingWindowsRuntimePack" , true ) ] ) ;
2225
+ }
2226
+
2227
+ [ TestMethod ]
2228
+ public async Task WinRTRelayCommandIsNotGeneratedBindableCustomPropertyCompatibleAnalyzer_TargetingWindows_Bindable_Included2_Warns ( )
2229
+ {
2230
+ const string source = """
2231
+ using System;
2232
+ using CommunityToolkit.Mvvm.ComponentModel;
2233
+ using CommunityToolkit.Mvvm.Input;
2234
+ using WinRT;
2235
+
2236
+ namespace MyApp
2237
+ {
2238
+ [GeneratedBindableCustomProperty(["Blah", "", "DoStuffCommand"], [])]
2239
+ public partial class SampleViewModel : ObservableObject
2240
+ {
2241
+ [RelayCommand]
2242
+ private void {|MVVMTK0046:DoStuff|}()
2243
+ {
2244
+ }
2245
+ }
2246
+ }
2247
+
2248
+ namespace WinRT
2249
+ {
2250
+ public class GeneratedBindableCustomPropertyAttribute(string[] a, string[] b) : Attribute
2251
+ {
2252
+ }
2253
+ }
2254
+ """ ;
2255
+
2256
+ await CSharpAnalyzerWithLanguageVersionTest < WinRTRelayCommandIsNotGeneratedBindableCustomPropertyCompatibleAnalyzer > . VerifyAnalyzerAsync (
2257
+ source ,
2258
+ LanguageVersion . CSharp12 ,
2259
+ editorconfig : [ ( "_MvvmToolkitIsUsingWindowsRuntimePack" , true ) ] ) ;
2260
+ }
2261
+
2087
2262
[ TestMethod ]
2088
2263
public async Task WinRTClassUsingNotifyPropertyChangedAttributesAnalyzer_NotTargetingWindows_DoesNotWarn ( )
2089
2264
{
0 commit comments