aboutsummaryrefslogtreecommitdiff
path: root/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/CSharpSourceGeneratorVerifier.cs
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-04-19 17:15:05 -0500
committerSean Hall <r.sean.hall@gmail.com>2022-04-19 18:35:15 -0500
commit57fd164d56466a52854e825afd5fdc2b6b97f12a (patch)
tree7d4ace6d7a55c2a50302e3b6866456026a2c6222 /src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/CSharpSourceGeneratorVerifier.cs
parent6435d26c7e2ce54ec38d0cc9eb4d2cb10e9614e0 (diff)
downloadwix-57fd164d56466a52854e825afd5fdc2b6b97f12a.tar.gz
wix-57fd164d56466a52854e825afd5fdc2b6b97f12a.tar.bz2
wix-57fd164d56466a52854e825afd5fdc2b6b97f12a.zip
Replace Dnc.Host with Dnc.HostGenerator to support linker trimming.
Diffstat (limited to 'src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/CSharpSourceGeneratorVerifier.cs')
-rw-r--r--src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/CSharpSourceGeneratorVerifier.cs45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/CSharpSourceGeneratorVerifier.cs b/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/CSharpSourceGeneratorVerifier.cs
new file mode 100644
index 00000000..27729ac8
--- /dev/null
+++ b/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/CSharpSourceGeneratorVerifier.cs
@@ -0,0 +1,45 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3namespace WixToolsetTest.Dnc.HostGenerator
4{
5 using System;
6 using System.Collections.Immutable;
7 using Microsoft.CodeAnalysis;
8 using Microsoft.CodeAnalysis.CSharp;
9 using Microsoft.CodeAnalysis.CSharp.Testing;
10 using Microsoft.CodeAnalysis.Testing.Verifiers;
11
12 public static class CSharpSourceGeneratorVerifier<TSourceGenerator>
13 where TSourceGenerator : ISourceGenerator, new()
14 {
15 public class Test : CSharpSourceGeneratorTest<TSourceGenerator, XUnitVerifier>
16 {
17 public Test()
18 {
19 }
20
21 protected override CompilationOptions CreateCompilationOptions()
22 {
23 var compilationOptions = base.CreateCompilationOptions();
24 return compilationOptions.WithSpecificDiagnosticOptions(
25 compilationOptions.SpecificDiagnosticOptions.SetItems(GetNullableWarningsFromCompiler()));
26 }
27
28 public LanguageVersion LanguageVersion { get; set; } = LanguageVersion.Default;
29
30 private static ImmutableDictionary<string, ReportDiagnostic> GetNullableWarningsFromCompiler()
31 {
32 string[] args = { "/warnaserror:nullable" };
33 var commandLineArguments = CSharpCommandLineParser.Default.Parse(args, baseDirectory: Environment.CurrentDirectory, sdkDirectory: Environment.CurrentDirectory);
34 var nullableWarnings = commandLineArguments.CompilationOptions.SpecificDiagnosticOptions;
35
36 return nullableWarnings;
37 }
38
39 protected override ParseOptions CreateParseOptions()
40 {
41 return ((CSharpParseOptions)base.CreateParseOptions()).WithLanguageVersion(this.LanguageVersion);
42 }
43 }
44 }
45}