@joebigelow / wix / commits / d38946ac

Ensure Class element without Context does not crash compiler

Rob Mensching committed Feb 4, 2022 at 07:29 UTC d38946ac8357d9d4f25a157571f8f8d5500f663f
3 files changed +126 -71
src/wix/test/WixToolsetTest.CoreIntegration/ClassFixture.cs new
+114
@@ -0,0 +1,114 @@
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.CoreIntegration
4 +{
5 + using System.IO;
6 + using WixBuildTools.TestSupport;
7 + using WixToolset.Core.TestPackage;
8 + using Xunit;
9 +
10 + public class ClassFixture
11 + {
12 + [Fact]
13 + public void ClassWithoutContextDoesNotCrash()
14 + {
15 + var folder = TestData.Get(@"TestData");
16 +
17 + using (var fs = new DisposableFileSystem())
18 + {
19 + var baseFolder = fs.GetFolder();
20 + var intermediateFolder = Path.Combine(baseFolder, "obj");
21 + var msiPath = Path.Combine(baseFolder, @"bin\test.msi");
22 +
23 + var result = WixRunner.Execute(new[]
24 + {
25 + "build",
26 + Path.Combine(folder, "Class", "ClassWithoutContext.wxs"),
27 + Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"),
28 + Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"),
29 + "-bindpath", Path.Combine(folder, ".Data"),
30 + "-bindpath", Path.Combine(folder, "SingleFile", "data"),
31 + "-intermediateFolder", intermediateFolder,
32 + "-o", msiPath
33 + });
34 +
35 + result.AssertSuccess();
36 +
37 + var results = Query.QueryDatabase(msiPath, new[] { "Class", "Registry" });
38 + Assert.Empty(results);
39 + }
40 + }
41 +
42 + [Fact]
43 + public void PopulatesClassTablesWhenIconIndexIsZero()
44 + {
45 + var folder = TestData.Get(@"TestData");
46 +
47 + using (var fs = new DisposableFileSystem())
48 + {
49 + var baseFolder = fs.GetFolder();
50 + var intermediateFolder = Path.Combine(baseFolder, "obj");
51 + var msiPath = Path.Combine(baseFolder, @"bin\test.msi");
52 +
53 + var result = WixRunner.Execute(new[]
54 + {
55 + "build",
56 + Path.Combine(folder, "Class", "IconIndex0.wxs"),
57 + Path.Combine(folder, "Icon", "SampleIcon.wxs"),
58 + Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"),
59 + Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"),
60 + "-bindpath", Path.Combine(folder, ".Data"),
61 + "-bindpath", Path.Combine(folder, "SingleFile", "data"),
62 + "-intermediateFolder", intermediateFolder,
63 + "-o", msiPath
64 + });
65 +
66 + result.AssertSuccess();
67 +
68 + Assert.True(File.Exists(msiPath));
69 + var results = Query.QueryDatabase(msiPath, new[] { "Class" });
70 + WixAssert.CompareLineByLine(new[]
71 + {
72 + "Class:{3FAED4CC-C473-4B8A-BE8B-303871377A4A}\tLocalServer32\tClassComp\t\tFakeClass3FAE\t\t\tSampleIcon\t0\t\t\tProductFeature\t",
73 + }, results);
74 + }
75 + }
76 +
77 + [Fact]
78 + public void PopulatesClassTablesWhenProgIdIsNestedUnderAdvertisedClass()
79 + {
80 + var folder = TestData.Get(@"TestData");
81 +
82 + using (var fs = new DisposableFileSystem())
83 + {
84 + var baseFolder = fs.GetFolder();
85 + var intermediateFolder = Path.Combine(baseFolder, "obj");
86 + var msiPath = Path.Combine(baseFolder, @"bin\test.msi");
87 +
88 + var result = WixRunner.Execute(new[]
89 + {
90 + "build",
91 + Path.Combine(folder, "ProgId", "NestedUnderClass.wxs"),
92 + Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"),
93 + Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"),
94 + "-bindpath", Path.Combine(folder, "SingleFile", "data"),
95 + "-intermediateFolder", intermediateFolder,
96 + "-o", msiPath
97 + });
98 +
99 + result.AssertSuccess();
100 +
101 + Assert.True(File.Exists(msiPath));
102 + var results = Query.QueryDatabase(msiPath, new[] { "Class", "ProgId", "Registry" });
103 + WixAssert.CompareLineByLine(new[]
104 + {
105 + "Class:{F12A6F69-117F-471F-AE73-F8E74218F498}\tLocalServer32\tProgIdComp\t73E7DF7E-EFAC-4E11-90E2-6EBAEB8DE58D\tFakeClassF12A\t\t\t\t\t\t\tProductFeature\t",
106 + "ProgId:73E7DF7E-EFAC-4E11-90E2-6EBAEB8DE58D\t\t{F12A6F69-117F-471F-AE73-F8E74218F498}\tFakeClassF12A\t\t",
107 + "Registry:regUIIK326nDZpkWHuexeF58EikQvA\t0\t73E7DF7E-EFAC-4E11-90E2-6EBAEB8DE58D\tNoOpen\tNoOpen73E7\tProgIdComp",
108 + "Registry:regvrhMurMp98anbQJkpgA8yJCefdM\t0\tCLSID\\{F12A6F69-117F-471F-AE73-F8E74218F498}\\Version\t\t0.0.0.1\tProgIdComp",
109 + "Registry:regY1F4E2lvu_Up6gV6c3jeN5ukn8s\t0\tCLSID\\{F12A6F69-117F-471F-AE73-F8E74218F498}\\LocalServer32\tThreadingModel\tApartment\tProgIdComp",
110 + }, results);
111 + }
112 + }
113 + }
114 +}
src/wix/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs
-71
@@ -219,77 +219,6 @@ namespace WixToolsetTest.CoreIntegration
219 }
220 }
221
222 - [Fact]
223 - public void PopulatesClassTablesWhenIconIndexIsZero()
224 - {
225 - var folder = TestData.Get(@"TestData");
226 -
227 - using (var fs = new DisposableFileSystem())
228 - {
229 - var baseFolder = fs.GetFolder();
230 - var intermediateFolder = Path.Combine(baseFolder, "obj");
231 - var msiPath = Path.Combine(baseFolder, @"bin\test.msi");
232 -
233 - var result = WixRunner.Execute(new[]
234 - {
235 - "build",
236 - Path.Combine(folder, "Class", "IconIndex0.wxs"),
237 - Path.Combine(folder, "Icon", "SampleIcon.wxs"),
238 - Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"),
239 - Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"),
240 - "-bindpath", Path.Combine(folder, ".Data"),
241 - "-bindpath", Path.Combine(folder, "SingleFile", "data"),
242 - "-intermediateFolder", intermediateFolder,
243 - "-o", msiPath
244 - });
245 -
246 - result.AssertSuccess();
247 -
248 - Assert.True(File.Exists(msiPath));
249 - var results = Query.QueryDatabase(msiPath, new[] { "Class" });
250 - WixAssert.CompareLineByLine(new[]
251 - {
252 - "Class:{3FAED4CC-C473-4B8A-BE8B-303871377A4A}\tLocalServer32\tClassComp\t\tFakeClass3FAE\t\t\tSampleIcon\t0\t\t\tProductFeature\t",
253 - }, results);
254 - }
255 - }
256 -
257 - [Fact]
258 - public void PopulatesClassTablesWhenProgIdIsNestedUnderAdvertisedClass()
259 - {
260 - var folder = TestData.Get(@"TestData");
261 -
262 - using (var fs = new DisposableFileSystem())
263 - {
264 - var baseFolder = fs.GetFolder();
265 - var intermediateFolder = Path.Combine(baseFolder, "obj");
266 - var msiPath = Path.Combine(baseFolder, @"bin\test.msi");
267 -
268 - var result = WixRunner.Execute(new[]
269 - {
270 - "build",
271 - Path.Combine(folder, "ProgId", "NestedUnderClass.wxs"),
272 - Path.Combine(folder, "ProductWithComponentGroupRef", "MinimalComponentGroup.wxs"),
273 - Path.Combine(folder, "ProductWithComponentGroupRef", "Product.wxs"),
274 - "-bindpath", Path.Combine(folder, "SingleFile", "data"),
275 - "-intermediateFolder", intermediateFolder,
276 - "-o", msiPath
277 - });
278 -
279 - result.AssertSuccess();
280 -
281 - Assert.True(File.Exists(msiPath));
282 - var results = Query.QueryDatabase(msiPath, new[] { "Class", "ProgId", "Registry" });
283 - WixAssert.CompareLineByLine(new[]
284 - {
285 - "Class:{F12A6F69-117F-471F-AE73-F8E74218F498}\tLocalServer32\tProgIdComp\t73E7DF7E-EFAC-4E11-90E2-6EBAEB8DE58D\tFakeClassF12A\t\t\t\t\t\t\tProductFeature\t",
286 - "ProgId:73E7DF7E-EFAC-4E11-90E2-6EBAEB8DE58D\t\t{F12A6F69-117F-471F-AE73-F8E74218F498}\tFakeClassF12A\t\t",
287 - "Registry:regUIIK326nDZpkWHuexeF58EikQvA\t0\t73E7DF7E-EFAC-4E11-90E2-6EBAEB8DE58D\tNoOpen\tNoOpen73E7\tProgIdComp",
288 - "Registry:regvrhMurMp98anbQJkpgA8yJCefdM\t0\tCLSID\\{F12A6F69-117F-471F-AE73-F8E74218F498}\\Version\t\t0.0.0.1\tProgIdComp",
289 - "Registry:regY1F4E2lvu_Up6gV6c3jeN5ukn8s\t0\tCLSID\\{F12A6F69-117F-471F-AE73-F8E74218F498}\\LocalServer32\tThreadingModel\tApartment\tProgIdComp",
290 - }, results);
291 - }
292 - }
222 [Fact]
223 public void PopulatesCreateFolderTableForNullKeypathComponents()
224 {
src/wix/test/WixToolsetTest.CoreIntegration/TestData/Class/ClassWithoutContext.wxs new
+12
@@ -0,0 +1,12 @@
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3 + <Fragment>
4 + <ComponentGroup Id="ProductComponents">
5 + <Component Id="ClassComp" Directory="INSTALLFOLDER" Guid="9BFDA7DC-CA16-40B3-A6B5-961E60B30892">
6 + <File Source="test.txt" Name="ClassComp.txt">
7 + <Class Id="3FAED4CC-C473-4B8A-BE8B-303871377A4A" />
8 + </File>
9 + </Component>
10 + </ComponentGroup>
11 + </Fragment>
12 +</Wix>