@joebigelow / wix-1 / commits / 5d52c1a6

Always parse extension attributes in ParsePayloadElementContent.

Sean Hall committed Dec 7, 2020 at 18:54 UTC 5d52c1a6f20b818dc472cb1a82b20028abc8fedb
1 file changed +20 -22
src/WixToolset.Core/Compiler_Bundle.cs
+20 -22
@@ -652,8 +652,8 @@ namespace WixToolset.Core
652 var dpiAwareness = WixBootstrapperApplicationDpiAwarenessType.PerMonitorV2;
653
654 // The BootstrapperApplication element acts like a Payload element so delegate to the "Payload" attribute parsing code to parse and create a Payload entry.
655 - var id = this.ParsePayloadElementContent(node, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId, false);
656 - if (null != id)
655 + var hasSourceFile = this.ParsePayloadElementContent(node, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId, false, out var id);
656 + if (hasSourceFile)
657 {
658 previousId = id;
659 previousType = ComplexReferenceChildType.Payload;
@@ -726,7 +726,7 @@ namespace WixToolset.Core
726 this.Core.Write(ErrorMessages.ExpectedElement(sourceLineNumbers, node.Name.LocalName, "Payload"));
727 }
728
729 - // Add the application as an attached container and if an Id was provided add that too.
729 + // Add the application as an attached container and if a SourceFile was provided add the Id as the BA.
730 if (!this.Core.EncounteredError)
731 {
732 this.Core.AddSymbol(new WixBundleContainerSymbol(sourceLineNumbers, Compiler.BurnUXContainerId)
@@ -735,7 +735,7 @@ namespace WixToolset.Core
735 Type = ContainerType.Attached
736 });
737
738 - if (null != id)
738 + if (hasSourceFile)
739 {
740 this.Core.AddSymbol(new WixBootstrapperApplicationSymbol(sourceLineNumbers, id)
741 {
@@ -1122,8 +1122,7 @@ namespace WixToolset.Core
1122 var previousType = ComplexReferenceChildType.Unknown;
1123
1124 // The BundleExtension element acts like a Payload element so delegate to the "Payload" attribute parsing code to parse and create a Payload entry.
1125 - var id = this.ParsePayloadElementContent(node, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId, false);
1126 - if (null != id)
1125 + if (this.ParsePayloadElementContent(node, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId, false, out var id))
1126 {
1127 previousId = id;
1128 previousType = ComplexReferenceChildType.Payload;
@@ -1290,7 +1289,7 @@ namespace WixToolset.Core
1289 Debug.Assert(ComplexReferenceParentType.PayloadGroup == parentType || ComplexReferenceParentType.Package == parentType || ComplexReferenceParentType.Container == parentType);
1290 Debug.Assert(ComplexReferenceChildType.Unknown == previousType || ComplexReferenceChildType.PayloadGroup == previousType || ComplexReferenceChildType.Payload == previousType);
1291
1293 - var id = this.ParsePayloadElementContent(node, parentType, parentId, previousType, previousId, true);
1292 + this.ParsePayloadElementContent(node, parentType, parentId, previousType, previousId, true, out var id);
1293 var context = new Dictionary<string, string>
1294 {
1295 ["Id"] = id?.Id
@@ -1322,14 +1321,15 @@ namespace WixToolset.Core
1321 /// <param name="node">Element to parse</param>
1322 /// <param name="parentType">ComplexReferenceParentType of parent element.</param>
1323 /// <param name="parentId">Identifier of parent element.</param>
1325 - private Identifier ParsePayloadElementContent(XElement node, ComplexReferenceParentType parentType, Identifier parentId, ComplexReferenceChildType previousType, Identifier previousId, bool required)
1324 + /// <returns>Whether SourceFile was specified.</returns>
1325 + private bool ParsePayloadElementContent(XElement node, ComplexReferenceParentType parentType, Identifier parentId, ComplexReferenceChildType previousType, Identifier previousId, bool required, out Identifier id)
1326 {
1327 Debug.Assert(ComplexReferenceParentType.PayloadGroup == parentType || ComplexReferenceParentType.Package == parentType || ComplexReferenceParentType.Container == parentType);
1328
1329 var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
1330 var compressed = YesNoDefaultType.Default;
1331 var enableSignatureVerification = YesNoType.No;
1332 - Identifier id = null;
1332 + id = null;
1333 string name = null;
1334 string sourceFile = null;
1335 string downloadUrl = null;
@@ -1379,12 +1379,6 @@ namespace WixToolset.Core
1379 }
1380 }
1381
1382 - if (!required && null == sourceFile)
1383 - {
1384 - // Nothing left to do!
1385 - return null;
1386 - }
1387 -
1382 if (null == id)
1383 {
1384 id = this.Core.CreateIdentifier("pay", sourceFile?.ToUpperInvariant() ?? String.Empty);
@@ -1393,7 +1387,7 @@ namespace WixToolset.Core
1387 // Now that the PayloadId is known, we can parse the extension attributes.
1388 var context = new Dictionary<string, string>
1389 {
1396 - ["Id"] = id?.Id
1390 + ["Id"] = id.Id
1391 };
1392
1393 foreach (var extensionAttribute in extensionAttributes)
@@ -1403,11 +1397,6 @@ namespace WixToolset.Core
1397
1398 // Let caller handle the children.
1399
1406 - if (null == sourceFile)
1407 - {
1408 - sourceFile = String.Empty;
1409 - }
1410 -
1400 if (Compiler.BurnUXContainerId == parentId)
1401 {
1402 if (compressed == YesNoDefaultType.No)
@@ -1418,9 +1407,18 @@ namespace WixToolset.Core
1407 compressed = YesNoDefaultType.Yes;
1408 }
1409
1410 + if (sourceFile == null)
1411 + {
1412 + if (required)
1413 + {
1414 + this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "SourceFile"));
1415 + }
1416 + return false;
1417 + }
1418 +
1419 this.CreatePayloadRow(sourceLineNumbers, id, name, sourceFile, downloadUrl, parentType, parentId, previousType, previousId, compressed, enableSignatureVerification, null, null, null);
1420
1423 - return id;
1421 + return true;
1422 }
1423
1424 private RemotePayload ParseRemotePayloadElement(XElement node)