diff options
| author | Rob Mensching <rob@firegiant.com> | 2017-12-19 12:25:40 -0800 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2017-12-19 12:25:40 -0800 |
| commit | 155a6e96346e0cb3d9ab6f5372fa29b46ebaee89 (patch) | |
| tree | 59d1f151bfde8068b6014b05b5c8cfea3402c974 /src/WixToolset.Core.WindowsInstaller/Differ.cs | |
| parent | 6f1665ed759b31bd095f186f9239232c653597cd (diff) | |
| download | wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.tar.gz wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.tar.bz2 wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.zip | |
Integrate simplified message handling
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Differ.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Differ.cs | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Differ.cs b/src/WixToolset.Core.WindowsInstaller/Differ.cs index 9bbde302..7cc204f9 100644 --- a/src/WixToolset.Core.WindowsInstaller/Differ.cs +++ b/src/WixToolset.Core.WindowsInstaller/Differ.cs | |||
| @@ -10,26 +10,29 @@ namespace WixToolset.Core.WindowsInstaller | |||
| 10 | using WixToolset.Data.WindowsInstaller; | 10 | using WixToolset.Data.WindowsInstaller; |
| 11 | using WixToolset.Data.WindowsInstaller.Rows; | 11 | using WixToolset.Data.WindowsInstaller.Rows; |
| 12 | using WixToolset.Extensibility; | 12 | using WixToolset.Extensibility; |
| 13 | using WixToolset.Extensibility.Services; | ||
| 13 | using WixToolset.Msi; | 14 | using WixToolset.Msi; |
| 14 | 15 | ||
| 15 | /// <summary> | 16 | /// <summary> |
| 16 | /// Creates a transform by diffing two outputs. | 17 | /// Creates a transform by diffing two outputs. |
| 17 | /// </summary> | 18 | /// </summary> |
| 18 | public sealed class Differ : IMessageHandler | 19 | public sealed class Differ |
| 19 | { | 20 | { |
| 20 | private List<IInspectorExtension> inspectorExtensions; | 21 | private List<IInspectorExtension> inspectorExtensions; |
| 21 | private bool showPedanticMessages; | 22 | private bool showPedanticMessages; |
| 22 | private bool suppressKeepingSpecialRows; | 23 | private bool suppressKeepingSpecialRows; |
| 23 | private bool preserveUnchangedRows; | 24 | private bool preserveUnchangedRows; |
| 24 | private const char sectionDelimiter = '/'; | 25 | private const char sectionDelimiter = '/'; |
| 26 | private readonly IMessaging messaging; | ||
| 25 | private SummaryInformationStreams transformSummaryInfo; | 27 | private SummaryInformationStreams transformSummaryInfo; |
| 26 | 28 | ||
| 27 | /// <summary> | 29 | /// <summary> |
| 28 | /// Instantiates a new Differ class. | 30 | /// Instantiates a new Differ class. |
| 29 | /// </summary> | 31 | /// </summary> |
| 30 | public Differ() | 32 | public Differ(IMessaging messaging) |
| 31 | { | 33 | { |
| 32 | this.inspectorExtensions = new List<IInspectorExtension>(); | 34 | this.inspectorExtensions = new List<IInspectorExtension>(); |
| 35 | this.messaging = messaging; | ||
| 33 | } | 36 | } |
| 34 | 37 | ||
| 35 | /// <summary> | 38 | /// <summary> |
| @@ -99,17 +102,17 @@ namespace WixToolset.Core.WindowsInstaller | |||
| 99 | // compare the codepages | 102 | // compare the codepages |
| 100 | if (targetOutput.Codepage != updatedOutput.Codepage && 0 == (TransformFlags.ErrorChangeCodePage & validationFlags)) | 103 | if (targetOutput.Codepage != updatedOutput.Codepage && 0 == (TransformFlags.ErrorChangeCodePage & validationFlags)) |
| 101 | { | 104 | { |
| 102 | this.OnMessage(WixErrors.OutputCodepageMismatch(targetOutput.SourceLineNumbers, targetOutput.Codepage, updatedOutput.Codepage)); | 105 | this.messaging.Write(ErrorMessages.OutputCodepageMismatch(targetOutput.SourceLineNumbers, targetOutput.Codepage, updatedOutput.Codepage)); |
| 103 | if (null != updatedOutput.SourceLineNumbers) | 106 | if (null != updatedOutput.SourceLineNumbers) |
| 104 | { | 107 | { |
| 105 | this.OnMessage(WixErrors.OutputCodepageMismatch2(updatedOutput.SourceLineNumbers)); | 108 | this.messaging.Write(ErrorMessages.OutputCodepageMismatch2(updatedOutput.SourceLineNumbers)); |
| 106 | } | 109 | } |
| 107 | } | 110 | } |
| 108 | 111 | ||
| 109 | // compare the output types | 112 | // compare the output types |
| 110 | if (targetOutput.Type != updatedOutput.Type) | 113 | if (targetOutput.Type != updatedOutput.Type) |
| 111 | { | 114 | { |
| 112 | throw new WixException(WixErrors.OutputTypeMismatch(targetOutput.SourceLineNumbers, targetOutput.Type.ToString(), updatedOutput.Type.ToString())); | 115 | throw new WixException(ErrorMessages.OutputTypeMismatch(targetOutput.SourceLineNumbers, targetOutput.Type.ToString(), updatedOutput.Type.ToString())); |
| 113 | } | 116 | } |
| 114 | 117 | ||
| 115 | // compare the contents of the tables | 118 | // compare the contents of the tables |
| @@ -160,15 +163,6 @@ namespace WixToolset.Core.WindowsInstaller | |||
| 160 | } | 163 | } |
| 161 | 164 | ||
| 162 | /// <summary> | 165 | /// <summary> |
| 163 | /// Sends a message to the message delegate if there is one. | ||
| 164 | /// </summary> | ||
| 165 | /// <param name="mea">Message event arguments.</param> | ||
| 166 | public void OnMessage(MessageEventArgs e) | ||
| 167 | { | ||
| 168 | Messaging.Instance.OnMessage(e); | ||
| 169 | } | ||
| 170 | |||
| 171 | /// <summary> | ||
| 172 | /// Add a row to the <paramref name="index"/> using the primary key. | 166 | /// Add a row to the <paramref name="index"/> using the primary key. |
| 173 | /// </summary> | 167 | /// </summary> |
| 174 | /// <param name="index">The indexed rows.</param> | 168 | /// <param name="index">The indexed rows.</param> |
| @@ -210,7 +204,7 @@ namespace WixToolset.Core.WindowsInstaller | |||
| 210 | } | 204 | } |
| 211 | else if (this.showPedanticMessages) | 205 | else if (this.showPedanticMessages) |
| 212 | { | 206 | { |
| 213 | this.OnMessage(WixWarnings.DuplicatePrimaryKey(row.SourceLineNumbers, primaryKey, row.Table.Name)); | 207 | this.messaging.Write(ErrorMessages.DuplicatePrimaryKey(row.SourceLineNumbers, primaryKey, row.Table.Name)); |
| 214 | } | 208 | } |
| 215 | } | 209 | } |
| 216 | else // use the string representation of the row as its primary key (it may not be unique) | 210 | else // use the string representation of the row as its primary key (it may not be unique) |
| @@ -370,7 +364,7 @@ namespace WixToolset.Core.WindowsInstaller | |||
| 370 | if (0 != targetTable.Definition.CompareTo(updatedTable.Definition)) | 364 | if (0 != targetTable.Definition.CompareTo(updatedTable.Definition)) |
| 371 | { | 365 | { |
| 372 | // continue to the next table; may be more mismatches | 366 | // continue to the next table; may be more mismatches |
| 373 | this.OnMessage(WixErrors.DatabaseSchemaMismatch(targetOutput.SourceLineNumbers, targetTable.Name)); | 367 | this.messaging.Write(ErrorMessages.DatabaseSchemaMismatch(targetOutput.SourceLineNumbers, targetTable.Name)); |
| 374 | } | 368 | } |
| 375 | else | 369 | else |
| 376 | { | 370 | { |
| @@ -425,7 +419,7 @@ namespace WixToolset.Core.WindowsInstaller | |||
| 425 | this.transformSummaryInfo.TargetProductCode = (string)row[1]; | 419 | this.transformSummaryInfo.TargetProductCode = (string)row[1]; |
| 426 | if ("*" == this.transformSummaryInfo.TargetProductCode) | 420 | if ("*" == this.transformSummaryInfo.TargetProductCode) |
| 427 | { | 421 | { |
| 428 | this.OnMessage(WixErrors.ProductCodeInvalidForTransform(row.SourceLineNumbers)); | 422 | this.messaging.Write(ErrorMessages.ProductCodeInvalidForTransform(row.SourceLineNumbers)); |
| 429 | } | 423 | } |
| 430 | } | 424 | } |
| 431 | else if ("ProductVersion" == (string)row[0]) | 425 | else if ("ProductVersion" == (string)row[0]) |
| @@ -466,7 +460,7 @@ namespace WixToolset.Core.WindowsInstaller | |||
| 466 | this.transformSummaryInfo.UpdatedProductCode = (string)row[1]; | 460 | this.transformSummaryInfo.UpdatedProductCode = (string)row[1]; |
| 467 | if ("*" == this.transformSummaryInfo.UpdatedProductCode) | 461 | if ("*" == this.transformSummaryInfo.UpdatedProductCode) |
| 468 | { | 462 | { |
| 469 | this.OnMessage(WixErrors.ProductCodeInvalidForTransform(row.SourceLineNumbers)); | 463 | this.messaging.Write(ErrorMessages.ProductCodeInvalidForTransform(row.SourceLineNumbers)); |
| 470 | } | 464 | } |
| 471 | } | 465 | } |
| 472 | else if ("ProductVersion" == (string)row[0]) | 466 | else if ("ProductVersion" == (string)row[0]) |
