From 46c5b7c03dd1cfcba83995217e7c5c34120b5e7e Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 26 Aug 2022 15:24:31 -0700 Subject: Small code cleanup in patch build. --- .../Bind/GenerateTransformCommand.cs | 39 +++++++++++----------- .../Unbind/UnbindTransformCommand.cs | 4 +-- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Bind/GenerateTransformCommand.cs b/src/wix/WixToolset.Core.WindowsInstaller/Bind/GenerateTransformCommand.cs index faa03762..575065bb 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Bind/GenerateTransformCommand.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Bind/GenerateTransformCommand.cs @@ -75,7 +75,7 @@ namespace WixToolset.Core.WindowsInstaller this.transformSummaryInfo = new SummaryInformationStreams(); - // compare the codepages + // Compare the codepages. if (targetOutput.Codepage != updatedOutput.Codepage && 0 == (TransformFlags.ErrorChangeCodePage & validationFlags)) { this.messaging.Write(ErrorMessages.OutputCodepageMismatch(targetOutput.SourceLineNumbers, targetOutput.Codepage, updatedOutput.Codepage)); @@ -85,19 +85,18 @@ namespace WixToolset.Core.WindowsInstaller } } - // compare the output types + // Compare the output types. if (targetOutput.Type != updatedOutput.Type) { throw new WixException(ErrorMessages.OutputTypeMismatch(targetOutput.SourceLineNumbers, targetOutput.Type.ToString(), updatedOutput.Type.ToString())); } - // compare the contents of the tables + // Compare the contents of the tables. foreach (var targetTable in targetOutput.Tables) { var updatedTable = updatedOutput.Tables[targetTable.Name]; - var operation = TableOperation.None; - var rows = this.CompareTables(targetOutput, targetTable, updatedTable, out operation); + var rows = this.CompareTables(targetOutput, targetTable, updatedTable, out var operation); if (TableOperation.Drop == operation) { @@ -114,10 +113,10 @@ namespace WixToolset.Core.WindowsInstaller } } - // added tables + // Add all of the rows for tables that only exist in the update. foreach (var updatedTable in updatedOutput.Tables) { - if (null == targetOutput.Tables[updatedTable.Name]) + if (!targetOutput.Tables.TryGetTable(updatedTable.Name, out var _)) { var addedTable = transform.EnsureTable(updatedTable.Definition); addedTable.Operation = TableOperation.Add; @@ -131,7 +130,7 @@ namespace WixToolset.Core.WindowsInstaller } } - // set summary information properties + // Set summary information properties. if (!this.SuppressKeepingSpecialRows) { var summaryInfoTable = transform.Tables["_SummaryInformation"]; @@ -319,20 +318,20 @@ namespace WixToolset.Core.WindowsInstaller var rows = new List(); operation = TableOperation.None; - // dropped tables - if (null == updatedTable ^ null == targetTable) + // No tables. + if (null == targetTable && null == updatedTable) { - if (null == targetTable) - { - operation = TableOperation.Add; - rows.AddRange(updatedTable.Rows); - } - else if (null == updatedTable) - { - operation = TableOperation.Drop; - } } - else // possibly modified tables + else if (null == targetTable) // added table. + { + operation = TableOperation.Add; + rows.AddRange(updatedTable.Rows); + } + else if (null == updatedTable) // removed table. + { + operation = TableOperation.Drop; + } + else // possibly modified table. { var updatedPrimaryKeys = new Dictionary(); var targetPrimaryKeys = new Dictionary(); diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Unbind/UnbindTransformCommand.cs b/src/wix/WixToolset.Core.WindowsInstaller/Unbind/UnbindTransformCommand.cs index ea40fa9f..01ff1a80 100644 --- a/src/wix/WixToolset.Core.WindowsInstaller/Unbind/UnbindTransformCommand.cs +++ b/src/wix/WixToolset.Core.WindowsInstaller/Unbind/UnbindTransformCommand.cs @@ -67,7 +67,6 @@ namespace WixToolset.Core.WindowsInstaller.Unbind // create a schema msi which hopefully matches the table schemas in the transform var schemaOutput = new WindowsInstallerData(null); - var msiDatabaseFile = Path.Combine(this.IntermediateFolder, "schema.msi"); foreach (var tableDefinition in this.TableDefinitions) { // skip unreal tables and the Patch table @@ -81,9 +80,10 @@ namespace WixToolset.Core.WindowsInstaller.Unbind Table transformViewTable; // Bind the schema msi. + var msiDatabaseFile = Path.Combine(this.IntermediateFolder, "schema.msi"); this.GenerateDatabase(schemaOutput, msiDatabaseFile); - // apply the transform to the database and retrieve the modifications + // Apply the transform to the database and retrieve the modifications. using (var msiDatabase = new Database(msiDatabaseFile, OpenDatabase.Transact)) { // apply the transform with the ViewTransform option to collect all the modifications -- cgit v1.2.3-55-g6feb