@@ -561,7 +561,7 @@ private void GreetUser(User user)
561
561
/// <param name="source">The input source to process.</param>
562
562
/// <param name="diagnosticsIds">The diagnostic ids to expect for the input source code.</param>
563
563
private static void VerifyGeneratedDiagnostics < TGenerator > ( string source , params string [ ] diagnosticsIds )
564
- where TGenerator : class , new ( )
564
+ where TGenerator : class , IIncrementalGenerator , new ( )
565
565
{
566
566
VerifyGeneratedDiagnostics < TGenerator > ( CSharpSyntaxTree . ParseText ( source ) , diagnosticsIds ) ;
567
567
}
@@ -573,7 +573,7 @@ private static void VerifyGeneratedDiagnostics<TGenerator>(string source, params
573
573
/// <param name="syntaxTree">The input source tree to process.</param>
574
574
/// <param name="diagnosticsIds">The diagnostic ids to expect for the input source code.</param>
575
575
private static void VerifyGeneratedDiagnostics < TGenerator > ( SyntaxTree syntaxTree , params string [ ] diagnosticsIds )
576
- where TGenerator : class , new ( )
576
+ where TGenerator : class , IIncrementalGenerator , new ( )
577
577
{
578
578
Type observableObjectType = typeof ( ObservableObject ) ;
579
579
Type validationAttributeType = typeof ( ValidationAttribute ) ;
@@ -590,12 +590,9 @@ from assembly in AppDomain.CurrentDomain.GetAssemblies()
590
590
references ,
591
591
new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
592
592
593
- GeneratorDriver driver = new TGenerator ( ) switch
594
- {
595
- ISourceGenerator generator => CSharpGeneratorDriver . Create ( generator ) . WithUpdatedParseOptions ( ( CSharpParseOptions ) syntaxTree . Options ) ,
596
- IIncrementalGenerator incrementalGenerator => CSharpGeneratorDriver . Create ( incrementalGenerator ) . WithUpdatedParseOptions ( ( CSharpParseOptions ) syntaxTree . Options ) ,
597
- _ => throw new ArgumentException ( "Invalid generator type" , nameof ( TGenerator ) )
598
- } ;
593
+ IIncrementalGenerator generator = new TGenerator ( ) ;
594
+
595
+ GeneratorDriver driver = CSharpGeneratorDriver . Create ( generator ) . WithUpdatedParseOptions ( ( CSharpParseOptions ) syntaxTree . Options ) ;
599
596
600
597
_ = driver . RunGeneratorsAndUpdateCompilation ( compilation , out Compilation outputCompilation , out ImmutableArray < Diagnostic > diagnostics ) ;
601
598
0 commit comments