From 06e86dadb969ad1d337db11956814a1f79bbcd02 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 17 Jun 2020 14:07:26 -0700 Subject: Moved more inner text to attribute --- src/WixToolset.Core/Compiler_2.cs | 341 ++++++++++++++++++----------- src/WixToolset.Core/Compiler_EmbeddedUI.cs | 11 +- src/WixToolset.Core/Compiler_UI.cs | 38 +++- 3 files changed, 253 insertions(+), 137 deletions(-) diff --git a/src/WixToolset.Core/Compiler_2.cs b/src/WixToolset.Core/Compiler_2.cs index 84961f9b..234c1ebc 100644 --- a/src/WixToolset.Core/Compiler_2.cs +++ b/src/WixToolset.Core/Compiler_2.cs @@ -2621,6 +2621,9 @@ namespace WixToolset.Core this.Core.UnexpectedAttribute(child, attrib); } break; + case "Condition": + condition = this.Core.GetAttributeValue(childSourceLineNumbers, attrib); + break; case "Dialog": if (showDialog) { @@ -2678,7 +2681,10 @@ namespace WixToolset.Core } // Get the condition from the inner text of the element. - condition = this.Core.GetConditionInnerText(child); + if (condition == null) + { + condition = this.Core.GetConditionInnerText(child); + } if (customAction && "Custom" == actionName) { @@ -2901,128 +2907,7 @@ namespace WixToolset.Core switch (child.Name.LocalName) { case "RequiredPrivilege": - var privilege = this.Core.GetTrimmedInnerText(child); - switch (privilege) - { - case "assignPrimaryToken": - privilege = "SeAssignPrimaryTokenPrivilege"; - break; - case "audit": - privilege = "SeAuditPrivilege"; - break; - case "backup": - privilege = "SeBackupPrivilege"; - break; - case "changeNotify": - privilege = "SeChangeNotifyPrivilege"; - break; - case "createGlobal": - privilege = "SeCreateGlobalPrivilege"; - break; - case "createPagefile": - privilege = "SeCreatePagefilePrivilege"; - break; - case "createPermanent": - privilege = "SeCreatePermanentPrivilege"; - break; - case "createSymbolicLink": - privilege = "SeCreateSymbolicLinkPrivilege"; - break; - case "createToken": - privilege = "SeCreateTokenPrivilege"; - break; - case "debug": - privilege = "SeDebugPrivilege"; - break; - case "enableDelegation": - privilege = "SeEnableDelegationPrivilege"; - break; - case "impersonate": - privilege = "SeImpersonatePrivilege"; - break; - case "increaseBasePriority": - privilege = "SeIncreaseBasePriorityPrivilege"; - break; - case "increaseQuota": - privilege = "SeIncreaseQuotaPrivilege"; - break; - case "increaseWorkingSet": - privilege = "SeIncreaseWorkingSetPrivilege"; - break; - case "loadDriver": - privilege = "SeLoadDriverPrivilege"; - break; - case "lockMemory": - privilege = "SeLockMemoryPrivilege"; - break; - case "machineAccount": - privilege = "SeMachineAccountPrivilege"; - break; - case "manageVolume": - privilege = "SeManageVolumePrivilege"; - break; - case "profileSingleProcess": - privilege = "SeProfileSingleProcessPrivilege"; - break; - case "relabel": - privilege = "SeRelabelPrivilege"; - break; - case "remoteShutdown": - privilege = "SeRemoteShutdownPrivilege"; - break; - case "restore": - privilege = "SeRestorePrivilege"; - break; - case "security": - privilege = "SeSecurityPrivilege"; - break; - case "shutdown": - privilege = "SeShutdownPrivilege"; - break; - case "syncAgent": - privilege = "SeSyncAgentPrivilege"; - break; - case "systemEnvironment": - privilege = "SeSystemEnvironmentPrivilege"; - break; - case "systemProfile": - privilege = "SeSystemProfilePrivilege"; - break; - case "systemTime": - case "modifySystemTime": - privilege = "SeSystemtimePrivilege"; - break; - case "takeOwnership": - privilege = "SeTakeOwnershipPrivilege"; - break; - case "tcb": - case "trustedComputerBase": - privilege = "SeTcbPrivilege"; - break; - case "timeZone": - case "modifyTimeZone": - privilege = "SeTimeZonePrivilege"; - break; - case "trustedCredManAccess": - case "trustedCredentialManagerAccess": - privilege = "SeTrustedCredManAccessPrivilege"; - break; - case "undock": - privilege = "SeUndockPrivilege"; - break; - case "unsolicitedInput": - privilege = "SeUnsolicitedInputPrivilege"; - break; - default: - // allow everything else to pass through that are hopefully "formatted" Properties. - break; - } - - if (null != requiredPrivileges) - { - requiredPrivileges = String.Concat(requiredPrivileges, "[~]"); - } - requiredPrivileges = String.Concat(requiredPrivileges, privilege); + requiredPrivileges = this.ParseRequiredPrivilege(child, requiredPrivileges); break; default: this.Core.UnexpectedElement(node, child); @@ -3128,6 +3013,157 @@ namespace WixToolset.Core } } + private string ParseRequiredPrivilege(XElement node, string requiredPrivileges) + { + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + string privilege = null; + + foreach (var attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Name": + privilege = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + switch (privilege) + { + case "assignPrimaryToken": + privilege = "SeAssignPrimaryTokenPrivilege"; + break; + case "audit": + privilege = "SeAuditPrivilege"; + break; + case "backup": + privilege = "SeBackupPrivilege"; + break; + case "changeNotify": + privilege = "SeChangeNotifyPrivilege"; + break; + case "createGlobal": + privilege = "SeCreateGlobalPrivilege"; + break; + case "createPagefile": + privilege = "SeCreatePagefilePrivilege"; + break; + case "createPermanent": + privilege = "SeCreatePermanentPrivilege"; + break; + case "createSymbolicLink": + privilege = "SeCreateSymbolicLinkPrivilege"; + break; + case "createToken": + privilege = "SeCreateTokenPrivilege"; + break; + case "debug": + privilege = "SeDebugPrivilege"; + break; + case "enableDelegation": + privilege = "SeEnableDelegationPrivilege"; + break; + case "impersonate": + privilege = "SeImpersonatePrivilege"; + break; + case "increaseBasePriority": + privilege = "SeIncreaseBasePriorityPrivilege"; + break; + case "increaseQuota": + privilege = "SeIncreaseQuotaPrivilege"; + break; + case "increaseWorkingSet": + privilege = "SeIncreaseWorkingSetPrivilege"; + break; + case "loadDriver": + privilege = "SeLoadDriverPrivilege"; + break; + case "lockMemory": + privilege = "SeLockMemoryPrivilege"; + break; + case "machineAccount": + privilege = "SeMachineAccountPrivilege"; + break; + case "manageVolume": + privilege = "SeManageVolumePrivilege"; + break; + case "profileSingleProcess": + privilege = "SeProfileSingleProcessPrivilege"; + break; + case "relabel": + privilege = "SeRelabelPrivilege"; + break; + case "remoteShutdown": + privilege = "SeRemoteShutdownPrivilege"; + break; + case "restore": + privilege = "SeRestorePrivilege"; + break; + case "security": + privilege = "SeSecurityPrivilege"; + break; + case "shutdown": + privilege = "SeShutdownPrivilege"; + break; + case "syncAgent": + privilege = "SeSyncAgentPrivilege"; + break; + case "systemEnvironment": + privilege = "SeSystemEnvironmentPrivilege"; + break; + case "systemProfile": + privilege = "SeSystemProfilePrivilege"; + break; + case "systemTime": + case "modifySystemTime": + privilege = "SeSystemtimePrivilege"; + break; + case "takeOwnership": + privilege = "SeTakeOwnershipPrivilege"; + break; + case "tcb": + case "trustedComputerBase": + privilege = "SeTcbPrivilege"; + break; + case "timeZone": + case "modifyTimeZone": + privilege = "SeTimeZonePrivilege"; + break; + case "trustedCredManAccess": + case "trustedCredentialManagerAccess": + privilege = "SeTrustedCredManAccessPrivilege"; + break; + case "undock": + privilege = "SeUndockPrivilege"; + break; + case "unsolicitedInput": + privilege = "SeUnsolicitedInputPrivilege"; + break; + default: + // allow everything else to pass through that are hopefully "formatted" Properties. + break; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; + } + } + } + + if (privilege == null) + { + privilege = Common.GetInnerText(node); + } + + if (privilege == null) + { + this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name")); + } + + this.Core.ParseForExtensionElements(node); + + return (requiredPrivileges == null) ? privilege : String.Concat(requiredPrivileges, "[~]", privilege); + } + /// /// Parses a service config failure actions element. /// @@ -3427,11 +3463,7 @@ namespace WixToolset.Core switch (child.Name.LocalName) { case "ServiceArgument": - if (null != arguments) - { - arguments = String.Concat(arguments, "[~]"); - } - arguments = String.Concat(arguments, this.Core.GetTrimmedInnerText(child)); + arguments = this.ParseServiceArgument(child, arguments); break; default: this.Core.UnexpectedElement(node, child); @@ -3462,6 +3494,42 @@ namespace WixToolset.Core } } + private string ParseServiceArgument(XElement node, string arguments) + { + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + string argument = null; + + foreach (var attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Value": + argument = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; + } + } + } + + if (argument == null) + { + argument = this.Core.GetTrimmedInnerText(node); + } + + if (argument == null) + { + this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Value")); + } + + this.Core.ParseForExtensionElements(node); + + return (arguments == null) ? argument : String.Concat(arguments, "[~]", argument); + } + /// /// Parses a service dependency element. /// @@ -3746,6 +3814,9 @@ namespace WixToolset.Core case "Action": actionName = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); break; + case "Condition": + condition = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; case "Id": id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); this.Core.CreateSimpleReference(sourceLineNumbers, TupleDefinitions.Directory, id); @@ -3786,7 +3857,10 @@ namespace WixToolset.Core } } - condition = this.Core.GetConditionInnerText(node); + if (condition == null) + { + condition = this.Core.GetConditionInnerText(node); + } if (null == id) { @@ -3831,6 +3905,7 @@ namespace WixToolset.Core var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string actionName = null; string id = null; + string condition = null; string afterAction = null; string beforeAction = null; var executionType = CustomActionExecutionType.Immediate; @@ -3849,6 +3924,9 @@ namespace WixToolset.Core case "Id": id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); break; + case "Condition": + condition = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; case "After": afterAction = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); break; @@ -3914,7 +3992,10 @@ namespace WixToolset.Core } } - var condition = this.Core.GetConditionInnerText(node); + if (condition == null) + { + condition = this.Core.GetConditionInnerText(node); + } if (null == id) { diff --git a/src/WixToolset.Core/Compiler_EmbeddedUI.cs b/src/WixToolset.Core/Compiler_EmbeddedUI.cs index 706fe6e9..1827a200 100644 --- a/src/WixToolset.Core/Compiler_EmbeddedUI.cs +++ b/src/WixToolset.Core/Compiler_EmbeddedUI.cs @@ -23,6 +23,7 @@ namespace WixToolset.Core var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string commandLine = null; + string condition = null; string source = null; var type = 0; @@ -47,6 +48,9 @@ namespace WixToolset.Core case "CommandLine": commandLine = this.Core.GetAttributeValue(sourceLineNumbers, attrib); break; + case "Condition": + condition = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; case "FileSource": if (null != source) { @@ -76,8 +80,11 @@ namespace WixToolset.Core } } - // Get the condition from the inner text of the element. - var condition = this.Core.GetConditionInnerText(node); + if (condition == null) + { + // Get the condition from the inner text of the element. + condition = this.Core.GetConditionInnerText(node); + } if (null == id) { diff --git a/src/WixToolset.Core/Compiler_UI.cs b/src/WixToolset.Core/Compiler_UI.cs index 19c2fdcc..0b5b3980 100644 --- a/src/WixToolset.Core/Compiler_UI.cs +++ b/src/WixToolset.Core/Compiler_UI.cs @@ -666,6 +666,7 @@ namespace WixToolset.Core { var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string action = null; + string message = null; string template = null; foreach (var attrib in node.Attributes()) @@ -677,6 +678,9 @@ namespace WixToolset.Core case "Action": action = this.Core.GetAttributeValue(sourceLineNumbers, attrib); break; + case "Message": + message = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; case "Template": template = this.Core.GetAttributeValue(sourceLineNumbers, attrib); break; @@ -696,6 +700,11 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Action")); } + if (null == message) + { + message = Common.GetInnerText(node); + } + this.Core.ParseForExtensionElements(node); if (!this.Core.EncounteredError) @@ -703,7 +712,7 @@ namespace WixToolset.Core this.Core.AddTuple(new ActionTextTuple(sourceLineNumbers) { Action = action, - Description = Common.GetInnerText(node), + Description = message, Template = template, }); } @@ -728,6 +737,9 @@ namespace WixToolset.Core case "Id": id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); break; + case "Value": + text = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; default: this.Core.UnexpectedAttribute(node, attrib); break; @@ -739,7 +751,10 @@ namespace WixToolset.Core } } - text = Common.GetInnerText(node); + if (null == text) + { + text = Common.GetInnerText(node); + } if (null == id) { @@ -1406,6 +1421,9 @@ namespace WixToolset.Core case "SourceFile": sourceFile = this.Core.GetAttributeValue(childSourceLineNumbers, attrib); break; + case "Value": + text = this.Core.GetAttributeValue(childSourceLineNumbers, attrib); + break; default: this.Core.UnexpectedAttribute(child, attrib); break; @@ -1417,10 +1435,14 @@ namespace WixToolset.Core } } - text = Common.GetInnerText(child); + if (null == text) + { + text = Common.GetInnerText(child); + } + if (!String.IsNullOrEmpty(text) && null != sourceFile) { - this.Core.Write(ErrorMessages.IllegalAttributeWithInnerText(childSourceLineNumbers, child.Name.LocalName, "SourceFile")); + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(childSourceLineNumbers, child.Name.LocalName, "SourceFile", "Text")); } break; default: @@ -1589,6 +1611,9 @@ namespace WixToolset.Core { switch (attrib.Name.LocalName) { + case "Condition": + condition = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; case "Control": if (null != control) { @@ -1627,7 +1652,10 @@ namespace WixToolset.Core } } - condition = this.Core.GetConditionInnerText(node); + if (null == condition) + { + condition = this.Core.GetConditionInnerText(node); + } if (null == control) { -- cgit v1.2.3-55-g6feb