From 6155da0bc9e7faa97612d15def98dd68ea2557cd Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Fri, 18 Oct 2019 11:30:10 -0700 Subject: Small tuple based fixes --- .../Bind/CreateOutputFromIRCommand.cs | 50 +++++++++++++++++++--- src/WixToolset.Core/Compiler_2.cs | 2 +- src/WixToolset.Core/Compiler_UI.cs | 37 +++++----------- .../MsiQueryFixture.cs | 6 +-- .../WixlibQueryFixture.cs | 2 +- 5 files changed, 58 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs index cdda4ebc..ebb494c0 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateOutputFromIRCommand.cs @@ -50,13 +50,17 @@ namespace WixToolset.Core.WindowsInstaller.Bind switch (tuple.Definition.Type) { case TupleDefinitionType.Binary: - this.AddTupleDefaultly(tuple, output, true); + this.AddTupleDefaultly(tuple, output, idIsPrimaryKey: true); break; case TupleDefinitionType.BBControl: this.AddBBControlTuple((BBControlTuple)tuple, output); break; + case TupleDefinitionType.Class: + this.AddClassTuple((ClassTuple)tuple, output); + break; + case TupleDefinitionType.Control: this.AddControlTuple((ControlTuple)tuple, output); break; @@ -89,6 +93,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind this.AddFileTuple((FileTuple)tuple, output); break; + case TupleDefinitionType.Icon: + this.AddTupleDefaultly(tuple, output, idIsPrimaryKey: true); + break; + case TupleDefinitionType.IniFile: this.AddIniFileTuple((IniFileTuple)tuple, output); break; @@ -118,7 +126,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind break; case TupleDefinitionType.MsiShortcutProperty: - this.AddTupleDefaultly(tuple, output, true); + this.AddTupleDefaultly(tuple, output, idIsPrimaryKey: true); break; case TupleDefinitionType.MoveFile: @@ -146,7 +154,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind break; case TupleDefinitionType.ReserveCost: - this.AddTupleDefaultly(tuple, output, true); + this.AddTupleDefaultly(tuple, output, idIsPrimaryKey: true); break; case TupleDefinitionType.ServiceControl: @@ -162,7 +170,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind break; case TupleDefinitionType.Signature: - this.AddTupleDefaultly(tuple, output, true); + this.AddTupleDefaultly(tuple, output, idIsPrimaryKey: true); break; case TupleDefinitionType.SummaryInformation: @@ -228,6 +236,25 @@ namespace WixToolset.Core.WindowsInstaller.Bind row[8] = tuple.Text; } + private void AddClassTuple(ClassTuple tuple, Output output) + { + var table = output.EnsureTable(this.TableDefinitions["Class"]); + var row = table.CreateRow(tuple.SourceLineNumbers); + row[0] = tuple.CLSID; + row[1] = tuple.Context; + row[2] = tuple.ComponentRef; + row[3] = tuple.DefaultProgIdRef; + row[4] = tuple.Description; + row[5] = tuple.AppIdRef; + row[6] = tuple.FileTypeMask; + row[7] = tuple.IconRef; + row[8] = tuple.IconIndex; + row[9] = tuple.DefInprocHandler; + row[10] = tuple.Argument; + row[11] = tuple.FeatureRef; + row[12] = tuple.RelativePath ? (int?)1 : null; + } + private void AddControlTuple(ControlTuple tuple, Output output) { var text = tuple.Text; @@ -326,7 +353,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind row[1] = type; row[2] = tuple.Source; row[3] = tuple.Target; - row[4] = tuple.PatchUninstall ? WindowsInstallerConstants.MsidbCustomActionTypePatchUninstall : 0; + row[4] = tuple.PatchUninstall ? (int?)WindowsInstallerConstants.MsidbCustomActionTypePatchUninstall : null; } private void AddDialogTuple(DialogTuple tuple, Output output) @@ -775,13 +802,22 @@ namespace WixToolset.Core.WindowsInstaller.Bind styleBits |= tuple.Strike ? WindowsInstallerConstants.MsidbTextStyleStyleBitsStrike : 0; styleBits |= tuple.Underline ? WindowsInstallerConstants.MsidbTextStyleStyleBitsUnderline : 0; + long? color = null; + + if (tuple.Red.HasValue || tuple.Green.HasValue || tuple.Blue.HasValue) + { + color = tuple.Red ?? 0; + color += (long)(tuple.Green ?? 0) * 256; + color += (long)(tuple.Blue ?? 0) * 65536; + } + var table = output.EnsureTable(this.TableDefinitions["TextStyle"]); var row = table.CreateRow(tuple.SourceLineNumbers); row[0] = tuple.Id.Id; row[1] = tuple.FaceName; row[2] = tuple.Size; - row[3] = tuple.Color; - row[4] = styleBits; + row[3] = color; + row[4] = styleBits == 0 ? null : (int?)styleBits; } private void AddUpgradeTuple(UpgradeTuple tuple, Output output) diff --git a/src/WixToolset.Core/Compiler_2.cs b/src/WixToolset.Core/Compiler_2.cs index 740219cb..10416850 100644 --- a/src/WixToolset.Core/Compiler_2.cs +++ b/src/WixToolset.Core/Compiler_2.cs @@ -27,7 +27,7 @@ namespace WixToolset.Core { var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); var codepage = 65001; - string productCode = "*"; + var productCode = "*"; string upgradeCode = null; string manufacturer = null; string version = null; diff --git a/src/WixToolset.Core/Compiler_UI.cs b/src/WixToolset.Core/Compiler_UI.cs index 6b933d09..30bb7ab6 100644 --- a/src/WixToolset.Core/Compiler_UI.cs +++ b/src/WixToolset.Core/Compiler_UI.cs @@ -746,7 +746,9 @@ namespace WixToolset.Core { var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - var color = CompilerConstants.IntegerNotSet; + int? red = null; + int? green = null; + int? blue = null; var bold = false; var italic = false; var strike = false; @@ -769,42 +771,21 @@ namespace WixToolset.Core var redColor = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Byte.MaxValue); if (CompilerConstants.IllegalInteger != redColor) { - if (CompilerConstants.IntegerNotSet == color) - { - color = redColor; - } - else - { - color += redColor; - } + red = redColor; } break; case "Green": var greenColor = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Byte.MaxValue); if (CompilerConstants.IllegalInteger != greenColor) { - if (CompilerConstants.IntegerNotSet == color) - { - color = greenColor * 256; - } - else - { - color += greenColor * 256; - } + green = greenColor; } break; case "Blue": var blueColor = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Byte.MaxValue); if (CompilerConstants.IllegalInteger != blueColor) { - if (CompilerConstants.IntegerNotSet == color) - { - color = blueColor * 65536; - } - else - { - color += blueColor * 65536; - } + blue = blueColor; } break; @@ -843,7 +824,7 @@ namespace WixToolset.Core if (null == id) { - this.Core.CreateIdentifier("txs", faceName, size.ToString(), color.ToString(), bold.ToString(), italic.ToString(), strike.ToString(), underline.ToString()); + this.Core.CreateIdentifier("txs", faceName, size.ToString(), (red ?? 0).ToString(), (green ?? 0).ToString(), (blue ?? 0).ToString(), bold.ToString(), italic.ToString(), strike.ToString(), underline.ToString()); } if (null == faceName) @@ -858,7 +839,9 @@ namespace WixToolset.Core var tuple = new TextStyleTuple(sourceLineNumbers, id) { FaceName = faceName, - Color = color, + Red = red, + Green = green, + Blue = blue, Bold = bold, Italic = italic, Strike = strike, diff --git a/src/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs b/src/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs index d31c9ee8..8535f69c 100644 --- a/src/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/MsiQueryFixture.cs @@ -146,7 +146,7 @@ namespace WixToolsetTest.CoreIntegration } } - [Fact(Skip = "Test demonstrates failure")] + [Fact] public void PopulatesClassTablesWhenIconIndexIsZero() { var folder = TestData.Get(@"TestData"); @@ -218,7 +218,7 @@ namespace WixToolsetTest.CoreIntegration } } - [Fact(Skip = "Test demonstrates failure")] + [Fact] public void PopulatesCustomActionTable() { var folder = TestData.Get(@"TestData"); @@ -647,7 +647,7 @@ namespace WixToolsetTest.CoreIntegration } } - [Fact(Skip = "Test demonstrates failure")] + [Fact] public void PopulatesTextStyleTableWhenColorIsNull() { var folder = TestData.Get(@"TestData"); diff --git a/src/test/WixToolsetTest.CoreIntegration/WixlibQueryFixture.cs b/src/test/WixToolsetTest.CoreIntegration/WixlibQueryFixture.cs index 517bddbf..7f9b9686 100644 --- a/src/test/WixToolsetTest.CoreIntegration/WixlibQueryFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/WixlibQueryFixture.cs @@ -43,7 +43,7 @@ namespace WixToolsetTest.CoreIntegration } } - [Fact(Skip = "Test demonstrates failure")] + [Fact] public void TypeLibLanguageAsStringReturnsZero() { var folder = TestData.Get(@"TestData\TypeLib"); -- cgit v1.2.3-55-g6feb