Skip to content

Commit d7aa905

Browse files
committed
Unify CSharpSourceGeneratorTest according to dotnet/roslyn-sdk#941
1 parent fd8ec88 commit d7aa905

File tree

3 files changed

+14
-198
lines changed

3 files changed

+14
-198
lines changed

src/System.ServiceModel.BuildTools/tests/CSharpGeneratorVerifier.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System;
5+
using System.Collections.Generic;
56
using System.Collections.Immutable;
67
using Microsoft.CodeAnalysis;
78
using Microsoft.CodeAnalysis.CSharp;
@@ -15,11 +16,7 @@ public static class CSharpGeneratorVerifier<TSourceGenerator>
1516
where TSourceGenerator : ISourceGenerator, new()
1617
#endif
1718
{
18-
#if ROSLYN4_0_OR_GREATER
19-
public class Test : CSharpIncrementalGeneratorTest<TSourceGenerator, DefaultVerifier>
20-
#else
21-
public class Test : CSharpSourceGeneratorTest<TSourceGenerator, DefaultVerifier>
22-
#endif
19+
public class Test : CSharpSourceGeneratorTest<EmptySourceGeneratorProvider, DefaultVerifier>
2320
{
2421
public Test()
2522
{
@@ -48,6 +45,18 @@ private static ImmutableDictionary<string, ReportDiagnostic> GetNullableWarnings
4845
protected override ParseOptions CreateParseOptions()
4946
=> ((CSharpParseOptions)base.CreateParseOptions()).WithLanguageVersion(LanguageVersion);
5047

48+
#if ROSLYN4_0_OR_GREATER
49+
protected override IEnumerable<ISourceGenerator> GetSourceGenerators()
50+
{
51+
yield return new TSourceGenerator().AsSourceGenerator();
52+
}
53+
#else
54+
protected override IEnumerable<ISourceGenerator> GetSourceGenerators()
55+
{
56+
yield return new TSourceGenerator();
57+
}
58+
#endif
59+
5160
protected override bool IsCompilerDiagnosticIncluded(Diagnostic diagnostic, CompilerDiagnostics compilerDiagnostics) => false;
5261
}
5362
}

src/System.ServiceModel.BuildTools/tests/CSharpIncrementalGeneratorTest`2.cs

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/System.ServiceModel.BuildTools/tests/IncrementalGeneratorTest`1.cs

Lines changed: 0 additions & 151 deletions
This file was deleted.

0 commit comments

Comments
 (0)