aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.Burn
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2021-03-14 07:38:48 -0700
committerRob Mensching <rob@firegiant.com>2021-03-14 07:47:48 -0700
commit3ccd5e439da4296d6f2b66ce47075ab20d039676 (patch)
treeb5546552613b869367d09f444492a0bbcfadcfe0 /src/WixToolset.Core.Burn
parent574785ab1421c9b67336c13ade5c2263e665ca07 (diff)
downloadwix-3ccd5e439da4296d6f2b66ce47075ab20d039676.tar.gz
wix-3ccd5e439da4296d6f2b66ce47075ab20d039676.tar.bz2
wix-3ccd5e439da4296d6f2b66ce47075ab20d039676.zip
Minimize public surface area of Core
Fixes wixtoolset/issues#6374
Diffstat (limited to 'src/WixToolset.Core.Burn')
-rw-r--r--src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs8
-rw-r--r--src/WixToolset.Core.Burn/Bundles/CreateBootstrapperApplicationManifestCommand.cs2
-rw-r--r--src/WixToolset.Core.Burn/Bundles/CreateBundleExtensionManifestCommand.cs2
-rw-r--r--src/WixToolset.Core.Burn/Bundles/ProcessMsiPackageCommand.cs12
-rw-r--r--src/WixToolset.Core.Burn/ExtensibilityServices/BurnBackendHelper.cs34
-rw-r--r--src/WixToolset.Core.Burn/RowIndexedList.cs21
-rw-r--r--src/WixToolset.Core.Burn/TableExtensions.cs24
7 files changed, 53 insertions, 50 deletions
diff --git a/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs b/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs
index e58e2464..afaf65ee 100644
--- a/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs
+++ b/src/WixToolset.Core.Burn/Bind/BindBundleCommand.cs
@@ -130,10 +130,9 @@ namespace WixToolset.Core.Burn
130 130
131 // Extract files that come from binary .wixlibs and WixExtensions (this does not extract files from merge modules). 131 // Extract files that come from binary .wixlibs and WixExtensions (this does not extract files from merge modules).
132 { 132 {
133 var command = new ExtractEmbeddedFilesCommand(this.BackendHelper, this.ExpectedEmbeddedFiles); 133 var extractedFiles = this.BackendHelper.ExtractEmbeddedFiles(this.ExpectedEmbeddedFiles);
134 command.Execute();
135 134
136 trackedFiles.AddRange(command.TrackedFiles); 135 trackedFiles.AddRange(extractedFiles);
137 } 136 }
138 137
139 // Get the explicit payloads. 138 // Get the explicit payloads.
@@ -367,8 +366,7 @@ namespace WixToolset.Core.Burn
367 // Resolve any delayed fields before generating the manifest. 366 // Resolve any delayed fields before generating the manifest.
368 if (this.DelayedFields.Any()) 367 if (this.DelayedFields.Any())
369 { 368 {
370 var resolveDelayedFieldsCommand = new ResolveDelayedFieldsCommand(this.Messaging, this.DelayedFields, variableCache); 369 this.BackendHelper.ResolveDelayedFields(this.DelayedFields, variableCache);
371 resolveDelayedFieldsCommand.Execute();
372 } 370 }
373 371
374 Dictionary<string, ProvidesDependencySymbol> dependencySymbolsByKey; 372 Dictionary<string, ProvidesDependencySymbol> dependencySymbolsByKey;
diff --git a/src/WixToolset.Core.Burn/Bundles/CreateBootstrapperApplicationManifestCommand.cs b/src/WixToolset.Core.Burn/Bundles/CreateBootstrapperApplicationManifestCommand.cs
index a24137f3..63a168a0 100644
--- a/src/WixToolset.Core.Burn/Bundles/CreateBootstrapperApplicationManifestCommand.cs
+++ b/src/WixToolset.Core.Burn/Bundles/CreateBootstrapperApplicationManifestCommand.cs
@@ -244,7 +244,7 @@ namespace WixToolset.Core.Burn.Bundles
244 244
245 private WixBundlePayloadSymbol CreateBootstrapperApplicationManifestPayloadRow(string baManifestPath) 245 private WixBundlePayloadSymbol CreateBootstrapperApplicationManifestPayloadRow(string baManifestPath)
246 { 246 {
247 var generatedId = Common.GenerateIdentifier("ux", BurnCommon.BADataFileName); 247 var generatedId = this.InternalBurnBackendHelper.GenerateIdentifier("ux", BurnCommon.BADataFileName);
248 248
249 var symbol = this.Section.AddSymbol(new WixBundlePayloadSymbol(this.BundleSymbol.SourceLineNumbers, new Identifier(AccessModifier.Section, generatedId)) 249 var symbol = this.Section.AddSymbol(new WixBundlePayloadSymbol(this.BundleSymbol.SourceLineNumbers, new Identifier(AccessModifier.Section, generatedId))
250 { 250 {
diff --git a/src/WixToolset.Core.Burn/Bundles/CreateBundleExtensionManifestCommand.cs b/src/WixToolset.Core.Burn/Bundles/CreateBundleExtensionManifestCommand.cs
index 9e1f85bc..7b5b9656 100644
--- a/src/WixToolset.Core.Burn/Bundles/CreateBundleExtensionManifestCommand.cs
+++ b/src/WixToolset.Core.Burn/Bundles/CreateBundleExtensionManifestCommand.cs
@@ -66,7 +66,7 @@ namespace WixToolset.Core.Burn.Bundles
66 66
67 private WixBundlePayloadSymbol CreateBundleExtensionManifestPayloadRow(string bextManifestPath) 67 private WixBundlePayloadSymbol CreateBundleExtensionManifestPayloadRow(string bextManifestPath)
68 { 68 {
69 var generatedId = Common.GenerateIdentifier("ux", BurnCommon.BundleExtensionDataFileName); 69 var generatedId = this.InternalBurnBackendHelper.GenerateIdentifier("ux", BurnCommon.BundleExtensionDataFileName);
70 70
71 var symbol = this.Section.AddSymbol(new WixBundlePayloadSymbol(this.BundleSymbol.SourceLineNumbers, new Identifier(AccessModifier.Section, generatedId)) 71 var symbol = this.Section.AddSymbol(new WixBundlePayloadSymbol(this.BundleSymbol.SourceLineNumbers, new Identifier(AccessModifier.Section, generatedId))
72 { 72 {
diff --git a/src/WixToolset.Core.Burn/Bundles/ProcessMsiPackageCommand.cs b/src/WixToolset.Core.Burn/Bundles/ProcessMsiPackageCommand.cs
index 5ba1ad07..dc1a1913 100644
--- a/src/WixToolset.Core.Burn/Bundles/ProcessMsiPackageCommand.cs
+++ b/src/WixToolset.Core.Burn/Bundles/ProcessMsiPackageCommand.cs
@@ -94,7 +94,7 @@ namespace WixToolset.Core.Burn.Bundles
94 msiPackage.ProductLanguage = Convert.ToInt32(ProcessMsiPackageCommand.GetProperty(db, "ProductLanguage"), CultureInfo.InvariantCulture); 94 msiPackage.ProductLanguage = Convert.ToInt32(ProcessMsiPackageCommand.GetProperty(db, "ProductLanguage"), CultureInfo.InvariantCulture);
95 msiPackage.ProductVersion = ProcessMsiPackageCommand.GetProperty(db, "ProductVersion"); 95 msiPackage.ProductVersion = ProcessMsiPackageCommand.GetProperty(db, "ProductVersion");
96 96
97 if (!Common.IsValidModuleOrBundleVersion(msiPackage.ProductVersion)) 97 if (!this.BackendHelper.IsValidFourPartVersion(msiPackage.ProductVersion))
98 { 98 {
99 // not a proper .NET version (e.g., five fields); can we get a valid four-part version number? 99 // not a proper .NET version (e.g., five fields); can we get a valid four-part version number?
100 string version = null; 100 string version = null;
@@ -109,7 +109,7 @@ namespace WixToolset.Core.Burn.Bundles
109 } 109 }
110 } 110 }
111 111
112 if (!String.IsNullOrEmpty(version) && Common.IsValidModuleOrBundleVersion(version)) 112 if (!String.IsNullOrEmpty(version) && this.BackendHelper.IsValidFourPartVersion(version))
113 { 113 {
114 this.Messaging.Write(WarningMessages.VersionTruncated(this.Facade.PackageSymbol.SourceLineNumbers, msiPackage.ProductVersion, sourcePath, version)); 114 this.Messaging.Write(WarningMessages.VersionTruncated(this.Facade.PackageSymbol.SourceLineNumbers, msiPackage.ProductVersion, sourcePath, version));
115 msiPackage.ProductVersion = version; 115 msiPackage.ProductVersion = version;
@@ -394,7 +394,7 @@ namespace WixToolset.Core.Burn.Bundles
394 394
395 if (!payloadNames.Contains(cabinetName)) 395 if (!payloadNames.Contains(cabinetName))
396 { 396 {
397 var generatedId = Common.GenerateIdentifier("cab", packagePayload.Id.Id, cabinet); 397 var generatedId = this.BackendHelper.GenerateIdentifier("cab", packagePayload.Id.Id, cabinet);
398 var payloadSourceFile = this.ResolveRelatedFile(packagePayload.SourceFile.Path, packagePayload.UnresolvedSourceFile, cabinet, "Cabinet", this.Facade.PackageSymbol.SourceLineNumbers); 398 var payloadSourceFile = this.ResolveRelatedFile(packagePayload.SourceFile.Path, packagePayload.UnresolvedSourceFile, cabinet, "Cabinet", this.Facade.PackageSymbol.SourceLineNumbers);
399 399
400 this.Section.AddSymbol(new WixBundlePayloadSymbol(this.Facade.PackageSymbol.SourceLineNumbers, new Identifier(AccessModifier.Section, generatedId)) 400 this.Section.AddSymbol(new WixBundlePayloadSymbol(this.Facade.PackageSymbol.SourceLineNumbers, new Identifier(AccessModifier.Section, generatedId))
@@ -437,7 +437,7 @@ namespace WixToolset.Core.Burn.Bundles
437 break; 437 break;
438 } 438 }
439 439
440 var sourceName = Common.GetName(record.GetString(3), true, longNamesInImage); 440 var sourceName = this.BackendHelper.GetMsiFileName(record.GetString(3), true, longNamesInImage);
441 441
442 var resolvedDirectory = this.BackendHelper.CreateResolvedDirectory(record.GetString(2), sourceName); 442 var resolvedDirectory = this.BackendHelper.CreateResolvedDirectory(record.GetString(2), sourceName);
443 443
@@ -471,7 +471,7 @@ namespace WixToolset.Core.Burn.Bundles
471 471
472 if (!payloadNames.Contains(name)) 472 if (!payloadNames.Contains(name))
473 { 473 {
474 var generatedId = Common.GenerateIdentifier("f", packagePayload.Id.Id, record.GetString(2)); 474 var generatedId = this.BackendHelper.GenerateIdentifier("f", packagePayload.Id.Id, record.GetString(2));
475 var payloadSourceFile = this.ResolveRelatedFile(packagePayload.SourceFile.Path, packagePayload.UnresolvedSourceFile, fileSourcePath, "File", this.Facade.PackageSymbol.SourceLineNumbers); 475 var payloadSourceFile = this.ResolveRelatedFile(packagePayload.SourceFile.Path, packagePayload.UnresolvedSourceFile, fileSourcePath, "File", this.Facade.PackageSymbol.SourceLineNumbers);
476 476
477 this.Section.AddSymbol(new WixBundlePayloadSymbol(this.Facade.PackageSymbol.SourceLineNumbers, new Identifier(AccessModifier.Section, generatedId)) 477 this.Section.AddSymbol(new WixBundlePayloadSymbol(this.Facade.PackageSymbol.SourceLineNumbers, new Identifier(AccessModifier.Section, generatedId))
@@ -526,7 +526,7 @@ namespace WixToolset.Core.Burn.Bundles
526 break; 526 break;
527 } 527 }
528 528
529 var id = new Identifier(AccessModifier.Section, Common.GenerateIdentifier("dep", msiPackage.Id.Id, record.GetString(1))); 529 var id = new Identifier(AccessModifier.Section, this.BackendHelper.GenerateIdentifier("dep", msiPackage.Id.Id, record.GetString(1)));
530 530
531 // Import the provider key and attributes. 531 // Import the provider key and attributes.
532 this.Section.AddSymbol(new ProvidesDependencySymbol(msiPackage.SourceLineNumbers, id) 532 this.Section.AddSymbol(new ProvidesDependencySymbol(msiPackage.SourceLineNumbers, id)
diff --git a/src/WixToolset.Core.Burn/ExtensibilityServices/BurnBackendHelper.cs b/src/WixToolset.Core.Burn/ExtensibilityServices/BurnBackendHelper.cs
index 59efcbc9..5502b43b 100644
--- a/src/WixToolset.Core.Burn/ExtensibilityServices/BurnBackendHelper.cs
+++ b/src/WixToolset.Core.Burn/ExtensibilityServices/BurnBackendHelper.cs
@@ -9,6 +9,8 @@ namespace WixToolset.Core.Burn.ExtensibilityServices
9 using System.Xml; 9 using System.Xml;
10 using WixToolset.Core.Burn.Bundles; 10 using WixToolset.Core.Burn.Bundles;
11 using WixToolset.Data; 11 using WixToolset.Data;
12 using WixToolset.Data.Symbols;
13 using WixToolset.Data.WindowsInstaller.Rows;
12 using WixToolset.Extensibility.Data; 14 using WixToolset.Extensibility.Data;
13 using WixToolset.Extensibility.Services; 15 using WixToolset.Extensibility.Services;
14 16
@@ -30,14 +32,44 @@ namespace WixToolset.Core.Burn.ExtensibilityServices
30 32
31 #region IBackendHelper interfaces 33 #region IBackendHelper interfaces
32 34
35 public IFileFacade CreateFileFacade(FileSymbol file, AssemblySymbol assembly) => this.backendHelper.CreateFileFacade(file, assembly);
36
37 public IFileFacade CreateFileFacade(FileRow fileRow) => this.backendHelper.CreateFileFacade(fileRow);
38
39 public IFileFacade CreateFileFacadeFromMergeModule(FileSymbol fileSymbol) => this.backendHelper.CreateFileFacadeFromMergeModule(fileSymbol);
40
33 public IFileTransfer CreateFileTransfer(string source, string destination, bool move, SourceLineNumber sourceLineNumbers = null) => this.backendHelper.CreateFileTransfer(source, destination, move, sourceLineNumbers); 41 public IFileTransfer CreateFileTransfer(string source, string destination, bool move, SourceLineNumber sourceLineNumbers = null) => this.backendHelper.CreateFileTransfer(source, destination, move, sourceLineNumbers);
34 42
43 public string CreateGuid() => this.backendHelper.CreateGuid();
44
35 public string CreateGuid(Guid namespaceGuid, string value) => this.backendHelper.CreateGuid(namespaceGuid, value); 45 public string CreateGuid(Guid namespaceGuid, string value) => this.backendHelper.CreateGuid(namespaceGuid, value);
36 46
37 public IResolvedDirectory CreateResolvedDirectory(string directoryParent, string name) => this.backendHelper.CreateResolvedDirectory(directoryParent, name); 47 public IResolvedDirectory CreateResolvedDirectory(string directoryParent, string name) => this.backendHelper.CreateResolvedDirectory(directoryParent, name);
38 48
49 public IEnumerable<ITrackedFile> ExtractEmbeddedFiles(IEnumerable<IExpectedExtractFile> embeddedFiles) => this.backendHelper.ExtractEmbeddedFiles(embeddedFiles);
50
51 public string GenerateIdentifier(string prefix, params string[] args) => this.backendHelper.GenerateIdentifier(prefix, args);
52
39 public string GetCanonicalRelativePath(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string relativePath) => this.backendHelper.GetCanonicalRelativePath(sourceLineNumbers, elementName, attributeName, relativePath); 53 public string GetCanonicalRelativePath(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string relativePath) => this.backendHelper.GetCanonicalRelativePath(sourceLineNumbers, elementName, attributeName, relativePath);
40 54
55 public int GetValidCodePage(string value, bool allowNoChange, bool onlyAnsi = false, SourceLineNumber sourceLineNumbers = null) => this.backendHelper.GetValidCodePage(value, allowNoChange, onlyAnsi, sourceLineNumbers);
56
57 public string GetMsiFileName(string value, bool source, bool longName) => this.backendHelper.GetMsiFileName(value, source, longName);
58
59 public bool IsValidBinderVariable(string variable) => this.backendHelper.IsValidBinderVariable(variable);
60
61 public bool IsValidFourPartVersion(string version) => this.backendHelper.IsValidFourPartVersion(version);
62
63 public bool IsValidIdentifier(string id) => this.backendHelper.IsValidIdentifier(id);
64
65 public bool IsValidLongFilename(string filename, bool allowWildcards, bool allowRelative) => this.backendHelper.IsValidLongFilename(filename, allowWildcards, allowRelative);
66
67 public bool IsValidShortFilename(string filename, bool allowWildcards) => this.backendHelper.IsValidShortFilename(filename, allowWildcards);
68
69 public void ResolveDelayedFields(IEnumerable<IDelayedField> delayedFields, Dictionary<string, string> variableCache) => this.backendHelper.ResolveDelayedFields(delayedFields, variableCache);
70
71 public string[] SplitMsiFileName(string value) => this.backendHelper.SplitMsiFileName(value);
72
41 public ITrackedFile TrackFile(string path, TrackedFileType type, SourceLineNumber sourceLineNumbers = null) => this.backendHelper.TrackFile(path, type, sourceLineNumbers); 73 public ITrackedFile TrackFile(string path, TrackedFileType type, SourceLineNumber sourceLineNumbers = null) => this.backendHelper.TrackFile(path, type, sourceLineNumbers);
42 74
43 #endregion 75 #endregion
@@ -87,7 +119,7 @@ namespace WixToolset.Core.Burn.ExtensibilityServices
87 119
88 private ManifestData GetBundleExtensionManifestData(string extensionId) 120 private ManifestData GetBundleExtensionManifestData(string extensionId)
89 { 121 {
90 if (!Common.IsIdentifier(extensionId)) 122 if (!this.backendHelper.IsValidIdentifier(extensionId))
91 { 123 {
92 throw new ArgumentException($"'{extensionId}' is not a valid extensionId"); 124 throw new ArgumentException($"'{extensionId}' is not a valid extensionId");
93 } 125 }
diff --git a/src/WixToolset.Core.Burn/RowIndexedList.cs b/src/WixToolset.Core.Burn/RowIndexedList.cs
index 73172dc2..fd762a24 100644
--- a/src/WixToolset.Core.Burn/RowIndexedList.cs
+++ b/src/WixToolset.Core.Burn/RowIndexedList.cs
@@ -13,9 +13,9 @@ namespace WixToolset.Core.Burn
13 /// </summary> 13 /// </summary>
14 internal sealed class RowIndexedList<T> : IList<T> where T : Row 14 internal sealed class RowIndexedList<T> : IList<T> where T : Row
15 { 15 {
16 private Dictionary<string, T> index; 16 private readonly Dictionary<string, T> index;
17 private List<T> rows; 17 private readonly List<T> rows;
18 private List<T> duplicates; 18 private readonly List<T> duplicates;
19 19
20 /// <summary> 20 /// <summary>
21 /// Creates an empty <see cref="RowIndexedList{T}"/>. 21 /// Creates an empty <see cref="RowIndexedList{T}"/>.
@@ -34,7 +34,7 @@ namespace WixToolset.Core.Burn
34 public RowIndexedList(IEnumerable<T> rows) 34 public RowIndexedList(IEnumerable<T> rows)
35 : this() 35 : this()
36 { 36 {
37 foreach (T row in rows) 37 foreach (var row in rows)
38 { 38 {
39 this.Add(row); 39 this.Add(row);
40 } 40 }
@@ -81,8 +81,7 @@ namespace WixToolset.Core.Burn
81 /// <returns>Row or null if key is not found.</returns> 81 /// <returns>Row or null if key is not found.</returns>
82 public T Get(string key) 82 public T Get(string key)
83 { 83 {
84 T result; 84 return this.TryGet(key, out var result) ? result : null;
85 return this.TryGet(key, out result) ? result : null;
86 } 85 }
87 86
88 /// <summary> 87 /// <summary>
@@ -169,12 +168,11 @@ namespace WixToolset.Core.Burn
169 /// <param name="index">Index to remove the row at.</param> 168 /// <param name="index">Index to remove the row at.</param>
170 public void RemoveAt(int index) 169 public void RemoveAt(int index)
171 { 170 {
172 T row = this.rows[index]; 171 var row = this.rows[index];
173 172
174 this.rows.RemoveAt(index); 173 this.rows.RemoveAt(index);
175 174
176 T indexRow; 175 if (this.index.TryGetValue(row.GetKey(), out var indexRow) && indexRow == row)
177 if (this.index.TryGetValue(row.GetKey(), out indexRow) && indexRow == row)
178 { 176 {
179 this.index.Remove(row.GetKey()); 177 this.index.Remove(row.GetKey());
180 } 178 }
@@ -264,11 +262,10 @@ namespace WixToolset.Core.Burn
264 /// <returns></returns> 262 /// <returns></returns>
265 public bool Remove(T row) 263 public bool Remove(T row)
266 { 264 {
267 bool removed = this.rows.Remove(row); 265 var removed = this.rows.Remove(row);
268 if (removed) 266 if (removed)
269 { 267 {
270 T indexRow; 268 if (this.index.TryGetValue(row.GetKey(), out var indexRow) && indexRow == row)
271 if (this.index.TryGetValue(row.GetKey(), out indexRow) && indexRow == row)
272 { 269 {
273 this.index.Remove(row.GetKey()); 270 this.index.Remove(row.GetKey());
274 } 271 }
diff --git a/src/WixToolset.Core.Burn/TableExtensions.cs b/src/WixToolset.Core.Burn/TableExtensions.cs
deleted file mode 100644
index 465bf870..00000000
--- a/src/WixToolset.Core.Burn/TableExtensions.cs
+++ /dev/null
@@ -1,24 +0,0 @@
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 WixToolset.Core.Burn
4{
5 using System.Collections.Generic;
6 using System.Linq;
7 using WixToolset.Data.WindowsInstaller;
8
9 /// <summary>
10 /// Methods that extend <see cref="Table"/>.
11 /// </summary>
12 public static class TableExtensions
13 {
14 /// <summary>
15 /// Gets the rows contained in the table as a particular row type.
16 /// </summary>
17 /// <param name="table">Table to get rows from.</param>
18 /// <remarks>If the <paramref name="table"/> is null, an empty enumerable will be returned.</remarks>
19 public static IEnumerable<T> RowsAs<T>(this Table table) where T : Row
20 {
21 return (null == table) ? Enumerable.Empty<T>() : table.Rows.Cast<T>();
22 }
23 }
24}