Add BundleCustomDataRef element. Default BundleCustomData to Type=bootstrapperApplication.
Add BundleCustomDataRef element. Default BundleCustomData to Type=bootstrapperApplication.
Sean Hall committed
Jun 21, 2020 at 16:40 UTC
b3197fdf8b437d0d8fcc2e564cb1e3484bb1392a
3 files changed
+92
-9
src/WixToolset.Core/Compiler.cs
+3
@@ -6229,6 +6229,9 @@ namespace WixToolset.Core
6229
case "BundleCustomData":
6230
this.ParseBundleCustomDataElement(child);
6231
break;
6232
+ case "BundleCustomDataRef":
6233
+ this.ParseBundleCustomDataRefElement(child);
6234
+ break;
6235
case "BundleExtension":
6236
this.ParseBundleExtensionElement(child);
6237
break;
src/WixToolset.Core/Compiler_Bundle.cs
+75
-2
@@ -280,6 +280,9 @@ namespace WixToolset.Core
280
case "BundleCustomData":
281
this.ParseBundleCustomDataElement(child);
282
break;
283
+ case "BundleCustomDataRef":
284
+ this.ParseBundleCustomDataRefElement(child);
285
+ break;
286
case "BundleExtension":
287
this.ParseBundleExtensionElement(child);
288
break;
@@ -784,6 +787,7 @@ namespace WixToolset.Core
787
WixBundleCustomDataType? customDataType = null;
788
string extensionId = null;
789
var attributeDefinitions = new List<WixBundleCustomDataAttributeTuple>();
790
+ var foundAttributeDefinitions = false;
791
792
foreach (var attrib in node.Attributes())
793
{
@@ -831,9 +835,9 @@ namespace WixToolset.Core
835
}
836
837
var hasExtensionId = null != extensionId;
834
- if (hasExtensionId && !customDataType.HasValue)
838
+ if (!customDataType.HasValue)
839
{
836
- customDataType = WixBundleCustomDataType.BundleExtension;
840
+ customDataType = hasExtensionId ? WixBundleCustomDataType.BundleExtension : WixBundleCustomDataType.BootstrapperApplication;
841
}
842
843
if (!customDataType.HasValue)
@@ -860,6 +864,8 @@ namespace WixToolset.Core
864
switch (child.Name.LocalName)
865
{
866
case "BundleAttributeDefinition":
867
+ foundAttributeDefinitions = true;
868
+
869
var attributeDefinition = this.ParseBundleAttributeDefinitionElement(child, childSourceLineNumbers, customDataId);
870
if (attributeDefinition != null)
871
{
@@ -894,6 +900,73 @@ namespace WixToolset.Core
900
});
901
}
902
}
903
+ else if (!foundAttributeDefinitions)
904
+ {
905
+ this.Core.Write(ErrorMessages.ExpectedElement(sourceLineNumbers, node.Name.LocalName, "BundleAttributeDefinition"));
906
+ }
907
+ }
908
+
909
+ /// <summary>
910
+ /// Parses a BundleCustomDataRef element.
911
+ /// </summary>
912
+ /// <param name="node">Element to parse.</param>
913
+ private void ParseBundleCustomDataRefElement(XElement node)
914
+ {
915
+ var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
916
+ string customDataId = null;
917
+ var foundChild = false;
918
+
919
+ foreach (var attrib in node.Attributes())
920
+ {
921
+ if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
922
+ {
923
+ switch (attrib.Name.LocalName)
924
+ {
925
+ case "Id":
926
+ customDataId = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
927
+ break;
928
+ default:
929
+ this.Core.UnexpectedAttribute(node, attrib);
930
+ break;
931
+ }
932
+ }
933
+ else
934
+ {
935
+ this.Core.ParseExtensionAttribute(node, attrib);
936
+ }
937
+ }
938
+
939
+ if (null == customDataId)
940
+ {
941
+ this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id"));
942
+ }
943
+
944
+ foreach (var child in node.Elements())
945
+ {
946
+ foundChild = true;
947
+ if (CompilerCore.WixNamespace == child.Name.Namespace)
948
+ {
949
+ var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child);
950
+ switch (child.Name.LocalName)
951
+ {
952
+ case "BundleElement":
953
+ this.ParseBundleElementElement(child, childSourceLineNumbers, customDataId);
954
+ break;
955
+ default:
956
+ this.Core.UnexpectedElement(node, child);
957
+ break;
958
+ }
959
+ }
960
+ else
961
+ {
962
+ this.Core.ParseExtensionElement(node, child);
963
+ }
964
+ }
965
+
966
+ if (!foundChild)
967
+ {
968
+ this.Core.Write(ErrorMessages.ExpectedElement(sourceLineNumbers, node.Name.LocalName));
969
+ }
970
}
971
972
/// <summary>
src/test/WixToolsetTest.CoreIntegration/TestData/BundleCustomTable/BundleCustomTable.wxs
+14
-7
@@ -5,7 +5,7 @@
5
<PackageGroupRef Id="MinimalPackageGroup" />
6
</PackageGroup>
7
8
- <BundleCustomData Id="BundleCustomTableBA" Type="bootstrapperApplication">
8
+ <BundleCustomData Id="BundleCustomTableBA">
9
<BundleAttributeDefinition Id="Id" />
10
<BundleAttributeDefinition Id="Column2" />
11
@@ -17,16 +17,23 @@
17
<BundleAttribute Id="Column2"><</BundleAttribute>
18
<BundleAttribute Id="Id">></BundleAttribute>
19
</BundleElement>
20
- <BundleElement>
21
- <BundleAttribute Id="Id">1</BundleAttribute>
22
- <BundleAttribute Id="Column2">2</BundleAttribute>
23
- </BundleElement>
20
</BundleCustomData>
21
26
- <BundleCustomData Id="BundleCustomTableBE" Type="bundleExtension" ExtensionId="CustomTableExtension">
22
+ <BundleCustomData Id="BundleCustomTableBE" ExtensionId="CustomTableExtension">
23
<BundleAttributeDefinition Id="Id" />
24
<BundleAttributeDefinition Id="Column2" />
25
+ </BundleCustomData>
26
+ </Fragment>
27
28
+ <Fragment>
29
+ <BundleCustomDataRef Id="BundleCustomTableBA">
30
+ <BundleElement>
31
+ <BundleAttribute Id="Id">1</BundleAttribute>
32
+ <BundleAttribute Id="Column2">2</BundleAttribute>
33
+ </BundleElement>
34
+ </BundleCustomDataRef>
35
+
36
+ <BundleCustomDataRef Id="BundleCustomTableBE">
37
<BundleElement>
38
<BundleAttribute Id="Id">one</BundleAttribute>
39
<BundleAttribute Id="Column2">two</BundleAttribute>
@@ -39,7 +46,7 @@
46
<BundleAttribute Id="Id">1</BundleAttribute>
47
<BundleAttribute Id="Column2">2</BundleAttribute>
48
</BundleElement>
42
- </BundleCustomData>
49
+ </BundleCustomDataRef>
50
51
<BundleExtension Id="CustomTableExtension" SourceFile="fakeba.dll" />
52
</Fragment>