From 453107d72fa96e7b942ef4698ab10e4bcac91d2e Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Tue, 19 Jan 2021 15:38:47 -0600 Subject: Use new logic for -sw in DecompileCommand. --- .../CommandLine/DecompileCommand.cs | 37 ++++++++++++++++------ .../CustomTableFixture.cs | 3 +- .../DecompileFixture.cs | 2 +- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/WixToolset.Core/CommandLine/DecompileCommand.cs b/src/WixToolset.Core/CommandLine/DecompileCommand.cs index 393e2a4e..06402a13 100644 --- a/src/WixToolset.Core/CommandLine/DecompileCommand.cs +++ b/src/WixToolset.Core/CommandLine/DecompileCommand.cs @@ -128,19 +128,19 @@ namespace WixToolset.Core.CommandLine case "verbose": this.Messaging.ShowVerboseMessages = true; return true; + } - case "sw": - case "suppresswarning": - var warning = parser.GetNextArgumentOrError(arg); - if (!String.IsNullOrEmpty(warning)) - { - var warningNumber = Convert.ToInt32(warning); - this.Messaging.SuppressWarningMessage(warningNumber); - } + if (parameter.StartsWith("sw")) + { + this.ParseSuppressWarning(parameter, "sw".Length, parser); return true; } - - if (parameter.StartsWith("wx")) + else if (parameter.StartsWith("suppresswarning")) + { + this.ParseSuppressWarning(parameter, "suppresswarning".Length, parser); + return true; + } + else if (parameter.StartsWith("wx")) { this.ParseWarningAsError(parameter, "wx".Length, parser); return true; @@ -218,6 +218,23 @@ namespace WixToolset.Core.CommandLine return String.IsNullOrEmpty(this.OutputFile) ? Path.ChangeExtension(this.DecompileFilePath, ".wxs") : this.OutputFile; } + private void ParseSuppressWarning(string parameter, int offset, ICommandLineParser parser) + { + var paramArg = parameter.Substring(offset); + if (paramArg.Length == 0) + { + this.Messaging.SuppressAllWarnings = true; + } + else if (Int32.TryParse(paramArg, out var suppressWarning) && suppressWarning > 0) + { + this.Messaging.SuppressWarningMessage(suppressWarning); + } + else + { + parser.ReportErrorArgument(parameter, ErrorMessages.IllegalSuppressWarningId(paramArg)); + } + } + private void ParseWarningAsError(string parameter, int offset, ICommandLineParser parser) { var paramArg = parameter.Substring(offset); diff --git a/src/test/WixToolsetTest.CoreIntegration/CustomTableFixture.cs b/src/test/WixToolsetTest.CoreIntegration/CustomTableFixture.cs index 3ee88640..f9cd2c70 100644 --- a/src/test/WixToolsetTest.CoreIntegration/CustomTableFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/CustomTableFixture.cs @@ -216,9 +216,10 @@ namespace WixToolsetTest.CoreIntegration result.AssertSuccess(); Assert.True(File.Exists(msiPath)); - result = WixRunner.Execute(false, new[] + result = WixRunner.Execute(new[] { "decompile", msiPath, + "-sw1060", "-intermediateFolder", intermediateFolder, "-o", decompiledWxsPath }); diff --git a/src/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs b/src/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs index 924337ba..b07f5bda 100644 --- a/src/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/DecompileFixture.cs @@ -20,7 +20,7 @@ namespace WixToolsetTest.CoreIntegration var intermediateFolder = fs.GetFolder(); var outputPath = Path.Combine(intermediateFolder, @"Actual.wxs"); - var result = WixRunner.Execute(false, new[] + var result = WixRunner.Execute(new[] { "decompile", Path.Combine(folder, msiName), -- cgit v1.2.3-55-g6feb