From 110bfc5b5bfee7c4592d9898406d2250f3c96ca3 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 4 Jun 2020 10:28:49 -0700 Subject: Correctly pass extension context when Id attribute is null --- src/WixToolset.Core/Compiler.cs | 4 ++-- src/WixToolset.Core/Compiler_2.cs | 6 +++--- src/WixToolset.Core/Compiler_Bundle.cs | 6 +++--- src/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/WixToolset.Core/Compiler.cs b/src/WixToolset.Core/Compiler.cs index 83623883..3365789f 100644 --- a/src/WixToolset.Core/Compiler.cs +++ b/src/WixToolset.Core/Compiler.cs @@ -2416,7 +2416,7 @@ namespace WixToolset.Core } else { - var context = new Dictionary() { { "ComponentId", id.Id }, { "DirectoryId", directoryId }, { "Win64", win64.ToString() }, }; + var context = new Dictionary() { { "ComponentId", id?.Id }, { "DirectoryId", directoryId }, { "Win64", win64.ToString() }, }; var possibleKeyPath = this.Core.ParsePossibleKeyPathExtensionElement(node, child, context); if (null != possibleKeyPath) { @@ -5753,7 +5753,7 @@ namespace WixToolset.Core } else { - var context = new Dictionary() { { "FileId", id.Id }, { "ComponentId", componentId }, { "DirectoryId", directoryId }, { "Win64", win64Component.ToString() } }; + var context = new Dictionary() { { "FileId", id?.Id }, { "ComponentId", componentId }, { "DirectoryId", directoryId }, { "Win64", win64Component.ToString() } }; this.Core.ParseExtensionElement(node, child, context); } } diff --git a/src/WixToolset.Core/Compiler_2.cs b/src/WixToolset.Core/Compiler_2.cs index c5f3fb6f..9e2ddb5b 100644 --- a/src/WixToolset.Core/Compiler_2.cs +++ b/src/WixToolset.Core/Compiler_2.cs @@ -1794,7 +1794,7 @@ namespace WixToolset.Core } else { - var context = new Dictionary() { { "RegistryId", id.Id }, { "ComponentId", componentId }, { "Win64", win64Component.ToString() } }; + var context = new Dictionary() { { "RegistryId", id?.Id }, { "ComponentId", componentId }, { "Win64", win64Component.ToString() } }; this.Core.ParseExtensionElement(node, child, context); } } @@ -1991,7 +1991,7 @@ namespace WixToolset.Core } else { - var context = new Dictionary() { { "RegistryId", id.Id }, { "ComponentId", componentId }, { "Win64", win64Component.ToString() } }; + var context = new Dictionary() { { "RegistryId", id?.Id }, { "ComponentId", componentId }, { "Win64", win64Component.ToString() } }; this.Core.ParseExtensionElement(node, child, context); } } @@ -3658,7 +3658,7 @@ namespace WixToolset.Core } else { - var context = new Dictionary() { { "ServiceInstallId", id.Id }, { "ServiceInstallName", name }, { "ServiceInstallComponentId", componentId }, { "Win64", win64Component.ToString() } }; + var context = new Dictionary() { { "ServiceInstallId", id?.Id }, { "ServiceInstallName", name }, { "ServiceInstallComponentId", componentId }, { "Win64", win64Component.ToString() } }; this.Core.ParseExtensionElement(node, child, context); } } diff --git a/src/WixToolset.Core/Compiler_Bundle.cs b/src/WixToolset.Core/Compiler_Bundle.cs index 9858ae17..31896a42 100644 --- a/src/WixToolset.Core/Compiler_Bundle.cs +++ b/src/WixToolset.Core/Compiler_Bundle.cs @@ -949,7 +949,7 @@ namespace WixToolset.Core var id = this.ParsePayloadElementContent(node, parentType, parentId, previousType, previousId, true); var context = new Dictionary { - ["Id"] = id.Id + ["Id"] = id?.Id }; foreach (var child in node.Elements()) @@ -1044,7 +1044,7 @@ namespace WixToolset.Core // Now that the PayloadId is known, we can parse the extension attributes. var context = new Dictionary { - ["Id"] = id.Id + ["Id"] = id?.Id }; foreach (var extensionAttribute in extensionAttributes) @@ -2070,7 +2070,7 @@ namespace WixToolset.Core } else { - var context = new Dictionary() { { "Id", id.Id } }; + var context = new Dictionary() { { "Id", id?.Id } }; this.Core.ParseExtensionElement(node, child, context); } } diff --git a/src/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs b/src/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs index 8482dcbe..d6c7b091 100644 --- a/src/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs +++ b/src/test/WixToolsetTest.CoreIntegration/BadInputFixture.cs @@ -10,7 +10,7 @@ namespace WixToolsetTest.CoreIntegration public class BadInputFixture { - [Fact(Skip = "Test demonstrates failure")] + [Fact] public void RegistryKeyWithoutAttributesDoesntCrash() { var folder = TestData.Get(@"TestData\BadInput"); -- cgit v1.2.3-55-g6feb