@@ -1495,6 +1495,42 @@ private void GreetUser(User user)
1495
1495
VerifyGeneratedDiagnostics < RelayCommandGenerator > ( source , "MVVMTK0031" ) ;
1496
1496
}
1497
1497
1498
+ [ TestMethod ]
1499
+ public async Task UsingINotifyPropertyChangedAttributeOnClassWithNoBaseType ( )
1500
+ {
1501
+ string source = """
1502
+ using CommunityToolkit.Mvvm.ComponentModel;
1503
+
1504
+ namespace MyApp
1505
+ {
1506
+ [INotifyPropertyChanged]
1507
+ public partial class {|MVVMTK0032:SampleViewModel|}
1508
+ {
1509
+ }
1510
+ }
1511
+ """ ;
1512
+
1513
+ await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration < ClassUsingAttributeInsteadOfInheritanceAnalyzer > ( source , LanguageVersion . CSharp8 ) ;
1514
+ }
1515
+
1516
+ [ TestMethod ]
1517
+ public async Task UsingObservableObjectAttributeOnClassWithNoBaseType ( )
1518
+ {
1519
+ string source = """
1520
+ using CommunityToolkit.Mvvm.ComponentModel;
1521
+
1522
+ namespace MyApp
1523
+ {
1524
+ [ObservableObject]
1525
+ public partial class {|MVVMTK0033:SampleViewModel|}
1526
+ {
1527
+ }
1528
+ }
1529
+ """ ;
1530
+
1531
+ await VerifyAnalyzerDiagnosticsAndSuccessfulGeneration < ClassUsingAttributeInsteadOfInheritanceAnalyzer > ( source , LanguageVersion . CSharp8 ) ;
1532
+ }
1533
+
1498
1534
/// <summary>
1499
1535
/// Verifies the diagnostic errors for a given analyzer, and that all available source generators can run successfully with the input source (including subsequent compilation).
1500
1536
/// </summary>
@@ -1538,20 +1574,6 @@ private static void VerifyGeneratedDiagnostics<TGenerator>(string source, params
1538
1574
VerifyGeneratedDiagnostics ( CSharpSyntaxTree . ParseText ( source , CSharpParseOptions . Default . WithLanguageVersion ( LanguageVersion . CSharp8 ) ) , new [ ] { generator } , diagnosticsIds ) ;
1539
1575
}
1540
1576
1541
- /// <summary>
1542
- /// Verifies the output of a source generator.
1543
- /// </summary>
1544
- /// <typeparam name="TGenerator">The generator type to use.</typeparam>
1545
- /// <param name="syntaxTree">The input source to process.</param>
1546
- /// <param name="diagnosticsIds">The diagnostic ids to expect for the input source code.</param>
1547
- private static void VerifyGeneratedDiagnostics < TGenerator > ( SyntaxTree syntaxTree , params string [ ] diagnosticsIds )
1548
- where TGenerator : class , IIncrementalGenerator , new ( )
1549
- {
1550
- IIncrementalGenerator generator = new TGenerator ( ) ;
1551
-
1552
- VerifyGeneratedDiagnostics ( syntaxTree , new [ ] { generator } , diagnosticsIds ) ;
1553
- }
1554
-
1555
1577
/// <summary>
1556
1578
/// Verifies the output of one or more source generators.
1557
1579
/// </summary>
0 commit comments