@@ -468,7 +468,7 @@ namespace MyApp
468
468
{
469
469
public partial class SampleViewModel : ObservableObject
470
470
{
471
- [{|MVVMTK0051:ObservableProperty|}]
471
+ [{|MVVMTK0051:ObservableProperty|}]
472
472
private string {|MVVMTK0045:name|};
473
473
}
474
474
}
@@ -480,6 +480,58 @@ await CSharpAnalyzerWithLanguageVersionTest<WinRTObservablePropertyOnFieldsIsNot
480
480
editorconfig : [ ( "_MvvmToolkitIsUsingWindowsRuntimePack" , true ) , ( "CsWinRTAotOptimizerEnabled" , "auto" ) ] ) ;
481
481
}
482
482
483
+ [ TestMethod ]
484
+ public async Task WinRTObservablePropertyOnFieldsIsNotAotCompatibleAnalyzer_TargetingWindows_CsWinRTAotOptimizerEnabled_Auto_NotCSharpPreview_MultipleFields_Warns_WithCompilationWarning_ConsistentLocation ( )
485
+ {
486
+ const string source = """
487
+ using CommunityToolkit.Mvvm.ComponentModel;
488
+
489
+ namespace MyApp
490
+ {
491
+ public partial class SampleViewModel : ObservableObject
492
+ {
493
+ [{|MVVMTK0051:ObservableProperty|}]
494
+ private string {|MVVMTK0045:f1|};
495
+
496
+ [ObservableProperty]
497
+ private string {|MVVMTK0045:f2|};
498
+
499
+ [ObservableProperty]
500
+ private string {|MVVMTK0045:f3|};
501
+ }
502
+
503
+ public partial class OtherViewModel : ObservableObject
504
+ {
505
+ [ObservableProperty]
506
+ private string {|MVVMTK0045:f1|};
507
+
508
+ [ObservableProperty]
509
+ private string {|MVVMTK0045:f2|};
510
+
511
+ [ObservableProperty]
512
+ private string {|MVVMTK0045:f3|};
513
+ }
514
+ }
515
+
516
+ namespace OtherNamespace
517
+ {
518
+ public partial class YetAnotherViewModel : ObservableObject
519
+ {
520
+ [ObservableProperty]
521
+ private string {|MVVMTK0045:f1|};
522
+
523
+ [ObservableProperty]
524
+ private string {|MVVMTK0045:f2|};
525
+ }
526
+ }
527
+ """ ;
528
+
529
+ await CSharpAnalyzerWithLanguageVersionTest < WinRTObservablePropertyOnFieldsIsNotAotCompatibleAnalyzer > . VerifyAnalyzerAsync (
530
+ source ,
531
+ LanguageVersion . CSharp12 ,
532
+ editorconfig : [ ( "_MvvmToolkitIsUsingWindowsRuntimePack" , true ) , ( "CsWinRTAotOptimizerEnabled" , "auto" ) ] ) ;
533
+ }
534
+
483
535
[ TestMethod ]
484
536
public async Task WinRTObservablePropertyOnFieldsIsNotAotCompatibleAnalyzer_TargetingWindows_CsWinRTAotOptimizerEnabled_True_NoXaml_Level1_DoesNotWarn ( )
485
537
{
0 commit comments