@joebigelow / wix / commits / dedb3eed

Move Feature\Condition inner text to new Level element

Rob Mensching committed Jun 22, 2020 at 23:15 UTC dedb3eedbd4dd79b64a45ffa50a4edffdfcf13e1
1 file changed +69
src/WixToolset.Core/Compiler.cs
+69
@@ -4873,6 +4873,9 @@ namespace WixToolset.Core
4873 case "FeatureRef":
4874 this.ParseFeatureRefElement(child, ComplexReferenceParentType.Feature, id.Id);
4875 break;
4876 + case "Level":
4877 + this.ParseLevelElement(child, id.Id);
4878 + break;
4879 case "MergeRef":
4880 this.ParseMergeRefElement(child, ComplexReferenceParentType.Feature, id.Id);
4881 break;
@@ -7818,6 +7821,72 @@ namespace WixToolset.Core
7821 return String.Concat(name, "=", value);
7822 }
7823
7824 + /// <summary>
7825 + /// Parses a condition element.
7826 + /// </summary>
7827 + /// <param name="node">Element to parse.</param>
7828 + /// <param name="featureId">Id of the parent Feature element.</param>
7829 + private void ParseLevelElement(XElement node, string featureId)
7830 + {
7831 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
7832 + string condition = null;
7833 + int? level = null;
7834 +
7835 + foreach (var attrib in node.Attributes())
7836 + {
7837 + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
7838 + {
7839 + switch (attrib.Name.LocalName)
7840 + {
7841 + case "Condition":
7842 + condition = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
7843 + break;
7844 + case "Value":
7845 + level = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue);
7846 + break;
7847 + default:
7848 + this.Core.UnexpectedAttribute(node, attrib);
7849 + break;
7850 + }
7851 + }
7852 + else
7853 + {
7854 + this.Core.ParseExtensionAttribute(node, attrib);
7855 + }
7856 + }
7857 +
7858 + if (!level.HasValue)
7859 + {
7860 + this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Level"));
7861 + }
7862 +
7863 + if (String.IsNullOrEmpty(condition))
7864 + {
7865 + this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Condition"));
7866 + }
7867 +
7868 + this.Core.ParseForExtensionElements(node);
7869 +
7870 + if (!this.Core.EncounteredError)
7871 + {
7872 + if (CompilerConstants.IntegerNotSet == level)
7873 + {
7874 + this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Level"));
7875 + level = CompilerConstants.IllegalInteger;
7876 + }
7877 +
7878 + if (!this.Core.EncounteredError)
7879 + {
7880 + this.Core.AddTuple(new ConditionTuple(sourceLineNumbers)
7881 + {
7882 + FeatureRef = featureId,
7883 + Level = level.Value,
7884 + Condition = condition
7885 + });
7886 + }
7887 + }
7888 + }
7889 +
7890 /// <summary>
7891 /// Parses a merge reference element.
7892 /// </summary>