@joebigelow / wix / commits / 46c5b7c0

Small code cleanup in patch build.

Rob Mensching committed Aug 26, 2022 at 15:24 UTC 46c5b7c03dd1cfcba83995217e7c5c34120b5e7e
2 files changed +21 -22
src/wix/WixToolset.Core.WindowsInstaller/Bind/GenerateTransformCommand.cs
+19 -20
@@ -75,7 +75,7 @@ namespace WixToolset.Core.WindowsInstaller
75
76 this.transformSummaryInfo = new SummaryInformationStreams();
77
78 - // compare the codepages
78 + // Compare the codepages.
79 if (targetOutput.Codepage != updatedOutput.Codepage && 0 == (TransformFlags.ErrorChangeCodePage & validationFlags))
80 {
81 this.messaging.Write(ErrorMessages.OutputCodepageMismatch(targetOutput.SourceLineNumbers, targetOutput.Codepage, updatedOutput.Codepage));
@@ -85,19 +85,18 @@ namespace WixToolset.Core.WindowsInstaller
85 }
86 }
87
88 - // compare the output types
88 + // Compare the output types.
89 if (targetOutput.Type != updatedOutput.Type)
90 {
91 throw new WixException(ErrorMessages.OutputTypeMismatch(targetOutput.SourceLineNumbers, targetOutput.Type.ToString(), updatedOutput.Type.ToString()));
92 }
93
94 - // compare the contents of the tables
94 + // Compare the contents of the tables.
95 foreach (var targetTable in targetOutput.Tables)
96 {
97 var updatedTable = updatedOutput.Tables[targetTable.Name];
98 - var operation = TableOperation.None;
98
100 - var rows = this.CompareTables(targetOutput, targetTable, updatedTable, out operation);
99 + var rows = this.CompareTables(targetOutput, targetTable, updatedTable, out var operation);
100
101 if (TableOperation.Drop == operation)
102 {
@@ -114,10 +113,10 @@ namespace WixToolset.Core.WindowsInstaller
113 }
114 }
115
117 - // added tables
116 + // Add all of the rows for tables that only exist in the update.
117 foreach (var updatedTable in updatedOutput.Tables)
118 {
120 - if (null == targetOutput.Tables[updatedTable.Name])
119 + if (!targetOutput.Tables.TryGetTable(updatedTable.Name, out var _))
120 {
121 var addedTable = transform.EnsureTable(updatedTable.Definition);
122 addedTable.Operation = TableOperation.Add;
@@ -131,7 +130,7 @@ namespace WixToolset.Core.WindowsInstaller
130 }
131 }
132
134 - // set summary information properties
133 + // Set summary information properties.
134 if (!this.SuppressKeepingSpecialRows)
135 {
136 var summaryInfoTable = transform.Tables["_SummaryInformation"];
@@ -319,20 +318,20 @@ namespace WixToolset.Core.WindowsInstaller
318 var rows = new List<Row>();
319 operation = TableOperation.None;
320
322 - // dropped tables
323 - if (null == updatedTable ^ null == targetTable)
321 + // No tables.
322 + if (null == targetTable && null == updatedTable)
323 {
325 - if (null == targetTable)
326 - {
327 - operation = TableOperation.Add;
328 - rows.AddRange(updatedTable.Rows);
329 - }
330 - else if (null == updatedTable)
331 - {
332 - operation = TableOperation.Drop;
333 - }
324 }
335 - else // possibly modified tables
325 + else if (null == targetTable) // added table.
326 + {
327 + operation = TableOperation.Add;
328 + rows.AddRange(updatedTable.Rows);
329 + }
330 + else if (null == updatedTable) // removed table.
331 + {
332 + operation = TableOperation.Drop;
333 + }
334 + else // possibly modified table.
335 {
336 var updatedPrimaryKeys = new Dictionary<string, Row>();
337 var targetPrimaryKeys = new Dictionary<string, Row>();
src/wix/WixToolset.Core.WindowsInstaller/Unbind/UnbindTransformCommand.cs
+2 -2
@@ -67,7 +67,6 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
67
68 // create a schema msi which hopefully matches the table schemas in the transform
69 var schemaOutput = new WindowsInstallerData(null);
70 - var msiDatabaseFile = Path.Combine(this.IntermediateFolder, "schema.msi");
70 foreach (var tableDefinition in this.TableDefinitions)
71 {
72 // skip unreal tables and the Patch table
@@ -81,9 +80,10 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
80 Table transformViewTable;
81
82 // Bind the schema msi.
83 + var msiDatabaseFile = Path.Combine(this.IntermediateFolder, "schema.msi");
84 this.GenerateDatabase(schemaOutput, msiDatabaseFile);
85
86 - // apply the transform to the database and retrieve the modifications
86 + // Apply the transform to the database and retrieve the modifications.
87 using (var msiDatabase = new Database(msiDatabaseFile, OpenDatabase.Transact))
88 {
89 // apply the transform with the ViewTransform option to collect all the modifications