diff options
author | Sean Hall <r.sean.hall@gmail.com> | 2022-04-19 17:15:05 -0500 |
---|---|---|
committer | Sean Hall <r.sean.hall@gmail.com> | 2022-04-19 18:35:15 -0500 |
commit | 57fd164d56466a52854e825afd5fdc2b6b97f12a (patch) | |
tree | 7d4ace6d7a55c2a50302e3b6866456026a2c6222 /src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/DncHostGeneratorTests.cs | |
parent | 6435d26c7e2ce54ec38d0cc9eb4d2cb10e9614e0 (diff) | |
download | wix-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/DncHostGeneratorTests.cs')
-rw-r--r-- | src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/DncHostGeneratorTests.cs | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/DncHostGeneratorTests.cs b/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/DncHostGeneratorTests.cs new file mode 100644 index 00000000..6ede1089 --- /dev/null +++ b/src/ext/Bal/test/WixToolsetTest.Dnc.HostGenerator/DncHostGeneratorTests.cs | |||
@@ -0,0 +1,88 @@ | |||
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 | |||
3 | namespace WixToolsetTest.Dnc.HostGenerator | ||
4 | { | ||
5 | using System; | ||
6 | using System.Text; | ||
7 | using System.Threading.Tasks; | ||
8 | using Microsoft.CodeAnalysis; | ||
9 | using Microsoft.CodeAnalysis.Testing; | ||
10 | using Microsoft.CodeAnalysis.Text; | ||
11 | using WixToolset.Dnc.HostGenerator; | ||
12 | using WixToolset.Mba.Core; | ||
13 | using Xunit; | ||
14 | |||
15 | using VerifyCS = CSharpSourceGeneratorVerifier<WixToolset.Dnc.HostGenerator.DncHostGenerator>; | ||
16 | |||
17 | public class DncHostGeneratorTests | ||
18 | { | ||
19 | static readonly MetadataReference MbaCoreAssembly = MetadataReference.CreateFromFile(typeof(BootstrapperApplicationFactoryAttribute).Assembly.Location); | ||
20 | |||
21 | [Fact] | ||
22 | public async Task FailsBuildWhenMissingAttribute() | ||
23 | { | ||
24 | var code = @" | ||
25 | //[assembly: WixToolset.Mba.Core.BootstrapperApplicationFactory(typeof(Test.BAFactory))] | ||
26 | namespace Test | ||
27 | { | ||
28 | using WixToolset.Mba.Core; | ||
29 | |||
30 | public class BAFactory : BaseBootstrapperApplicationFactory | ||
31 | { | ||
32 | protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand) | ||
33 | { | ||
34 | return null; | ||
35 | } | ||
36 | } | ||
37 | } | ||
38 | "; | ||
39 | |||
40 | await new VerifyCS.Test | ||
41 | { | ||
42 | TestState = | ||
43 | { | ||
44 | Sources = { code }, | ||
45 | AdditionalReferences = { MbaCoreAssembly }, | ||
46 | ExpectedDiagnostics = | ||
47 | { | ||
48 | new DiagnosticResult(DncHostGenerator.MissingFactoryAttributeDescriptor), | ||
49 | }, | ||
50 | }, | ||
51 | }.RunAsync(); | ||
52 | } | ||
53 | |||
54 | [Fact] | ||
55 | public async Task GeneratesEntryPoint() | ||
56 | { | ||
57 | var code = @" | ||
58 | [assembly: WixToolset.Mba.Core.BootstrapperApplicationFactory(typeof(Test.BAFactory))] | ||
59 | namespace Test | ||
60 | { | ||
61 | using WixToolset.Mba.Core; | ||
62 | |||
63 | public class BAFactory : BaseBootstrapperApplicationFactory | ||
64 | { | ||
65 | protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand) | ||
66 | { | ||
67 | return null; | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | "; | ||
72 | var generated = String.Format(DncHostGenerator.Template, DncHostGenerator.Version, "Test.BAFactory"); | ||
73 | |||
74 | await new VerifyCS.Test | ||
75 | { | ||
76 | TestState = | ||
77 | { | ||
78 | Sources = { code }, | ||
79 | GeneratedSources = | ||
80 | { | ||
81 | (typeof(DncHostGenerator), "WixToolset.Dnc.Host.g.cs", SourceText.From(generated, Encoding.UTF8, SourceHashAlgorithm.Sha256)), | ||
82 | }, | ||
83 | AdditionalReferences = { MbaCoreAssembly }, | ||
84 | }, | ||
85 | }.RunAsync(); | ||
86 | } | ||
87 | } | ||
88 | } | ||