|  | 
| 12 | 12 | using Microsoft.CodeAnalysis.CSharp.Syntax; | 
| 13 | 13 | using Microsoft.CodeAnalysis.Testing; | 
| 14 | 14 | using Microsoft.CodeAnalysis.Text; | 
| 15 |  | -using VerifyTest = Microsoft.CodeAnalysis.CSharp.Testing.CSharpSourceGeneratorTest< | 
| 16 |  | -    Microsoft.Windows.CsWin32.SourceGenerator, | 
| 17 |  | -    Microsoft.CodeAnalysis.Testing.Verifiers.XUnitVerifier>; | 
|  | 15 | +using VerifyTest = Microsoft.CodeAnalysis.CSharp.Testing.CSharpSourceGeneratorTest<Microsoft.Windows.CsWin32.SourceGenerator, Microsoft.CodeAnalysis.Testing.Verifiers.XUnitVerifier>; | 
| 18 | 16 | 
 | 
| 19 | 17 | public class GeneratorTests : IDisposable, IAsyncLifetime | 
| 20 | 18 | { | 
| @@ -42,6 +40,7 @@ public class GeneratorTests : IDisposable, IAsyncLifetime | 
| 42 | 40 | 
 | 
| 43 | 41 |     private readonly ITestOutputHelper logger; | 
| 44 | 42 |     private readonly Dictionary<string, CSharpCompilation> starterCompilations = new(); | 
|  | 43 | +    private readonly Dictionary<string, string[]> preprocessorSymbolsByTfm = new(); | 
| 45 | 44 |     private CSharpCompilation compilation; | 
| 46 | 45 |     private CSharpParseOptions parseOptions; | 
| 47 | 46 |     private Generator? generator; | 
| @@ -110,6 +109,20 @@ public async Task InitializeAsync() | 
| 110 | 109 |         this.starterCompilations.Add("net6.0-x86", await this.CreateCompilationAsync(MyReferenceAssemblies.Net.Net60, Platform.X86)); | 
| 111 | 110 |         this.starterCompilations.Add("net6.0-x64", await this.CreateCompilationAsync(MyReferenceAssemblies.Net.Net60, Platform.X64)); | 
| 112 | 111 | 
 | 
|  | 112 | +        foreach (string tfm in this.starterCompilations.Keys) | 
|  | 113 | +        { | 
|  | 114 | +            if (tfm.StartsWith("net6")) | 
|  | 115 | +            { | 
|  | 116 | +                AddSymbols("NET5_0_OR_GREATER", "NET6_0_OR_GREATER", "NET6_0"); | 
|  | 117 | +            } | 
|  | 118 | +            else | 
|  | 119 | +            { | 
|  | 120 | +                AddSymbols(); | 
|  | 121 | +            } | 
|  | 122 | + | 
|  | 123 | +            void AddSymbols(params string[] symbols) => this.preprocessorSymbolsByTfm.Add(tfm, symbols); | 
|  | 124 | +        } | 
|  | 125 | + | 
| 113 | 126 |         this.compilation = this.starterCompilations["netstandard2.0"]; | 
| 114 | 127 |     } | 
| 115 | 128 | 
 | 
| @@ -557,6 +570,17 @@ public void ComOutPtrTypedAsOutObject() | 
| 557 | 570 |         Assert.Contains(this.FindGeneratedMethod(methodName), m => m.ParameterList.Parameters.Last() is { } last && last.Modifiers.Any(SyntaxKind.OutKeyword) && last.Type is PredefinedTypeSyntax { Keyword: { RawKind: (int)SyntaxKind.ObjectKeyword } }); | 
| 558 | 571 |     } | 
| 559 | 572 | 
 | 
|  | 573 | +    [Theory, CombinatorialData] | 
|  | 574 | +    public void Decimal([CombinatorialValues("net472", "net6.0")] string tfm) | 
|  | 575 | +    { | 
|  | 576 | +        this.compilation = this.starterCompilations[tfm]; | 
|  | 577 | +        this.parseOptions = this.parseOptions.WithPreprocessorSymbols(this.preprocessorSymbolsByTfm[tfm]); | 
|  | 578 | +        this.generator = this.CreateGenerator(); | 
|  | 579 | +        Assert.True(this.generator.TryGenerate("DECIMAL", CancellationToken.None)); | 
|  | 580 | +        this.CollectGeneratedCode(this.generator); | 
|  | 581 | +        this.AssertNoDiagnostics(); | 
|  | 582 | +    } | 
|  | 583 | + | 
| 560 | 584 |     [Fact] | 
| 561 | 585 |     public void ComOutPtrTypedAsIntPtr() | 
| 562 | 586 |     { | 
|  | 
0 commit comments