From b3197fdf8b437d0d8fcc2e564cb1e3484bb1392a Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Sun, 21 Jun 2020 16:40:17 +1000 Subject: Add BundleCustomDataRef element. Default BundleCustomData to Type=bootstrapperApplication. --- src/WixToolset.Core/Compiler.cs | 3 + src/WixToolset.Core/Compiler_Bundle.cs | 77 +++++++++++++++++++++- .../BundleCustomTable/BundleCustomTable.wxs | 21 ++++-- 3 files changed, 92 insertions(+), 9 deletions(-) diff --git a/src/WixToolset.Core/Compiler.cs b/src/WixToolset.Core/Compiler.cs index cb85281d..9681cb3f 100644 --- a/src/WixToolset.Core/Compiler.cs +++ b/src/WixToolset.Core/Compiler.cs @@ -6229,6 +6229,9 @@ namespace WixToolset.Core case "BundleCustomData": this.ParseBundleCustomDataElement(child); break; + case "BundleCustomDataRef": + this.ParseBundleCustomDataRefElement(child); + break; case "BundleExtension": this.ParseBundleExtensionElement(child); break; diff --git a/src/WixToolset.Core/Compiler_Bundle.cs b/src/WixToolset.Core/Compiler_Bundle.cs index 5154a72f..2b274474 100644 --- a/src/WixToolset.Core/Compiler_Bundle.cs +++ b/src/WixToolset.Core/Compiler_Bundle.cs @@ -280,6 +280,9 @@ namespace WixToolset.Core case "BundleCustomData": this.ParseBundleCustomDataElement(child); break; + case "BundleCustomDataRef": + this.ParseBundleCustomDataRefElement(child); + break; case "BundleExtension": this.ParseBundleExtensionElement(child); break; @@ -784,6 +787,7 @@ namespace WixToolset.Core WixBundleCustomDataType? customDataType = null; string extensionId = null; var attributeDefinitions = new List(); + var foundAttributeDefinitions = false; foreach (var attrib in node.Attributes()) { @@ -831,9 +835,9 @@ namespace WixToolset.Core } var hasExtensionId = null != extensionId; - if (hasExtensionId && !customDataType.HasValue) + if (!customDataType.HasValue) { - customDataType = WixBundleCustomDataType.BundleExtension; + customDataType = hasExtensionId ? WixBundleCustomDataType.BundleExtension : WixBundleCustomDataType.BootstrapperApplication; } if (!customDataType.HasValue) @@ -860,6 +864,8 @@ namespace WixToolset.Core switch (child.Name.LocalName) { case "BundleAttributeDefinition": + foundAttributeDefinitions = true; + var attributeDefinition = this.ParseBundleAttributeDefinitionElement(child, childSourceLineNumbers, customDataId); if (attributeDefinition != null) { @@ -894,6 +900,73 @@ namespace WixToolset.Core }); } } + else if (!foundAttributeDefinitions) + { + this.Core.Write(ErrorMessages.ExpectedElement(sourceLineNumbers, node.Name.LocalName, "BundleAttributeDefinition")); + } + } + + /// + /// Parses a BundleCustomDataRef element. + /// + /// Element to parse. + private void ParseBundleCustomDataRefElement(XElement node) + { + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + string customDataId = null; + var foundChild = false; + + foreach (var attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + customDataId = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; + } + } + else + { + this.Core.ParseExtensionAttribute(node, attrib); + } + } + + if (null == customDataId) + { + this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); + } + + foreach (var child in node.Elements()) + { + foundChild = true; + if (CompilerCore.WixNamespace == child.Name.Namespace) + { + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + switch (child.Name.LocalName) + { + case "BundleElement": + this.ParseBundleElementElement(child, childSourceLineNumbers, customDataId); + break; + default: + this.Core.UnexpectedElement(node, child); + break; + } + } + else + { + this.Core.ParseExtensionElement(node, child); + } + } + + if (!foundChild) + { + this.Core.Write(ErrorMessages.ExpectedElement(sourceLineNumbers, node.Name.LocalName)); + } } /// diff --git a/src/test/WixToolsetTest.CoreIntegration/TestData/BundleCustomTable/BundleCustomTable.wxs b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleCustomTable/BundleCustomTable.wxs index 38d207ca..8482a57e 100644 --- a/src/test/WixToolsetTest.CoreIntegration/TestData/BundleCustomTable/BundleCustomTable.wxs +++ b/src/test/WixToolsetTest.CoreIntegration/TestData/BundleCustomTable/BundleCustomTable.wxs @@ -5,7 +5,7 @@ - + @@ -17,16 +17,23 @@ < > - - 1 - 2 - - + + + + + + + 1 + 2 + + + + one two @@ -39,7 +46,7 @@ 1 2 - + -- cgit v1.2.3-55-g6feb