From 0ecb2ac1ba28d33b0b3d17a2d7134d2f5485814d Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 24 Oct 2018 21:00:13 -0700 Subject: Minor code clean up to match .editorconfig --- src/WixToolset.Core/Common.cs | 109 +- src/WixToolset.Core/Compiler.cs | 15916 +++++++++++++++++----------------- src/WixToolset.Core/Localizer.cs | 2 +- src/WixToolset.Core/Preprocessor.cs | 2 +- 4 files changed, 7976 insertions(+), 8053 deletions(-) (limited to 'src/WixToolset.Core') diff --git a/src/WixToolset.Core/Common.cs b/src/WixToolset.Core/Common.cs index 2d8f9509..610bfcaa 100644 --- a/src/WixToolset.Core/Common.cs +++ b/src/WixToolset.Core/Common.cs @@ -21,6 +21,12 @@ namespace WixToolset.Core /// public static class Common { + // TODO: Find a place to put all of these so they doesn't have to be public and exposed by WixToolset.Core.dll + public const string UpgradeDetectedProperty = "WIX_UPGRADE_DETECTED"; + public const string UpgradePreventedCondition = "NOT WIX_UPGRADE_DETECTED"; + public const string DowngradeDetectedProperty = "WIX_DOWNGRADE_DETECTED"; + public const string DowngradePreventedCondition = "NOT WIX_DOWNGRADE_DETECTED"; + //------------------------------------------------------------------------------------------------- // Layout of an Access Mask (from http://technet.microsoft.com/en-us/library/cc783530(WS.10).aspx) // @@ -45,7 +51,8 @@ namespace WixToolset.Core // GENERIC_EXECUTE (0x20000000L) // GENERIC_WRITE (0x40000000L) // GENERIC_READ (0x80000000L) - internal static readonly string[] GenericPermissions = { "GenericAll", "GenericExecute", "GenericWrite", "GenericRead" }; + // TODO: Find a place to put this that it doesn't have to be public and exposed by WixToolset.Core.dll + public static readonly string[] GenericPermissions = { "GenericAll", "GenericExecute", "GenericWrite", "GenericRead" }; // Standard Access Rights (per WinNT.h) // ---------------------- @@ -54,7 +61,8 @@ namespace WixToolset.Core // WRITE_DAC (0x00040000L) // WRITE_OWNER (0x00080000L) // SYNCHRONIZE (0x00100000L) - internal static readonly string[] StandardPermissions = { "Delete", "ReadPermission", "ChangePermission", "TakeOwnership", "Synchronize" }; + // TODO: Find a place to put this that it doesn't have to be public and exposed by WixToolset.Core.dll + public static readonly string[] StandardPermissions = { "Delete", "ReadPermission", "ChangePermission", "TakeOwnership", "Synchronize" }; // Object-Specific Access Rights // ============================= @@ -69,11 +77,13 @@ namespace WixToolset.Core // FILE_DELETE_CHILD ( 0x0040 ) // FILE_READ_ATTRIBUTES ( 0x0080 ) // FILE_WRITE_ATTRIBUTES ( 0x0100 ) - internal static readonly string[] FolderPermissions = { "Read", "CreateFile", "CreateChild", "ReadExtendedAttributes", "WriteExtendedAttributes", "Traverse", "DeleteChild", "ReadAttributes", "WriteAttributes" }; + // TODO: Find a place to put this that it doesn't have to be public and exposed by WixToolset.Core.dll + public static readonly string[] FolderPermissions = { "Read", "CreateFile", "CreateChild", "ReadExtendedAttributes", "WriteExtendedAttributes", "Traverse", "DeleteChild", "ReadAttributes", "WriteAttributes" }; // Registry Access Rights (per TODO) // ---------------------- - internal static readonly string[] RegistryPermissions = { "Read", "Write", "CreateSubkeys", "EnumerateSubkeys", "Notify", "CreateLink" }; + // TODO: Find a place to put this that it doesn't have to be public and exposed by WixToolset.Core.dll + public static readonly string[] RegistryPermissions = { "Read", "Write", "CreateSubkeys", "EnumerateSubkeys", "Notify", "CreateLink" }; // File Access Rights (per WinNT.h) // ------------------ @@ -89,7 +99,8 @@ namespace WixToolset.Core // // STANDARD_RIGHTS_REQUIRED (0x000F0000L) // FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF) - internal static readonly string[] FilePermissions = { "Read", "Write", "Append", "ReadExtendedAttributes", "WriteExtendedAttributes", "Execute", "FileAllRights", "ReadAttributes", "WriteAttributes" }; + // TODO: Find a place to put this that it doesn't have to be public and exposed by WixToolset.Core.dll + public static readonly string[] FilePermissions = { "Read", "Write", "Append", "ReadExtendedAttributes", "WriteExtendedAttributes", "Execute", "FileAllRights", "ReadAttributes", "WriteAttributes" }; public static readonly Regex WixVariableRegex = new Regex(@"(\!|\$)\((?loc|wix|bind|bindpath)\.(?(?[_A-Za-z][0-9A-Za-z_]+)(\.(?[_A-Za-z][0-9A-Za-z_\.]*))?)(\=(?.+?))?\)", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.ExplicitCapture); @@ -106,58 +117,6 @@ namespace WixToolset.Core private const string LegalWildcardShortFilenameCharacters = @"[^\\|><:/""\+,;=\[\]\. ]"; // illegal: \ | > < : / " + , ; = [ ] . (space) private static readonly Regex LegalWildcardShortFilename = new Regex(String.Concat("^", LegalWildcardShortFilenameCharacters, @"{1,16}(\.", LegalWildcardShortFilenameCharacters, "{0,6})?$")); - /// - /// Cleans up the temp files. - /// - /// The temporary directory to delete. - /// The message handler. - /// True if all files were deleted, false otherwise. - internal static bool DeleteTempFiles(string path, IMessaging messageHandler) - { - // try three times and give up with a warning if the temp files aren't gone by then - int retryLimit = 3; - bool removedReadOnly = false; - - for (int i = 0; i < retryLimit; i++) - { - try - { - Directory.Delete(path, true); // toast the whole temp directory - break; // no exception means we got success the first time - } - catch (UnauthorizedAccessException) - { - if (!removedReadOnly) // should only need to unmark readonly once - there's no point in doing it again and again - { - removedReadOnly = true; - RecursiveFileAttributes(path, FileAttributes.ReadOnly, false, messageHandler); // toasting will fail if any files are read-only. Try changing them to not be. - } - else - { - messageHandler.Write(WarningMessages.AccessDeniedForDeletion(null, path)); - return false; - } - } - catch (DirectoryNotFoundException) - { - // if the path doesn't exist, then there is nothing for us to worry about - break; - } - catch (IOException) // directory in use - { - if (i == (retryLimit - 1)) // last try failed still, give up - { - messageHandler.Write(WarningMessages.DirectoryInUse(null, path)); - return false; - } - - System.Threading.Thread.Sleep(300); // sleep a bit before trying again - } - } - - return true; - } - /// /// Gets a valid code page from the given web name or integer value. /// @@ -315,30 +274,6 @@ namespace WixToolset.Core return match.Success && ("bind" == match.Groups["namespace"].Value || "wix" == match.Groups["namespace"].Value); } - /// - /// Get the value of an attribute with type YesNoType. - /// - /// Source information for the value. - /// Name of the element for this attribute, used for a possible exception. - /// Name of the attribute. - /// Value to process. - /// Returns true for a value of 'yes' and false for a value of 'no'. - /// Thrown when the attribute's value is not 'yes' or 'no'. - internal static bool IsYes(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value) - { - switch (value) - { - case "no": - case "false": - return false; - case "yes": - case "true": - return true; - default: - throw new WixException(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, elementName, attributeName, value, "no", "yes")); - } - } - /// /// Verifies the given string is a valid module or bundle version. /// @@ -471,18 +406,6 @@ namespace WixToolset.Core } } - public static string GetFileHash(string path) - { - using (SHA1Managed managed = new SHA1Managed()) - { - using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Delete | FileShare.Read)) - { - byte[] hash = managed.ComputeHash(stream); - return BitConverter.ToString(hash).Replace("-", String.Empty); - } - } - } - /// /// Takes an id, and demodularizes it (if possible). /// diff --git a/src/WixToolset.Core/Compiler.cs b/src/WixToolset.Core/Compiler.cs index ffe907e8..f35533ac 100644 --- a/src/WixToolset.Core/Compiler.cs +++ b/src/WixToolset.Core/Compiler.cs @@ -24,10 +24,6 @@ namespace WixToolset.Core /// internal class Compiler : ICompiler { - public const string UpgradeDetectedProperty = "WIX_UPGRADE_DETECTED"; - public const string UpgradePreventedCondition = "NOT WIX_UPGRADE_DETECTED"; - public const string DowngradeDetectedProperty = "WIX_DOWNGRADE_DETECTED"; - public const string DowngradePreventedCondition = "NOT WIX_DOWNGRADE_DETECTED"; public const string DefaultComponentIdPlaceholderFormat = "WixComponentIdPlaceholder{0}"; public const string DefaultComponentIdPlaceholderWixVariableFormat = "!(wix.{0})"; public const string BurnUXContainerId = "WixUXContainer"; @@ -297,12 +293,12 @@ namespace WixToolset.Core if (!String.IsNullOrEmpty(value)) { - Regex regex = new Regex(@"\[(?[a-zA-Z_][a-zA-Z0-9_\.]*)]", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.ExplicitCapture); - MatchCollection matches = regex.Matches(value); + var regex = new Regex(@"\[(?[a-zA-Z_][a-zA-Z0-9_\.]*)]", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.ExplicitCapture); + var matches = regex.Matches(value); foreach (Match match in matches) { - Group group = match.Groups["identifier"]; + var group = match.Groups["identifier"]; if (group.Success) { this.Core.Write(WarningMessages.PropertyValueContainsPropertyReference(sourceLineNumbers, property.Id, group.Value)); @@ -317,7 +313,7 @@ namespace WixToolset.Core // Add the row to a separate section if requested. if (fragment) { - string id = String.Concat(this.Core.ActiveSection.Id, ".", property.Id); + var id = String.Concat(this.Core.ActiveSection.Id, ".", property.Id); section = this.Core.CreateSection(id, SectionType.Fragment, this.Core.ActiveSection.Codepage, this.Context.CompilationId); @@ -384,53 +380,53 @@ namespace WixToolset.Core /// Optional TypeLib Version for CLSID Interfaces (if any). private void ParseAppIdElement(XElement node, string componentId, YesNoType advertise, string fileServer, string typeLibId, string typeLibVersion) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string appId = null; string remoteServerName = null; string localService = null; string serviceParameters = null; string dllSurrogate = null; - YesNoType activateAtStorage = YesNoType.NotSet; - YesNoType appIdAdvertise = YesNoType.NotSet; - YesNoType runAsInteractiveUser = YesNoType.NotSet; + var activateAtStorage = YesNoType.NotSet; + var appIdAdvertise = YesNoType.NotSet; + var runAsInteractiveUser = YesNoType.NotSet; string description = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - appId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - case "ActivateAtStorage": - activateAtStorage = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Advertise": - appIdAdvertise = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Description": - description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "DllSurrogate": - dllSurrogate = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); - break; - case "LocalService": - localService = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "RemoteServerName": - remoteServerName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "RunAsInteractiveUser": - runAsInteractiveUser = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "ServiceParameters": - serviceParameters = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + appId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + case "ActivateAtStorage": + activateAtStorage = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Advertise": + appIdAdvertise = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Description": + description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DllSurrogate": + dllSurrogate = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); + break; + case "LocalService": + localService = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "RemoteServerName": + remoteServerName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "RunAsInteractiveUser": + runAsInteractiveUser = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "ServiceParameters": + serviceParameters = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -459,18 +455,18 @@ namespace WixToolset.Core advertise = YesNoType.No; } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Class": - this.ParseClassElement(child, componentId, advertise, fileServer, typeLibId, typeLibVersion, appId); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "Class": + this.ParseClassElement(child, componentId, advertise, fileServer, typeLibId, typeLibVersion, appId); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -555,25 +551,25 @@ namespace WixToolset.Core /// Parent's component id. private void ParseAssemblyName(XElement node, string componentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; string value = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Value": - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Value": + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -606,39 +602,39 @@ namespace WixToolset.Core [SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] private Identifier ParseBinaryElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string sourceFile = null; - YesNoType suppressModularization = YesNoType.NotSet; + var suppressModularization = YesNoType.NotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "SourceFile": - case "src": - if (null != sourceFile) - { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "SourceFile", "src")); - } + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "SourceFile": + case "src": + if (null != sourceFile) + { + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "SourceFile", "src")); + } - if ("src" == attrib.Name.LocalName) - { - this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "SourceFile")); - } - sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "SuppressModularization": - suppressModularization = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + if ("src" == attrib.Name.LocalName) + { + this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "SourceFile")); + } + sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "SuppressModularization": + suppressModularization = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -695,25 +691,25 @@ namespace WixToolset.Core /// Identifier for the new row. private string ParseIconElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string sourceFile = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "SourceFile": - sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "SourceFile": + sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -764,22 +760,22 @@ namespace WixToolset.Core /// Element to parse. private void ParseInstanceTransformsElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string property = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Property": - property = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "Property", property); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Property": + property = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "Property", property); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -794,18 +790,18 @@ namespace WixToolset.Core } // find unexpected child elements - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Instance": - ParseInstanceElement(child, property); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "Instance": + this.ParseInstanceElement(child, property); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -822,33 +818,33 @@ namespace WixToolset.Core /// Identifier of instance property. private void ParseInstanceElement(XElement node, string propertyId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; string productCode = null; string productName = null; string upgradeCode = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "ProductCode": - productCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, true); - break; - case "ProductName": - productName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "UpgradeCode": - upgradeCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "ProductCode": + productCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, true); + break; + case "ProductName": + productName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "UpgradeCode": + upgradeCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -893,34 +889,34 @@ namespace WixToolset.Core /// Identifier of parent component. private void ParseCategoryElement(XElement node, string componentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; string appData = null; string feature = null; string qualifier = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - case "AppData": - appData = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Feature": - feature = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "Feature", feature); - break; - case "Qualifier": - qualifier = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + case "AppData": + appData = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Feature": + feature = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "Feature", feature); + break; + case "Qualifier": + qualifier = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -971,105 +967,105 @@ namespace WixToolset.Core /// Optional parent AppId. private void ParseClassElement(XElement node, string componentId, YesNoType advertise, string fileServer, string typeLibId, string typeLibVersion, string parentAppId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string appId = null; string argument = null; - bool class16bit = false; - bool class32bit = false; + var class16bit = false; + var class32bit = false; string classId = null; - YesNoType classAdvertise = YesNoType.NotSet; - string[] contexts = new string[0]; + var classAdvertise = YesNoType.NotSet; + var contexts = new string[0]; string formattedContextString = null; - bool control = false; + var control = false; string defaultInprocHandler = null; string defaultProgId = null; string description = null; string fileTypeMask = null; string foreignServer = null; string icon = null; - int iconIndex = CompilerConstants.IntegerNotSet; + var iconIndex = CompilerConstants.IntegerNotSet; string insertable = null; string localFileServer = null; - bool programmable = false; - YesNoType relativePath = YesNoType.NotSet; - bool safeForInit = false; - bool safeForScripting = false; - bool shortServerPath = false; + var programmable = false; + var relativePath = YesNoType.NotSet; + var safeForInit = false; + var safeForScripting = false; + var shortServerPath = false; string threadingModel = null; string version = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - classId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - case "Advertise": - classAdvertise = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "AppId": - appId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - case "Argument": - argument = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Context": - contexts = this.Core.GetAttributeValue(sourceLineNumbers, attrib).Split("\r\n\t ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); - break; - case "Control": - control = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Description": - description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Handler": - defaultInprocHandler = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Icon": - icon = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "IconIndex": - iconIndex = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, short.MinValue + 1, short.MaxValue); - break; - case "RelativePath": - relativePath = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; + case "Id": + classId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + case "Advertise": + classAdvertise = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "AppId": + appId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + case "Argument": + argument = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Context": + contexts = this.Core.GetAttributeValue(sourceLineNumbers, attrib).Split("\r\n\t ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + break; + case "Control": + control = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Description": + description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Handler": + defaultInprocHandler = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Icon": + icon = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "IconIndex": + iconIndex = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, Int16.MinValue + 1, Int16.MaxValue); + break; + case "RelativePath": + relativePath = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; - // The following attributes result in rows always added to the Registry table rather than the Class table - case "Insertable": - insertable = (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) ? "Insertable" : "NotInsertable"; - break; - case "Programmable": - programmable = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "SafeForInitializing": - safeForInit = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "SafeForScripting": - safeForScripting = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "ForeignServer": - foreignServer = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Server": - localFileServer = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "ShortPath": - shortServerPath = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "ThreadingModel": - threadingModel = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Version": - version = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + // The following attributes result in rows always added to the Registry table rather than the Class table + case "Insertable": + insertable = (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) ? "Insertable" : "NotInsertable"; + break; + case "Programmable": + programmable = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "SafeForInitializing": + safeForInit = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "SafeForScripting": + safeForScripting = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "ForeignServer": + foreignServer = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Server": + localFileServer = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "ShortPath": + shortServerPath = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "ThreadingModel": + threadingModel = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Version": + version = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -1083,8 +1079,8 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); } - HashSet uniqueContexts = new HashSet(); - foreach (string context in contexts) + var uniqueContexts = new HashSet(); + foreach (var context in contexts) { if (uniqueContexts.Contains(context)) { @@ -1136,44 +1132,44 @@ namespace WixToolset.Core } // Local variables used strictly for child node processing. - int fileTypeMaskIndex = 0; - YesNoType firstProgIdForClass = YesNoType.Yes; + var fileTypeMaskIndex = 0; + var firstProgIdForClass = YesNoType.Yes; - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "FileTypeMask": - if (YesNoType.Yes == advertise) - { - fileTypeMask = String.Concat(fileTypeMask, null == fileTypeMask ? String.Empty : ";", this.ParseFileTypeMaskElement(child)); - } - else if (YesNoType.No == advertise) - { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); - this.Core.CreateRegistryRow(childSourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("FileType\\", classId, "\\", fileTypeMaskIndex.ToString()), String.Empty, this.ParseFileTypeMaskElement(child), componentId); - fileTypeMaskIndex++; - } - break; - case "Interface": - this.ParseInterfaceElement(child, componentId, class16bit ? classId : null, class32bit ? classId : null, typeLibId, typeLibVersion); - break; - case "ProgId": - { - bool foundExtension = false; - string progId = this.ParseProgIdElement(child, componentId, advertise, classId, description, null, ref foundExtension, firstProgIdForClass); - if (null == defaultProgId) - { - defaultProgId = progId; - } - firstProgIdForClass = YesNoType.No; - } - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "FileTypeMask": + if (YesNoType.Yes == advertise) + { + fileTypeMask = String.Concat(fileTypeMask, null == fileTypeMask ? String.Empty : ";", this.ParseFileTypeMaskElement(child)); + } + else if (YesNoType.No == advertise) + { + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + this.Core.CreateRegistryRow(childSourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("FileType\\", classId, "\\", fileTypeMaskIndex.ToString()), String.Empty, this.ParseFileTypeMaskElement(child), componentId); + fileTypeMaskIndex++; + } + break; + case "Interface": + this.ParseInterfaceElement(child, componentId, class16bit ? classId : null, class32bit ? classId : null, typeLibId, typeLibVersion); + break; + case "ProgId": + { + var foundExtension = false; + var progId = this.ParseProgIdElement(child, componentId, advertise, classId, description, null, ref foundExtension, firstProgIdForClass); + if (null == defaultProgId) + { + defaultProgId = progId; + } + firstProgIdForClass = YesNoType.No; + } + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -1203,7 +1199,7 @@ namespace WixToolset.Core // add a Class row for each context if (!this.Core.EncounteredError) { - foreach (string context in contexts) + foreach (var context in contexts) { var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.Class); row.Set(0, classId); @@ -1262,7 +1258,7 @@ namespace WixToolset.Core } // add the core registry keys for each context in the class - foreach (string context in contexts) + foreach (var context in contexts) { if (context.StartsWith("InprocServer", StringComparison.Ordinal)) // dll server { @@ -1338,19 +1334,19 @@ namespace WixToolset.Core { switch (defaultInprocHandler) // ClassId Default Inproc Handler { - case "1": - this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler"), String.Empty, "ole.dll", componentId); - break; - case "2": - this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler32"), String.Empty, "ole32.dll", componentId); - break; - case "3": - this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler"), String.Empty, "ole.dll", componentId); - this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler32"), String.Empty, "ole32.dll", componentId); - break; - default: - this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler32"), String.Empty, defaultInprocHandler, componentId); - break; + case "1": + this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler"), String.Empty, "ole.dll", componentId); + break; + case "2": + this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler32"), String.Empty, "ole32.dll", componentId); + break; + case "3": + this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler"), String.Empty, "ole.dll", componentId); + this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler32"), String.Empty, "ole32.dll", componentId); + break; + default: + this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler32"), String.Empty, defaultInprocHandler, componentId); + break; } } @@ -1365,7 +1361,7 @@ namespace WixToolset.Core threadingModel = Compiler.UppercaseFirstChar(threadingModel); // add a threading model for each context in the class - foreach (string context in contexts) + foreach (var context in contexts) { this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\", context), "ThreadingModel", threadingModel, componentId); } @@ -1421,43 +1417,43 @@ namespace WixToolset.Core /// Version of the TypeLib to which this interface belongs. Required if typeLibId is specified private void ParseInterfaceElement(XElement node, string componentId, string proxyId, string proxyId32, string typeLibId, string typelibVersion) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string baseInterface = null; string interfaceId = null; string name = null; - int numMethods = CompilerConstants.IntegerNotSet; - bool versioned = true; + var numMethods = CompilerConstants.IntegerNotSet; + var versioned = true; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - interfaceId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - case "BaseInterface": - baseInterface = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - case "Name": - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "NumMethods": - numMethods = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); - break; - case "ProxyStubClassId": - proxyId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib); - break; - case "ProxyStubClassId32": - proxyId32 = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - case "Versioned": - versioned = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + interfaceId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + case "BaseInterface": + baseInterface = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + case "Name": + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "NumMethods": + numMethods = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int32.MaxValue); + break; + case "ProxyStubClassId": + proxyId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib); + break; + case "ProxyStubClassId32": + proxyId32 = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + case "Versioned": + versioned = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -1516,30 +1512,30 @@ namespace WixToolset.Core /// String representing the file type mask elements. private string ParseFileTypeMaskElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - int cb = 0; - int offset = CompilerConstants.IntegerNotSet; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var cb = 0; + var offset = CompilerConstants.IntegerNotSet; string mask = null; string value = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Mask": - mask = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Offset": - offset = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); - break; - case "Value": - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Mask": + mask = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Offset": + offset = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int32.MaxValue); + break; + case "Value": + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -1585,53 +1581,53 @@ namespace WixToolset.Core /// Signature for search element. private void ParseProductSearchElement(XElement node, string propertyId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string upgradeCode = null; string language = null; string maximum = null; string minimum = null; - int options = MsiInterop.MsidbUpgradeAttributesVersionMinInclusive | MsiInterop.MsidbUpgradeAttributesOnlyDetect; + var options = MsiInterop.MsidbUpgradeAttributesVersionMinInclusive | MsiInterop.MsidbUpgradeAttributesOnlyDetect; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "ExcludeLanguages": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - options |= MsiInterop.MsidbUpgradeAttributesLanguagesExclusive; - } - break; - case "IncludeMaximum": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - options |= MsiInterop.MsidbUpgradeAttributesVersionMaxInclusive; - } - break; - case "IncludeMinimum": // this is "yes" by default - if (YesNoType.No == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - options &= ~MsiInterop.MsidbUpgradeAttributesVersionMinInclusive; - } - break; - case "Language": - language = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Minimum": - minimum = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Maximum": - maximum = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "UpgradeCode": - upgradeCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "ExcludeLanguages": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + options |= MsiInterop.MsidbUpgradeAttributesLanguagesExclusive; + } + break; + case "IncludeMaximum": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + options |= MsiInterop.MsidbUpgradeAttributesVersionMaxInclusive; + } + break; + case "IncludeMinimum": // this is "yes" by default + if (YesNoType.No == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + options &= ~MsiInterop.MsidbUpgradeAttributesVersionMinInclusive; + } + break; + case "Language": + language = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Minimum": + minimum = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Maximum": + maximum = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "UpgradeCode": + upgradeCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -1666,63 +1662,63 @@ namespace WixToolset.Core /// Signature for search element. private string ParseRegistrySearchElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - bool explicitWin64 = false; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var explicitWin64 = false; Identifier id = null; string key = null; string name = null; string signature = null; - int root = CompilerConstants.IntegerNotSet; - int type = CompilerConstants.IntegerNotSet; - bool search64bit = false; + var root = CompilerConstants.IntegerNotSet; + var type = CompilerConstants.IntegerNotSet; + var search64bit = false; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Key": - key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Name": - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Root": - root = this.Core.GetAttributeMsidbRegistryRootValue(sourceLineNumbers, attrib, false); - break; - case "Type": - string typeValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < typeValue.Length) + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Key": + key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Root": + root = this.Core.GetAttributeMsidbRegistryRootValue(sourceLineNumbers, attrib, false); + break; + case "Type": + var typeValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < typeValue.Length) + { + var typeType = Wix.RegistrySearch.ParseTypeType(typeValue); + switch (typeType) { - Wix.RegistrySearch.TypeType typeType = Wix.RegistrySearch.ParseTypeType(typeValue); - switch (typeType) - { - case Wix.RegistrySearch.TypeType.directory: - type = 0; - break; - case Wix.RegistrySearch.TypeType.file: - type = 1; - break; - case Wix.RegistrySearch.TypeType.raw: - type = 2; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Type", typeValue, "directory", "file", "raw")); - break; - } + case Wix.RegistrySearch.TypeType.directory: + type = 0; + break; + case Wix.RegistrySearch.TypeType.file: + type = 1; + break; + case Wix.RegistrySearch.TypeType.raw: + type = 2; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Type", typeValue, "directory", "file", "raw")); + break; } - break; - case "Win64": - explicitWin64 = true; - search64bit = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + case "Win64": + explicitWin64 = true; + search64bit = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -1757,53 +1753,53 @@ namespace WixToolset.Core } signature = id.Id; - bool oneChild = false; - foreach (XElement child in node.Elements()) + var oneChild = false; + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "DirectorySearch": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; + case "DirectorySearch": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; - // directorysearch parentage should work like directory element, not the rest of the signature type because of the DrLocator.Parent column - signature = this.ParseDirectorySearchElement(child, id.Id); - break; - case "DirectorySearchRef": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - signature = this.ParseDirectorySearchRefElement(child, id.Id); - break; - case "FileSearch": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - signature = this.ParseFileSearchElement(child, id.Id, false, CompilerConstants.IntegerNotSet); - id = new Identifier(signature, AccessModifier.Private); // FileSearch signatures override parent signatures - break; - case "FileSearchRef": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - string newId = this.ParseSimpleRefElement(child, "Signature"); // FileSearch signatures override parent signatures - id = new Identifier(newId, AccessModifier.Private); - signature = null; - break; - default: - this.Core.UnexpectedElement(node, child); - break; + // directorysearch parentage should work like directory element, not the rest of the signature type because of the DrLocator.Parent column + signature = this.ParseDirectorySearchElement(child, id.Id); + break; + case "DirectorySearchRef": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + signature = this.ParseDirectorySearchRefElement(child, id.Id); + break; + case "FileSearch": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + signature = this.ParseFileSearchElement(child, id.Id, false, CompilerConstants.IntegerNotSet); + id = new Identifier(signature, AccessModifier.Private); // FileSearch signatures override parent signatures + break; + case "FileSearchRef": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + var newId = this.ParseSimpleRefElement(child, "Signature"); // FileSearch signatures override parent signatures + id = new Identifier(newId, AccessModifier.Private); + signature = null; + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -1832,22 +1828,22 @@ namespace WixToolset.Core /// Signature of referenced search element. private string ParseRegistrySearchRefElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "RegLocator", id); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "RegLocator", id); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -1873,42 +1869,42 @@ namespace WixToolset.Core /// Returns list of string signatures. private List ParseSearchSignatures(XElement node) { - List signatures = new List(); + var signatures = new List(); - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { string signature = null; if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "ComplianceDrive": - signature = this.ParseComplianceDriveElement(child); - break; - case "ComponentSearch": - signature = this.ParseComponentSearchElement(child); - break; - case "DirectorySearch": - signature = this.ParseDirectorySearchElement(child, String.Empty); - break; - case "DirectorySearchRef": - signature = this.ParseDirectorySearchRefElement(child, String.Empty); - break; - case "IniFileSearch": - signature = this.ParseIniFileSearchElement(child); - break; - case "ProductSearch": - // handled in ParsePropertyElement - break; - case "RegistrySearch": - signature = this.ParseRegistrySearchElement(child); - break; - case "RegistrySearchRef": - signature = this.ParseRegistrySearchRefElement(child); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "ComplianceDrive": + signature = this.ParseComplianceDriveElement(child); + break; + case "ComponentSearch": + signature = this.ParseComponentSearchElement(child); + break; + case "DirectorySearch": + signature = this.ParseDirectorySearchElement(child, String.Empty); + break; + case "DirectorySearchRef": + signature = this.ParseDirectorySearchRefElement(child, String.Empty); + break; + case "IniFileSearch": + signature = this.ParseIniFileSearchElement(child); + break; + case "ProductSearch": + // handled in ParsePropertyElement + break; + case "RegistrySearch": + signature = this.ParseRegistrySearchElement(child); + break; + case "RegistrySearchRef": + signature = this.ParseRegistrySearchRefElement(child); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -1933,36 +1929,36 @@ namespace WixToolset.Core /// Signature of nested search elements. private string ParseComplianceDriveElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string signature = null; - bool oneChild = false; - foreach (XElement child in node.Elements()) + var oneChild = false; + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); switch (child.Name.LocalName) { - case "DirectorySearch": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - signature = this.ParseDirectorySearchElement(child, "CCP_DRIVE"); - break; - case "DirectorySearchRef": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - signature = this.ParseDirectorySearchRefElement(child, "CCP_DRIVE"); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "DirectorySearch": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + signature = this.ParseDirectorySearchElement(child, "CCP_DRIVE"); + break; + case "DirectorySearchRef": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + signature = this.ParseDirectorySearchRefElement(child, "CCP_DRIVE"); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -1985,17 +1981,17 @@ namespace WixToolset.Core /// Element to parse. private void ParseComplianceCheckElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -2007,8 +2003,8 @@ namespace WixToolset.Core string signature = null; // see if this property is used for appSearch - List signatures = this.ParseSearchSignatures(node); - foreach (string sig in signatures) + var signatures = this.ParseSearchSignatures(node); + foreach (var sig in signatures) { // if we haven't picked a signature for this ComplianceCheck pick // this one @@ -2048,137 +2044,137 @@ namespace WixToolset.Core [SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] private void ParseComponentElement(XElement node, ComplexReferenceParentType parentType, string parentId, string parentLanguage, int diskId, string directoryId, string srcPath) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - int bits = 0; - int comPlusBits = CompilerConstants.IntegerNotSet; + var bits = 0; + var comPlusBits = CompilerConstants.IntegerNotSet; string condition = null; - bool encounteredODBCDataSource = false; - bool explicitWin64 = false; - int files = 0; - string guid = "*"; - string componentIdPlaceholder = String.Format(Compiler.DefaultComponentIdPlaceholderFormat, this.componentIdPlaceholdersResolver.VariableCount); // placeholder id for defaulting Component/@Id to keypath id. - string componentIdPlaceholderWixVariable = String.Format(Compiler.DefaultComponentIdPlaceholderWixVariableFormat, componentIdPlaceholder); - Identifier id = new Identifier(componentIdPlaceholderWixVariable, AccessModifier.Private); - int keyBits = 0; - bool keyFound = false; + var encounteredODBCDataSource = false; + var explicitWin64 = false; + var files = 0; + var guid = "*"; + var componentIdPlaceholder = String.Format(Compiler.DefaultComponentIdPlaceholderFormat, this.componentIdPlaceholdersResolver.VariableCount); // placeholder id for defaulting Component/@Id to keypath id. + var componentIdPlaceholderWixVariable = String.Format(Compiler.DefaultComponentIdPlaceholderWixVariableFormat, componentIdPlaceholder); + var id = new Identifier(componentIdPlaceholderWixVariable, AccessModifier.Private); + var keyBits = 0; + var keyFound = false; string keyPath = null; - bool shouldAddCreateFolder = false; - bool win64 = false; - bool multiInstance = false; - List symbols = new List(); + var shouldAddCreateFolder = false; + var win64 = false; + var multiInstance = false; + var symbols = new List(); string feature = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "ComPlusFlags": - comPlusBits = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "DisableRegistryReflection": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits |= MsiInterop.MsidbComponentAttributesDisableRegistryReflection; - } - break; - case "Directory": - directoryId = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, directoryId); - break; - case "DiskId": - diskId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); - break; - case "Feature": - feature = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "Guid": - guid = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, true, true); - break; - case "KeyPath": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - keyFound = true; - keyPath = null; - keyBits = 0; - shouldAddCreateFolder = true; - } - break; - case "Location": - string location = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < location.Length) - { - Wix.Component.LocationType locationType = Wix.Component.ParseLocationType(location); - switch (locationType) - { - case Wix.Component.LocationType.either: - bits |= MsiInterop.MsidbComponentAttributesOptional; - break; - case Wix.Component.LocationType.local: // this is the default - break; - case Wix.Component.LocationType.source: - bits |= MsiInterop.MsidbComponentAttributesSourceOnly; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "either", "local", "source")); - break; - } - } - break; - case "MultiInstance": - multiInstance = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "NeverOverwrite": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits |= MsiInterop.MsidbComponentAttributesNeverOverwrite; - } - break; - case "Permanent": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits |= MsiInterop.MsidbComponentAttributesPermanent; - } - break; - case "Shared": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits |= MsiInterop.MsidbComponentAttributesShared; - } - break; - case "SharedDllRefCount": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits |= MsiInterop.MsidbComponentAttributesSharedDllRefCount; - } - break; - case "Transitive": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits |= MsiInterop.MsidbComponentAttributesTransitive; - } - break; - case "UninstallWhenSuperseded": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits |= MsiInterop.MsidbComponentAttributesUninstallOnSupersedence; - } - break; - case "Win64": - explicitWin64 = true; - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "ComPlusFlags": + comPlusBits = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "DisableRegistryReflection": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits |= MsiInterop.MsidbComponentAttributesDisableRegistryReflection; + } + break; + case "Directory": + directoryId = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, directoryId); + break; + case "DiskId": + diskId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, Int16.MaxValue); + break; + case "Feature": + feature = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "Guid": + guid = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, true, true); + break; + case "KeyPath": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + keyFound = true; + keyPath = null; + keyBits = 0; + shouldAddCreateFolder = true; + } + break; + case "Location": + var location = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < location.Length) + { + var locationType = Wix.Component.ParseLocationType(location); + switch (locationType) { - bits |= MsiInterop.MsidbComponentAttributes64bit; - win64 = true; + case Wix.Component.LocationType.either: + bits |= MsiInterop.MsidbComponentAttributesOptional; + break; + case Wix.Component.LocationType.local: // this is the default + break; + case Wix.Component.LocationType.source: + bits |= MsiInterop.MsidbComponentAttributesSourceOnly; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "either", "local", "source")); + break; } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + case "MultiInstance": + multiInstance = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "NeverOverwrite": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits |= MsiInterop.MsidbComponentAttributesNeverOverwrite; + } + break; + case "Permanent": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits |= MsiInterop.MsidbComponentAttributesPermanent; + } + break; + case "Shared": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits |= MsiInterop.MsidbComponentAttributesShared; + } + break; + case "SharedDllRefCount": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits |= MsiInterop.MsidbComponentAttributesSharedDllRefCount; + } + break; + case "Transitive": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits |= MsiInterop.MsidbComponentAttributesTransitive; + } + break; + case "UninstallWhenSuperseded": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits |= MsiInterop.MsidbComponentAttributesUninstallOnSupersedence; + } + break; + case "Win64": + explicitWin64 = true; + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits |= MsiInterop.MsidbComponentAttributes64bit; + win64 = true; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -2227,134 +2223,134 @@ namespace WixToolset.Core } } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { - YesNoType keyPathSet = YesNoType.NotSet; + var keyPathSet = YesNoType.NotSet; string keyPossible = null; - int keyBit = 0; + var keyBit = 0; if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "AppId": - this.ParseAppIdElement(child, id.Id, YesNoType.NotSet, null, null, null); - break; - case "Category": - this.ParseCategoryElement(child, id.Id); - break; - case "Class": - this.ParseClassElement(child, id.Id, YesNoType.NotSet, null, null, null, null); - break; - case "Condition": - if (null != condition) - { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - this.Core.Write(ErrorMessages.TooManyChildren(childSourceLineNumbers, node.Name.LocalName, child.Name.LocalName)); - } - condition = this.ParseConditionElement(child, node.Name.LocalName, null, null); - break; - case "CopyFile": - this.ParseCopyFileElement(child, id.Id, null); - break; - case "CreateFolder": - string createdFolder = this.ParseCreateFolderElement(child, id.Id, directoryId, win64); - if (directoryId == createdFolder) - { - shouldAddCreateFolder = false; - } - break; - case "Environment": - this.ParseEnvironmentElement(child, id.Id); - break; - case "Extension": - this.ParseExtensionElement(child, id.Id, YesNoType.NotSet, null); - break; - case "File": - keyPathSet = this.ParseFileElement(child, id.Id, directoryId, diskId, srcPath, out keyPossible, win64, guid); - if (null != keyPossible) - { - keyBit = 0; - } - files++; - break; - case "IniFile": - this.ParseIniFileElement(child, id.Id); - break; - case "Interface": - this.ParseInterfaceElement(child, id.Id, null, null, null, null); - break; - case "IsolateComponent": - this.ParseIsolateComponentElement(child, id.Id); - break; - case "ODBCDataSource": - keyPathSet = this.ParseODBCDataSource(child, id.Id, null, out keyPossible); - keyBit = MsiInterop.MsidbComponentAttributesODBCDataSource; - encounteredODBCDataSource = true; - break; - case "ODBCDriver": - this.ParseODBCDriverOrTranslator(child, id.Id, null, TupleDefinitionType.ODBCDriver); - break; - case "ODBCTranslator": - this.ParseODBCDriverOrTranslator(child, id.Id, null, TupleDefinitionType.ODBCTranslator); - break; - case "ProgId": - bool foundExtension = false; - this.ParseProgIdElement(child, id.Id, YesNoType.NotSet, null, null, null, ref foundExtension, YesNoType.NotSet); - break; - case "RegistryKey": - keyPathSet = this.ParseRegistryKeyElement(child, id.Id, CompilerConstants.IntegerNotSet, null, win64, out keyPossible); - keyBit = MsiInterop.MsidbComponentAttributesRegistryKeyPath; - break; - case "RegistryValue": - keyPathSet = this.ParseRegistryValueElement(child, id.Id, CompilerConstants.IntegerNotSet, null, win64, out keyPossible); - keyBit = MsiInterop.MsidbComponentAttributesRegistryKeyPath; - break; - case "RemoveFile": - this.ParseRemoveFileElement(child, id.Id, directoryId); - break; - case "RemoveFolder": - this.ParseRemoveFolderElement(child, id.Id, directoryId); - break; - case "RemoveRegistryKey": - this.ParseRemoveRegistryKeyElement(child, id.Id); - break; - case "RemoveRegistryValue": - this.ParseRemoveRegistryValueElement(child, id.Id); - break; - case "ReserveCost": - this.ParseReserveCostElement(child, id.Id, directoryId); - break; - case "ServiceConfig": - this.ParseServiceConfigElement(child, id.Id, null); - break; - case "ServiceConfigFailureActions": - this.ParseServiceConfigFailureActionsElement(child, id.Id, null); - break; - case "ServiceControl": - this.ParseServiceControlElement(child, id.Id); - break; - case "ServiceInstall": - this.ParseServiceInstallElement(child, id.Id, win64); - break; - case "Shortcut": - this.ParseShortcutElement(child, id.Id, node.Name.LocalName, directoryId, YesNoType.No); - break; - case "SymbolPath": - symbols.Add(this.ParseSymbolPathElement(child)); - break; - case "TypeLib": - this.ParseTypeLibElement(child, id.Id, null, win64); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "AppId": + this.ParseAppIdElement(child, id.Id, YesNoType.NotSet, null, null, null); + break; + case "Category": + this.ParseCategoryElement(child, id.Id); + break; + case "Class": + this.ParseClassElement(child, id.Id, YesNoType.NotSet, null, null, null, null); + break; + case "Condition": + if (null != condition) + { + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + this.Core.Write(ErrorMessages.TooManyChildren(childSourceLineNumbers, node.Name.LocalName, child.Name.LocalName)); + } + condition = this.ParseConditionElement(child, node.Name.LocalName, null, null); + break; + case "CopyFile": + this.ParseCopyFileElement(child, id.Id, null); + break; + case "CreateFolder": + var createdFolder = this.ParseCreateFolderElement(child, id.Id, directoryId, win64); + if (directoryId == createdFolder) + { + shouldAddCreateFolder = false; + } + break; + case "Environment": + this.ParseEnvironmentElement(child, id.Id); + break; + case "Extension": + this.ParseExtensionElement(child, id.Id, YesNoType.NotSet, null); + break; + case "File": + keyPathSet = this.ParseFileElement(child, id.Id, directoryId, diskId, srcPath, out keyPossible, win64, guid); + if (null != keyPossible) + { + keyBit = 0; + } + files++; + break; + case "IniFile": + this.ParseIniFileElement(child, id.Id); + break; + case "Interface": + this.ParseInterfaceElement(child, id.Id, null, null, null, null); + break; + case "IsolateComponent": + this.ParseIsolateComponentElement(child, id.Id); + break; + case "ODBCDataSource": + keyPathSet = this.ParseODBCDataSource(child, id.Id, null, out keyPossible); + keyBit = MsiInterop.MsidbComponentAttributesODBCDataSource; + encounteredODBCDataSource = true; + break; + case "ODBCDriver": + this.ParseODBCDriverOrTranslator(child, id.Id, null, TupleDefinitionType.ODBCDriver); + break; + case "ODBCTranslator": + this.ParseODBCDriverOrTranslator(child, id.Id, null, TupleDefinitionType.ODBCTranslator); + break; + case "ProgId": + var foundExtension = false; + this.ParseProgIdElement(child, id.Id, YesNoType.NotSet, null, null, null, ref foundExtension, YesNoType.NotSet); + break; + case "RegistryKey": + keyPathSet = this.ParseRegistryKeyElement(child, id.Id, CompilerConstants.IntegerNotSet, null, win64, out keyPossible); + keyBit = MsiInterop.MsidbComponentAttributesRegistryKeyPath; + break; + case "RegistryValue": + keyPathSet = this.ParseRegistryValueElement(child, id.Id, CompilerConstants.IntegerNotSet, null, win64, out keyPossible); + keyBit = MsiInterop.MsidbComponentAttributesRegistryKeyPath; + break; + case "RemoveFile": + this.ParseRemoveFileElement(child, id.Id, directoryId); + break; + case "RemoveFolder": + this.ParseRemoveFolderElement(child, id.Id, directoryId); + break; + case "RemoveRegistryKey": + this.ParseRemoveRegistryKeyElement(child, id.Id); + break; + case "RemoveRegistryValue": + this.ParseRemoveRegistryValueElement(child, id.Id); + break; + case "ReserveCost": + this.ParseReserveCostElement(child, id.Id, directoryId); + break; + case "ServiceConfig": + this.ParseServiceConfigElement(child, id.Id, null); + break; + case "ServiceConfigFailureActions": + this.ParseServiceConfigFailureActionsElement(child, id.Id, null); + break; + case "ServiceControl": + this.ParseServiceControlElement(child, id.Id); + break; + case "ServiceInstall": + this.ParseServiceInstallElement(child, id.Id, win64); + break; + case "Shortcut": + this.ParseShortcutElement(child, id.Id, node.Name.LocalName, directoryId, YesNoType.No); + break; + case "SymbolPath": + symbols.Add(this.ParseSymbolPathElement(child)); + break; + case "TypeLib": + this.ParseTypeLibElement(child, id.Id, null, win64); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else { - Dictionary context = new Dictionary() { { "ComponentId", id.Id }, { "DirectoryId", directoryId }, { "Win64", win64.ToString() }, }; - ComponentKeyPath possibleKeyPath = this.Core.ParsePossibleKeyPathExtensionElement(node, child, context); + var context = new Dictionary() { { "ComponentId", id.Id }, { "DirectoryId", directoryId }, { "Win64", win64.ToString() }, }; + var possibleKeyPath = this.Core.ParsePossibleKeyPathExtensionElement(node, child, context); if (null != possibleKeyPath) { if (ComponentKeyPathType.None == possibleKeyPath.Type) @@ -2407,7 +2403,7 @@ namespace WixToolset.Core } // check for conditions that exclude this component from using generated guids - bool isGeneratableGuidOk = "*" == guid; + var isGeneratableGuidOk = "*" == guid; if (isGeneratableGuidOk) { if (encounteredODBCDataSource) @@ -2501,31 +2497,31 @@ namespace WixToolset.Core [SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] private void ParseComponentGroupElement(XElement node, ComplexReferenceParentType parentType, string parentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string directoryId = null; string source = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Directory": - // If the inline syntax is invalid it returns null. Use a static error identifier so the null - // directory identifier here doesn't trickle down false errors into child elements. - directoryId = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null) ?? "ErrorParsingInlineSyntax"; - break; - case "Source": - source = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Directory": + // If the inline syntax is invalid it returns null. Use a static error identifier so the null + // directory identifier here doesn't trickle down false errors into child elements. + directoryId = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null) ?? "ErrorParsingInlineSyntax"; + break; + case "Source": + source = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -2545,24 +2541,24 @@ namespace WixToolset.Core source = String.Concat(source, Path.DirectorySeparatorChar); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "ComponentGroupRef": - this.ParseComponentGroupRefElement(child, ComplexReferenceParentType.ComponentGroup, id.Id, null); - break; - case "ComponentRef": - this.ParseComponentRefElement(child, ComplexReferenceParentType.ComponentGroup, id.Id, null); - break; - case "Component": - this.ParseComponentElement(child, ComplexReferenceParentType.ComponentGroup, id.Id, null, CompilerConstants.IntegerNotSet, directoryId, source); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "ComponentGroupRef": + this.ParseComponentGroupRefElement(child, ComplexReferenceParentType.ComponentGroup, id.Id, null); + break; + case "ComponentRef": + this.ParseComponentRefElement(child, ComplexReferenceParentType.ComponentGroup, id.Id, null); + break; + case "Component": + this.ParseComponentElement(child, ComplexReferenceParentType.ComponentGroup, id.Id, null, CompilerConstants.IntegerNotSet, directoryId, source); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -2591,26 +2587,26 @@ namespace WixToolset.Core { Debug.Assert(ComplexReferenceParentType.ComponentGroup == parentType || ComplexReferenceParentType.FeatureGroup == parentType || ComplexReferenceParentType.Feature == parentType || ComplexReferenceParentType.Module == parentType); - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - YesNoType primary = YesNoType.NotSet; + var primary = YesNoType.NotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "WixComponentGroup", id); - break; - case "Primary": - primary = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "WixComponentGroup", id); + break; + case "Primary": + primary = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -2640,26 +2636,26 @@ namespace WixToolset.Core { Debug.Assert(ComplexReferenceParentType.FeatureGroup == parentType || ComplexReferenceParentType.ComponentGroup == parentType || ComplexReferenceParentType.Feature == parentType || ComplexReferenceParentType.Module == parentType); - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - YesNoType primary = YesNoType.NotSet; + var primary = YesNoType.NotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "Component", id); - break; - case "Primary": - primary = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "Component", id); + break; + case "Primary": + primary = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -2685,46 +2681,46 @@ namespace WixToolset.Core /// Signature for search element. private string ParseComponentSearchElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string componentId = null; - int type = MsiInterop.MsidbLocatorTypeFileName; + var type = MsiInterop.MsidbLocatorTypeFileName; string signature = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Guid": - componentId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - case "Type": - string typeValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < typeValue.Length) + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Guid": + componentId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + case "Type": + var typeValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < typeValue.Length) + { + var typeType = Wix.ComponentSearch.ParseTypeType(typeValue); + switch (typeType) { - Wix.ComponentSearch.TypeType typeType = Wix.ComponentSearch.ParseTypeType(typeValue); - switch (typeType) - { - case Wix.ComponentSearch.TypeType.directory: - type = MsiInterop.MsidbLocatorTypeDirectory; - break; - case Wix.ComponentSearch.TypeType.file: - type = MsiInterop.MsidbLocatorTypeFileName; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, typeValue, "directory", "file")); - break; - } + case Wix.ComponentSearch.TypeType.directory: + type = MsiInterop.MsidbLocatorTypeDirectory; + break; + case Wix.ComponentSearch.TypeType.file: + type = MsiInterop.MsidbLocatorTypeFileName; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, typeValue, "directory", "file")); + break; } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -2739,53 +2735,53 @@ namespace WixToolset.Core } signature = id.Id; - bool oneChild = false; - foreach (XElement child in node.Elements()) + var oneChild = false; + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "DirectorySearch": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; + case "DirectorySearch": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; - // directorysearch parentage should work like directory element, not the rest of the signature type because of the DrLocator.Parent column - signature = this.ParseDirectorySearchElement(child, id.Id); - break; - case "DirectorySearchRef": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - signature = this.ParseDirectorySearchRefElement(child, id.Id); - break; - case "FileSearch": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - signature = this.ParseFileSearchElement(child, id.Id, false, CompilerConstants.IntegerNotSet); - id = new Identifier(signature, AccessModifier.Private); // FileSearch signatures override parent signatures - break; - case "FileSearchRef": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - string newId = this.ParseSimpleRefElement(child, "Signature"); // FileSearch signatures override parent signatures - id = new Identifier(newId, AccessModifier.Private); - signature = null; - break; - default: - this.Core.UnexpectedElement(node, child); - break; + // directorysearch parentage should work like directory element, not the rest of the signature type because of the DrLocator.Parent column + signature = this.ParseDirectorySearchElement(child, id.Id); + break; + case "DirectorySearchRef": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + signature = this.ParseDirectorySearchRefElement(child, id.Id); + break; + case "FileSearch": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + signature = this.ParseFileSearchElement(child, id.Id, false, CompilerConstants.IntegerNotSet); + id = new Identifier(signature, AccessModifier.Private); // FileSearch signatures override parent signatures + break; + case "FileSearchRef": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + var newId = this.ParseSimpleRefElement(child, "Signature"); // FileSearch signatures override parent signatures + id = new Identifier(newId, AccessModifier.Private); + signature = null; + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -2814,19 +2810,19 @@ namespace WixToolset.Core /// Identifier for the directory that will be created private string ParseCreateFolderElement(XElement node, string componentId, string directoryId, bool win64Component) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - foreach (XAttribute attrib in node.Attributes()) + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Directory": - directoryId = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, directoryId); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Directory": + directoryId = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, directoryId); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -2835,29 +2831,29 @@ namespace WixToolset.Core } } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Shortcut": - this.ParseShortcutElement(child, componentId, node.Name.LocalName, directoryId, YesNoType.No); - break; - case "Permission": - this.ParsePermissionElement(child, directoryId, "CreateFolder"); - break; - case "PermissionEx": - this.ParsePermissionExElement(child, directoryId, "CreateFolder"); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "Shortcut": + this.ParseShortcutElement(child, componentId, node.Name.LocalName, directoryId, YesNoType.No); + break; + case "Permission": + this.ParsePermissionElement(child, directoryId, "CreateFolder"); + break; + case "PermissionEx": + this.ParsePermissionExElement(child, directoryId, "CreateFolder"); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else { - Dictionary context = new Dictionary() { { "DirectoryId", directoryId }, { "ComponentId", componentId }, { "Win64", win64Component.ToString() } }; + var context = new Dictionary() { { "DirectoryId", directoryId }, { "ComponentId", componentId }, { "Win64", win64Component.ToString() } }; this.Core.ParseExtensionElement(node, child, context); } } @@ -2880,9 +2876,9 @@ namespace WixToolset.Core /// Identifier of file to copy (null if moving the file). private void ParseCopyFileElement(XElement node, string componentId, string fileId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - bool delete = false; + var delete = false; string destinationDirectory = null; string destinationName = null; string destinationShortName = null; @@ -2892,50 +2888,50 @@ namespace WixToolset.Core string sourceName = null; string sourceProperty = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Delete": - delete = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "DestinationDirectory": - destinationDirectory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null); - break; - case "DestinationName": - destinationName = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); - break; - case "DestinationProperty": - destinationProperty = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "DestinationShortName": - destinationShortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false); - break; - case "FileId": - if (null != fileId) - { - this.Core.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, node.Parent.Name.LocalName)); - } - fileId = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "File", fileId); - break; - case "SourceDirectory": - sourceDirectory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null); - break; - case "SourceName": - sourceName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "SourceProperty": - sourceProperty = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Delete": + delete = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "DestinationDirectory": + destinationDirectory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null); + break; + case "DestinationName": + destinationName = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); + break; + case "DestinationProperty": + destinationProperty = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "DestinationShortName": + destinationShortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false); + break; + case "FileId": + if (null != fileId) + { + this.Core.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, node.Parent.Name.LocalName)); + } + fileId = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "File", fileId); + break; + case "SourceDirectory": + sourceDirectory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null); + break; + case "SourceName": + sourceName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "SourceProperty": + sourceProperty = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -2990,7 +2986,7 @@ namespace WixToolset.Core var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.MoveFile, id); row.Set(1, componentId); row.Set(2, sourceName); - row.Set(3, String.IsNullOrEmpty(destinationShortName) && String.IsNullOrEmpty(destinationName) ? null : GetMsiFilenameValue(destinationShortName, destinationName)); + row.Set(3, String.IsNullOrEmpty(destinationShortName) && String.IsNullOrEmpty(destinationName) ? null : this.GetMsiFilenameValue(destinationShortName, destinationName)); if (null != sourceDirectory) { row.Set(4, sourceDirectory); @@ -3052,7 +3048,7 @@ namespace WixToolset.Core var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.DuplicateFile, id); row.Set(1, componentId); row.Set(2, fileId); - row.Set(3, String.IsNullOrEmpty(destinationShortName) && String.IsNullOrEmpty(destinationName) ? null : GetMsiFilenameValue(destinationShortName, destinationName)); + row.Set(3, String.IsNullOrEmpty(destinationShortName) && String.IsNullOrEmpty(destinationName) ? null : this.GetMsiFilenameValue(destinationShortName, destinationName)); if (null != destinationDirectory) { row.Set(4, destinationDirectory); @@ -3071,264 +3067,264 @@ namespace WixToolset.Core /// Element to parse. private void ParseCustomActionElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - int bits = 0; - int extendedBits = 0; - bool inlineScript = false; + var bits = 0; + var extendedBits = 0; + var inlineScript = false; string innerText = null; string source = null; - int sourceBits = 0; - YesNoType suppressModularization = YesNoType.NotSet; + var sourceBits = 0; + var suppressModularization = YesNoType.NotSet; string target = null; - int targetBits = 0; - bool explicitWin64 = false; + var targetBits = 0; + var explicitWin64 = false; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "BinaryKey": - if (null != source) - { - this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script")); - } - source = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - sourceBits = MsiInterop.MsidbCustomActionTypeBinaryData; - this.Core.CreateSimpleReference(sourceLineNumbers, "Binary", source); // add a reference to the appropriate Binary - break; - case "Directory": - if (null != source) - { - this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script")); - } - source = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null); - sourceBits = MsiInterop.MsidbCustomActionTypeDirectory; - break; - case "DllEntry": - if (null != target) - { - this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall")); - } - target = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - targetBits = MsiInterop.MsidbCustomActionTypeDll; - break; - case "Error": - if (null != target) - { - this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall")); - } - target = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - targetBits = MsiInterop.MsidbCustomActionTypeTextData | MsiInterop.MsidbCustomActionTypeSourceFile; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "BinaryKey": + if (null != source) + { + this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script")); + } + source = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + sourceBits = MsiInterop.MsidbCustomActionTypeBinaryData; + this.Core.CreateSimpleReference(sourceLineNumbers, "Binary", source); // add a reference to the appropriate Binary + break; + case "Directory": + if (null != source) + { + this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script")); + } + source = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null); + sourceBits = MsiInterop.MsidbCustomActionTypeDirectory; + break; + case "DllEntry": + if (null != target) + { + this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall")); + } + target = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + targetBits = MsiInterop.MsidbCustomActionTypeDll; + break; + case "Error": + if (null != target) + { + this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall")); + } + target = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + targetBits = MsiInterop.MsidbCustomActionTypeTextData | MsiInterop.MsidbCustomActionTypeSourceFile; - bool errorReference = true; + var errorReference = true; - try - { - // The target can be either a formatted error string or a literal - // error number. Try to convert to error number to determine whether - // to add a reference. No need to look at the value. - Convert.ToInt32(target, CultureInfo.InvariantCulture.NumberFormat); - } - catch (FormatException) - { - errorReference = false; - } - catch (OverflowException) - { - errorReference = false; - } + try + { + // The target can be either a formatted error string or a literal + // error number. Try to convert to error number to determine whether + // to add a reference. No need to look at the value. + Convert.ToInt32(target, CultureInfo.InvariantCulture.NumberFormat); + } + catch (FormatException) + { + errorReference = false; + } + catch (OverflowException) + { + errorReference = false; + } - if (errorReference) - { - this.Core.CreateSimpleReference(sourceLineNumbers, "Error", target); - } - break; - case "ExeCommand": - if (null != target) - { - this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall")); - } - target = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); // one of the few cases where an empty string value is valid - targetBits = MsiInterop.MsidbCustomActionTypeExe; - break; - case "Execute": - string execute = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < execute.Length) + if (errorReference) + { + this.Core.CreateSimpleReference(sourceLineNumbers, "Error", target); + } + break; + case "ExeCommand": + if (null != target) + { + this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall")); + } + target = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); // one of the few cases where an empty string value is valid + targetBits = MsiInterop.MsidbCustomActionTypeExe; + break; + case "Execute": + var execute = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < execute.Length) + { + var executeType = Wix.CustomAction.ParseExecuteType(execute); + switch (executeType) { - Wix.CustomAction.ExecuteType executeType = Wix.CustomAction.ParseExecuteType(execute); - switch (executeType) - { - case Wix.CustomAction.ExecuteType.commit: - bits |= MsiInterop.MsidbCustomActionTypeInScript | MsiInterop.MsidbCustomActionTypeCommit; - break; - case Wix.CustomAction.ExecuteType.deferred: - bits |= MsiInterop.MsidbCustomActionTypeInScript; - break; - case Wix.CustomAction.ExecuteType.firstSequence: - bits |= MsiInterop.MsidbCustomActionTypeFirstSequence; - break; - case Wix.CustomAction.ExecuteType.immediate: - break; - case Wix.CustomAction.ExecuteType.oncePerProcess: - bits |= MsiInterop.MsidbCustomActionTypeOncePerProcess; - break; - case Wix.CustomAction.ExecuteType.rollback: - bits |= MsiInterop.MsidbCustomActionTypeInScript | MsiInterop.MsidbCustomActionTypeRollback; - break; - case Wix.CustomAction.ExecuteType.secondSequence: - bits |= MsiInterop.MsidbCustomActionTypeClientRepeat; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, execute, "commit", "deferred", "firstSequence", "immediate", "oncePerProcess", "rollback", "secondSequence")); - break; - } - } - break; - case "FileKey": - if (null != source) - { - this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script")); - } - source = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - sourceBits = MsiInterop.MsidbCustomActionTypeSourceFile; - this.Core.CreateSimpleReference(sourceLineNumbers, "File", source); // add a reference to the appropriate File - break; - case "HideTarget": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits |= MsiInterop.MsidbCustomActionTypeHideTarget; - } - break; - case "Impersonate": - if (YesNoType.No == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits |= MsiInterop.MsidbCustomActionTypeNoImpersonate; - } - break; - case "JScriptCall": - if (null != target) - { - this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall")); - } - target = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); // one of the few cases where an empty string value is valid - targetBits = MsiInterop.MsidbCustomActionTypeJScript; - break; - case "PatchUninstall": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - extendedBits |= MsiInterop.MsidbCustomActionTypePatchUninstall; - } - break; - case "Property": - if (null != source) - { - this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script")); - } - source = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - sourceBits = MsiInterop.MsidbCustomActionTypeProperty; - break; - case "Return": - string returnValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < returnValue.Length) - { - Wix.CustomAction.ReturnType returnType = Wix.CustomAction.ParseReturnType(returnValue); - switch (returnType) - { - case Wix.CustomAction.ReturnType.asyncNoWait: - bits |= MsiInterop.MsidbCustomActionTypeAsync | MsiInterop.MsidbCustomActionTypeContinue; - break; - case Wix.CustomAction.ReturnType.asyncWait: - bits |= MsiInterop.MsidbCustomActionTypeAsync; - break; - case Wix.CustomAction.ReturnType.check: - break; - case Wix.CustomAction.ReturnType.ignore: - bits |= MsiInterop.MsidbCustomActionTypeContinue; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, returnValue, "asyncNoWait", "asyncWait", "check", "ignore")); - break; - } + case Wix.CustomAction.ExecuteType.commit: + bits |= MsiInterop.MsidbCustomActionTypeInScript | MsiInterop.MsidbCustomActionTypeCommit; + break; + case Wix.CustomAction.ExecuteType.deferred: + bits |= MsiInterop.MsidbCustomActionTypeInScript; + break; + case Wix.CustomAction.ExecuteType.firstSequence: + bits |= MsiInterop.MsidbCustomActionTypeFirstSequence; + break; + case Wix.CustomAction.ExecuteType.immediate: + break; + case Wix.CustomAction.ExecuteType.oncePerProcess: + bits |= MsiInterop.MsidbCustomActionTypeOncePerProcess; + break; + case Wix.CustomAction.ExecuteType.rollback: + bits |= MsiInterop.MsidbCustomActionTypeInScript | MsiInterop.MsidbCustomActionTypeRollback; + break; + case Wix.CustomAction.ExecuteType.secondSequence: + bits |= MsiInterop.MsidbCustomActionTypeClientRepeat; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, execute, "commit", "deferred", "firstSequence", "immediate", "oncePerProcess", "rollback", "secondSequence")); + break; } - break; - case "Script": - if (null != source) + } + break; + case "FileKey": + if (null != source) + { + this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script")); + } + source = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + sourceBits = MsiInterop.MsidbCustomActionTypeSourceFile; + this.Core.CreateSimpleReference(sourceLineNumbers, "File", source); // add a reference to the appropriate File + break; + case "HideTarget": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits |= MsiInterop.MsidbCustomActionTypeHideTarget; + } + break; + case "Impersonate": + if (YesNoType.No == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits |= MsiInterop.MsidbCustomActionTypeNoImpersonate; + } + break; + case "JScriptCall": + if (null != target) + { + this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall")); + } + target = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); // one of the few cases where an empty string value is valid + targetBits = MsiInterop.MsidbCustomActionTypeJScript; + break; + case "PatchUninstall": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + extendedBits |= MsiInterop.MsidbCustomActionTypePatchUninstall; + } + break; + case "Property": + if (null != source) + { + this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script")); + } + source = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + sourceBits = MsiInterop.MsidbCustomActionTypeProperty; + break; + case "Return": + var returnValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < returnValue.Length) + { + var returnType = Wix.CustomAction.ParseReturnType(returnValue); + switch (returnType) { - this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script")); + case Wix.CustomAction.ReturnType.asyncNoWait: + bits |= MsiInterop.MsidbCustomActionTypeAsync | MsiInterop.MsidbCustomActionTypeContinue; + break; + case Wix.CustomAction.ReturnType.asyncWait: + bits |= MsiInterop.MsidbCustomActionTypeAsync; + break; + case Wix.CustomAction.ReturnType.check: + break; + case Wix.CustomAction.ReturnType.ignore: + bits |= MsiInterop.MsidbCustomActionTypeContinue; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, returnValue, "asyncNoWait", "asyncWait", "check", "ignore")); + break; } + } + break; + case "Script": + if (null != source) + { + this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script")); + } - if (null != target) - { - this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall")); - } + if (null != target) + { + this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall")); + } - // set the source and target to empty string for error messages when the user sets multiple sources or targets - source = string.Empty; - target = string.Empty; + // set the source and target to empty string for error messages when the user sets multiple sources or targets + source = String.Empty; + target = String.Empty; - inlineScript = true; + inlineScript = true; - string script = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < script.Length) - { - Wix.CustomAction.ScriptType scriptType = Wix.CustomAction.ParseScriptType(script); - switch (scriptType) - { - case Wix.CustomAction.ScriptType.jscript: - sourceBits = MsiInterop.MsidbCustomActionTypeDirectory; - targetBits = MsiInterop.MsidbCustomActionTypeJScript; - break; - case Wix.CustomAction.ScriptType.vbscript: - sourceBits = MsiInterop.MsidbCustomActionTypeDirectory; - targetBits = MsiInterop.MsidbCustomActionTypeVBScript; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, script, "jscript", "vbscript")); - break; - } - } - break; - case "SuppressModularization": - suppressModularization = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "TerminalServerAware": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits |= MsiInterop.MsidbCustomActionTypeTSAware; - } - break; - case "Value": - if (null != target) - { - this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall")); - } - target = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); // one of the few cases where an empty string value is valid - targetBits = MsiInterop.MsidbCustomActionTypeTextData; - break; - case "VBScriptCall": - if (null != target) - { - this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall")); - } - target = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); // one of the few cases where an empty string value is valid - targetBits = MsiInterop.MsidbCustomActionTypeVBScript; - break; - case "Win64": - explicitWin64 = true; - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + var script = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < script.Length) + { + var scriptType = Wix.CustomAction.ParseScriptType(script); + switch (scriptType) { - bits |= MsiInterop.MsidbCustomActionType64BitScript; + case Wix.CustomAction.ScriptType.jscript: + sourceBits = MsiInterop.MsidbCustomActionTypeDirectory; + targetBits = MsiInterop.MsidbCustomActionTypeJScript; + break; + case Wix.CustomAction.ScriptType.vbscript: + sourceBits = MsiInterop.MsidbCustomActionTypeDirectory; + targetBits = MsiInterop.MsidbCustomActionTypeVBScript; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, script, "jscript", "vbscript")); + break; } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + case "SuppressModularization": + suppressModularization = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "TerminalServerAware": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits |= MsiInterop.MsidbCustomActionTypeTSAware; + } + break; + case "Value": + if (null != target) + { + this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall")); + } + target = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); // one of the few cases where an empty string value is valid + targetBits = MsiInterop.MsidbCustomActionTypeTextData; + break; + case "VBScriptCall": + if (null != target) + { + this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall")); + } + target = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); // one of the few cases where an empty string value is valid + targetBits = MsiInterop.MsidbCustomActionTypeVBScript; + break; + case "Win64": + explicitWin64 = true; + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits |= MsiInterop.MsidbCustomActionType64BitScript; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -3461,22 +3457,22 @@ namespace WixToolset.Core /// Id of the referenced element. private string ParseSimpleRefElement(XElement node, string table) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, table, id); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, table, id); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -3504,24 +3500,24 @@ namespace WixToolset.Core /// Id of the referenced element. private void ParsePatchFamilyRefElement(XElement node, ComplexReferenceParentType parentType, string parentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - string[] primaryKeys = new string[2]; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var primaryKeys = new string[2]; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - primaryKeys[0] = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "ProductCode": - primaryKeys[1] = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + primaryKeys[0] = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "ProductCode": + primaryKeys[1] = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -3552,21 +3548,21 @@ namespace WixToolset.Core [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] private void ParsePatchFamilyGroupElement(XElement node, ComplexReferenceParentType parentType, string parentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -3581,24 +3577,24 @@ namespace WixToolset.Core id = Identifier.Invalid; } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "PatchFamily": - this.ParsePatchFamilyElement(child, ComplexReferenceParentType.PatchFamilyGroup, id.Id); - break; - case "PatchFamilyRef": - this.ParsePatchFamilyRefElement(child, ComplexReferenceParentType.PatchFamilyGroup, id.Id); - break; - case "PatchFamilyGroupRef": - this.ParsePatchFamilyGroupRefElement(child, ComplexReferenceParentType.PatchFamilyGroup, id.Id); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "PatchFamily": + this.ParsePatchFamilyElement(child, ComplexReferenceParentType.PatchFamilyGroup, id.Id); + break; + case "PatchFamilyRef": + this.ParsePatchFamilyRefElement(child, ComplexReferenceParentType.PatchFamilyGroup, id.Id); + break; + case "PatchFamilyGroupRef": + this.ParsePatchFamilyGroupRefElement(child, ComplexReferenceParentType.PatchFamilyGroup, id.Id); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -3626,22 +3622,22 @@ namespace WixToolset.Core { Debug.Assert(ComplexReferenceParentType.PatchFamilyGroup == parentType || ComplexReferenceParentType.Patch == parentType); - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "WixPatchFamilyGroup", id); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "WixPatchFamilyGroup", id); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -3669,21 +3665,21 @@ namespace WixToolset.Core /// Element to parse. private void ParseEnsureTableElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -3713,11 +3709,11 @@ namespace WixToolset.Core /// not cleaned private void ParseCustomTableElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string tableId = null; string categories = null; - int columnCount = 0; + var columnCount = 0; string columnNames = null; string columnTypes = null; string descriptions = null; @@ -3728,23 +3724,23 @@ namespace WixToolset.Core string modularizations = null; string primaryKeys = null; string sets = null; - bool bootstrapperApplicationData = false; + var bootstrapperApplicationData = false; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - tableId = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "BootstrapperApplicationData": - bootstrapperApplicationData = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + tableId = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "BootstrapperApplicationData": + bootstrapperApplicationData = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -3762,203 +3758,203 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.CustomTableNameTooLong(sourceLineNumbers, node.Name.LocalName, "Id", tableId)); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); switch (child.Name.LocalName) { - case "Column": - ++columnCount; - - string category = String.Empty; - string columnName = null; - string columnType = null; - string description = String.Empty; - int keyColumn = CompilerConstants.IntegerNotSet; - string keyTable = String.Empty; - bool localizable = false; - long maxValue = CompilerConstants.LongNotSet; - long minValue = CompilerConstants.LongNotSet; - string modularization = "None"; - bool nullable = false; - bool primaryKey = false; - string setValues = String.Empty; - string typeName = null; - int width = 0; - - foreach (XAttribute childAttrib in child.Attributes()) + case "Column": + ++columnCount; + + var category = String.Empty; + string columnName = null; + string columnType = null; + var description = String.Empty; + var keyColumn = CompilerConstants.IntegerNotSet; + var keyTable = String.Empty; + var localizable = false; + var maxValue = CompilerConstants.LongNotSet; + var minValue = CompilerConstants.LongNotSet; + var modularization = "None"; + var nullable = false; + var primaryKey = false; + var setValues = String.Empty; + string typeName = null; + var width = 0; + + foreach (var childAttrib in child.Attributes()) + { + switch (childAttrib.Name.LocalName) { - switch (childAttrib.Name.LocalName) + case "Id": + columnName = this.Core.GetAttributeIdentifierValue(childSourceLineNumbers, childAttrib); + break; + case "Category": + category = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib); + break; + case "Description": + description = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib); + break; + case "KeyColumn": + keyColumn = this.Core.GetAttributeIntegerValue(childSourceLineNumbers, childAttrib, 1, 32); + break; + case "KeyTable": + keyTable = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib); + break; + case "Localizable": + localizable = YesNoType.Yes == this.Core.GetAttributeYesNoValue(childSourceLineNumbers, childAttrib); + break; + case "MaxValue": + maxValue = this.Core.GetAttributeLongValue(childSourceLineNumbers, childAttrib, Int32.MinValue + 1, Int32.MaxValue); + break; + case "MinValue": + minValue = this.Core.GetAttributeLongValue(childSourceLineNumbers, childAttrib, Int32.MinValue + 1, Int32.MaxValue); + break; + case "Modularize": + modularization = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib); + break; + case "Nullable": + nullable = YesNoType.Yes == this.Core.GetAttributeYesNoValue(childSourceLineNumbers, childAttrib); + break; + case "PrimaryKey": + primaryKey = YesNoType.Yes == this.Core.GetAttributeYesNoValue(childSourceLineNumbers, childAttrib); + break; + case "Set": + setValues = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib); + break; + case "Type": + var typeValue = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib); + if (0 < typeValue.Length) { - case "Id": - columnName = this.Core.GetAttributeIdentifierValue(childSourceLineNumbers, childAttrib); - break; - case "Category": - category = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib); - break; - case "Description": - description = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib); - break; - case "KeyColumn": - keyColumn = this.Core.GetAttributeIntegerValue(childSourceLineNumbers, childAttrib, 1, 32); - break; - case "KeyTable": - keyTable = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib); - break; - case "Localizable": - localizable = YesNoType.Yes == this.Core.GetAttributeYesNoValue(childSourceLineNumbers, childAttrib); - break; - case "MaxValue": - maxValue = this.Core.GetAttributeLongValue(childSourceLineNumbers, childAttrib, int.MinValue + 1, int.MaxValue); - break; - case "MinValue": - minValue = this.Core.GetAttributeLongValue(childSourceLineNumbers, childAttrib, int.MinValue + 1, int.MaxValue); - break; - case "Modularize": - modularization = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib); - break; - case "Nullable": - nullable = YesNoType.Yes == this.Core.GetAttributeYesNoValue(childSourceLineNumbers, childAttrib); - break; - case "PrimaryKey": - primaryKey = YesNoType.Yes == this.Core.GetAttributeYesNoValue(childSourceLineNumbers, childAttrib); - break; - case "Set": - setValues = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib); + var typeType = Wix.Column.ParseTypeType(typeValue); + switch (typeType) + { + case Wix.Column.TypeType.binary: + typeName = "OBJECT"; break; - case "Type": - string typeValue = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib); - if (0 < typeValue.Length) - { - Wix.Column.TypeType typeType = Wix.Column.ParseTypeType(typeValue); - switch (typeType) - { - case Wix.Column.TypeType.binary: - typeName = "OBJECT"; - break; - case Wix.Column.TypeType.@int: - typeName = "SHORT"; - break; - case Wix.Column.TypeType.@string: - typeName = "CHAR"; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(childSourceLineNumbers, child.Name.LocalName, "Type", typeValue, "binary", "int", "string")); - break; - } - } + case Wix.Column.TypeType.@int: + typeName = "SHORT"; break; - case "Width": - width = this.Core.GetAttributeIntegerValue(childSourceLineNumbers, childAttrib, 0, int.MaxValue); + case Wix.Column.TypeType.@string: + typeName = "CHAR"; break; default: - this.Core.UnexpectedAttribute(child, childAttrib); + this.Core.Write(ErrorMessages.IllegalAttributeValue(childSourceLineNumbers, child.Name.LocalName, "Type", typeValue, "binary", "int", "string")); break; + } } + break; + case "Width": + width = this.Core.GetAttributeIntegerValue(childSourceLineNumbers, childAttrib, 0, Int32.MaxValue); + break; + default: + this.Core.UnexpectedAttribute(child, childAttrib); + break; } + } - if (null == columnName) - { - this.Core.Write(ErrorMessages.ExpectedAttribute(childSourceLineNumbers, child.Name.LocalName, "Id")); - } + if (null == columnName) + { + this.Core.Write(ErrorMessages.ExpectedAttribute(childSourceLineNumbers, child.Name.LocalName, "Id")); + } - if (null == typeName) - { - this.Core.Write(ErrorMessages.ExpectedAttribute(childSourceLineNumbers, child.Name.LocalName, "Type")); - } - else if ("SHORT" == typeName) - { - if (2 != width && 4 != width) - { - this.Core.Write(ErrorMessages.CustomTableIllegalColumnWidth(childSourceLineNumbers, child.Name.LocalName, "Width", width)); - } - columnType = String.Concat(nullable ? "I" : "i", width); - } - else if ("CHAR" == typeName) + if (null == typeName) + { + this.Core.Write(ErrorMessages.ExpectedAttribute(childSourceLineNumbers, child.Name.LocalName, "Type")); + } + else if ("SHORT" == typeName) + { + if (2 != width && 4 != width) { - string typeChar = localizable ? "l" : "s"; - columnType = String.Concat(nullable ? typeChar.ToUpper(CultureInfo.InvariantCulture) : typeChar.ToLower(CultureInfo.InvariantCulture), width); + this.Core.Write(ErrorMessages.CustomTableIllegalColumnWidth(childSourceLineNumbers, child.Name.LocalName, "Width", width)); } - else if ("OBJECT" == typeName) + columnType = String.Concat(nullable ? "I" : "i", width); + } + else if ("CHAR" == typeName) + { + var typeChar = localizable ? "l" : "s"; + columnType = String.Concat(nullable ? typeChar.ToUpper(CultureInfo.InvariantCulture) : typeChar.ToLower(CultureInfo.InvariantCulture), width); + } + else if ("OBJECT" == typeName) + { + if ("Binary" != category) { - if ("Binary" != category) - { - this.Core.Write(ErrorMessages.ExpectedBinaryCategory(childSourceLineNumbers)); - } - columnType = String.Concat(nullable ? "V" : "v", width); + this.Core.Write(ErrorMessages.ExpectedBinaryCategory(childSourceLineNumbers)); } + columnType = String.Concat(nullable ? "V" : "v", width); + } - this.Core.ParseForExtensionElements(child); - - columnNames = String.Concat(columnNames, null == columnNames ? String.Empty : "\t", columnName); - columnTypes = String.Concat(columnTypes, null == columnTypes ? String.Empty : "\t", columnType); - if (primaryKey) - { - primaryKeys = String.Concat(primaryKeys, null == primaryKeys ? String.Empty : "\t", columnName); - } + this.Core.ParseForExtensionElements(child); - minValues = String.Concat(minValues, null == minValues ? String.Empty : "\t", CompilerConstants.LongNotSet != minValue ? minValue.ToString(CultureInfo.InvariantCulture) : String.Empty); - maxValues = String.Concat(maxValues, null == maxValues ? String.Empty : "\t", CompilerConstants.LongNotSet != maxValue ? maxValue.ToString(CultureInfo.InvariantCulture) : String.Empty); - keyTables = String.Concat(keyTables, null == keyTables ? String.Empty : "\t", keyTable); - keyColumns = String.Concat(keyColumns, null == keyColumns ? String.Empty : "\t", CompilerConstants.IntegerNotSet != keyColumn ? keyColumn.ToString(CultureInfo.InvariantCulture) : String.Empty); - categories = String.Concat(categories, null == categories ? String.Empty : "\t", category); - sets = String.Concat(sets, null == sets ? String.Empty : "\t", setValues); - descriptions = String.Concat(descriptions, null == descriptions ? String.Empty : "\t", description); - modularizations = String.Concat(modularizations, null == modularizations ? String.Empty : "\t", modularization); + columnNames = String.Concat(columnNames, null == columnNames ? String.Empty : "\t", columnName); + columnTypes = String.Concat(columnTypes, null == columnTypes ? String.Empty : "\t", columnType); + if (primaryKey) + { + primaryKeys = String.Concat(primaryKeys, null == primaryKeys ? String.Empty : "\t", columnName); + } - break; - case "Row": - string dataValue = null; + minValues = String.Concat(minValues, null == minValues ? String.Empty : "\t", CompilerConstants.LongNotSet != minValue ? minValue.ToString(CultureInfo.InvariantCulture) : String.Empty); + maxValues = String.Concat(maxValues, null == maxValues ? String.Empty : "\t", CompilerConstants.LongNotSet != maxValue ? maxValue.ToString(CultureInfo.InvariantCulture) : String.Empty); + keyTables = String.Concat(keyTables, null == keyTables ? String.Empty : "\t", keyTable); + keyColumns = String.Concat(keyColumns, null == keyColumns ? String.Empty : "\t", CompilerConstants.IntegerNotSet != keyColumn ? keyColumn.ToString(CultureInfo.InvariantCulture) : String.Empty); + categories = String.Concat(categories, null == categories ? String.Empty : "\t", category); + sets = String.Concat(sets, null == sets ? String.Empty : "\t", setValues); + descriptions = String.Concat(descriptions, null == descriptions ? String.Empty : "\t", description); + modularizations = String.Concat(modularizations, null == modularizations ? String.Empty : "\t", modularization); - foreach (XAttribute childAttrib in child.Attributes()) - { - this.Core.ParseExtensionAttribute(child, childAttrib); - } + break; + case "Row": + string dataValue = null; - foreach (XElement data in child.Elements()) + foreach (var childAttrib in child.Attributes()) + { + this.Core.ParseExtensionAttribute(child, childAttrib); + } + + foreach (var data in child.Elements()) + { + var dataSourceLineNumbers = Preprocessor.GetSourceLineNumbers(data); + switch (data.Name.LocalName) { - SourceLineNumber dataSourceLineNumbers = Preprocessor.GetSourceLineNumbers(data); - switch (data.Name.LocalName) + case "Data": + columnName = null; + foreach (var dataAttrib in data.Attributes()) { - case "Data": - columnName = null; - foreach (XAttribute dataAttrib in data.Attributes()) - { - switch (dataAttrib.Name.LocalName) - { - case "Column": - columnName = this.Core.GetAttributeValue(dataSourceLineNumbers, dataAttrib); - break; - default: - this.Core.UnexpectedAttribute(data, dataAttrib); - break; - } - } - - if (null == columnName) - { - this.Core.Write(ErrorMessages.ExpectedAttribute(dataSourceLineNumbers, data.Name.LocalName, "Column")); - } - - dataValue = String.Concat(dataValue, null == dataValue ? String.Empty : Common.CustomRowFieldSeparator.ToString(), columnName, ":", Common.GetInnerText(data)); + switch (dataAttrib.Name.LocalName) + { + case "Column": + columnName = this.Core.GetAttributeValue(dataSourceLineNumbers, dataAttrib); + break; + default: + this.Core.UnexpectedAttribute(data, dataAttrib); break; + } } - } - this.Core.CreateSimpleReference(sourceLineNumbers, "WixCustomTable", tableId); + if (null == columnName) + { + this.Core.Write(ErrorMessages.ExpectedAttribute(dataSourceLineNumbers, data.Name.LocalName, "Column")); + } - if (!this.Core.EncounteredError) - { - var rowRow = this.Core.CreateRow(childSourceLineNumbers, TupleDefinitionType.WixCustomRow); - rowRow.Set(0, tableId); - rowRow.Set(1, dataValue); + dataValue = String.Concat(dataValue, null == dataValue ? String.Empty : Common.CustomRowFieldSeparator.ToString(), columnName, ":", Common.GetInnerText(data)); + break; } - break; - default: - this.Core.UnexpectedElement(node, child); - break; + } + + this.Core.CreateSimpleReference(sourceLineNumbers, "WixCustomTable", tableId); + + if (!this.Core.EncounteredError) + { + var rowRow = this.Core.CreateRow(childSourceLineNumbers, TupleDefinitionType.WixCustomRow); + rowRow.Set(0, tableId); + rowRow.Set(1, dataValue); + } + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -4005,12 +4001,12 @@ namespace WixToolset.Core [SuppressMessage("Microsoft.Performance", "CA1820:TestForEmptyStringsUsingStringLength")] private void ParseDirectoryElement(XElement node, string parentId, int diskId, string fileSource) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string componentGuidGenerationSeed = null; - bool fileSourceAttribSet = false; - bool nameHasValue = false; - string name = "."; // default to parent directory. + var fileSourceAttribSet = false; + var nameHasValue = false; + var name = "."; // default to parent directory. string[] inlineSyntax = null; string shortName = null; string sourceName = null; @@ -4018,55 +4014,55 @@ namespace WixToolset.Core string defaultDir = null; string symbols = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "ComponentGuidGenerationSeed": - componentGuidGenerationSeed = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - case "DiskId": - diskId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); - break; - case "FileSource": - fileSource = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - fileSourceAttribSet = true; - break; - case "Name": - nameHasValue = true; - if (attrib.Value.Equals(".")) - { - name = attrib.Value; - } - else - { - inlineSyntax = this.Core.GetAttributeInlineDirectorySyntax(sourceLineNumbers, attrib); - } - break; - case "ShortName": - shortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false); - break; - case "ShortSourceName": - shortSourceName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false); - break; - case "SourceName": - if ("." == attrib.Value) - { - sourceName = attrib.Value; - } - else - { - sourceName = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); - } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "ComponentGuidGenerationSeed": + componentGuidGenerationSeed = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + case "DiskId": + diskId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, Int16.MaxValue); + break; + case "FileSource": + fileSource = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + fileSourceAttribSet = true; + break; + case "Name": + nameHasValue = true; + if (attrib.Value.Equals(".")) + { + name = attrib.Value; + } + else + { + inlineSyntax = this.Core.GetAttributeInlineDirectorySyntax(sourceLineNumbers, attrib); + } + break; + case "ShortName": + shortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false); + break; + case "ShortSourceName": + shortSourceName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false); + break; + case "SourceName": + if ("." == attrib.Value) + { + sourceName = attrib.Value; + } + else + { + sourceName = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -4086,7 +4082,7 @@ namespace WixToolset.Core } else { - int pathStartsAt = 0; + var pathStartsAt = 0; if (inlineSyntax[0].EndsWith(":")) { parentId = inlineSyntax[0].TrimEnd(':'); @@ -4095,9 +4091,9 @@ namespace WixToolset.Core pathStartsAt = 1; } - for (int i = pathStartsAt; i < inlineSyntax.Length - 1; ++i) + for (var i = pathStartsAt; i < inlineSyntax.Length - 1; ++i) { - Identifier inlineId = this.Core.CreateDirectoryRow(sourceLineNumbers, null, parentId, inlineSyntax[i]); + var inlineId = this.Core.CreateDirectoryRow(sourceLineNumbers, null, parentId, inlineSyntax[i]); parentId = inlineId.Id; } @@ -4206,34 +4202,34 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.IllegalTargetDirDefaultDir(sourceLineNumbers, defaultDir)); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Component": - this.ParseComponentElement(child, ComplexReferenceParentType.Unknown, null, null, diskId, id.Id, fileSource); - break; - case "Directory": - this.ParseDirectoryElement(child, id.Id, diskId, fileSource); - break; - case "Merge": - this.ParseMergeElement(child, id.Id, diskId); - break; - case "SymbolPath": - if (null != symbols) - { - symbols += ";" + this.ParseSymbolPathElement(child); - } - else - { - symbols = this.ParseSymbolPathElement(child); - } - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "Component": + this.ParseComponentElement(child, ComplexReferenceParentType.Unknown, null, null, diskId, id.Id, fileSource); + break; + case "Directory": + this.ParseDirectoryElement(child, id.Id, diskId, fileSource); + break; + case "Merge": + this.ParseMergeElement(child, id.Id, diskId); + break; + case "SymbolPath": + if (null != symbols) + { + symbols += ";" + this.ParseSymbolPathElement(child); + } + else + { + symbols = this.ParseSymbolPathElement(child); + } + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -4271,30 +4267,30 @@ namespace WixToolset.Core [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] private void ParseDirectoryRefElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - int diskId = CompilerConstants.IntegerNotSet; - string fileSource = String.Empty; + var diskId = CompilerConstants.IntegerNotSet; + var fileSource = String.Empty; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "Directory", id); - break; - case "DiskId": - diskId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); - break; - case "FileSource": - fileSource = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "Directory", id); + break; + case "DiskId": + diskId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, Int16.MaxValue); + break; + case "FileSource": + fileSource = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -4313,24 +4309,24 @@ namespace WixToolset.Core fileSource = String.Concat(fileSource, Path.DirectorySeparatorChar); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Component": - this.ParseComponentElement(child, ComplexReferenceParentType.Unknown, null, null, diskId, id, fileSource); - break; - case "Directory": - this.ParseDirectoryElement(child, id, diskId, fileSource); - break; - case "Merge": - this.ParseMergeElement(child, id, diskId); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "Component": + this.ParseComponentElement(child, ComplexReferenceParentType.Unknown, null, null, diskId, id, fileSource); + break; + case "Directory": + this.ParseDirectoryElement(child, id, diskId, fileSource); + break; + case "Merge": + this.ParseMergeElement(child, id, diskId); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -4348,34 +4344,34 @@ namespace WixToolset.Core /// Signature of search element. private string ParseDirectorySearchElement(XElement node, string parentSignature) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - int depth = CompilerConstants.IntegerNotSet; + var depth = CompilerConstants.IntegerNotSet; string path = null; - bool assignToProperty = false; + var assignToProperty = false; string signature = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Depth": - depth = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "Path": - path = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "AssignToProperty": - assignToProperty = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Depth": + depth = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "Path": + path = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "AssignToProperty": + assignToProperty = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -4391,51 +4387,51 @@ namespace WixToolset.Core signature = id.Id; - bool oneChild = false; - bool hasFileSearch = false; - foreach (XElement child in node.Elements()) + var oneChild = false; + var hasFileSearch = false; + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); switch (child.Name.LocalName) { - case "DirectorySearch": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - signature = this.ParseDirectorySearchElement(child, id.Id); - break; - case "DirectorySearchRef": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - signature = this.ParseDirectorySearchRefElement(child, id.Id); - break; - case "FileSearch": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - hasFileSearch = true; - signature = this.ParseFileSearchElement(child, id.Id, assignToProperty, depth); - break; - case "FileSearchRef": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - signature = this.ParseSimpleRefElement(child, "Signature"); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "DirectorySearch": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + signature = this.ParseDirectorySearchElement(child, id.Id); + break; + case "DirectorySearchRef": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + signature = this.ParseDirectorySearchRefElement(child, id.Id); + break; + case "FileSearch": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + hasFileSearch = true; + signature = this.ParseFileSearchElement(child, id.Id, assignToProperty, depth); + break; + case "FileSearchRef": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + signature = this.ParseSimpleRefElement(child, "Signature"); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } // If AssignToProperty is set, only a FileSearch @@ -4497,30 +4493,30 @@ namespace WixToolset.Core /// Signature of search element. private string ParseDirectorySearchRefElement(XElement node, string parentSignature) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; Identifier parent = null; string path = null; string signature = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Parent": - parent = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Path": - path = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Parent": + parent = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Path": + path = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -4548,49 +4544,49 @@ namespace WixToolset.Core signature = id.Id; - bool oneChild = false; - foreach (XElement child in node.Elements()) + var oneChild = false; + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); switch (child.Name.LocalName) { - case "DirectorySearch": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - signature = this.ParseDirectorySearchElement(child, id.Id); - break; - case "DirectorySearchRef": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - signature = this.ParseDirectorySearchRefElement(child, id.Id); - break; - case "FileSearch": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - signature = this.ParseFileSearchElement(child, id.Id, false, CompilerConstants.IntegerNotSet); - break; - case "FileSearchRef": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - signature = this.ParseSimpleRefElement(child, "Signature"); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "DirectorySearch": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + signature = this.ParseDirectorySearchElement(child, id.Id); + break; + case "DirectorySearchRef": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + signature = this.ParseDirectorySearchRefElement(child, id.Id); + break; + case "FileSearch": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + signature = this.ParseFileSearchElement(child, id.Id, false, CompilerConstants.IntegerNotSet); + break; + case "FileSearchRef": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + signature = this.ParseSimpleRefElement(child, "Signature"); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -4616,132 +4612,132 @@ namespace WixToolset.Core [SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] private void ParseFeatureElement(XElement node, ComplexReferenceParentType parentType, string parentId, ref int lastDisplay) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string allowAdvertise = null; - int bits = 0; + var bits = 0; string configurableDirectory = null; string description = null; - string display = "collapse"; - YesNoType followParent = YesNoType.NotSet; + var display = "collapse"; + var followParent = YesNoType.NotSet; string installDefault = null; - int level = 1; + var level = 1; string title = null; string typicalDefault = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Absent": - string absent = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < absent.Length) + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Absent": + var absent = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < absent.Length) + { + var absentType = Wix.Feature.ParseAbsentType(absent); + switch (absentType) { - Wix.Feature.AbsentType absentType = Wix.Feature.ParseAbsentType(absent); - switch (absentType) - { - case Wix.Feature.AbsentType.allow: // this is the default - break; - case Wix.Feature.AbsentType.disallow: - bits = bits | MsiInterop.MsidbFeatureAttributesUIDisallowAbsent; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, absent, "allow", "disallow")); - break; - } + case Wix.Feature.AbsentType.allow: // this is the default + break; + case Wix.Feature.AbsentType.disallow: + bits = bits | MsiInterop.MsidbFeatureAttributesUIDisallowAbsent; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, absent, "allow", "disallow")); + break; } - break; - case "AllowAdvertise": - allowAdvertise = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < allowAdvertise.Length) + } + break; + case "AllowAdvertise": + allowAdvertise = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < allowAdvertise.Length) + { + var allowAdvertiseType = Wix.Feature.ParseAllowAdvertiseType(allowAdvertise); + switch (allowAdvertiseType) { - Wix.Feature.AllowAdvertiseType allowAdvertiseType = Wix.Feature.ParseAllowAdvertiseType(allowAdvertise); - switch (allowAdvertiseType) - { - case Wix.Feature.AllowAdvertiseType.no: - bits |= MsiInterop.MsidbFeatureAttributesDisallowAdvertise; - break; - case Wix.Feature.AllowAdvertiseType.system: - bits |= MsiInterop.MsidbFeatureAttributesNoUnsupportedAdvertise; - break; - case Wix.Feature.AllowAdvertiseType.yes: // this is the default - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, allowAdvertise, "no", "system", "yes")); - break; - } + case Wix.Feature.AllowAdvertiseType.no: + bits |= MsiInterop.MsidbFeatureAttributesDisallowAdvertise; + break; + case Wix.Feature.AllowAdvertiseType.system: + bits |= MsiInterop.MsidbFeatureAttributesNoUnsupportedAdvertise; + break; + case Wix.Feature.AllowAdvertiseType.yes: // this is the default + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, allowAdvertise, "no", "system", "yes")); + break; } - break; - case "ConfigurableDirectory": - configurableDirectory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null); - break; - case "Description": - description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Display": - display = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "InstallDefault": - installDefault = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < installDefault.Length) + } + break; + case "ConfigurableDirectory": + configurableDirectory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null); + break; + case "Description": + description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Display": + display = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "InstallDefault": + installDefault = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < installDefault.Length) + { + var installDefaultType = Wix.Feature.ParseInstallDefaultType(installDefault); + switch (installDefaultType) { - Wix.Feature.InstallDefaultType installDefaultType = Wix.Feature.ParseInstallDefaultType(installDefault); - switch (installDefaultType) + case Wix.Feature.InstallDefaultType.followParent: + if (ComplexReferenceParentType.Product == parentType) { - case Wix.Feature.InstallDefaultType.followParent: - if (ComplexReferenceParentType.Product == parentType) - { - this.Core.Write(ErrorMessages.RootFeatureCannotFollowParent(sourceLineNumbers)); - } - bits = bits | MsiInterop.MsidbFeatureAttributesFollowParent; - break; - case Wix.Feature.InstallDefaultType.local: // this is the default - break; - case Wix.Feature.InstallDefaultType.source: - bits = bits | MsiInterop.MsidbFeatureAttributesFavorSource; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, installDefault, "followParent", "local", "source")); - break; + this.Core.Write(ErrorMessages.RootFeatureCannotFollowParent(sourceLineNumbers)); } + bits = bits | MsiInterop.MsidbFeatureAttributesFollowParent; + break; + case Wix.Feature.InstallDefaultType.local: // this is the default + break; + case Wix.Feature.InstallDefaultType.source: + bits = bits | MsiInterop.MsidbFeatureAttributesFavorSource; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, installDefault, "followParent", "local", "source")); + break; } - break; - case "Level": - level = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "Title": - title = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if ("PUT-FEATURE-TITLE-HERE" == title) - { - this.Core.Write(WarningMessages.PlaceholderValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, title)); - } - break; - case "TypicalDefault": - typicalDefault = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < typicalDefault.Length) + } + break; + case "Level": + level = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "Title": + title = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if ("PUT-FEATURE-TITLE-HERE" == title) + { + this.Core.Write(WarningMessages.PlaceholderValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, title)); + } + break; + case "TypicalDefault": + typicalDefault = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < typicalDefault.Length) + { + var typicalDefaultType = Wix.Feature.ParseTypicalDefaultType(typicalDefault); + switch (typicalDefaultType) { - Wix.Feature.TypicalDefaultType typicalDefaultType = Wix.Feature.ParseTypicalDefaultType(typicalDefault); - switch (typicalDefaultType) - { - case Wix.Feature.TypicalDefaultType.advertise: - bits = bits | MsiInterop.MsidbFeatureAttributesFavorAdvertise; - break; - case Wix.Feature.TypicalDefaultType.install: // this is the default - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, typicalDefault, "advertise", "install")); - break; - } + case Wix.Feature.TypicalDefaultType.advertise: + bits = bits | MsiInterop.MsidbFeatureAttributesFavorAdvertise; + break; + case Wix.Feature.TypicalDefaultType.install: // this is the default + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, typicalDefault, "advertise", "install")); + break; } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -4775,40 +4771,40 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.FeatureCannotFollowParentAndFavorLocalOrSource(sourceLineNumbers, node.Name.LocalName, "InstallDefault", "FollowParent", "yes")); } - int childDisplay = 0; - foreach (XElement child in node.Elements()) + var childDisplay = 0; + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "ComponentGroupRef": - this.ParseComponentGroupRefElement(child, ComplexReferenceParentType.Feature, id.Id, null); - break; - case "ComponentRef": - this.ParseComponentRefElement(child, ComplexReferenceParentType.Feature, id.Id, null); - break; - case "Component": - this.ParseComponentElement(child, ComplexReferenceParentType.Feature, id.Id, null, CompilerConstants.IntegerNotSet, null, null); - break; - case "Condition": - this.ParseConditionElement(child, node.Name.LocalName, id.Id, null); - break; - case "Feature": - this.ParseFeatureElement(child, ComplexReferenceParentType.Feature, id.Id, ref childDisplay); - break; - case "FeatureGroupRef": - this.ParseFeatureGroupRefElement(child, ComplexReferenceParentType.Feature, id.Id); - break; - case "FeatureRef": - this.ParseFeatureRefElement(child, ComplexReferenceParentType.Feature, id.Id); - break; - case "MergeRef": - this.ParseMergeRefElement(child, ComplexReferenceParentType.Feature, id.Id); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "ComponentGroupRef": + this.ParseComponentGroupRefElement(child, ComplexReferenceParentType.Feature, id.Id, null); + break; + case "ComponentRef": + this.ParseComponentRefElement(child, ComplexReferenceParentType.Feature, id.Id, null); + break; + case "Component": + this.ParseComponentElement(child, ComplexReferenceParentType.Feature, id.Id, null, CompilerConstants.IntegerNotSet, null, null); + break; + case "Condition": + this.ParseConditionElement(child, node.Name.LocalName, id.Id, null); + break; + case "Feature": + this.ParseFeatureElement(child, ComplexReferenceParentType.Feature, id.Id, ref childDisplay); + break; + case "FeatureGroupRef": + this.ParseFeatureGroupRefElement(child, ComplexReferenceParentType.Feature, id.Id); + break; + case "FeatureRef": + this.ParseFeatureRefElement(child, ComplexReferenceParentType.Feature, id.Id); + break; + case "MergeRef": + this.ParseMergeRefElement(child, ComplexReferenceParentType.Feature, id.Id); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -4827,33 +4823,33 @@ namespace WixToolset.Core { switch (display) { - case "collapse": - lastDisplay = (lastDisplay | 1) + 1; - row.Set(4, lastDisplay); - break; - case "expand": - lastDisplay = (lastDisplay + 1) | 1; - row.Set(4, lastDisplay); - break; - case "hidden": - row.Set(4, 0); - break; - default: - int value; - if (!Int32.TryParse(display, NumberStyles.Integer, CultureInfo.InvariantCulture, out value)) - { - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Display", display, "collapse", "expand", "hidden")); - } - else + case "collapse": + lastDisplay = (lastDisplay | 1) + 1; + row.Set(4, lastDisplay); + break; + case "expand": + lastDisplay = (lastDisplay + 1) | 1; + row.Set(4, lastDisplay); + break; + case "hidden": + row.Set(4, 0); + break; + default: + int value; + if (!Int32.TryParse(display, NumberStyles.Integer, CultureInfo.InvariantCulture, out value)) + { + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Display", display, "collapse", "expand", "hidden")); + } + else + { + row.Set(4, value); + // save the display value of this row (if its not hidden) for subsequent rows + if (0 != (int)row[4]) { - row.Set(4, value); - // save the display value of this row (if its not hidden) for subsequent rows - if (0 != (int)row[4]) - { - lastDisplay = (int)row[4]; - } + lastDisplay = (int)row[4]; } - break; + } + break; } } row.Set(5, level); @@ -4876,26 +4872,26 @@ namespace WixToolset.Core [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] private void ParseFeatureRefElement(XElement node, ComplexReferenceParentType parentType, string parentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - YesNoType ignoreParent = YesNoType.NotSet; + var ignoreParent = YesNoType.NotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "Feature", id); - break; - case "IgnoreParent": - ignoreParent = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "Feature", id); + break; + case "IgnoreParent": + ignoreParent = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -4910,40 +4906,40 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); } - int lastDisplay = 0; - foreach (XElement child in node.Elements()) + var lastDisplay = 0; + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "ComponentGroupRef": - this.ParseComponentGroupRefElement(child, ComplexReferenceParentType.Feature, id, null); - break; - case "ComponentRef": - this.ParseComponentRefElement(child, ComplexReferenceParentType.Feature, id, null); - break; - case "Component": - this.ParseComponentElement(child, ComplexReferenceParentType.Feature, id, null, CompilerConstants.IntegerNotSet, null, null); - break; - case "Feature": - this.ParseFeatureElement(child, ComplexReferenceParentType.Feature, id, ref lastDisplay); - break; - case "FeatureGroup": - this.ParseFeatureGroupElement(child, ComplexReferenceParentType.Feature, id); - break; - case "FeatureGroupRef": - this.ParseFeatureGroupRefElement(child, ComplexReferenceParentType.Feature, id); - break; - case "FeatureRef": - this.ParseFeatureRefElement(child, ComplexReferenceParentType.Feature, id); - break; - case "MergeRef": - this.ParseMergeRefElement(child, ComplexReferenceParentType.Feature, id); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "ComponentGroupRef": + this.ParseComponentGroupRefElement(child, ComplexReferenceParentType.Feature, id, null); + break; + case "ComponentRef": + this.ParseComponentRefElement(child, ComplexReferenceParentType.Feature, id, null); + break; + case "Component": + this.ParseComponentElement(child, ComplexReferenceParentType.Feature, id, null, CompilerConstants.IntegerNotSet, null, null); + break; + case "Feature": + this.ParseFeatureElement(child, ComplexReferenceParentType.Feature, id, ref lastDisplay); + break; + case "FeatureGroup": + this.ParseFeatureGroupElement(child, ComplexReferenceParentType.Feature, id); + break; + case "FeatureGroupRef": + this.ParseFeatureGroupRefElement(child, ComplexReferenceParentType.Feature, id); + break; + case "FeatureRef": + this.ParseFeatureRefElement(child, ComplexReferenceParentType.Feature, id); + break; + case "MergeRef": + this.ParseMergeRefElement(child, ComplexReferenceParentType.Feature, id); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -4968,21 +4964,21 @@ namespace WixToolset.Core [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] private void ParseFeatureGroupElement(XElement node, ComplexReferenceParentType parentType, string parentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -4997,37 +4993,37 @@ namespace WixToolset.Core id = Identifier.Invalid; } - int lastDisplay = 0; - foreach (XElement child in node.Elements()) + var lastDisplay = 0; + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "ComponentGroupRef": - this.ParseComponentGroupRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id, null); - break; - case "ComponentRef": - this.ParseComponentRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id, null); - break; - case "Component": - this.ParseComponentElement(child, ComplexReferenceParentType.FeatureGroup, id.Id, null, CompilerConstants.IntegerNotSet, null, null); - break; - case "Feature": - this.ParseFeatureElement(child, ComplexReferenceParentType.FeatureGroup, id.Id, ref lastDisplay); - break; - case "FeatureGroupRef": - this.ParseFeatureGroupRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id); - break; - case "FeatureRef": - this.ParseFeatureRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id); - break; - case "MergeRef": - this.ParseMergeRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "ComponentGroupRef": + this.ParseComponentGroupRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id, null); + break; + case "ComponentRef": + this.ParseComponentRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id, null); + break; + case "Component": + this.ParseComponentElement(child, ComplexReferenceParentType.FeatureGroup, id.Id, null, CompilerConstants.IntegerNotSet, null, null); + break; + case "Feature": + this.ParseFeatureElement(child, ComplexReferenceParentType.FeatureGroup, id.Id, ref lastDisplay); + break; + case "FeatureGroupRef": + this.ParseFeatureGroupRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id); + break; + case "FeatureRef": + this.ParseFeatureRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id); + break; + case "MergeRef": + this.ParseMergeRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -5055,30 +5051,30 @@ namespace WixToolset.Core { Debug.Assert(ComplexReferenceParentType.Feature == parentType || ComplexReferenceParentType.FeatureGroup == parentType || ComplexReferenceParentType.ComponentGroup == parentType || ComplexReferenceParentType.Product == parentType); - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - YesNoType ignoreParent = YesNoType.NotSet; - YesNoType primary = YesNoType.NotSet; + var ignoreParent = YesNoType.NotSet; + var primary = YesNoType.NotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "WixFeatureGroup", id); - break; - case "IgnoreParent": - ignoreParent = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Primary": - primary = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "WixFeatureGroup", id); + break; + case "IgnoreParent": + ignoreParent = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Primary": + primary = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -5110,74 +5106,74 @@ namespace WixToolset.Core /// Identifier of parent component. private void ParseEnvironmentElement(XElement node, string componentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string action = null; string name = null; - Wix.Environment.PartType partType = Wix.Environment.PartType.NotSet; + var partType = Wix.Environment.PartType.NotSet; string part = null; - bool permanent = false; - string separator = ";"; // default to ';' - bool system = false; + var permanent = false; + var separator = ";"; // default to ';' + var system = false; string text = null; - string uninstall = "-"; // default to remove at uninstall + var uninstall = "-"; // default to remove at uninstall - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Action": - string value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < value.Length) - { - Wix.Environment.ActionType actionType = Wix.Environment.ParseActionType(value); - switch (actionType) - { - case Wix.Environment.ActionType.create: - action = "+"; - break; - case Wix.Environment.ActionType.set: - action = "="; - break; - case Wix.Environment.ActionType.remove: - action = "!"; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, value, "create", "set", "remove")); - break; - } - } - break; - case "Name": - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Part": - part = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (!Wix.Environment.TryParsePartType(part, out partType)) + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Action": + var value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < value.Length) + { + var actionType = Wix.Environment.ParseActionType(value); + switch (actionType) { - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Part", part, "all", "first", "last")); + case Wix.Environment.ActionType.create: + action = "+"; + break; + case Wix.Environment.ActionType.set: + action = "="; + break; + case Wix.Environment.ActionType.remove: + action = "!"; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, value, "create", "set", "remove")); + break; } - break; - case "Permanent": - permanent = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Separator": - separator = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "System": - system = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Value": - text = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + case "Name": + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Part": + part = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (!Wix.Environment.TryParsePartType(part, out partType)) + { + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Part", part, "all", "first", "last")); + } + break; + case "Permanent": + permanent = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Separator": + separator = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "System": + system = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Value": + text = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -5205,14 +5201,14 @@ namespace WixToolset.Core switch (partType) { - case Wix.Environment.PartType.all: - break; - case Wix.Environment.PartType.first: - text = String.Concat(text, separator, "[~]"); - break; - case Wix.Environment.PartType.last: - text = String.Concat("[~]", separator, text); - break; + case Wix.Environment.PartType.all: + break; + case Wix.Environment.PartType.first: + text = String.Concat(text, separator, "[~]"); + break; + case Wix.Environment.PartType.last: + text = String.Concat("[~]", separator, text); + break; } } @@ -5238,21 +5234,21 @@ namespace WixToolset.Core /// Element to parse. private void ParseErrorElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - int id = CompilerConstants.IntegerNotSet; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var id = CompilerConstants.IntegerNotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -5286,38 +5282,38 @@ namespace WixToolset.Core /// ProgId for extension. private void ParseExtensionElement(XElement node, string componentId, YesNoType advertise, string progId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string extension = null; string mime = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - extension = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Advertise": - YesNoType extensionAdvertise = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - if ((YesNoType.No == advertise && YesNoType.Yes == extensionAdvertise) || (YesNoType.Yes == advertise && YesNoType.No == extensionAdvertise)) - { - this.Core.Write(ErrorMessages.AdvertiseStateMustMatch(sourceLineNumbers, extensionAdvertise.ToString(), advertise.ToString())); - } - advertise = extensionAdvertise; - break; - case "ContentType": - mime = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + extension = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Advertise": + var extensionAdvertise = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + if ((YesNoType.No == advertise && YesNoType.Yes == extensionAdvertise) || (YesNoType.Yes == advertise && YesNoType.No == extensionAdvertise)) + { + this.Core.Write(ErrorMessages.AdvertiseStateMustMatch(sourceLineNumbers, extensionAdvertise.ToString(), advertise.ToString())); + } + advertise = extensionAdvertise; + break; + case "ContentType": + mime = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else { - Dictionary context = new Dictionary() { { "ProgId", progId }, { "ComponentId", componentId } }; + var context = new Dictionary() { { "ProgId", progId }, { "ComponentId", componentId } }; this.Core.ParseExtensionAttribute(node, attrib, context); } } @@ -5327,25 +5323,25 @@ namespace WixToolset.Core advertise = YesNoType.No; } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Verb": - this.ParseVerbElement(child, extension, progId, componentId, advertise); - break; - case "MIME": - string newMime = this.ParseMIMEElement(child, extension, componentId, advertise); - if (null != newMime && null == mime) - { - mime = newMime; - } - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "Verb": + this.ParseVerbElement(child, extension, progId, componentId, advertise); + break; + case "MIME": + var newMime = this.ParseMIMEElement(child, extension, componentId, advertise); + if (null != newMime && null == mime) + { + mime = newMime; + } + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -5394,33 +5390,33 @@ namespace WixToolset.Core [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] private YesNoType ParseFileElement(XElement node, string componentId, string directoryId, int diskId, string sourcePath, out string possibleKeyPath, bool win64Component, string componentGuid) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - FileAssemblyType assemblyType = FileAssemblyType.NotAnAssembly; + var assemblyType = FileAssemblyType.NotAnAssembly; string assemblyApplication = null; string assemblyManifest = null; string bindPath = null; //int bits = MsiInterop.MsidbFileAttributesVital; - bool readOnly = false; - bool checksum = false; + var readOnly = false; + var checksum = false; bool? compressed = null; - bool hidden = false; - bool system = false; - bool vital = true; // assume all files are vital. + var hidden = false; + var system = false; + var vital = true; // assume all files are vital. string companionFile = null; string defaultLanguage = null; - int defaultSize = 0; + var defaultSize = 0; string defaultVersion = null; string fontTitle = null; - bool generatedShortFileName = false; - YesNoType keyPath = YesNoType.NotSet; + var generatedShortFileName = false; + var keyPath = YesNoType.NotSet; string name = null; - int patchGroup = CompilerConstants.IntegerNotSet; - bool patchIgnore = false; - bool patchIncludeWholeFile = false; - bool patchAllowIgnoreOnError = false; + var patchGroup = CompilerConstants.IntegerNotSet; + var patchIgnore = false; + var patchIncludeWholeFile = false; + var patchAllowIgnoreOnError = false; string ignoreLengths = null; string ignoreOffsets = null; @@ -5429,188 +5425,188 @@ namespace WixToolset.Core string symbols = null; string procArch = null; - int selfRegCost = CompilerConstants.IntegerNotSet; + var selfRegCost = CompilerConstants.IntegerNotSet; string shortName = null; - string source = sourcePath; // assume we'll use the parents as the source for this file - bool sourceSet = false; + var source = sourcePath; // assume we'll use the parents as the source for this file + var sourceSet = false; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Assembly": - string assemblyValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < assemblyValue.Length) + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Assembly": + var assemblyValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < assemblyValue.Length) + { + var parsedAssemblyType = Wix.File.ParseAssemblyType(assemblyValue); + switch (parsedAssemblyType) { - Wix.File.AssemblyType parsedAssemblyType = Wix.File.ParseAssemblyType(assemblyValue); - switch (parsedAssemblyType) - { - case Wix.File.AssemblyType.net: - assemblyType = FileAssemblyType.DotNetAssembly; - break; - case Wix.File.AssemblyType.no: - assemblyType = FileAssemblyType.NotAnAssembly; - break; - case Wix.File.AssemblyType.win32: - assemblyType = FileAssemblyType.Win32Assembly; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, "File", "Assembly", assemblyValue, "no", "win32", ".net")); - break; - } - } - break; - case "AssemblyApplication": - assemblyApplication = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "File", assemblyApplication); - break; - case "AssemblyManifest": - assemblyManifest = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "File", assemblyManifest); - break; - case "BindPath": - bindPath = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); - break; - case "Checksum": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - checksum = true; - //bits |= MsiInterop.MsidbFileAttributesChecksum; - } - break; - case "CompanionFile": - companionFile = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "File", companionFile); - break; - case "Compressed": - YesNoDefaultType compressedValue = this.Core.GetAttributeYesNoDefaultValue(sourceLineNumbers, attrib); - if (YesNoDefaultType.Yes == compressedValue) - { - compressed = true; - //bits |= MsiInterop.MsidbFileAttributesCompressed; - } - else if (YesNoDefaultType.No == compressedValue) - { - compressed = false; - //bits |= MsiInterop.MsidbFileAttributesNoncompressed; - } - break; - case "DefaultLanguage": - defaultLanguage = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "DefaultSize": - defaultSize = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); - break; - case "DefaultVersion": - defaultVersion = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "DiskId": - diskId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); - break; - case "FontTitle": - fontTitle = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Hidden": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - hidden = true; - //bits |= MsiInterop.MsidbFileAttributesHidden; - } - break; - case "KeyPath": - keyPath = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Name": - name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); - break; - case "PatchGroup": - patchGroup = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, int.MaxValue); - break; - case "PatchIgnore": - patchIgnore = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "PatchWholeFile": - patchIncludeWholeFile = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "PatchAllowIgnoreOnError": - patchAllowIgnoreOnError = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "ProcessorArchitecture": - string procArchValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < procArchValue.Length) - { - Wix.File.ProcessorArchitectureType procArchType = Wix.File.ParseProcessorArchitectureType(procArchValue); - switch (procArchType) - { - case Wix.File.ProcessorArchitectureType.msil: - procArch = "MSIL"; - break; - case Wix.File.ProcessorArchitectureType.x86: - procArch = "x86"; - break; - case Wix.File.ProcessorArchitectureType.x64: - procArch = "amd64"; - break; - case Wix.File.ProcessorArchitectureType.ia64: - procArch = "ia64"; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, "File", "ProcessorArchitecture", procArchValue, "msil", "x86", "x64", "ia64")); - break; - } - } - break; - case "ReadOnly": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - readOnly = true; - //bits |= MsiInterop.MsidbFileAttributesReadOnly; - } - break; - case "SelfRegCost": - selfRegCost = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "ShortName": - shortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false); - break; - case "Source": - source = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - sourceSet = true; - break; - case "System": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - system = true; - //bits |= MsiInterop.MsidbFileAttributesSystem; - } - break; - case "TrueType": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - fontTitle = String.Empty; - } - break; - case "Vital": - YesNoType isVital = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - if (YesNoType.Yes == isVital) - { - vital = true; - //bits |= MsiInterop.MsidbFileAttributesVital; + case Wix.File.AssemblyType.net: + assemblyType = FileAssemblyType.DotNetAssembly; + break; + case Wix.File.AssemblyType.no: + assemblyType = FileAssemblyType.NotAnAssembly; + break; + case Wix.File.AssemblyType.win32: + assemblyType = FileAssemblyType.Win32Assembly; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, "File", "Assembly", assemblyValue, "no", "win32", ".net")); + break; } - else if (YesNoType.No == isVital) + } + break; + case "AssemblyApplication": + assemblyApplication = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "File", assemblyApplication); + break; + case "AssemblyManifest": + assemblyManifest = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "File", assemblyManifest); + break; + case "BindPath": + bindPath = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); + break; + case "Checksum": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + checksum = true; + //bits |= MsiInterop.MsidbFileAttributesChecksum; + } + break; + case "CompanionFile": + companionFile = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "File", companionFile); + break; + case "Compressed": + var compressedValue = this.Core.GetAttributeYesNoDefaultValue(sourceLineNumbers, attrib); + if (YesNoDefaultType.Yes == compressedValue) + { + compressed = true; + //bits |= MsiInterop.MsidbFileAttributesCompressed; + } + else if (YesNoDefaultType.No == compressedValue) + { + compressed = false; + //bits |= MsiInterop.MsidbFileAttributesNoncompressed; + } + break; + case "DefaultLanguage": + defaultLanguage = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DefaultSize": + defaultSize = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int32.MaxValue); + break; + case "DefaultVersion": + defaultVersion = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DiskId": + diskId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, Int16.MaxValue); + break; + case "FontTitle": + fontTitle = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Hidden": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + hidden = true; + //bits |= MsiInterop.MsidbFileAttributesHidden; + } + break; + case "KeyPath": + keyPath = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); + break; + case "PatchGroup": + patchGroup = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, Int32.MaxValue); + break; + case "PatchIgnore": + patchIgnore = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "PatchWholeFile": + patchIncludeWholeFile = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "PatchAllowIgnoreOnError": + patchAllowIgnoreOnError = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "ProcessorArchitecture": + var procArchValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < procArchValue.Length) + { + var procArchType = Wix.File.ParseProcessorArchitectureType(procArchValue); + switch (procArchType) { - vital = false; - //bits &= ~MsiInterop.MsidbFileAttributesVital; + case Wix.File.ProcessorArchitectureType.msil: + procArch = "MSIL"; + break; + case Wix.File.ProcessorArchitectureType.x86: + procArch = "x86"; + break; + case Wix.File.ProcessorArchitectureType.x64: + procArch = "amd64"; + break; + case Wix.File.ProcessorArchitectureType.ia64: + procArch = "ia64"; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, "File", "ProcessorArchitecture", procArchValue, "msil", "x86", "x64", "ia64")); + break; } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + case "ReadOnly": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + readOnly = true; + //bits |= MsiInterop.MsidbFileAttributesReadOnly; + } + break; + case "SelfRegCost": + selfRegCost = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "ShortName": + shortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false); + break; + case "Source": + source = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + sourceSet = true; + break; + case "System": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + system = true; + //bits |= MsiInterop.MsidbFileAttributesSystem; + } + break; + case "TrueType": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + fontTitle = String.Empty; + } + break; + case "Vital": + var isVital = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + if (YesNoType.Yes == isVital) + { + vital = true; + //bits |= MsiInterop.MsidbFileAttributesVital; + } + else if (YesNoType.No == isVital) + { + vital = false; + //bits &= ~MsiInterop.MsidbFileAttributesVital; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -5685,66 +5681,66 @@ namespace WixToolset.Core } } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "AppId": - this.ParseAppIdElement(child, componentId, YesNoType.NotSet, id.Id, null, null); - break; - case "AssemblyName": - this.ParseAssemblyName(child, componentId); - break; - case "Class": - this.ParseClassElement(child, componentId, YesNoType.NotSet, id.Id, null, null, null); - break; - case "CopyFile": - this.ParseCopyFileElement(child, componentId, id.Id); - break; - case "IgnoreRange": - this.ParseRangeElement(child, ref ignoreOffsets, ref ignoreLengths); - break; - case "ODBCDriver": - this.ParseODBCDriverOrTranslator(child, componentId, id.Id, TupleDefinitionType.ODBCDriver); - break; - case "ODBCTranslator": - this.ParseODBCDriverOrTranslator(child, componentId, id.Id, TupleDefinitionType.ODBCTranslator); - break; - case "Permission": - this.ParsePermissionElement(child, id.Id, "File"); - break; - case "PermissionEx": - this.ParsePermissionExElement(child, id.Id, "File"); - break; - case "ProtectRange": - this.ParseRangeElement(child, ref protectOffsets, ref protectLengths); - break; - case "Shortcut": - this.ParseShortcutElement(child, componentId, node.Name.LocalName, id.Id, keyPath); - break; - case "SymbolPath": - if (null != symbols) - { - symbols += ";" + this.ParseSymbolPathElement(child); - } - else - { - symbols = this.ParseSymbolPathElement(child); - } - break; - case "TypeLib": - this.ParseTypeLibElement(child, componentId, id.Id, win64Component); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "AppId": + this.ParseAppIdElement(child, componentId, YesNoType.NotSet, id.Id, null, null); + break; + case "AssemblyName": + this.ParseAssemblyName(child, componentId); + break; + case "Class": + this.ParseClassElement(child, componentId, YesNoType.NotSet, id.Id, null, null, null); + break; + case "CopyFile": + this.ParseCopyFileElement(child, componentId, id.Id); + break; + case "IgnoreRange": + this.ParseRangeElement(child, ref ignoreOffsets, ref ignoreLengths); + break; + case "ODBCDriver": + this.ParseODBCDriverOrTranslator(child, componentId, id.Id, TupleDefinitionType.ODBCDriver); + break; + case "ODBCTranslator": + this.ParseODBCDriverOrTranslator(child, componentId, id.Id, TupleDefinitionType.ODBCTranslator); + break; + case "Permission": + this.ParsePermissionElement(child, id.Id, "File"); + break; + case "PermissionEx": + this.ParsePermissionExElement(child, id.Id, "File"); + break; + case "ProtectRange": + this.ParseRangeElement(child, ref protectOffsets, ref protectLengths); + break; + case "Shortcut": + this.ParseShortcutElement(child, componentId, node.Name.LocalName, id.Id, keyPath); + break; + case "SymbolPath": + if (null != symbols) + { + symbols += ";" + this.ParseSymbolPathElement(child); + } + else + { + symbols = this.ParseSymbolPathElement(child); + } + break; + case "TypeLib": + this.ParseTypeLibElement(child, componentId, id.Id, win64Component); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else { - Dictionary context = new Dictionary() { { "FileId", id.Id }, { "ComponentId", componentId }, { "Win64", win64Component.ToString() } }; + var context = new Dictionary() { { "FileId", id.Id }, { "ComponentId", componentId }, { "Win64", win64Component.ToString() } }; this.Core.ParseExtensionElement(node, child, context); } } @@ -5752,7 +5748,7 @@ namespace WixToolset.Core if (!this.Core.EncounteredError) { - PatchAttributeType patchAttributes = PatchAttributeType.None; + var patchAttributes = PatchAttributeType.None; if (patchIgnore) { patchAttributes |= PatchAttributeType.Ignore; @@ -5895,57 +5891,57 @@ namespace WixToolset.Core /// Signature of search element. private string ParseFileSearchElement(XElement node, string parentSignature, bool parentDirectorySearch, int parentDepth) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string languages = null; - int minDate = CompilerConstants.IntegerNotSet; - int maxDate = CompilerConstants.IntegerNotSet; - int maxSize = CompilerConstants.IntegerNotSet; - int minSize = CompilerConstants.IntegerNotSet; + var minDate = CompilerConstants.IntegerNotSet; + var maxDate = CompilerConstants.IntegerNotSet; + var maxSize = CompilerConstants.IntegerNotSet; + var minSize = CompilerConstants.IntegerNotSet; string maxVersion = null; string minVersion = null; string name = null; string shortName = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Name": - name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); - break; - case "MinVersion": - minVersion = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "MaxVersion": - maxVersion = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "MinSize": - minSize = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); - break; - case "MaxSize": - maxSize = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); - break; - case "MinDate": - minDate = this.Core.GetAttributeDateTimeValue(sourceLineNumbers, attrib); - break; - case "MaxDate": - maxDate = this.Core.GetAttributeDateTimeValue(sourceLineNumbers, attrib); - break; - case "Languages": - languages = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "ShortName": - shortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); + break; + case "MinVersion": + minVersion = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "MaxVersion": + maxVersion = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "MinSize": + minSize = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int32.MaxValue); + break; + case "MaxSize": + maxSize = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int32.MaxValue); + break; + case "MinDate": + minDate = this.Core.GetAttributeDateTimeValue(sourceLineNumbers, attrib); + break; + case "MaxDate": + maxDate = this.Core.GetAttributeDateTimeValue(sourceLineNumbers, attrib); + break; + case "Languages": + languages = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "ShortName": + shortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -5989,7 +5985,7 @@ namespace WixToolset.Core } } - bool isSameId = String.Equals(id.Id, parentSignature, StringComparison.Ordinal); + var isSameId = String.Equals(id.Id, parentSignature, StringComparison.Ordinal); if (parentDirectorySearch) { // If searching for the parent directory, the Id attribute @@ -6067,24 +6063,24 @@ namespace WixToolset.Core /// Element to parse. private void ParseFragmentElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; this.activeName = null; this.activeLanguage = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -6097,158 +6093,158 @@ namespace WixToolset.Core this.Core.CreateActiveSection(id, SectionType.Fragment, 0, this.Context.CompilationId); - int featureDisplay = 0; - foreach (XElement child in node.Elements()) + var featureDisplay = 0; + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "_locDefinition": - break; - case "AdminExecuteSequence": - this.ParseSequenceElement(child, child.Name.LocalName); - break; - case "AdminUISequence": - this.ParseSequenceElement(child, child.Name.LocalName); - break; - case "AdvertiseExecuteSequence": - this.ParseSequenceElement(child, child.Name.LocalName); - break; - case "InstallExecuteSequence": - this.ParseSequenceElement(child, child.Name.LocalName); - break; - case "InstallUISequence": - this.ParseSequenceElement(child, child.Name.LocalName); - break; - case "AppId": - this.ParseAppIdElement(child, null, YesNoType.Yes, null, null, null); - break; - case "Binary": - this.ParseBinaryElement(child); - break; - case "BootstrapperApplication": - this.ParseBootstrapperApplicationElement(child); - break; - case "BootstrapperApplicationRef": - this.ParseBootstrapperApplicationRefElement(child); - break; - case "ComplianceCheck": - this.ParseComplianceCheckElement(child); - break; - case "Component": - this.ParseComponentElement(child, ComplexReferenceParentType.Unknown, null, null, CompilerConstants.IntegerNotSet, null, null); - break; - case "ComponentGroup": - this.ParseComponentGroupElement(child, ComplexReferenceParentType.Unknown, id); - break; - case "Condition": - this.ParseConditionElement(child, node.Name.LocalName, null, null); - break; - case "Container": - this.ParseContainerElement(child); - break; - case "CustomAction": - this.ParseCustomActionElement(child); - break; - case "CustomActionRef": - this.ParseSimpleRefElement(child, "CustomAction"); - break; - case "CustomTable": - this.ParseCustomTableElement(child); - break; - case "Directory": - this.ParseDirectoryElement(child, null, CompilerConstants.IntegerNotSet, String.Empty); - break; - case "DirectoryRef": - this.ParseDirectoryRefElement(child); - break; - case "EmbeddedChainer": - this.ParseEmbeddedChainerElement(child); - break; - case "EmbeddedChainerRef": - this.ParseSimpleRefElement(child, "MsiEmbeddedChainer"); - break; - case "EnsureTable": - this.ParseEnsureTableElement(child); - break; - case "Feature": - this.ParseFeatureElement(child, ComplexReferenceParentType.Unknown, null, ref featureDisplay); - break; - case "FeatureGroup": - this.ParseFeatureGroupElement(child, ComplexReferenceParentType.Unknown, id); - break; - case "FeatureRef": - this.ParseFeatureRefElement(child, ComplexReferenceParentType.Unknown, null); - break; - case "Icon": - this.ParseIconElement(child); - break; - case "IgnoreModularization": - this.ParseIgnoreModularizationElement(child); - break; - case "Media": - this.ParseMediaElement(child, null); - break; - case "MediaTemplate": - this.ParseMediaTemplateElement(child, null); - break; - case "PackageGroup": - this.ParsePackageGroupElement(child); - break; - case "PackageCertificates": - case "PatchCertificates": - this.ParseCertificatesElement(child); - break; - case "PatchFamily": - this.ParsePatchFamilyElement(child, ComplexReferenceParentType.Unknown, id); - break; - case "PatchFamilyGroup": - this.ParsePatchFamilyGroupElement(child, ComplexReferenceParentType.Unknown, id); - break; - case "PatchFamilyGroupRef": - this.ParsePatchFamilyGroupRefElement(child, ComplexReferenceParentType.Unknown, id); - break; - case "PayloadGroup": - this.ParsePayloadGroupElement(child, ComplexReferenceParentType.Unknown, null); - break; - case "Property": - this.ParsePropertyElement(child); - break; - case "PropertyRef": - this.ParseSimpleRefElement(child, "Property"); - break; - case "RelatedBundle": - this.ParseRelatedBundleElement(child); - break; - case "SetDirectory": - this.ParseSetDirectoryElement(child); - break; - case "SetProperty": - this.ParseSetPropertyElement(child); - break; - case "SFPCatalog": - string parentName = null; - this.ParseSFPCatalogElement(child, ref parentName); - break; - case "UI": - this.ParseUIElement(child); - break; - case "UIRef": - this.ParseSimpleRefElement(child, "WixUI"); - break; - case "Upgrade": - this.ParseUpgradeElement(child); - break; - case "Variable": - this.ParseVariableElement(child); - break; - case "WixVariable": - this.ParseWixVariableElement(child); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "_locDefinition": + break; + case "AdminExecuteSequence": + this.ParseSequenceElement(child, child.Name.LocalName); + break; + case "AdminUISequence": + this.ParseSequenceElement(child, child.Name.LocalName); + break; + case "AdvertiseExecuteSequence": + this.ParseSequenceElement(child, child.Name.LocalName); + break; + case "InstallExecuteSequence": + this.ParseSequenceElement(child, child.Name.LocalName); + break; + case "InstallUISequence": + this.ParseSequenceElement(child, child.Name.LocalName); + break; + case "AppId": + this.ParseAppIdElement(child, null, YesNoType.Yes, null, null, null); + break; + case "Binary": + this.ParseBinaryElement(child); + break; + case "BootstrapperApplication": + this.ParseBootstrapperApplicationElement(child); + break; + case "BootstrapperApplicationRef": + this.ParseBootstrapperApplicationRefElement(child); + break; + case "ComplianceCheck": + this.ParseComplianceCheckElement(child); + break; + case "Component": + this.ParseComponentElement(child, ComplexReferenceParentType.Unknown, null, null, CompilerConstants.IntegerNotSet, null, null); + break; + case "ComponentGroup": + this.ParseComponentGroupElement(child, ComplexReferenceParentType.Unknown, id); + break; + case "Condition": + this.ParseConditionElement(child, node.Name.LocalName, null, null); + break; + case "Container": + this.ParseContainerElement(child); + break; + case "CustomAction": + this.ParseCustomActionElement(child); + break; + case "CustomActionRef": + this.ParseSimpleRefElement(child, "CustomAction"); + break; + case "CustomTable": + this.ParseCustomTableElement(child); + break; + case "Directory": + this.ParseDirectoryElement(child, null, CompilerConstants.IntegerNotSet, String.Empty); + break; + case "DirectoryRef": + this.ParseDirectoryRefElement(child); + break; + case "EmbeddedChainer": + this.ParseEmbeddedChainerElement(child); + break; + case "EmbeddedChainerRef": + this.ParseSimpleRefElement(child, "MsiEmbeddedChainer"); + break; + case "EnsureTable": + this.ParseEnsureTableElement(child); + break; + case "Feature": + this.ParseFeatureElement(child, ComplexReferenceParentType.Unknown, null, ref featureDisplay); + break; + case "FeatureGroup": + this.ParseFeatureGroupElement(child, ComplexReferenceParentType.Unknown, id); + break; + case "FeatureRef": + this.ParseFeatureRefElement(child, ComplexReferenceParentType.Unknown, null); + break; + case "Icon": + this.ParseIconElement(child); + break; + case "IgnoreModularization": + this.ParseIgnoreModularizationElement(child); + break; + case "Media": + this.ParseMediaElement(child, null); + break; + case "MediaTemplate": + this.ParseMediaTemplateElement(child, null); + break; + case "PackageGroup": + this.ParsePackageGroupElement(child); + break; + case "PackageCertificates": + case "PatchCertificates": + this.ParseCertificatesElement(child); + break; + case "PatchFamily": + this.ParsePatchFamilyElement(child, ComplexReferenceParentType.Unknown, id); + break; + case "PatchFamilyGroup": + this.ParsePatchFamilyGroupElement(child, ComplexReferenceParentType.Unknown, id); + break; + case "PatchFamilyGroupRef": + this.ParsePatchFamilyGroupRefElement(child, ComplexReferenceParentType.Unknown, id); + break; + case "PayloadGroup": + this.ParsePayloadGroupElement(child, ComplexReferenceParentType.Unknown, null); + break; + case "Property": + this.ParsePropertyElement(child); + break; + case "PropertyRef": + this.ParseSimpleRefElement(child, "Property"); + break; + case "RelatedBundle": + this.ParseRelatedBundleElement(child); + break; + case "SetDirectory": + this.ParseSetDirectoryElement(child); + break; + case "SetProperty": + this.ParseSetPropertyElement(child); + break; + case "SFPCatalog": + string parentName = null; + this.ParseSFPCatalogElement(child, ref parentName); + break; + case "UI": + this.ParseUIElement(child); + break; + case "UIRef": + this.ParseSimpleRefElement(child, "WixUI"); + break; + case "Upgrade": + this.ParseUpgradeElement(child); + break; + case "Variable": + this.ParseVariableElement(child); + break; + case "WixVariable": + this.ParseWixVariableElement(child); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -6275,63 +6271,62 @@ namespace WixToolset.Core /// The condition if one was found. private string ParseConditionElement(XElement node, string parentElementLocalName, string id, string dialog) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string action = null; string condition = null; - int level = CompilerConstants.IntegerNotSet; + var level = CompilerConstants.IntegerNotSet; string message = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Action": - if ("Control" == parentElementLocalName) + case "Action": + if ("Control" == parentElementLocalName) + { + action = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < action.Length) { - action = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < action.Length) + if (Wix.Condition.TryParseActionType(action, out var actionType)) { - Wix.Condition.ActionType actionType; - if (Wix.Condition.TryParseActionType(action, out actionType)) - { - action = Compiler.UppercaseFirstChar(action); - } - else - { - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, action, "default", "disable", "enable", "hide", "show")); - } + action = Compiler.UppercaseFirstChar(action); + } + else + { + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, action, "default", "disable", "enable", "hide", "show")); } } - else - { - this.Core.UnexpectedAttribute(node, attrib); - } - break; - case "Level": - if ("Feature" == parentElementLocalName) - { - level = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - } - else - { - this.Core.UnexpectedAttribute(node, attrib); - } - break; - case "Message": - if ("Fragment" == parentElementLocalName || "Product" == parentElementLocalName) - { - message = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - } - else - { - this.Core.UnexpectedAttribute(node, attrib); - } - break; - default: + } + else + { this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + case "Level": + if ("Feature" == parentElementLocalName) + { + level = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + } + else + { + this.Core.UnexpectedAttribute(node, attrib); + } + break; + case "Message": + if ("Fragment" == parentElementLocalName || "Product" == parentElementLocalName) + { + message = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + } + else + { + this.Core.UnexpectedAttribute(node, attrib); + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -6354,50 +6349,50 @@ namespace WixToolset.Core switch (parentElementLocalName) { - case "Control": - if (null == action) - { - this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Action")); - } + case "Control": + if (null == action) + { + this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Action")); + } - if (!this.Core.EncounteredError) - { - var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.ControlCondition); - row.Set(0, dialog); - row.Set(1, id); - row.Set(2, action); - row.Set(3, condition); - } - break; - case "Feature": - if (CompilerConstants.IntegerNotSet == level) - { - this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Level")); - level = CompilerConstants.IllegalInteger; - } + if (!this.Core.EncounteredError) + { + var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.ControlCondition); + row.Set(0, dialog); + row.Set(1, id); + row.Set(2, action); + row.Set(3, condition); + } + break; + case "Feature": + if (CompilerConstants.IntegerNotSet == level) + { + this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Level")); + level = CompilerConstants.IllegalInteger; + } - if (!this.Core.EncounteredError) - { - var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.Condition); - row.Set(0, id); - row.Set(1, level); - row.Set(2, condition); - } - break; - case "Fragment": - case "Product": - if (null == message) - { - this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Message")); - } + if (!this.Core.EncounteredError) + { + var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.Condition); + row.Set(0, id); + row.Set(1, level); + row.Set(2, condition); + } + break; + case "Fragment": + case "Product": + if (null == message) + { + this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Message")); + } - if (!this.Core.EncounteredError) - { - var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.LaunchCondition); - row.Set(0, condition); - row.Set(1, message); - } - break; + if (!this.Core.EncounteredError) + { + var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.LaunchCondition); + row.Set(0, condition); + row.Set(1, message); + } + break; } return condition; @@ -6410,9 +6405,9 @@ namespace WixToolset.Core /// Identifier of the parent component. private void ParseIniFileElement(XElement node, string componentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - int action = CompilerConstants.IntegerNotSet; + var action = CompilerConstants.IntegerNotSet; string directory = null; string key = null; string name = null; @@ -6421,64 +6416,64 @@ namespace WixToolset.Core TupleDefinitionType tableName; string value = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Action": - string actionValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < actionValue.Length) + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Action": + var actionValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < actionValue.Length) + { + var actionType = Wix.IniFile.ParseActionType(actionValue); + switch (actionType) { - Wix.IniFile.ActionType actionType = Wix.IniFile.ParseActionType(actionValue); - switch (actionType) - { - case Wix.IniFile.ActionType.addLine: - action = MsiInterop.MsidbIniFileActionAddLine; - break; - case Wix.IniFile.ActionType.addTag: - action = MsiInterop.MsidbIniFileActionAddTag; - break; - case Wix.IniFile.ActionType.createLine: - action = MsiInterop.MsidbIniFileActionCreateLine; - break; - case Wix.IniFile.ActionType.removeLine: - action = MsiInterop.MsidbIniFileActionRemoveLine; - break; - case Wix.IniFile.ActionType.removeTag: - action = MsiInterop.MsidbIniFileActionRemoveTag; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Action", actionValue, "addLine", "addTag", "createLine", "removeLine", "removeTag")); - break; - } + case Wix.IniFile.ActionType.addLine: + action = MsiInterop.MsidbIniFileActionAddLine; + break; + case Wix.IniFile.ActionType.addTag: + action = MsiInterop.MsidbIniFileActionAddTag; + break; + case Wix.IniFile.ActionType.createLine: + action = MsiInterop.MsidbIniFileActionCreateLine; + break; + case Wix.IniFile.ActionType.removeLine: + action = MsiInterop.MsidbIniFileActionRemoveLine; + break; + case Wix.IniFile.ActionType.removeTag: + action = MsiInterop.MsidbIniFileActionRemoveTag; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Action", actionValue, "addLine", "addTag", "createLine", "removeLine", "removeTag")); + break; } - break; - case "Directory": - directory = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "Key": - key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Name": - name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); - break; - case "Section": - section = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "ShortName": - shortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false); - break; - case "Value": - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + case "Directory": + directory = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "Key": + key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); + break; + case "Section": + section = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "ShortName": + shortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false); + break; + case "Value": + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -6554,7 +6549,7 @@ namespace WixToolset.Core if (!this.Core.EncounteredError) { var row = this.Core.CreateRow(sourceLineNumbers, tableName, id); - row.Set(1, GetMsiFilenameValue(shortName, name)); + row.Set(1, this.GetMsiFilenameValue(shortName, name)); row.Set(2, directory); row.Set(3, section); row.Set(4, key); @@ -6571,65 +6566,65 @@ namespace WixToolset.Core /// Signature for search element. private string ParseIniFileSearchElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - int field = CompilerConstants.IntegerNotSet; + var field = CompilerConstants.IntegerNotSet; string key = null; string name = null; string section = null; string shortName = null; string signature = null; - int type = 1; // default is file + var type = 1; // default is file - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Field": - field = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "Key": - key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Name": - name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); - break; - case "Section": - section = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "ShortName": - shortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false); - break; - case "Type": - string typeValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < typeValue.Length) + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Field": + field = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "Key": + key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); + break; + case "Section": + section = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "ShortName": + shortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false); + break; + case "Type": + var typeValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < typeValue.Length) + { + var typeType = Wix.IniFileSearch.ParseTypeType(typeValue); + switch (typeType) { - Wix.IniFileSearch.TypeType typeType = Wix.IniFileSearch.ParseTypeType(typeValue); - switch (typeType) - { - case Wix.IniFileSearch.TypeType.directory: - type = 0; - break; - case Wix.IniFileSearch.TypeType.file: - type = 1; - break; - case Wix.IniFileSearch.TypeType.raw: - type = 2; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Type", typeValue, "directory", "file", "registry")); - break; - } + case Wix.IniFileSearch.TypeType.directory: + type = 0; + break; + case Wix.IniFileSearch.TypeType.file: + type = 1; + break; + case Wix.IniFileSearch.TypeType.raw: + type = 2; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Type", typeValue, "directory", "file", "registry")); + break; } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -6679,54 +6674,54 @@ namespace WixToolset.Core signature = id.Id; - bool oneChild = false; - foreach (XElement child in node.Elements()) + var oneChild = false; + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); - switch (child.Name.LocalName) - { - case "DirectorySearch": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - - // directorysearch parentage should work like directory element, not the rest of the signature type because of the DrLocator.Parent column - signature = this.ParseDirectorySearchElement(child, id.Id); - break; - case "DirectorySearchRef": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - signature = this.ParseDirectorySearchRefElement(child, id.Id); - break; - case "FileSearch": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - signature = this.ParseFileSearchElement(child, id.Id, false, CompilerConstants.IntegerNotSet); - id = new Identifier(signature, AccessModifier.Private); // FileSearch signatures override parent signatures - break; - case "FileSearchRef": - if (oneChild) - { - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); - } - oneChild = true; - string newId = this.ParseSimpleRefElement(child, "Signature"); // FileSearch signatures override parent signatures - id = new Identifier(newId, AccessModifier.Private); - signature = null; - break; - default: - this.Core.UnexpectedElement(node, child); - break; + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + switch (child.Name.LocalName) + { + case "DirectorySearch": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + + // directorysearch parentage should work like directory element, not the rest of the signature type because of the DrLocator.Parent column + signature = this.ParseDirectorySearchElement(child, id.Id); + break; + case "DirectorySearchRef": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + signature = this.ParseDirectorySearchRefElement(child, id.Id); + break; + case "FileSearch": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + signature = this.ParseFileSearchElement(child, id.Id, false, CompilerConstants.IntegerNotSet); + id = new Identifier(signature, AccessModifier.Private); // FileSearch signatures override parent signatures + break; + case "FileSearchRef": + if (oneChild) + { + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName)); + } + oneChild = true; + var newId = this.ParseSimpleRefElement(child, "Signature"); // FileSearch signatures override parent signatures + id = new Identifier(newId, AccessModifier.Private); + signature = null; + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -6738,7 +6733,7 @@ namespace WixToolset.Core if (!this.Core.EncounteredError) { var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.IniLocator, id); - row.Set(1, GetMsiFilenameValue(shortName, name)); + row.Set(1, this.GetMsiFilenameValue(shortName, name)); row.Set(2, section); row.Set(3, key); if (CompilerConstants.IntegerNotSet != field) @@ -6758,22 +6753,22 @@ namespace WixToolset.Core /// Identifier of parent component. private void ParseIsolateComponentElement(XElement node, string componentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string shared = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Shared": - shared = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "Component", shared); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Shared": + shared = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "Component", shared); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -6803,10 +6798,10 @@ namespace WixToolset.Core /// The element to parse. private void ParseCertificatesElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); // no attributes are supported for this element - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { @@ -6818,25 +6813,25 @@ namespace WixToolset.Core } } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "DigitalCertificate": - string name = this.ParseDigitalCertificateElement(child); + case "DigitalCertificate": + var name = this.ParseDigitalCertificateElement(child); - if (!this.Core.EncounteredError) - { - var row = this.Core.CreateRow(sourceLineNumbers, "PatchCertificates" == node.Name.LocalName ? TupleDefinitionType.MsiPatchCertificate : TupleDefinitionType.MsiPackageCertificate); - row.Set(0, name); - row.Set(1, name); - } - break; - default: - this.Core.UnexpectedElement(node, child); - break; + if (!this.Core.EncounteredError) + { + var row = this.Core.CreateRow(sourceLineNumbers, "PatchCertificates" == node.Name.LocalName ? TupleDefinitionType.MsiPatchCertificate : TupleDefinitionType.MsiPackageCertificate); + row.Set(0, name); + row.Set(1, name); + } + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -6853,25 +6848,25 @@ namespace WixToolset.Core /// The identifier of the certificate. private string ParseDigitalCertificateElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string sourceFile = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "SourceFile": - sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "SourceFile": + sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -6916,22 +6911,22 @@ namespace WixToolset.Core /// Disk id inherited from parent media. private void ParseDigitalSignatureElement(XElement node, string diskId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string certificateId = null; string sourceFile = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "SourceFile": - sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "SourceFile": + sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -6946,18 +6941,18 @@ namespace WixToolset.Core Debug.Assert(62 >= "MsiDigitalSignature.Media.".Length + diskId.Length); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "DigitalCertificate": - certificateId = this.ParseDigitalCertificateElement(child); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "DigitalCertificate": + certificateId = this.ParseDigitalCertificateElement(child); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -6988,78 +6983,78 @@ namespace WixToolset.Core /// The parent element. private void ParseMajorUpgradeElement(XElement node, IDictionary contextValues) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - int options = MsiInterop.MsidbUpgradeAttributesMigrateFeatures; - bool allowDowngrades = false; - bool allowSameVersionUpgrades = false; - bool blockUpgrades = false; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var options = MsiInterop.MsidbUpgradeAttributesMigrateFeatures; + var allowDowngrades = false; + var allowSameVersionUpgrades = false; + var blockUpgrades = false; string downgradeErrorMessage = null; string disallowUpgradeErrorMessage = null; string removeFeatures = null; string schedule = null; - string upgradeCode = contextValues["UpgradeCode"]; + var upgradeCode = contextValues["UpgradeCode"]; if (String.IsNullOrEmpty(upgradeCode)) { this.Core.Write(ErrorMessages.ParentElementAttributeRequired(sourceLineNumbers, "Product", "UpgradeCode", node.Name.LocalName)); } - string productVersion = contextValues["ProductVersion"]; + var productVersion = contextValues["ProductVersion"]; if (String.IsNullOrEmpty(productVersion)) { this.Core.Write(ErrorMessages.ParentElementAttributeRequired(sourceLineNumbers, "Product", "Version", node.Name.LocalName)); } - string productLanguage = contextValues["ProductLanguage"]; + var productLanguage = contextValues["ProductLanguage"]; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "AllowDowngrades": - allowDowngrades = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "AllowSameVersionUpgrades": - allowSameVersionUpgrades = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Disallow": - blockUpgrades = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "DowngradeErrorMessage": - downgradeErrorMessage = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "DisallowUpgradeErrorMessage": - disallowUpgradeErrorMessage = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "MigrateFeatures": - if (YesNoType.No == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - options &= ~MsiInterop.MsidbUpgradeAttributesMigrateFeatures; - } - break; - case "IgnoreLanguage": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - productLanguage = null; - } - break; - case "IgnoreRemoveFailure": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - options |= MsiInterop.MsidbUpgradeAttributesIgnoreRemoveFailure; - } - break; - case "RemoveFeatures": - removeFeatures = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Schedule": - schedule = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "AllowDowngrades": + allowDowngrades = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "AllowSameVersionUpgrades": + allowSameVersionUpgrades = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Disallow": + blockUpgrades = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "DowngradeErrorMessage": + downgradeErrorMessage = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DisallowUpgradeErrorMessage": + disallowUpgradeErrorMessage = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "MigrateFeatures": + if (YesNoType.No == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + options &= ~MsiInterop.MsidbUpgradeAttributesMigrateFeatures; + } + break; + case "IgnoreLanguage": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + productLanguage = null; + } + break; + case "IgnoreRemoveFailure": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + options |= MsiInterop.MsidbUpgradeAttributesIgnoreRemoveFailure; + } + break; + case "RemoveFeatures": + removeFeatures = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Schedule": + schedule = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -7116,16 +7111,16 @@ namespace WixToolset.Core } row.Set(5, removeFeatures); - row.Set(6, Compiler.UpgradeDetectedProperty); + row.Set(6, Common.UpgradeDetectedProperty); // Ensure the action property is secure. - this.AddWixPropertyRow(sourceLineNumbers, new Identifier(Compiler.UpgradeDetectedProperty, AccessModifier.Public), false, true, false); + this.AddWixPropertyRow(sourceLineNumbers, new Identifier(Common.UpgradeDetectedProperty, AccessModifier.Public), false, true, false); // Add launch condition that blocks upgrades if (blockUpgrades) { row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.LaunchCondition); - row.Set(0, Compiler.UpgradePreventedCondition); + row.Set(0, Common.UpgradePreventedCondition); row.Set(1, disallowUpgradeErrorMessage); } @@ -7139,13 +7134,13 @@ namespace WixToolset.Core row.Set(3, productLanguage); row.Set(4, MsiInterop.MsidbUpgradeAttributesOnlyDetect); // row.Set(5, removeFeatures); - row.Set(6, Compiler.DowngradeDetectedProperty); + row.Set(6, Common.DowngradeDetectedProperty); // Ensure the action property is secure. - this.AddWixPropertyRow(sourceLineNumbers, new Identifier(Compiler.DowngradeDetectedProperty, AccessModifier.Public), false, true, false); + this.AddWixPropertyRow(sourceLineNumbers, new Identifier(Common.DowngradeDetectedProperty, AccessModifier.Public), false, true, false); row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.LaunchCondition); - row.Set(0, Compiler.DowngradePreventedCondition); + row.Set(0, Common.DowngradePreventedCondition); row.Set(1, downgradeErrorMessage); } @@ -7159,27 +7154,27 @@ namespace WixToolset.Core switch (schedule) { - case null: - case "afterInstallValidate": - // row.Set(4, beforeAction; - row.Set(5, "InstallValidate"); - break; - case "afterInstallInitialize": - // row.Set(4, beforeAction; - row.Set(5, "InstallInitialize"); - break; - case "afterInstallExecute": - // row.Set(4, beforeAction; - row.Set(5, "InstallExecute"); - break; - case "afterInstallExecuteAgain": - // row.Set(4, beforeAction; - row.Set(5, "InstallExecuteAgain"); - break; - case "afterInstallFinalize": - // row.Set(4, beforeAction; - row.Set(5, "InstallFinalize"); - break; + case null: + case "afterInstallValidate": + // row.Set(4, beforeAction; + row.Set(5, "InstallValidate"); + break; + case "afterInstallInitialize": + // row.Set(4, beforeAction; + row.Set(5, "InstallInitialize"); + break; + case "afterInstallExecute": + // row.Set(4, beforeAction; + row.Set(5, "InstallExecute"); + break; + case "afterInstallExecuteAgain": + // row.Set(4, beforeAction; + row.Set(5, "InstallExecuteAgain"); + break; + case "afterInstallFinalize": + // row.Set(4, beforeAction; + row.Set(5, "InstallFinalize"); + break; } } } @@ -7191,75 +7186,74 @@ namespace WixToolset.Core /// Set to the PatchId if parsing Patch/Media element otherwise null. private void ParseMediaElement(XElement node, string patchId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - int id = CompilerConstants.IntegerNotSet; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var id = CompilerConstants.IntegerNotSet; string cabinet = null; CompressionLevel? compressionLevel = null; string diskPrompt = null; string layout = null; - bool patch = null != patchId; + var patch = null != patchId; string volumeLabel = null; string source = null; string symbols = null; - YesNoType embedCab = patch ? YesNoType.Yes : YesNoType.NotSet; + var embedCab = patch ? YesNoType.Yes : YesNoType.NotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); - break; - case "Cabinet": - cabinet = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "CompressionLevel": - string compressionLevelString = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < compressionLevelString.Length) + case "Id": + id = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, Int16.MaxValue); + break; + case "Cabinet": + cabinet = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "CompressionLevel": + var compressionLevelString = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < compressionLevelString.Length) + { + if (!Wix.Enums.TryParseCompressionLevelType(compressionLevelString, out var compressionLevelType)) { - Wix.CompressionLevelType compressionLevelType; - if (!Wix.Enums.TryParseCompressionLevelType(compressionLevelString, out compressionLevelType)) - { - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, compressionLevelString, "high", "low", "medium", "mszip", "none")); - } - else - { - compressionLevel = (CompressionLevel)Enum.Parse(typeof(CompressionLevel), compressionLevelString, true); - } + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, compressionLevelString, "high", "low", "medium", "mszip", "none")); } - break; - case "DiskPrompt": - diskPrompt = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "Property", "DiskPrompt"); // ensure the output has a DiskPrompt Property defined - break; - case "EmbedCab": - embedCab = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Layout": - case "src": - if (null != layout) + else { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "Layout", "src")); + compressionLevel = (CompressionLevel)Enum.Parse(typeof(CompressionLevel), compressionLevelString, true); } + } + break; + case "DiskPrompt": + diskPrompt = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "Property", "DiskPrompt"); // ensure the output has a DiskPrompt Property defined + break; + case "EmbedCab": + embedCab = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Layout": + case "src": + if (null != layout) + { + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "Layout", "src")); + } - if ("src" == attrib.Name.LocalName) - { - this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Layout")); - } - layout = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "VolumeLabel": - volumeLabel = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Source": - source = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + if ("src" == attrib.Name.LocalName) + { + this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Layout")); + } + layout = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "VolumeLabel": + volumeLabel = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Source": + source = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -7320,50 +7314,50 @@ namespace WixToolset.Core } } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "DigitalSignature": - if (YesNoType.Yes == embedCab) - { - this.Core.Write(ErrorMessages.SignedEmbeddedCabinet(childSourceLineNumbers)); - } - else if (null == cabinet) - { - this.Core.Write(ErrorMessages.ExpectedSignedCabinetName(childSourceLineNumbers)); - } - else - { - this.ParseDigitalSignatureElement(child, id.ToString(CultureInfo.InvariantCulture.NumberFormat)); - } - break; - case "PatchBaseline": - if (patch) - { - this.ParsePatchBaselineElement(child, id); - } - else - { - this.Core.UnexpectedElement(node, child); - } - break; - case "SymbolPath": - if (null != symbols) - { - symbols += "" + this.ParseSymbolPathElement(child); - } - else - { - symbols = this.ParseSymbolPathElement(child); - } - break; - default: + case "DigitalSignature": + if (YesNoType.Yes == embedCab) + { + this.Core.Write(ErrorMessages.SignedEmbeddedCabinet(childSourceLineNumbers)); + } + else if (null == cabinet) + { + this.Core.Write(ErrorMessages.ExpectedSignedCabinetName(childSourceLineNumbers)); + } + else + { + this.ParseDigitalSignatureElement(child, id.ToString(CultureInfo.InvariantCulture.NumberFormat)); + } + break; + case "PatchBaseline": + if (patch) + { + this.ParsePatchBaselineElement(child, id); + } + else + { this.Core.UnexpectedElement(node, child); - break; + } + break; + case "SymbolPath": + if (null != symbols) + { + symbols += "" + this.ParseSymbolPathElement(child); + } + else + { + symbols = this.ParseSymbolPathElement(child); + } + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -7411,78 +7405,78 @@ namespace WixToolset.Core /// Set to the PatchId if parsing Patch/Media element otherwise null. private void ParseMediaTemplateElement(XElement node, string patchId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - string cabinetTemplate = "cab{0}.cab"; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var cabinetTemplate = "cab{0}.cab"; string compressionLevel = null; // this defaults to mszip in Binder string diskPrompt = null; - bool patch = null != patchId; + var patch = null != patchId; string volumeLabel = null; - int maximumUncompressedMediaSize = CompilerConstants.IntegerNotSet; - int maximumCabinetSizeForLargeFileSplitting = CompilerConstants.IntegerNotSet; - Wix.CompressionLevelType compressionLevelType = Wix.CompressionLevelType.NotSet; + var maximumUncompressedMediaSize = CompilerConstants.IntegerNotSet; + var maximumCabinetSizeForLargeFileSplitting = CompilerConstants.IntegerNotSet; + var compressionLevelType = Wix.CompressionLevelType.NotSet; - YesNoType embedCab = patch ? YesNoType.Yes : YesNoType.NotSet; + var embedCab = patch ? YesNoType.Yes : YesNoType.NotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "CabinetTemplate": - string authoredCabinetTemplateValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); - if (!String.IsNullOrEmpty(authoredCabinetTemplateValue)) + case "CabinetTemplate": + var authoredCabinetTemplateValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); + if (!String.IsNullOrEmpty(authoredCabinetTemplateValue)) + { + cabinetTemplate = authoredCabinetTemplateValue; + } + + // Create an example cabinet name using the maximum number of cabinets supported, 999. + var exampleCabinetName = String.Format(cabinetTemplate, "###"); + if (!this.Core.IsValidLocIdentifier(exampleCabinetName)) + { + // The example name should not match the authored template since that would nullify the + // reason for having multiple cabients. External cabinet files must also be valid file names. + if (exampleCabinetName.Equals(authoredCabinetTemplateValue) || !this.Core.IsValidLongFilename(exampleCabinetName, false)) { - cabinetTemplate = authoredCabinetTemplateValue; + this.Core.Write(ErrorMessages.InvalidCabinetTemplate(sourceLineNumbers, cabinetTemplate)); } - - // Create an example cabinet name using the maximum number of cabinets supported, 999. - string exampleCabinetName = String.Format(cabinetTemplate, "###"); - if (!this.Core.IsValidLocIdentifier(exampleCabinetName)) + else if (!this.Core.IsValidShortFilename(exampleCabinetName, false) && !Common.WixVariableRegex.Match(exampleCabinetName).Success) // ignore short names with wix variables because it rarely works out. { - // The example name should not match the authored template since that would nullify the - // reason for having multiple cabients. External cabinet files must also be valid file names. - if (exampleCabinetName.Equals(authoredCabinetTemplateValue) || !this.Core.IsValidLongFilename(exampleCabinetName, false)) - { - this.Core.Write(ErrorMessages.InvalidCabinetTemplate(sourceLineNumbers, cabinetTemplate)); - } - else if (!this.Core.IsValidShortFilename(exampleCabinetName, false) && !Common.WixVariableRegex.Match(exampleCabinetName).Success) // ignore short names with wix variables because it rarely works out. - { - this.Core.Write(WarningMessages.MediaExternalCabinetFilenameIllegal(sourceLineNumbers, node.Name.LocalName, "CabinetTemplate", cabinetTemplate)); - } + this.Core.Write(WarningMessages.MediaExternalCabinetFilenameIllegal(sourceLineNumbers, node.Name.LocalName, "CabinetTemplate", cabinetTemplate)); } - break; - case "CompressionLevel": - compressionLevel = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < compressionLevel.Length) + } + break; + case "CompressionLevel": + compressionLevel = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < compressionLevel.Length) + { + if (!Wix.Enums.TryParseCompressionLevelType(compressionLevel, out compressionLevelType)) { - if (!Wix.Enums.TryParseCompressionLevelType(compressionLevel, out compressionLevelType)) - { - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, compressionLevel, "high", "low", "medium", "mszip", "none")); - } + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, compressionLevel, "high", "low", "medium", "mszip", "none")); } - break; - case "DiskPrompt": - diskPrompt = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "Property", "DiskPrompt"); // ensure the output has a DiskPrompt Property defined - this.Core.Write(WarningMessages.ReservedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); - break; - case "EmbedCab": - embedCab = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "VolumeLabel": - volumeLabel = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - this.Core.Write(WarningMessages.ReservedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); - break; - case "MaximumUncompressedMediaSize": - maximumUncompressedMediaSize = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, int.MaxValue); - break; - case "MaximumCabinetSizeForLargeFileSplitting": - maximumCabinetSizeForLargeFileSplitting = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, CompilerCore.MinValueOfMaxCabSizeForLargeFileSplitting, CompilerCore.MaxValueOfMaxCabSizeForLargeFileSplitting); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + case "DiskPrompt": + diskPrompt = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "Property", "DiskPrompt"); // ensure the output has a DiskPrompt Property defined + this.Core.Write(WarningMessages.ReservedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + break; + case "EmbedCab": + embedCab = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "VolumeLabel": + volumeLabel = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + this.Core.Write(WarningMessages.ReservedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + break; + case "MaximumUncompressedMediaSize": + maximumUncompressedMediaSize = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, Int32.MaxValue); + break; + case "MaximumCabinetSizeForLargeFileSplitting": + maximumCabinetSizeForLargeFileSplitting = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, CompilerCore.MinValueOfMaxCabSizeForLargeFileSplitting, CompilerCore.MaxValueOfMaxCabSizeForLargeFileSplitting); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -7529,21 +7523,21 @@ namespace WixToolset.Core switch (compressionLevelType) { - case Wix.CompressionLevelType.high: - mediaTemplateRow.CompressionLevel = CompressionLevel.High; - break; - case Wix.CompressionLevelType.low: - mediaTemplateRow.CompressionLevel = CompressionLevel.Low; - break; - case Wix.CompressionLevelType.medium: - mediaTemplateRow.CompressionLevel = CompressionLevel.Medium; - break; - case Wix.CompressionLevelType.none: - mediaTemplateRow.CompressionLevel = CompressionLevel.None; - break; - case Wix.CompressionLevelType.mszip: - mediaTemplateRow.CompressionLevel = CompressionLevel.Mszip; - break; + case Wix.CompressionLevelType.high: + mediaTemplateRow.CompressionLevel = CompressionLevel.High; + break; + case Wix.CompressionLevelType.low: + mediaTemplateRow.CompressionLevel = CompressionLevel.Low; + break; + case Wix.CompressionLevelType.medium: + mediaTemplateRow.CompressionLevel = CompressionLevel.Medium; + break; + case Wix.CompressionLevelType.none: + mediaTemplateRow.CompressionLevel = CompressionLevel.None; + break; + case Wix.CompressionLevelType.mszip: + mediaTemplateRow.CompressionLevel = CompressionLevel.Mszip; + break; } } } @@ -7556,38 +7550,38 @@ namespace WixToolset.Core /// Disk id inherited from parent directory. private void ParseMergeElement(XElement node, string directoryId, int diskId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - string configData = String.Empty; - YesNoType fileCompression = YesNoType.NotSet; + var configData = String.Empty; + var fileCompression = YesNoType.NotSet; string language = null; string sourceFile = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "DiskId": - diskId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); - this.Core.CreateSimpleReference(sourceLineNumbers, "Media", diskId.ToString(CultureInfo.InvariantCulture.NumberFormat)); - break; - case "FileCompression": - fileCompression = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Language": - language = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "SourceFile": - sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "DiskId": + diskId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, Int16.MaxValue); + this.Core.CreateSimpleReference(sourceLineNumbers, "Media", diskId.ToString(CultureInfo.InvariantCulture.NumberFormat)); + break; + case "FileCompression": + fileCompression = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Language": + language = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "SourceFile": + sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -7617,25 +7611,25 @@ namespace WixToolset.Core diskId = CompilerConstants.IllegalInteger; } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "ConfigurationData": - if (0 == configData.Length) - { - configData = this.ParseConfigurationDataElement(child); - } - else - { - configData = String.Concat(configData, ",", this.ParseConfigurationDataElement(child)); - } - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "ConfigurationData": + if (0 == configData.Length) + { + configData = this.ParseConfigurationDataElement(child); + } + else + { + configData = String.Concat(configData, ",", this.ParseConfigurationDataElement(child)); + } + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -7675,25 +7669,25 @@ namespace WixToolset.Core /// String in format "name=value" with '%', ',' and '=' hex encoded. private string ParseConfigurationDataElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string name = null; string value = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Name": - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Value": - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Name": + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Value": + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -7737,26 +7731,26 @@ namespace WixToolset.Core /// Identifier for parent feature or feature group. private void ParseMergeRefElement(XElement node, ComplexReferenceParentType parentType, string parentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - YesNoType primary = YesNoType.NotSet; + var primary = YesNoType.NotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "WixMerge", id); - break; - case "Primary": - primary = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "WixMerge", id); + break; + case "Primary": + primary = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -7785,33 +7779,33 @@ namespace WixToolset.Core /// Content type if this is the default for the MIME type. private string ParseMIMEElement(XElement node, string extension, string componentId, YesNoType parentAdvertised) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string classId = null; string contentType = null; - YesNoType advertise = parentAdvertised; - YesNoType returnContentType = YesNoType.NotSet; + var advertise = parentAdvertised; + var returnContentType = YesNoType.NotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Advertise": - advertise = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Class": - classId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - case "ContentType": - contentType = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Default": - returnContentType = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Advertise": + advertise = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Class": + classId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + case "ContentType": + contentType = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Default": + returnContentType = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -7871,47 +7865,47 @@ namespace WixToolset.Core /// Element to parse. private void ParseModuleElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - int codepage = 0; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var codepage = 0; string moduleId = null; string version = null; this.activeName = null; this.activeLanguage = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - this.activeName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if ("PUT-MODULE-NAME-HERE" == this.activeName) - { - this.Core.Write(WarningMessages.PlaceholderValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, this.activeName)); - } - else - { - this.activeName = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - } - break; - case "Codepage": - codepage = this.Core.GetAttributeCodePageValue(sourceLineNumbers, attrib); - break; - case "Guid": - moduleId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - this.Core.Write(WarningMessages.DeprecatedModuleGuidAttribute(sourceLineNumbers)); - break; - case "Language": - this.activeLanguage = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "Version": - version = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + this.activeName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if ("PUT-MODULE-NAME-HERE" == this.activeName) + { + this.Core.Write(WarningMessages.PlaceholderValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, this.activeName)); + } + else + { + this.activeName = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + } + break; + case "Codepage": + codepage = this.Core.GetAttributeCodePageValue(sourceLineNumbers, attrib); + break; + case "Guid": + moduleId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + this.Core.Write(WarningMessages.DeprecatedModuleGuidAttribute(sourceLineNumbers)); + break; + case "Language": + this.activeLanguage = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "Version": + version = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -7944,110 +7938,110 @@ namespace WixToolset.Core this.compilingModule = true; // notice that we are actually building a Merge Module here this.Core.CreateActiveSection(this.activeName, SectionType.Module, codepage, this.Context.CompilationId); - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "AdminExecuteSequence": - case "AdminUISequence": - case "AdvertiseExecuteSequence": - case "InstallExecuteSequence": - case "InstallUISequence": - this.ParseSequenceElement(child, child.Name.LocalName); - break; - case "AppId": - this.ParseAppIdElement(child, null, YesNoType.Yes, null, null, null); - break; - case "Binary": - this.ParseBinaryElement(child); - break; - case "Component": - this.ParseComponentElement(child, ComplexReferenceParentType.Module, this.activeName, this.activeLanguage, CompilerConstants.IntegerNotSet, null, null); - break; - case "ComponentGroupRef": - this.ParseComponentGroupRefElement(child, ComplexReferenceParentType.Module, this.activeName, this.activeLanguage); - break; - case "ComponentRef": - this.ParseComponentRefElement(child, ComplexReferenceParentType.Module, this.activeName, this.activeLanguage); - break; - case "Configuration": - this.ParseConfigurationElement(child); - break; - case "CustomAction": - this.ParseCustomActionElement(child); - break; - case "CustomActionRef": - this.ParseSimpleRefElement(child, "CustomAction"); - break; - case "CustomTable": - this.ParseCustomTableElement(child); - break; - case "Dependency": - this.ParseDependencyElement(child); - break; - case "Directory": - this.ParseDirectoryElement(child, null, CompilerConstants.IntegerNotSet, String.Empty); - break; - case "DirectoryRef": - this.ParseDirectoryRefElement(child); - break; - case "EmbeddedChainer": - this.ParseEmbeddedChainerElement(child); - break; - case "EmbeddedChainerRef": - this.ParseSimpleRefElement(child, "MsiEmbeddedChainer"); - break; - case "EnsureTable": - this.ParseEnsureTableElement(child); - break; - case "Exclusion": - this.ParseExclusionElement(child); - break; - case "Icon": - this.ParseIconElement(child); - break; - case "IgnoreModularization": - this.ParseIgnoreModularizationElement(child); - break; - case "IgnoreTable": - this.ParseIgnoreTableElement(child); - break; - case "Package": - this.ParsePackageElement(child, null, moduleId); - break; - case "Property": - this.ParsePropertyElement(child); - break; - case "PropertyRef": - this.ParseSimpleRefElement(child, "Property"); - break; - case "SetDirectory": - this.ParseSetDirectoryElement(child); - break; - case "SetProperty": - this.ParseSetPropertyElement(child); - break; - case "SFPCatalog": - string parentName = null; - this.ParseSFPCatalogElement(child, ref parentName); - break; - case "Substitution": - this.ParseSubstitutionElement(child); - break; - case "UI": - this.ParseUIElement(child); - break; - case "UIRef": - this.ParseSimpleRefElement(child, "WixUI"); - break; - case "WixVariable": - this.ParseWixVariableElement(child); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "AdminExecuteSequence": + case "AdminUISequence": + case "AdvertiseExecuteSequence": + case "InstallExecuteSequence": + case "InstallUISequence": + this.ParseSequenceElement(child, child.Name.LocalName); + break; + case "AppId": + this.ParseAppIdElement(child, null, YesNoType.Yes, null, null, null); + break; + case "Binary": + this.ParseBinaryElement(child); + break; + case "Component": + this.ParseComponentElement(child, ComplexReferenceParentType.Module, this.activeName, this.activeLanguage, CompilerConstants.IntegerNotSet, null, null); + break; + case "ComponentGroupRef": + this.ParseComponentGroupRefElement(child, ComplexReferenceParentType.Module, this.activeName, this.activeLanguage); + break; + case "ComponentRef": + this.ParseComponentRefElement(child, ComplexReferenceParentType.Module, this.activeName, this.activeLanguage); + break; + case "Configuration": + this.ParseConfigurationElement(child); + break; + case "CustomAction": + this.ParseCustomActionElement(child); + break; + case "CustomActionRef": + this.ParseSimpleRefElement(child, "CustomAction"); + break; + case "CustomTable": + this.ParseCustomTableElement(child); + break; + case "Dependency": + this.ParseDependencyElement(child); + break; + case "Directory": + this.ParseDirectoryElement(child, null, CompilerConstants.IntegerNotSet, String.Empty); + break; + case "DirectoryRef": + this.ParseDirectoryRefElement(child); + break; + case "EmbeddedChainer": + this.ParseEmbeddedChainerElement(child); + break; + case "EmbeddedChainerRef": + this.ParseSimpleRefElement(child, "MsiEmbeddedChainer"); + break; + case "EnsureTable": + this.ParseEnsureTableElement(child); + break; + case "Exclusion": + this.ParseExclusionElement(child); + break; + case "Icon": + this.ParseIconElement(child); + break; + case "IgnoreModularization": + this.ParseIgnoreModularizationElement(child); + break; + case "IgnoreTable": + this.ParseIgnoreTableElement(child); + break; + case "Package": + this.ParsePackageElement(child, null, moduleId); + break; + case "Property": + this.ParsePropertyElement(child); + break; + case "PropertyRef": + this.ParseSimpleRefElement(child, "Property"); + break; + case "SetDirectory": + this.ParseSetDirectoryElement(child); + break; + case "SetProperty": + this.ParseSetPropertyElement(child); + break; + case "SFPCatalog": + string parentName = null; + this.ParseSFPCatalogElement(child, ref parentName); + break; + case "Substitution": + this.ParseSubstitutionElement(child); + break; + case "UI": + this.ParseUIElement(child); + break; + case "UIRef": + this.ParseSimpleRefElement(child, "WixUI"); + break; + case "WixVariable": + this.ParseWixVariableElement(child); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -8077,54 +8071,54 @@ namespace WixToolset.Core /// The element to parse. private void ParsePatchCreationElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - bool clean = true; // Default is to clean - int codepage = 0; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var clean = true; // Default is to clean + var codepage = 0; string outputPath = null; - bool productMismatches = false; - string replaceGuids = String.Empty; + var productMismatches = false; + var replaceGuids = String.Empty; string sourceList = null; string symbolFlags = null; - string targetProducts = String.Empty; - bool versionMismatches = false; - bool wholeFiles = false; + var targetProducts = String.Empty; + var versionMismatches = false; + var wholeFiles = false; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - this.activeName = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - case "AllowMajorVersionMismatches": - versionMismatches = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "AllowProductCodeMismatches": - productMismatches = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "CleanWorkingFolder": - clean = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Codepage": - codepage = this.Core.GetAttributeCodePageValue(sourceLineNumbers, attrib); - break; - case "OutputPath": - outputPath = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "SourceList": - sourceList = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "SymbolFlags": - symbolFlags = String.Format(CultureInfo.InvariantCulture, "0x{0:x8}", this.Core.GetAttributeLongValue(sourceLineNumbers, attrib, 0, uint.MaxValue)); - break; - case "WholeFilesOnly": - wholeFiles = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + this.activeName = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + case "AllowMajorVersionMismatches": + versionMismatches = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "AllowProductCodeMismatches": + productMismatches = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "CleanWorkingFolder": + clean = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Codepage": + codepage = this.Core.GetAttributeCodePageValue(sourceLineNumbers, attrib); + break; + case "OutputPath": + outputPath = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "SourceList": + sourceList = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "SymbolFlags": + symbolFlags = String.Format(CultureInfo.InvariantCulture, "0x{0:x8}", this.Core.GetAttributeLongValue(sourceLineNumbers, attrib, 0, UInt32.MaxValue)); + break; + case "WholeFilesOnly": + wholeFiles = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -8140,41 +8134,41 @@ namespace WixToolset.Core this.Core.CreateActiveSection(this.activeName, SectionType.PatchCreation, codepage, this.Context.CompilationId); - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Family": - this.ParseFamilyElement(child); - break; - case "PatchInformation": - this.ParsePatchInformationElement(child); - break; - case "PatchMetadata": - this.ParsePatchMetadataElement(child); - break; - case "PatchProperty": - this.ParsePatchPropertyElement(child, false); - break; - case "PatchSequence": - this.ParsePatchSequenceElement(child); - break; - case "ReplacePatch": - replaceGuids = String.Concat(replaceGuids, this.ParseReplacePatchElement(child)); - break; - case "TargetProductCode": - string targetProduct = this.ParseTargetProductCodeElement(child); - if (0 < targetProducts.Length) - { - targetProducts = String.Concat(targetProducts, ";"); - } - targetProducts = String.Concat(targetProducts, targetProduct); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "Family": + this.ParseFamilyElement(child); + break; + case "PatchInformation": + this.ParsePatchInformationElement(child); + break; + case "PatchMetadata": + this.ParsePatchMetadataElement(child); + break; + case "PatchProperty": + this.ParsePatchPropertyElement(child, false); + break; + case "PatchSequence": + this.ParsePatchSequenceElement(child); + break; + case "ReplacePatch": + replaceGuids = String.Concat(replaceGuids, this.ParseReplacePatchElement(child)); + break; + case "TargetProductCode": + var targetProduct = this.ParseTargetProductCodeElement(child); + if (0 < targetProducts.Length) + { + targetProducts = String.Concat(targetProducts, ";"); + } + targetProducts = String.Concat(targetProducts, targetProduct); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -8221,41 +8215,41 @@ namespace WixToolset.Core /// The element to parse. private void ParseFamilyElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - int diskId = CompilerConstants.IntegerNotSet; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var diskId = CompilerConstants.IntegerNotSet; string diskPrompt = null; string mediaSrcProp = null; string name = null; - int sequenceStart = CompilerConstants.IntegerNotSet; + var sequenceStart = CompilerConstants.IntegerNotSet; string volumeLabel = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "DiskId": - diskId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); - break; - case "DiskPrompt": - diskPrompt = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "MediaSrcProp": - mediaSrcProp = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Name": - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "SequenceStart": - sequenceStart = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, int.MaxValue); - break; - case "VolumeLabel": - volumeLabel = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "DiskId": + diskId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, Int16.MaxValue); + break; + case "DiskPrompt": + diskPrompt = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "MediaSrcProp": + mediaSrcProp = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "SequenceStart": + sequenceStart = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, Int32.MaxValue); + break; + case "VolumeLabel": + volumeLabel = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -8276,7 +8270,7 @@ namespace WixToolset.Core } else // check for illegal characters { - foreach (char character in name) + foreach (var character in name) { if (!Char.IsLetterOrDigit(character) && '_' != character) { @@ -8286,24 +8280,24 @@ namespace WixToolset.Core } } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "UpgradeImage": - this.ParseUpgradeImageElement(child, name); - break; - case "ExternalFile": - this.ParseExternalFileElement(child, name); - break; - case "ProtectFile": - this.ParseProtectFileElement(child, name); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "UpgradeImage": + this.ParseUpgradeImageElement(child, name); + break; + case "ExternalFile": + this.ParseExternalFileElement(child, name); + break; + case "ProtectFile": + this.ParseProtectFileElement(child, name); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -8338,54 +8332,54 @@ namespace WixToolset.Core /// The family for this element. private void ParseUpgradeImageElement(XElement node, string family) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string sourceFile = null; string sourcePatch = null; - List symbols = new List(); + var symbols = new List(); string upgrade = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - upgrade = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (13 < upgrade.Length) - { - this.Core.Write(ErrorMessages.IdentifierTooLongError(sourceLineNumbers, node.Name.LocalName, "Id", upgrade, 13)); - } - break; - case "SourceFile": - case "src": - if (null != sourceFile) - { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "src", "SourceFile")); - } + case "Id": + upgrade = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (13 < upgrade.Length) + { + this.Core.Write(ErrorMessages.IdentifierTooLongError(sourceLineNumbers, node.Name.LocalName, "Id", upgrade, 13)); + } + break; + case "SourceFile": + case "src": + if (null != sourceFile) + { + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "src", "SourceFile")); + } - if ("src" == attrib.Name.LocalName) - { - this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "SourceFile")); - } - sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "SourcePatch": - case "srcPatch": - if (null != sourcePatch) - { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "srcPatch", "SourcePatch")); - } + if ("src" == attrib.Name.LocalName) + { + this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "SourceFile")); + } + sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "SourcePatch": + case "srcPatch": + if (null != sourcePatch) + { + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "srcPatch", "SourcePatch")); + } - if ("srcPatch" == attrib.Name.LocalName) - { - this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "SourcePatch")); - } - sourcePatch = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + if ("srcPatch" == attrib.Name.LocalName) + { + this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "SourcePatch")); + } + sourcePatch = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -8404,24 +8398,24 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "SourceFile")); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "SymbolPath": - symbols.Add(this.ParseSymbolPathElement(child)); - break; - case "TargetImage": - this.ParseTargetImageElement(child, upgrade, family); - break; - case "UpgradeFile": - this.ParseUpgradeFileElement(child, upgrade); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "SymbolPath": + symbols.Add(this.ParseSymbolPathElement(child)); + break; + case "TargetImage": + this.ParseTargetImageElement(child, upgrade, family); + break; + case "UpgradeFile": + this.ParseUpgradeFileElement(child, upgrade); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -8448,34 +8442,34 @@ namespace WixToolset.Core /// The upgrade key for this element. private void ParseUpgradeFileElement(XElement node, string upgrade) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - bool allowIgnoreOnError = false; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var allowIgnoreOnError = false; string file = null; - bool ignore = false; - List symbols = new List(); - bool wholeFile = false; + var ignore = false; + var symbols = new List(); + var wholeFile = false; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "AllowIgnoreOnError": - allowIgnoreOnError = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "File": - file = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Ignore": - ignore = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "WholeFile": - wholeFile = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "AllowIgnoreOnError": + allowIgnoreOnError = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "File": + file = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Ignore": + ignore = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "WholeFile": + wholeFile = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -8489,18 +8483,18 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "File")); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "SymbolPath": - symbols.Add(this.ParseSymbolPathElement(child)); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "SymbolPath": + symbols.Add(this.ParseSymbolPathElement(child)); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -8537,52 +8531,52 @@ namespace WixToolset.Core /// The family key for this element. private void ParseTargetImageElement(XElement node, string upgrade, string family) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - bool ignore = false; - int order = CompilerConstants.IntegerNotSet; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var ignore = false; + var order = CompilerConstants.IntegerNotSet; string sourceFile = null; string symbols = null; string target = null; string validation = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - target = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (target.Length > 13) - { - this.Core.Write(ErrorMessages.IdentifierTooLongError(sourceLineNumbers, node.Name.LocalName, "Id", target, 13)); - } - break; - case "IgnoreMissingFiles": - ignore = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Order": - order = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, int.MinValue + 2, int.MaxValue); - break; - case "SourceFile": - case "src": - if (null != sourceFile) - { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "src", "SourceFile")); - } + case "Id": + target = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (target.Length > 13) + { + this.Core.Write(ErrorMessages.IdentifierTooLongError(sourceLineNumbers, node.Name.LocalName, "Id", target, 13)); + } + break; + case "IgnoreMissingFiles": + ignore = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Order": + order = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, Int32.MinValue + 2, Int32.MaxValue); + break; + case "SourceFile": + case "src": + if (null != sourceFile) + { + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "src", "SourceFile")); + } - if ("src" == attrib.Name.LocalName) - { - this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "SourceFile")); - } - sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Validation": - validation = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + if ("src" == attrib.Name.LocalName) + { + this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "SourceFile")); + } + sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Validation": + validation = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -8606,28 +8600,28 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Order")); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "SymbolPath": - if (null != symbols) - { - symbols = String.Concat(symbols, ";", this.ParseSymbolPathElement(child)); - } - else - { - symbols = this.ParseSymbolPathElement(child); - } - break; - case "TargetFile": - this.ParseTargetFileElement(child, target, family); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "SymbolPath": + if (null != symbols) + { + symbols = String.Concat(symbols, ";", this.ParseSymbolPathElement(child)); + } + else + { + symbols = this.ParseSymbolPathElement(child); + } + break; + case "TargetFile": + this.ParseTargetFileElement(child, target, family); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -8657,7 +8651,7 @@ namespace WixToolset.Core /// The family key for this element. private void ParseTargetFileElement(XElement node, string target, string family) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string file = null; string ignoreLengths = null; string ignoreOffsets = null; @@ -8665,18 +8659,18 @@ namespace WixToolset.Core string protectOffsets = null; string symbols = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - file = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + file = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -8690,24 +8684,24 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "IgnoreRange": - this.ParseRangeElement(child, ref ignoreOffsets, ref ignoreLengths); - break; - case "ProtectRange": - this.ParseRangeElement(child, ref protectOffsets, ref protectLengths); - break; - case "SymbolPath": - symbols = this.ParseSymbolPathElement(child); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "IgnoreRange": + this.ParseRangeElement(child, ref ignoreOffsets, ref ignoreLengths); + break; + case "ProtectRange": + this.ParseRangeElement(child, ref protectOffsets, ref protectLengths); + break; + case "SymbolPath": + symbols = this.ParseSymbolPathElement(child); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -8745,44 +8739,44 @@ namespace WixToolset.Core /// The family for this element. private void ParseExternalFileElement(XElement node, string family) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string file = null; string ignoreLengths = null; string ignoreOffsets = null; - int order = CompilerConstants.IntegerNotSet; + var order = CompilerConstants.IntegerNotSet; string protectLengths = null; string protectOffsets = null; string source = null; string symbols = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "File": - file = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Order": - order = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, int.MinValue + 2, int.MaxValue); - break; - case "Source": - case "src": - if (null != source) - { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "src", "Source")); - } + case "File": + file = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Order": + order = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, Int32.MinValue + 2, Int32.MaxValue); + break; + case "Source": + case "src": + if (null != source) + { + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "src", "Source")); + } - if ("src" == attrib.Name.LocalName) - { - this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Source")); - } - source = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + if ("src" == attrib.Name.LocalName) + { + this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Source")); + } + source = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -8806,24 +8800,24 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Order")); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "IgnoreRange": - this.ParseRangeElement(child, ref ignoreOffsets, ref ignoreLengths); - break; - case "ProtectRange": - this.ParseRangeElement(child, ref protectOffsets, ref protectLengths); - break; - case "SymbolPath": - symbols = this.ParseSymbolPathElement(child); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "IgnoreRange": + this.ParseRangeElement(child, ref ignoreOffsets, ref ignoreLengths); + break; + case "ProtectRange": + this.ParseRangeElement(child, ref protectOffsets, ref protectLengths); + break; + case "SymbolPath": + symbols = this.ParseSymbolPathElement(child); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -8869,23 +8863,23 @@ namespace WixToolset.Core /// The family for this element. private void ParseProtectFileElement(XElement node, string family) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string file = null; string protectLengths = null; string protectOffsets = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "File": - file = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "File": + file = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -8899,18 +8893,18 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "File")); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "ProtectRange": - this.ParseRangeElement(child, ref protectOffsets, ref protectLengths); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "ProtectRange": + this.ParseRangeElement(child, ref protectOffsets, ref protectLengths); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -8942,25 +8936,25 @@ namespace WixToolset.Core /// Reference to the lengths string. private void ParseRangeElement(XElement node, ref string offsets, ref string lengths) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string length = null; string offset = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Length": - length = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Offset": - offset = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Length": + length = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Offset": + offset = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -9007,30 +9001,30 @@ namespace WixToolset.Core /// True if parsing an patch element. private void ParsePatchPropertyElement(XElement node, bool patch) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string name = null; string company = null; string value = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - case "Name": - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Company": - company = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Value": - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + case "Name": + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Company": + company = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Value": + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -9075,56 +9069,56 @@ namespace WixToolset.Core /// The element to parse. private void ParsePatchSequenceElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string family = null; string target = null; string sequence = null; - int attributes = 0; + var attributes = 0; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "PatchFamily": - family = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "ProductCode": - if (null != target) - { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Target", "TargetImage")); - } - target = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - case "Target": - if (null != target) - { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "TargetImage", "ProductCode")); - } - this.Core.Write(WarningMessages.DeprecatedPatchSequenceTargetAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); - target = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "TargetImage": - if (null != target) - { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Target", "ProductCode")); - } - target = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "TargetImages", target); - break; - case "Sequence": - sequence = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); - break; - case "Supersede": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= 0x1; - } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "PatchFamily": + family = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "ProductCode": + if (null != target) + { + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Target", "TargetImage")); + } + target = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + case "Target": + if (null != target) + { + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "TargetImage", "ProductCode")); + } + this.Core.Write(WarningMessages.DeprecatedPatchSequenceTargetAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + target = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "TargetImage": + if (null != target) + { + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Target", "ProductCode")); + } + target = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "TargetImages", target); + break; + case "Sequence": + sequence = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); + break; + case "Supersede": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= 0x1; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -9160,25 +9154,25 @@ namespace WixToolset.Core /// The id from the node. private string ParseTargetProductCodeElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (id.Length > 0 && "*" != id) - { - id = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (id.Length > 0 && "*" != id) + { + id = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -9203,22 +9197,22 @@ namespace WixToolset.Core /// The element to parse. private void ParseTargetProductCodesElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - bool replace = false; - List targetProductCodes = new List(); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var replace = false; + var targetProductCodes = new List(); - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Replace": - replace = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Replace": + replace = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -9227,26 +9221,26 @@ namespace WixToolset.Core } } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "TargetProductCode": - string id = this.ParseTargetProductCodeElement(child); - if (0 == String.CompareOrdinal("*", id)) - { - this.Core.Write(ErrorMessages.IllegalAttributeValueWhenNested(sourceLineNumbers, child.Name.LocalName, "Id", id, node.Name.LocalName)); - } - else - { - targetProductCodes.Add(id); - } - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "TargetProductCode": + var id = this.ParseTargetProductCodeElement(child); + if (0 == String.CompareOrdinal("*", id)) + { + this.Core.Write(ErrorMessages.IllegalAttributeValueWhenNested(sourceLineNumbers, child.Name.LocalName, "Id", id, node.Name.LocalName)); + } + else + { + targetProductCodes.Add(id); + } + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -9264,7 +9258,7 @@ namespace WixToolset.Core row.Set(0, "*"); } - foreach (string targetProductCode in targetProductCodes) + foreach (var targetProductCode in targetProductCodes) { var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.WixPatchTarget); row.Set(0, targetProductCode); @@ -9279,21 +9273,21 @@ namespace WixToolset.Core /// The id from the node. private string ParseReplacePatchElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -9319,21 +9313,21 @@ namespace WixToolset.Core /// The path from the node. private string ParseSymbolPathElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string path = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Path": - path = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Path": + path = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -9358,93 +9352,93 @@ namespace WixToolset.Core /// The element to parse. private void ParsePatchElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string patchId = null; - int codepage = 0; + var codepage = 0; ////bool versionMismatches = false; ////bool productMismatches = false; - bool allowRemoval = false; + var allowRemoval = false; string classification = null; string clientPatchId = null; string description = null; string displayName = null; string comments = null; string manufacturer = null; - YesNoType minorUpdateTargetRTM = YesNoType.NotSet; + var minorUpdateTargetRTM = YesNoType.NotSet; string moreInfoUrl = null; - int optimizeCA = CompilerConstants.IntegerNotSet; - YesNoType optimizedInstallMode = YesNoType.NotSet; + var optimizeCA = CompilerConstants.IntegerNotSet; + var optimizedInstallMode = YesNoType.NotSet; string targetProductName = null; // string replaceGuids = String.Empty; - int apiPatchingSymbolFlags = 0; - bool optimizePatchSizeForLargeFiles = false; + var apiPatchingSymbolFlags = 0; + var optimizePatchSizeForLargeFiles = false; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - patchId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, true); - break; - case "Codepage": - codepage = this.Core.GetAttributeCodePageValue(sourceLineNumbers, attrib); - break; - case "AllowMajorVersionMismatches": - ////versionMismatches = (YesNoType.Yes == this.core.GetAttributeYesNoValue(sourceLineNumbers, attrib)); - break; - case "AllowProductCodeMismatches": - ////productMismatches = (YesNoType.Yes == this.core.GetAttributeYesNoValue(sourceLineNumbers, attrib)); - break; - case "AllowRemoval": - allowRemoval = (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)); - break; - case "Classification": - classification = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "ClientPatchId": - clientPatchId = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Description": - description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "DisplayName": - displayName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Comments": - comments = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Manufacturer": - manufacturer = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "MinorUpdateTargetRTM": - minorUpdateTargetRTM = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "MoreInfoURL": - moreInfoUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "OptimizedInstallMode": - optimizedInstallMode = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "TargetProductName": - targetProductName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "ApiPatchingSymbolNoImagehlpFlag": - apiPatchingSymbolFlags |= (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) ? (int)PatchSymbolFlagsType.PATCH_SYMBOL_NO_IMAGEHLP : 0; - break; - case "ApiPatchingSymbolNoFailuresFlag": - apiPatchingSymbolFlags |= (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) ? (int)PatchSymbolFlagsType.PATCH_SYMBOL_NO_FAILURES : 0; - break; - case "ApiPatchingSymbolUndecoratedTooFlag": - apiPatchingSymbolFlags |= (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) ? (int)PatchSymbolFlagsType.PATCH_SYMBOL_UNDECORATED_TOO : 0; - break; - case "OptimizePatchSizeForLargeFiles": - optimizePatchSizeForLargeFiles = (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + patchId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, true); + break; + case "Codepage": + codepage = this.Core.GetAttributeCodePageValue(sourceLineNumbers, attrib); + break; + case "AllowMajorVersionMismatches": + ////versionMismatches = (YesNoType.Yes == this.core.GetAttributeYesNoValue(sourceLineNumbers, attrib)); + break; + case "AllowProductCodeMismatches": + ////productMismatches = (YesNoType.Yes == this.core.GetAttributeYesNoValue(sourceLineNumbers, attrib)); + break; + case "AllowRemoval": + allowRemoval = (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)); + break; + case "Classification": + classification = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "ClientPatchId": + clientPatchId = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Description": + description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DisplayName": + displayName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Comments": + comments = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Manufacturer": + manufacturer = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "MinorUpdateTargetRTM": + minorUpdateTargetRTM = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "MoreInfoURL": + moreInfoUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "OptimizedInstallMode": + optimizedInstallMode = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "TargetProductName": + targetProductName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "ApiPatchingSymbolNoImagehlpFlag": + apiPatchingSymbolFlags |= (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) ? (int)PatchSymbolFlagsType.PATCH_SYMBOL_NO_IMAGEHLP : 0; + break; + case "ApiPatchingSymbolNoFailuresFlag": + apiPatchingSymbolFlags |= (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) ? (int)PatchSymbolFlagsType.PATCH_SYMBOL_NO_FAILURES : 0; + break; + case "ApiPatchingSymbolUndecoratedTooFlag": + apiPatchingSymbolFlags |= (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) ? (int)PatchSymbolFlagsType.PATCH_SYMBOL_UNDECORATED_TOO : 0; + break; + case "OptimizePatchSizeForLargeFiles": + optimizePatchSizeForLargeFiles = (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -9487,42 +9481,42 @@ namespace WixToolset.Core this.Core.CreateActiveSection(this.activeName, SectionType.Patch, codepage, this.Context.CompilationId); - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "PatchInformation": - this.ParsePatchInformationElement(child); - break; - case "Media": - this.ParseMediaElement(child, patchId); - break; - case "OptimizeCustomActions": - optimizeCA = this.ParseOptimizeCustomActionsElement(child); - break; - case "PatchFamily": - this.ParsePatchFamilyElement(child, ComplexReferenceParentType.Patch, patchId); - break; - case "PatchFamilyRef": - this.ParsePatchFamilyRefElement(child, ComplexReferenceParentType.Patch, patchId); - break; - case "PatchFamilyGroup": - this.ParsePatchFamilyGroupElement(child, ComplexReferenceParentType.Patch, patchId); - break; - case "PatchFamilyGroupRef": - this.ParsePatchFamilyGroupRefElement(child, ComplexReferenceParentType.Patch, patchId); - break; - case "PatchProperty": - this.ParsePatchPropertyElement(child, true); - break; - case "TargetProductCodes": - this.ParseTargetProductCodesElement(child); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "PatchInformation": + this.ParsePatchInformationElement(child); + break; + case "Media": + this.ParseMediaElement(child, patchId); + break; + case "OptimizeCustomActions": + optimizeCA = this.ParseOptimizeCustomActionsElement(child); + break; + case "PatchFamily": + this.ParsePatchFamilyElement(child, ComplexReferenceParentType.Patch, patchId); + break; + case "PatchFamilyRef": + this.ParsePatchFamilyRefElement(child, ComplexReferenceParentType.Patch, patchId); + break; + case "PatchFamilyGroup": + this.ParsePatchFamilyGroupElement(child, ComplexReferenceParentType.Patch, patchId); + break; + case "PatchFamilyGroupRef": + this.ParsePatchFamilyGroupRefElement(child, ComplexReferenceParentType.Patch, patchId); + break; + case "PatchProperty": + this.ParsePatchPropertyElement(child, true); + break; + case "TargetProductCodes": + this.ParseTargetProductCodesElement(child); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -9632,36 +9626,36 @@ namespace WixToolset.Core /// The element to parse. private void ParsePatchFamilyElement(XElement node, ComplexReferenceParentType parentType, string parentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string productCode = null; string version = null; - int attributes = 0; + var attributes = 0; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "ProductCode": - productCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - case "Version": - version = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); - break; - case "Supersede": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= 0x1; - } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "ProductCode": + productCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + case "Version": + version = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); + break; + case "Supersede": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= 0x1; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -9686,45 +9680,45 @@ namespace WixToolset.Core } // find unexpected child elements - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "All": - this.ParseAllElement(child); - break; - case "BinaryRef": - this.ParsePatchChildRefElement(child, "Binary"); - break; - case "ComponentRef": - this.ParsePatchChildRefElement(child, "Component"); - break; - case "CustomActionRef": - this.ParsePatchChildRefElement(child, "CustomAction"); - break; - case "DirectoryRef": - this.ParsePatchChildRefElement(child, "Directory"); - break; - case "DigitalCertificateRef": - this.ParsePatchChildRefElement(child, "MsiDigitalCertificate"); - break; - case "FeatureRef": - this.ParsePatchChildRefElement(child, "Feature"); - break; - case "IconRef": - this.ParsePatchChildRefElement(child, "Icon"); - break; - case "PropertyRef": - this.ParsePatchChildRefElement(child, "Property"); - break; - case "UIRef": - this.ParsePatchChildRefElement(child, "WixUI"); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "All": + this.ParseAllElement(child); + break; + case "BinaryRef": + this.ParsePatchChildRefElement(child, "Binary"); + break; + case "ComponentRef": + this.ParsePatchChildRefElement(child, "Component"); + break; + case "CustomActionRef": + this.ParsePatchChildRefElement(child, "CustomAction"); + break; + case "DirectoryRef": + this.ParsePatchChildRefElement(child, "Directory"); + break; + case "DigitalCertificateRef": + this.ParsePatchChildRefElement(child, "MsiDigitalCertificate"); + break; + case "FeatureRef": + this.ParsePatchChildRefElement(child, "Feature"); + break; + case "IconRef": + this.ParsePatchChildRefElement(child, "Icon"); + break; + case "PropertyRef": + this.ParsePatchChildRefElement(child, "Property"); + break; + case "UIRef": + this.ParsePatchChildRefElement(child, "WixUI"); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -9754,10 +9748,10 @@ namespace WixToolset.Core /// The element to parse. private void ParseAllElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); // find unexpected attributes - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { @@ -9787,21 +9781,21 @@ namespace WixToolset.Core /// Table that reference was made to. private void ParsePatchChildRefElement(XElement node, string tableName) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -9830,23 +9824,23 @@ namespace WixToolset.Core /// Media index from parent element. private void ParsePatchBaselineElement(XElement node, int diskId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - bool parsedValidate = false; - TransformFlags validationFlags = TransformFlags.PatchTransformDefault; + var parsedValidate = false; + var validationFlags = TransformFlags.PatchTransformDefault; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -9865,27 +9859,27 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.IdentifierTooLongError(sourceLineNumbers, node.Name.LocalName, "Id", id.Id, 27)); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Validate": - if (parsedValidate) - { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); - this.Core.Write(ErrorMessages.TooManyChildren(childSourceLineNumbers, node.Name.LocalName, child.Name.LocalName)); - } - else - { - this.ParseValidateElement(child, ref validationFlags); - parsedValidate = true; - } - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "Validate": + if (parsedValidate) + { + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + this.Core.Write(ErrorMessages.TooManyChildren(childSourceLineNumbers, node.Name.LocalName, child.Name.LocalName)); + } + else + { + this.ParseValidateElement(child, ref validationFlags); + parsedValidate = true; + } + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -9909,153 +9903,153 @@ namespace WixToolset.Core /// TransformValidation flags to use when creating the authoring patch transform. private void ParseValidateElement(XElement node, ref TransformFlags validationFlags) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "ProductId": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - validationFlags |= TransformFlags.ValidateProduct; - } - else - { - validationFlags &= ~TransformFlags.ValidateProduct; - } - break; - case "ProductLanguage": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - validationFlags |= TransformFlags.ValidateLanguage; - } - else - { - validationFlags &= ~TransformFlags.ValidateLanguage; - } - break; - case "ProductVersion": - string check = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - validationFlags &= ~TransformFlags.ProductVersionMask; - Wix.Validate.ProductVersionType productVersionType = Wix.Validate.ParseProductVersionType(check); - switch (productVersionType) - { - case Wix.Validate.ProductVersionType.Major: - validationFlags |= TransformFlags.ValidateMajorVersion; - break; - case Wix.Validate.ProductVersionType.Minor: - validationFlags |= TransformFlags.ValidateMinorVersion; - break; - case Wix.Validate.ProductVersionType.Update: - validationFlags |= TransformFlags.ValidateUpdateVersion; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Version", check, "Major", "Minor", "Update")); - break; - } - break; - case "ProductVersionOperator": - string op = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - validationFlags &= ~TransformFlags.ProductVersionOperatorMask; - Wix.Validate.ProductVersionOperatorType opType = Wix.Validate.ParseProductVersionOperatorType(op); - switch (opType) - { - case Wix.Validate.ProductVersionOperatorType.Lesser: - validationFlags |= TransformFlags.ValidateNewLessBaseVersion; - break; - case Wix.Validate.ProductVersionOperatorType.LesserOrEqual: - validationFlags |= TransformFlags.ValidateNewLessEqualBaseVersion; - break; - case Wix.Validate.ProductVersionOperatorType.Equal: - validationFlags |= TransformFlags.ValidateNewEqualBaseVersion; - break; - case Wix.Validate.ProductVersionOperatorType.GreaterOrEqual: - validationFlags |= TransformFlags.ValidateNewGreaterEqualBaseVersion; - break; - case Wix.Validate.ProductVersionOperatorType.Greater: - validationFlags |= TransformFlags.ValidateNewGreaterBaseVersion; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Operator", op, "Lesser", "LesserOrEqual", "Equal", "GreaterOrEqual", "Greater")); - break; - } + case "ProductId": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + validationFlags |= TransformFlags.ValidateProduct; + } + else + { + validationFlags &= ~TransformFlags.ValidateProduct; + } + break; + case "ProductLanguage": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + validationFlags |= TransformFlags.ValidateLanguage; + } + else + { + validationFlags &= ~TransformFlags.ValidateLanguage; + } + break; + case "ProductVersion": + var check = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + validationFlags &= ~TransformFlags.ProductVersionMask; + var productVersionType = Wix.Validate.ParseProductVersionType(check); + switch (productVersionType) + { + case Wix.Validate.ProductVersionType.Major: + validationFlags |= TransformFlags.ValidateMajorVersion; break; - case "UpgradeCode": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - validationFlags |= TransformFlags.ValidateUpgradeCode; - } - else - { - validationFlags &= ~TransformFlags.ValidateUpgradeCode; - } + case Wix.Validate.ProductVersionType.Minor: + validationFlags |= TransformFlags.ValidateMinorVersion; break; - case "IgnoreAddExistingRow": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - validationFlags |= TransformFlags.ErrorAddExistingRow; - } - else - { - validationFlags &= ~TransformFlags.ErrorAddExistingRow; - } + case Wix.Validate.ProductVersionType.Update: + validationFlags |= TransformFlags.ValidateUpdateVersion; break; - case "IgnoreAddExistingTable": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - validationFlags |= TransformFlags.ErrorAddExistingTable; - } - else - { - validationFlags &= ~TransformFlags.ErrorAddExistingTable; - } + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Version", check, "Major", "Minor", "Update")); break; - case "IgnoreDeleteMissingRow": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - validationFlags |= TransformFlags.ErrorDeleteMissingRow; - } - else - { - validationFlags &= ~TransformFlags.ErrorDeleteMissingRow; - } + } + break; + case "ProductVersionOperator": + var op = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + validationFlags &= ~TransformFlags.ProductVersionOperatorMask; + var opType = Wix.Validate.ParseProductVersionOperatorType(op); + switch (opType) + { + case Wix.Validate.ProductVersionOperatorType.Lesser: + validationFlags |= TransformFlags.ValidateNewLessBaseVersion; break; - case "IgnoreDeleteMissingTable": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - validationFlags |= TransformFlags.ErrorDeleteMissingTable; - } - else - { - validationFlags &= ~TransformFlags.ErrorDeleteMissingTable; - } + case Wix.Validate.ProductVersionOperatorType.LesserOrEqual: + validationFlags |= TransformFlags.ValidateNewLessEqualBaseVersion; break; - case "IgnoreUpdateMissingRow": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - validationFlags |= TransformFlags.ErrorUpdateMissingRow; - } - else - { - validationFlags &= ~TransformFlags.ErrorUpdateMissingRow; - } + case Wix.Validate.ProductVersionOperatorType.Equal: + validationFlags |= TransformFlags.ValidateNewEqualBaseVersion; break; - case "IgnoreChangingCodePage": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - validationFlags |= TransformFlags.ErrorChangeCodePage; - } - else - { - validationFlags &= ~TransformFlags.ErrorChangeCodePage; - } + case Wix.Validate.ProductVersionOperatorType.GreaterOrEqual: + validationFlags |= TransformFlags.ValidateNewGreaterEqualBaseVersion; + break; + case Wix.Validate.ProductVersionOperatorType.Greater: + validationFlags |= TransformFlags.ValidateNewGreaterBaseVersion; break; default: - this.Core.UnexpectedAttribute(node, attrib); + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Operator", op, "Lesser", "LesserOrEqual", "Equal", "GreaterOrEqual", "Greater")); break; + } + break; + case "UpgradeCode": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + validationFlags |= TransformFlags.ValidateUpgradeCode; + } + else + { + validationFlags &= ~TransformFlags.ValidateUpgradeCode; + } + break; + case "IgnoreAddExistingRow": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + validationFlags |= TransformFlags.ErrorAddExistingRow; + } + else + { + validationFlags &= ~TransformFlags.ErrorAddExistingRow; + } + break; + case "IgnoreAddExistingTable": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + validationFlags |= TransformFlags.ErrorAddExistingTable; + } + else + { + validationFlags &= ~TransformFlags.ErrorAddExistingTable; + } + break; + case "IgnoreDeleteMissingRow": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + validationFlags |= TransformFlags.ErrorDeleteMissingRow; + } + else + { + validationFlags &= ~TransformFlags.ErrorDeleteMissingRow; + } + break; + case "IgnoreDeleteMissingTable": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + validationFlags |= TransformFlags.ErrorDeleteMissingTable; + } + else + { + validationFlags &= ~TransformFlags.ErrorDeleteMissingTable; + } + break; + case "IgnoreUpdateMissingRow": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + validationFlags |= TransformFlags.ErrorUpdateMissingRow; + } + else + { + validationFlags &= ~TransformFlags.ErrorUpdateMissingRow; + } + break; + case "IgnoreChangingCodePage": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + validationFlags |= TransformFlags.ErrorChangeCodePage; + } + else + { + validationFlags &= ~TransformFlags.ErrorChangeCodePage; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -10088,29 +10082,29 @@ namespace WixToolset.Core /// Element to parse. private void ParseDependencyElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string requiredId = null; - int requiredLanguage = CompilerConstants.IntegerNotSet; + var requiredLanguage = CompilerConstants.IntegerNotSet; string requiredVersion = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "RequiredId": - requiredId = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "RequiredLanguage": - requiredLanguage = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "RequiredVersion": - requiredVersion = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "RequiredId": + requiredId = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "RequiredLanguage": + requiredLanguage = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "RequiredVersion": + requiredVersion = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -10150,38 +10144,38 @@ namespace WixToolset.Core /// Element to parse. private void ParseExclusionElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string excludedId = null; - int excludeExceptLanguage = CompilerConstants.IntegerNotSet; - int excludeLanguage = CompilerConstants.IntegerNotSet; - string excludedLanguageField = "0"; + var excludeExceptLanguage = CompilerConstants.IntegerNotSet; + var excludeLanguage = CompilerConstants.IntegerNotSet; + var excludedLanguageField = "0"; string excludedMaxVersion = null; string excludedMinVersion = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "ExcludedId": - excludedId = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "ExcludeExceptLanguage": - excludeExceptLanguage = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "ExcludeLanguage": - excludeLanguage = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "ExcludedMaxVersion": - excludedMaxVersion = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "ExcludedMinVersion": - excludedMinVersion = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "ExcludedId": + excludedId = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "ExcludeExceptLanguage": + excludeExceptLanguage = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "ExcludeLanguage": + excludeLanguage = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "ExcludedMaxVersion": + excludedMaxVersion = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "ExcludedMinVersion": + excludedMinVersion = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -10229,88 +10223,88 @@ namespace WixToolset.Core /// Element to parse. private void ParseConfigurationElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - int attributes = 0; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var attributes = 0; string contextData = null; string defaultValue = null; string description = null; string displayName = null; - int format = CompilerConstants.IntegerNotSet; + var format = CompilerConstants.IntegerNotSet; string helpKeyword = null; string helpLocation = null; string name = null; string type = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Name": - name = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "ContextData": - contextData = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Description": - description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "DefaultValue": - defaultValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "DisplayName": - displayName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Format": - string formatStr = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < formatStr.Length) - { - Wix.Configuration.FormatType formatType = Wix.Configuration.ParseFormatType(formatStr); - switch (formatType) - { - case Wix.Configuration.FormatType.Text: - format = 0; - break; - case Wix.Configuration.FormatType.Key: - format = 1; - break; - case Wix.Configuration.FormatType.Integer: - format = 2; - break; - case Wix.Configuration.FormatType.Bitfield: - format = 3; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Format", formatStr, "Text", "Key", "Integer", "Bitfield")); - break; - } - } - break; - case "HelpKeyword": - helpKeyword = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "HelpLocation": - helpLocation = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "KeyNoOrphan": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= MsiInterop.MsidbMsmConfigurableOptionKeyNoOrphan; - } - break; - case "NonNullable": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + case "Name": + name = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "ContextData": + contextData = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Description": + description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DefaultValue": + defaultValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DisplayName": + displayName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Format": + var formatStr = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < formatStr.Length) + { + var formatType = Wix.Configuration.ParseFormatType(formatStr); + switch (formatType) { - attributes |= MsiInterop.MsidbMsmConfigurableOptionNonNullable; + case Wix.Configuration.FormatType.Text: + format = 0; + break; + case Wix.Configuration.FormatType.Key: + format = 1; + break; + case Wix.Configuration.FormatType.Integer: + format = 2; + break; + case Wix.Configuration.FormatType.Bitfield: + format = 3; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Format", formatStr, "Text", "Key", "Integer", "Bitfield")); + break; } - break; - case "Type": - type = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + case "HelpKeyword": + helpKeyword = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "HelpLocation": + helpLocation = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "KeyNoOrphan": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= MsiInterop.MsidbMsmConfigurableOptionKeyNoOrphan; + } + break; + case "NonNullable": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= MsiInterop.MsidbMsmConfigurableOptionNonNullable; + } + break; + case "Type": + type = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -10355,33 +10349,33 @@ namespace WixToolset.Core /// Element to parse. private void ParseSubstitutionElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string column = null; string rowKeys = null; string table = null; string value = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Column": - column = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "Row": - rowKeys = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Table": - table = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "Value": - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Column": + column = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "Row": + rowKeys = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Table": + table = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "Value": + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -10425,21 +10419,21 @@ namespace WixToolset.Core /// Element to parse. private void ParseIgnoreTableElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -10471,35 +10465,35 @@ namespace WixToolset.Core /// Table we're processing for. private void ParseODBCDriverOrTranslator(XElement node, string componentId, string fileId, TupleDefinitionType tableName) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - string driver = fileId; + var driver = fileId; string name = null; - string setup = fileId; + var setup = fileId; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "File": - driver = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "File", driver); - break; - case "Name": - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "SetupFile": - setup = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "File", setup); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "File": + driver = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "File", driver); + break; + case "Name": + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "SetupFile": + setup = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "File", setup); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -10522,22 +10516,22 @@ namespace WixToolset.Core if (TupleDefinitionType.ODBCDriver == tableName) { // process any data sources for the driver - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "ODBCDataSource": - string ignoredKeyPath = null; - this.ParseODBCDataSource(child, componentId, name, out ignoredKeyPath); - break; - case "Property": - this.ParseODBCProperty(child, id.Id, TupleDefinitionType.ODBCAttribute); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "ODBCDataSource": + string ignoredKeyPath = null; + this.ParseODBCDataSource(child, componentId, name, out ignoredKeyPath); + break; + case "Property": + this.ParseODBCProperty(child, id.Id, TupleDefinitionType.ODBCAttribute); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -10569,25 +10563,25 @@ namespace WixToolset.Core /// Name of the table to create property in. private void ParseODBCProperty(XElement node, string parentId, TupleDefinitionType tableName) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; string propertyValue = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Value": - propertyValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Value": + propertyValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -10622,52 +10616,52 @@ namespace WixToolset.Core /// Yes if this element was marked as the parent component's key path, No if explicitly marked as not being a key path, or NotSet otherwise. private YesNoType ParseODBCDataSource(XElement node, string componentId, string driverName, out string possibleKeyPath) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - YesNoType keyPath = YesNoType.NotSet; + var keyPath = YesNoType.NotSet; string name = null; - int registration = CompilerConstants.IntegerNotSet; + var registration = CompilerConstants.IntegerNotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "DriverName": - driverName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "KeyPath": - keyPath = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Name": - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Registration": - string registrationValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < registrationValue.Length) + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "DriverName": + driverName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "KeyPath": + keyPath = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Registration": + var registrationValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < registrationValue.Length) + { + var registrationType = Wix.ODBCDataSource.ParseRegistrationType(registrationValue); + switch (registrationType) { - Wix.ODBCDataSource.RegistrationType registrationType = Wix.ODBCDataSource.ParseRegistrationType(registrationValue); - switch (registrationType) - { - case Wix.ODBCDataSource.RegistrationType.machine: - registration = 0; - break; - case Wix.ODBCDataSource.RegistrationType.user: - registration = 1; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Registration", registrationValue, "machine", "user")); - break; - } + case Wix.ODBCDataSource.RegistrationType.machine: + registration = 0; + break; + case Wix.ODBCDataSource.RegistrationType.user: + registration = 1; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Registration", registrationValue, "machine", "user")); + break; } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -10687,18 +10681,18 @@ namespace WixToolset.Core id = this.Core.CreateIdentifier("odc", name, driverName, registration.ToString()); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Property": - this.ParseODBCProperty(child, id.Id, TupleDefinitionType.ODBCSourceAttribute); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "Property": + this.ParseODBCProperty(child, id.Id, TupleDefinitionType.ODBCSourceAttribute); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -10728,195 +10722,195 @@ namespace WixToolset.Core /// The module guid - this is necessary until Module/@Guid is removed. private void ParsePackageElement(XElement node, string productAuthor, string moduleId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - string codepage = "1252"; - string comments = String.Format(CultureInfo.InvariantCulture, "This installer database contains the logic and data required to install {0}.", this.activeName); - string keywords = "Installer"; - int msiVersion = 100; // lowest released version, really should be specified - string packageAuthor = productAuthor; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var codepage = "1252"; + var comments = String.Format(CultureInfo.InvariantCulture, "This installer database contains the logic and data required to install {0}.", this.activeName); + var keywords = "Installer"; + var msiVersion = 100; // lowest released version, really should be specified + var packageAuthor = productAuthor; string packageCode = null; - string packageLanguages = this.activeLanguage; - string packageName = this.activeName; + var packageLanguages = this.activeLanguage; + var packageName = this.activeName; string platform = null; string platformValue = null; - YesNoDefaultType security = YesNoDefaultType.Default; - int sourceBits = (this.compilingModule ? 2 : 0); + var security = YesNoDefaultType.Default; + var sourceBits = (this.compilingModule ? 2 : 0); IntermediateTuple row; - bool installPrivilegeSeen = false; - bool installScopeSeen = false; + var installPrivilegeSeen = false; + var installScopeSeen = false; switch (this.CurrentPlatform) { - case Platform.X86: - platform = "Intel"; - break; - case Platform.X64: - platform = "x64"; - msiVersion = 200; - break; - case Platform.IA64: - platform = "Intel64"; - msiVersion = 200; - break; - case Platform.ARM: - platform = "Arm"; - msiVersion = 500; - break; - default: - throw new ArgumentException(WixStrings.EXP_UnknownPlatformEnum, this.CurrentPlatform.ToString()); + case Platform.X86: + platform = "Intel"; + break; + case Platform.X64: + platform = "x64"; + msiVersion = 200; + break; + case Platform.IA64: + platform = "Intel64"; + msiVersion = 200; + break; + case Platform.ARM: + platform = "Arm"; + msiVersion = 500; + break; + default: + throw new ArgumentException(WixStrings.EXP_UnknownPlatformEnum, this.CurrentPlatform.ToString()); } - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - packageCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, this.compilingProduct); - break; - case "AdminImage": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - sourceBits = sourceBits | 4; - } - break; - case "Comments": - comments = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Compressed": - // merge modules must always be compressed, so this attribute is invalid - if (this.compilingModule) - { - this.Core.Write(WarningMessages.DeprecatedPackageCompressedAttribute(sourceLineNumbers)); - // this.core.OnMessage(WixErrors.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, "Compressed", "Module")); - } - else if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - sourceBits = sourceBits | 2; - } - break; - case "Description": - packageName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "InstallPrivileges": - string installPrivileges = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < installPrivileges.Length) - { - installPrivilegeSeen = true; - Wix.Package.InstallPrivilegesType installPrivilegesType = Wix.Package.ParseInstallPrivilegesType(installPrivileges); - switch (installPrivilegesType) - { - case Wix.Package.InstallPrivilegesType.elevated: - // this is the default setting - break; - case Wix.Package.InstallPrivilegesType.limited: - sourceBits = sourceBits | 8; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, installPrivileges, "elevated", "limited")); - break; - } - } - break; - case "InstallScope": - string installScope = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < installScope.Length) - { - installScopeSeen = true; - Wix.Package.InstallScopeType installScopeType = Wix.Package.ParseInstallScopeType(installScope); - switch (installScopeType) - { - case Wix.Package.InstallScopeType.perMachine: - { - row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.Property, new Identifier("ALLUSERS", AccessModifier.Public)); - row.Set(1, "1"); - } - break; - case Wix.Package.InstallScopeType.perUser: - sourceBits = sourceBits | 8; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, installScope, "perMachine", "perUser")); - break; - } - } - break; - case "InstallerVersion": - msiVersion = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); - break; - case "Keywords": - keywords = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Languages": - packageLanguages = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Manufacturer": - packageAuthor = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if ("PUT-COMPANY-NAME-HERE" == packageAuthor) + case "Id": + packageCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, this.compilingProduct); + break; + case "AdminImage": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + sourceBits = sourceBits | 4; + } + break; + case "Comments": + comments = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Compressed": + // merge modules must always be compressed, so this attribute is invalid + if (this.compilingModule) + { + this.Core.Write(WarningMessages.DeprecatedPackageCompressedAttribute(sourceLineNumbers)); + // this.core.OnMessage(WixErrors.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, "Compressed", "Module")); + } + else if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + sourceBits = sourceBits | 2; + } + break; + case "Description": + packageName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "InstallPrivileges": + var installPrivileges = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < installPrivileges.Length) + { + installPrivilegeSeen = true; + var installPrivilegesType = Wix.Package.ParseInstallPrivilegesType(installPrivileges); + switch (installPrivilegesType) { - this.Core.Write(WarningMessages.PlaceholderValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, packageAuthor)); + case Wix.Package.InstallPrivilegesType.elevated: + // this is the default setting + break; + case Wix.Package.InstallPrivilegesType.limited: + sourceBits = sourceBits | 8; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, installPrivileges, "elevated", "limited")); + break; } - break; - case "Platform": - if (null != platformValue) + } + break; + case "InstallScope": + var installScope = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < installScope.Length) + { + installScopeSeen = true; + var installScopeType = Wix.Package.ParseInstallScopeType(installScope); + switch (installScopeType) { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Platforms")); - } - - platformValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - Wix.Package.PlatformType platformType = Wix.Package.ParsePlatformType(platformValue); - switch (platformType) + case Wix.Package.InstallScopeType.perMachine: { - case Wix.Package.PlatformType.intel: - this.Core.Write(WarningMessages.DeprecatedAttributeValue(sourceLineNumbers, platformValue, node.Name.LocalName, attrib.Name.LocalName, "x86")); - goto case Wix.Package.PlatformType.x86; - case Wix.Package.PlatformType.x86: - platform = "Intel"; - break; - case Wix.Package.PlatformType.x64: - platform = "x64"; - break; - case Wix.Package.PlatformType.intel64: - this.Core.Write(WarningMessages.DeprecatedAttributeValue(sourceLineNumbers, platformValue, node.Name.LocalName, attrib.Name.LocalName, "ia64")); - goto case Wix.Package.PlatformType.ia64; - case Wix.Package.PlatformType.ia64: - platform = "Intel64"; - break; - case Wix.Package.PlatformType.arm: - platform = "Arm"; - break; - default: - this.Core.Write(ErrorMessages.InvalidPlatformValue(sourceLineNumbers, platformValue)); - break; + row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.Property, new Identifier("ALLUSERS", AccessModifier.Public)); + row.Set(1, "1"); } break; - case "Platforms": - if (null != platformValue) - { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Platform")); + case Wix.Package.InstallScopeType.perUser: + sourceBits = sourceBits | 8; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, installScope, "perMachine", "perUser")); + break; } + } + break; + case "InstallerVersion": + msiVersion = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int32.MaxValue); + break; + case "Keywords": + keywords = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Languages": + packageLanguages = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Manufacturer": + packageAuthor = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if ("PUT-COMPANY-NAME-HERE" == packageAuthor) + { + this.Core.Write(WarningMessages.PlaceholderValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, packageAuthor)); + } + break; + case "Platform": + if (null != platformValue) + { + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Platforms")); + } - this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Platform")); - platformValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - platform = platformValue; + platformValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + var platformType = Wix.Package.ParsePlatformType(platformValue); + switch (platformType) + { + case Wix.Package.PlatformType.intel: + this.Core.Write(WarningMessages.DeprecatedAttributeValue(sourceLineNumbers, platformValue, node.Name.LocalName, attrib.Name.LocalName, "x86")); + goto case Wix.Package.PlatformType.x86; + case Wix.Package.PlatformType.x86: + platform = "Intel"; break; - case "ReadOnly": - security = this.Core.GetAttributeYesNoDefaultValue(sourceLineNumbers, attrib); + case Wix.Package.PlatformType.x64: + platform = "x64"; break; - case "ShortNames": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - sourceBits = sourceBits | 1; - this.useShortFileNames = true; - } + case Wix.Package.PlatformType.intel64: + this.Core.Write(WarningMessages.DeprecatedAttributeValue(sourceLineNumbers, platformValue, node.Name.LocalName, attrib.Name.LocalName, "ia64")); + goto case Wix.Package.PlatformType.ia64; + case Wix.Package.PlatformType.ia64: + platform = "Intel64"; break; - case "SummaryCodepage": - codepage = this.Core.GetAttributeLocalizableCodePageValue(sourceLineNumbers, attrib, true); + case Wix.Package.PlatformType.arm: + platform = "Arm"; break; default: - this.Core.UnexpectedAttribute(node, attrib); + this.Core.Write(ErrorMessages.InvalidPlatformValue(sourceLineNumbers, platformValue)); break; + } + break; + case "Platforms": + if (null != platformValue) + { + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Platform")); + } + + this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Platform")); + platformValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + platform = platformValue; + break; + case "ReadOnly": + security = this.Core.GetAttributeYesNoDefaultValue(sourceLineNumbers, attrib); + break; + case "ShortNames": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + sourceBits = sourceBits | 1; + this.useShortFileNames = true; + } + break; + case "SummaryCodepage": + codepage = this.Core.GetAttributeLocalizableCodePageValue(sourceLineNumbers, attrib, true); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -11024,15 +11018,15 @@ namespace WixToolset.Core row.Set(0, 19); switch (security) { - case YesNoDefaultType.No: // no restriction - row.Set(1, "0"); - break; - case YesNoDefaultType.Default: // read-only recommended - row.Set(1, "2"); - break; - case YesNoDefaultType.Yes: // read-only enforced - row.Set(1, "4"); - break; + case YesNoDefaultType.No: // no restriction + row.Set(1, "0"); + break; + case YesNoDefaultType.Default: // read-only recommended + row.Set(1, "2"); + break; + case YesNoDefaultType.Yes: // read-only enforced + row.Set(1, "4"); + break; } } } @@ -11043,8 +11037,8 @@ namespace WixToolset.Core /// Element to parse. private void ParsePatchMetadataElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - YesNoType allowRemoval = YesNoType.NotSet; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var allowRemoval = YesNoType.NotSet; string classification = null; string creationTimeUtc = null; string description = null; @@ -11052,49 +11046,49 @@ namespace WixToolset.Core string manufacturerName = null; string minorUpdateTargetRTM = null; string moreInfoUrl = null; - int optimizeCA = CompilerConstants.IntegerNotSet; - YesNoType optimizedInstallMode = YesNoType.NotSet; + var optimizeCA = CompilerConstants.IntegerNotSet; + var optimizedInstallMode = YesNoType.NotSet; string targetProductName = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "AllowRemoval": - allowRemoval = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Classification": - classification = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "CreationTimeUTC": - creationTimeUtc = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Description": - description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "DisplayName": - displayName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "ManufacturerName": - manufacturerName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "MinorUpdateTargetRTM": - minorUpdateTargetRTM = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "MoreInfoURL": - moreInfoUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "OptimizedInstallMode": - optimizedInstallMode = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "TargetProductName": - targetProductName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "AllowRemoval": + allowRemoval = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Classification": + classification = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "CreationTimeUTC": + creationTimeUtc = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Description": + description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DisplayName": + displayName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "ManufacturerName": + manufacturerName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "MinorUpdateTargetRTM": + minorUpdateTargetRTM = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "MoreInfoURL": + moreInfoUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "OptimizedInstallMode": + optimizedInstallMode = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "TargetProductName": + targetProductName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -11138,21 +11132,21 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "TargetProductName")); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "CustomProperty": - this.ParseCustomPropertyElement(child); - break; - case "OptimizeCustomActions": - optimizeCA = this.ParseOptimizeCustomActionsElement(child); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "CustomProperty": + this.ParseCustomPropertyElement(child); + break; + case "OptimizeCustomActions": + optimizeCA = this.ParseOptimizeCustomActionsElement(child); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -11248,29 +11242,29 @@ namespace WixToolset.Core /// Element to parse. private void ParseCustomPropertyElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string company = null; string property = null; string value = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Company": - company = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Property": - property = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Value": - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Company": + company = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Property": + property = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Value": + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -11312,36 +11306,36 @@ namespace WixToolset.Core /// The combined integer value for callers to store as appropriate. private int ParseOptimizeCustomActionsElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - OptimizeCA optimizeCA = OptimizeCA.None; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var optimizeCA = OptimizeCA.None; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "SkipAssignment": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - optimizeCA |= OptimizeCA.SkipAssignment; - } - break; - case "SkipImmediate": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - optimizeCA |= OptimizeCA.SkipImmediate; - } - break; - case "SkipDeferred": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - optimizeCA |= OptimizeCA.SkipDeferred; - } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "SkipAssignment": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + optimizeCA |= OptimizeCA.SkipAssignment; + } + break; + case "SkipImmediate": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + optimizeCA |= OptimizeCA.SkipImmediate; + } + break; + case "SkipDeferred": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + optimizeCA |= OptimizeCA.SkipDeferred; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -11359,57 +11353,57 @@ namespace WixToolset.Core /// Element to parse. private void ParsePatchInformationElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - string codepage = "1252"; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var codepage = "1252"; string comments = null; - string keywords = "Installer,Patching,PCP,Database"; - int msiVersion = 1; // Should always be 1 for patches + var keywords = "Installer,Patching,PCP,Database"; + var msiVersion = 1; // Should always be 1 for patches string packageAuthor = null; - string packageName = this.activeName; - YesNoDefaultType security = YesNoDefaultType.Default; + var packageName = this.activeName; + var security = YesNoDefaultType.Default; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "AdminImage": - this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); - break; - case "Comments": - comments = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Compressed": - this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); - break; - case "Description": - packageName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Keywords": - keywords = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Languages": - this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); - break; - case "Manufacturer": - packageAuthor = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Platforms": - this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); - break; - case "ReadOnly": - security = this.Core.GetAttributeYesNoDefaultValue(sourceLineNumbers, attrib); - break; - case "ShortNames": - this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); - break; - case "SummaryCodepage": - codepage = this.Core.GetAttributeLocalizableCodePageValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "AdminImage": + this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + break; + case "Comments": + comments = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Compressed": + this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + break; + case "Description": + packageName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Keywords": + keywords = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Languages": + this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + break; + case "Manufacturer": + packageAuthor = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Platforms": + this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + break; + case "ReadOnly": + security = this.Core.GetAttributeYesNoDefaultValue(sourceLineNumbers, attrib); + break; + case "ShortNames": + this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + break; + case "SummaryCodepage": + codepage = this.Core.GetAttributeLocalizableCodePageValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -11479,15 +11473,15 @@ namespace WixToolset.Core row.Set(0, 19); switch (security) { - case YesNoDefaultType.No: // no restriction - row.Set(1, "0"); - break; - case YesNoDefaultType.Default: // read-only recommended - row.Set(1, "2"); - break; - case YesNoDefaultType.Yes: // read-only enforced - row.Set(1, "4"); - break; + case YesNoDefaultType.No: // no restriction + row.Set(1, "0"); + break; + case YesNoDefaultType.Default: // read-only recommended + row.Set(1, "2"); + break; + case YesNoDefaultType.Yes: // read-only enforced + row.Set(1, "4"); + break; } } } @@ -11498,26 +11492,26 @@ namespace WixToolset.Core /// XmlNode on an IgnoreModulatization element. private void ParseIgnoreModularizationElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string name = null; this.Core.Write(WarningMessages.DeprecatedIgnoreModularizationElement(sourceLineNumbers)); - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Name": - name = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "Type": - // this is actually not used - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Name": + name = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "Type": + // this is actually not used + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -11548,63 +11542,63 @@ namespace WixToolset.Core /// Name of table that contains objectId. private void ParsePermissionElement(XElement node, string objectId, string tableName) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - BitArray bits = new BitArray(32); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var bits = new BitArray(32); string domain = null; - int permission = 0; + var permission = 0; string[] specialPermissions = null; string user = null; switch (tableName) { - case "CreateFolder": - specialPermissions = Common.FolderPermissions; - break; - case "File": - specialPermissions = Common.FilePermissions; - break; - case "Registry": - specialPermissions = Common.RegistryPermissions; - break; - default: - this.Core.UnexpectedElement(node.Parent, node); - return; // stop processing this element since no valid permissions are available + case "CreateFolder": + specialPermissions = Common.FolderPermissions; + break; + case "File": + specialPermissions = Common.FilePermissions; + break; + case "Registry": + specialPermissions = Common.RegistryPermissions; + break; + default: + this.Core.UnexpectedElement(node.Parent, node); + return; // stop processing this element since no valid permissions are available } - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Domain": - domain = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "User": - user = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "FileAllRights": - // match the WinNT.h mask FILE_ALL_ACCESS for value 0x001F01FF (aka 1 1111 0000 0001 1111 1111 or 2032127) - bits[0] = bits[1] = bits[2] = bits[3] = bits[4] = bits[5] = bits[6] = bits[7] = bits[8] = bits[16] = bits[17] = bits[18] = bits[19] = bits[20] = true; - break; - case "SpecificRightsAll": - // match the WinNT.h mask SPECIFIC_RIGHTS_ALL for value 0x0000FFFF (aka 1111 1111 1111 1111) - bits[0] = bits[1] = bits[2] = bits[3] = bits[4] = bits[5] = bits[6] = bits[7] = bits[8] = bits[9] = bits[10] = bits[11] = bits[12] = bits[13] = bits[14] = bits[15] = true; - break; - default: - YesNoType attribValue = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - if (!this.Core.TrySetBitFromName(Common.StandardPermissions, attrib.Name.LocalName, attribValue, bits, 16)) + case "Domain": + domain = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "User": + user = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "FileAllRights": + // match the WinNT.h mask FILE_ALL_ACCESS for value 0x001F01FF (aka 1 1111 0000 0001 1111 1111 or 2032127) + bits[0] = bits[1] = bits[2] = bits[3] = bits[4] = bits[5] = bits[6] = bits[7] = bits[8] = bits[16] = bits[17] = bits[18] = bits[19] = bits[20] = true; + break; + case "SpecificRightsAll": + // match the WinNT.h mask SPECIFIC_RIGHTS_ALL for value 0x0000FFFF (aka 1111 1111 1111 1111) + bits[0] = bits[1] = bits[2] = bits[3] = bits[4] = bits[5] = bits[6] = bits[7] = bits[8] = bits[9] = bits[10] = bits[11] = bits[12] = bits[13] = bits[14] = bits[15] = true; + break; + default: + var attribValue = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + if (!this.Core.TrySetBitFromName(Common.StandardPermissions, attrib.Name.LocalName, attribValue, bits, 16)) + { + if (!this.Core.TrySetBitFromName(Common.GenericPermissions, attrib.Name.LocalName, attribValue, bits, 28)) { - if (!this.Core.TrySetBitFromName(Common.GenericPermissions, attrib.Name.LocalName, attribValue, bits, 28)) + if (!this.Core.TrySetBitFromName(specialPermissions, attrib.Name.LocalName, attribValue, bits, 0)) { - if (!this.Core.TrySetBitFromName(specialPermissions, attrib.Name.LocalName, attribValue, bits, 0)) - { - this.Core.UnexpectedAttribute(node, attrib); - break; - } + this.Core.UnexpectedAttribute(node, attrib); + break; } } - break; + } + break; } } else @@ -11620,7 +11614,7 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "User")); } - if (int.MinValue == permission) // just GENERIC_READ, which is MSI_NULL + if (Int32.MinValue == permission) // just GENERIC_READ, which is MSI_NULL { this.Core.Write(ErrorMessages.GenericReadNotAllowed(sourceLineNumbers)); } @@ -11646,38 +11640,38 @@ namespace WixToolset.Core /// Name of table that contains objectId. private void ParsePermissionExElement(XElement node, string objectId, string tableName) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string condition = null; Identifier id = null; string sddl = null; switch (tableName) { - case "CreateFolder": - case "File": - case "Registry": - case "ServiceInstall": - break; - default: - this.Core.UnexpectedElement(node.Parent, node); - return; // stop processing this element since nothing will be valid. + case "CreateFolder": + case "File": + case "Registry": + case "ServiceInstall": + break; + default: + this.Core.UnexpectedElement(node.Parent, node); + return; // stop processing this element since nothing will be valid. } - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Sddl": - sddl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Sddl": + sddl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -11696,24 +11690,24 @@ namespace WixToolset.Core id = this.Core.CreateIdentifier("pme", objectId, tableName, sddl); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Condition": - if (null != condition) - { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - this.Core.Write(ErrorMessages.TooManyChildren(childSourceLineNumbers, node.Name.LocalName, child.Name.LocalName)); - } + case "Condition": + if (null != condition) + { + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + this.Core.Write(ErrorMessages.TooManyChildren(childSourceLineNumbers, node.Name.LocalName, child.Name.LocalName)); + } - condition = this.ParseConditionElement(child, node.Name.LocalName, null, null); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + condition = this.ParseConditionElement(child, node.Name.LocalName, null, null); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -11739,8 +11733,8 @@ namespace WixToolset.Core [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")] private void ParseProductElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - int codepage = 65001; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var codepage = 65001; string productCode = null; string upgradeCode = null; string manufacturer = null; @@ -11750,48 +11744,48 @@ namespace WixToolset.Core this.activeName = null; this.activeLanguage = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - productCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, true); - break; - case "Codepage": - codepage = this.Core.GetAttributeCodePageValue(sourceLineNumbers, attrib); - break; - case "Language": - this.activeLanguage = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "Manufacturer": - manufacturer = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.MustHaveNonWhitespaceCharacters); - if ("PUT-COMPANY-NAME-HERE" == manufacturer) - { - this.Core.Write(WarningMessages.PlaceholderValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, manufacturer)); - } - break; - case "Name": - this.activeName = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.MustHaveNonWhitespaceCharacters); - if ("PUT-PRODUCT-NAME-HERE" == this.activeName) - { - this.Core.Write(WarningMessages.PlaceholderValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, this.activeName)); - } - break; - case "UpgradeCode": - upgradeCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - case "Version": // if the attribute is valid version, use the attribute value as is (so "1.0000.01.01" would *not* get translated to "1.0.1.1"). - string verifiedVersion = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); - if (!String.IsNullOrEmpty(verifiedVersion)) - { - version = attrib.Value; - } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + productCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, true); + break; + case "Codepage": + codepage = this.Core.GetAttributeCodePageValue(sourceLineNumbers, attrib); + break; + case "Language": + this.activeLanguage = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "Manufacturer": + manufacturer = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.MustHaveNonWhitespaceCharacters); + if ("PUT-COMPANY-NAME-HERE" == manufacturer) + { + this.Core.Write(WarningMessages.PlaceholderValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, manufacturer)); + } + break; + case "Name": + this.activeName = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.MustHaveNonWhitespaceCharacters); + if ("PUT-PRODUCT-NAME-HERE" == this.activeName) + { + this.Core.Write(WarningMessages.PlaceholderValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, this.activeName)); + } + break; + case "UpgradeCode": + upgradeCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + case "Version": // if the attribute is valid version, use the attribute value as is (so "1.0000.01.01" would *not* get translated to "1.0.1.1"). + var verifiedVersion = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); + if (!String.IsNullOrEmpty(verifiedVersion)) + { + version = attrib.Value; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -11854,141 +11848,143 @@ namespace WixToolset.Core this.AddProperty(sourceLineNumbers, new Identifier("UpgradeCode", AccessModifier.Public), upgradeCode, false, false, false, true); } - Dictionary contextValues = new Dictionary(); - contextValues["ProductLanguage"] = this.activeLanguage; - contextValues["ProductVersion"] = version; - contextValues["UpgradeCode"] = upgradeCode; + var contextValues = new Dictionary + { + ["ProductLanguage"] = this.activeLanguage, + ["ProductVersion"] = version, + ["UpgradeCode"] = upgradeCode + }; - int featureDisplay = 0; - foreach (XElement child in node.Elements()) + var featureDisplay = 0; + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "_locDefinition": - break; - case "AdminExecuteSequence": - case "AdminUISequence": - case "AdvertiseExecuteSequence": - case "InstallExecuteSequence": - case "InstallUISequence": - this.ParseSequenceElement(child, child.Name.LocalName); - break; - case "AppId": - this.ParseAppIdElement(child, null, YesNoType.Yes, null, null, null); - break; - case "Binary": - this.ParseBinaryElement(child); - break; - case "ComplianceCheck": - this.ParseComplianceCheckElement(child); - break; - case "Component": - this.ParseComponentElement(child, ComplexReferenceParentType.Unknown, null, null, CompilerConstants.IntegerNotSet, null, null); - break; - case "ComponentGroup": - this.ParseComponentGroupElement(child, ComplexReferenceParentType.Unknown, null); - break; - case "Condition": - this.ParseConditionElement(child, node.Name.LocalName, null, null); - break; - case "CustomAction": - this.ParseCustomActionElement(child); - break; - case "CustomActionRef": - this.ParseSimpleRefElement(child, "CustomAction"); - break; - case "CustomTable": - this.ParseCustomTableElement(child); - break; - case "Directory": - this.ParseDirectoryElement(child, null, CompilerConstants.IntegerNotSet, String.Empty); - break; - case "DirectoryRef": - this.ParseDirectoryRefElement(child); - break; - case "EmbeddedChainer": - this.ParseEmbeddedChainerElement(child); - break; - case "EmbeddedChainerRef": - this.ParseSimpleRefElement(child, "MsiEmbeddedChainer"); - break; - case "EnsureTable": - this.ParseEnsureTableElement(child); - break; - case "Feature": - this.ParseFeatureElement(child, ComplexReferenceParentType.Product, productCode, ref featureDisplay); - break; - case "FeatureRef": - this.ParseFeatureRefElement(child, ComplexReferenceParentType.Product, productCode); - break; - case "FeatureGroupRef": - this.ParseFeatureGroupRefElement(child, ComplexReferenceParentType.Product, productCode); - break; - case "Icon": - this.ParseIconElement(child); - break; - case "InstanceTransforms": - this.ParseInstanceTransformsElement(child); - break; - case "MajorUpgrade": - this.ParseMajorUpgradeElement(child, contextValues); - break; - case "Media": - this.ParseMediaElement(child, null); - break; - case "MediaTemplate": - this.ParseMediaTemplateElement(child, null); - break; - case "Package": - this.ParsePackageElement(child, manufacturer, null); - break; - case "PackageCertificates": - case "PatchCertificates": - this.ParseCertificatesElement(child); - break; - case "Property": - this.ParsePropertyElement(child); - break; - case "PropertyRef": - this.ParseSimpleRefElement(child, "Property"); - break; - case "SetDirectory": - this.ParseSetDirectoryElement(child); - break; - case "SetProperty": - this.ParseSetPropertyElement(child); - break; - case "SFPCatalog": - string parentName = null; - this.ParseSFPCatalogElement(child, ref parentName); - break; - case "SymbolPath": - if (null != symbols) - { - symbols += ";" + this.ParseSymbolPathElement(child); - } - else - { - symbols = this.ParseSymbolPathElement(child); - } - break; - case "UI": - this.ParseUIElement(child); - break; - case "UIRef": - this.ParseSimpleRefElement(child, "WixUI"); - break; - case "Upgrade": - this.ParseUpgradeElement(child); - break; - case "WixVariable": - this.ParseWixVariableElement(child); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "_locDefinition": + break; + case "AdminExecuteSequence": + case "AdminUISequence": + case "AdvertiseExecuteSequence": + case "InstallExecuteSequence": + case "InstallUISequence": + this.ParseSequenceElement(child, child.Name.LocalName); + break; + case "AppId": + this.ParseAppIdElement(child, null, YesNoType.Yes, null, null, null); + break; + case "Binary": + this.ParseBinaryElement(child); + break; + case "ComplianceCheck": + this.ParseComplianceCheckElement(child); + break; + case "Component": + this.ParseComponentElement(child, ComplexReferenceParentType.Unknown, null, null, CompilerConstants.IntegerNotSet, null, null); + break; + case "ComponentGroup": + this.ParseComponentGroupElement(child, ComplexReferenceParentType.Unknown, null); + break; + case "Condition": + this.ParseConditionElement(child, node.Name.LocalName, null, null); + break; + case "CustomAction": + this.ParseCustomActionElement(child); + break; + case "CustomActionRef": + this.ParseSimpleRefElement(child, "CustomAction"); + break; + case "CustomTable": + this.ParseCustomTableElement(child); + break; + case "Directory": + this.ParseDirectoryElement(child, null, CompilerConstants.IntegerNotSet, String.Empty); + break; + case "DirectoryRef": + this.ParseDirectoryRefElement(child); + break; + case "EmbeddedChainer": + this.ParseEmbeddedChainerElement(child); + break; + case "EmbeddedChainerRef": + this.ParseSimpleRefElement(child, "MsiEmbeddedChainer"); + break; + case "EnsureTable": + this.ParseEnsureTableElement(child); + break; + case "Feature": + this.ParseFeatureElement(child, ComplexReferenceParentType.Product, productCode, ref featureDisplay); + break; + case "FeatureRef": + this.ParseFeatureRefElement(child, ComplexReferenceParentType.Product, productCode); + break; + case "FeatureGroupRef": + this.ParseFeatureGroupRefElement(child, ComplexReferenceParentType.Product, productCode); + break; + case "Icon": + this.ParseIconElement(child); + break; + case "InstanceTransforms": + this.ParseInstanceTransformsElement(child); + break; + case "MajorUpgrade": + this.ParseMajorUpgradeElement(child, contextValues); + break; + case "Media": + this.ParseMediaElement(child, null); + break; + case "MediaTemplate": + this.ParseMediaTemplateElement(child, null); + break; + case "Package": + this.ParsePackageElement(child, manufacturer, null); + break; + case "PackageCertificates": + case "PatchCertificates": + this.ParseCertificatesElement(child); + break; + case "Property": + this.ParsePropertyElement(child); + break; + case "PropertyRef": + this.ParseSimpleRefElement(child, "Property"); + break; + case "SetDirectory": + this.ParseSetDirectoryElement(child); + break; + case "SetProperty": + this.ParseSetPropertyElement(child); + break; + case "SFPCatalog": + string parentName = null; + this.ParseSFPCatalogElement(child, ref parentName); + break; + case "SymbolPath": + if (null != symbols) + { + symbols += ";" + this.ParseSymbolPathElement(child); + } + else + { + symbols = this.ParseSymbolPathElement(child); + } + break; + case "UI": + this.ParseUIElement(child); + break; + case "UIRef": + this.ParseSimpleRefElement(child, "WixUI"); + break; + case "Upgrade": + this.ParseUpgradeElement(child); + break; + case "WixVariable": + this.ParseWixVariableElement(child); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -12028,40 +12024,40 @@ namespace WixToolset.Core /// This element's Id. private string ParseProgIdElement(XElement node, string componentId, YesNoType advertise, string classId, string description, string parent, ref bool foundExtension, YesNoType firstProgIdForClass) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string icon = null; - int iconIndex = CompilerConstants.IntegerNotSet; + var iconIndex = CompilerConstants.IntegerNotSet; string noOpen = null; string progId = null; - YesNoType progIdAdvertise = YesNoType.NotSet; + var progIdAdvertise = YesNoType.NotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - progId = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Advertise": - progIdAdvertise = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Description": - description = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); - break; - case "Icon": - icon = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "IconIndex": - iconIndex = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, short.MinValue + 1, short.MaxValue); - break; - case "NoOpen": - noOpen = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + progId = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Advertise": + progIdAdvertise = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Description": + description = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); + break; + case "Icon": + icon = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "IconIndex": + iconIndex = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, Int16.MinValue + 1, Int16.MaxValue); + break; + case "NoOpen": + noOpen = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -12089,41 +12085,41 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.VersionIndependentProgIdsCannotHaveIcons(sourceLineNumbers)); } - YesNoType firstProgIdForNestedClass = YesNoType.Yes; - foreach (XElement child in node.Elements()) + var firstProgIdForNestedClass = YesNoType.Yes; + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Extension": - this.ParseExtensionElement(child, componentId, advertise, progId); - foundExtension = true; - break; - case "ProgId": - // Only allow one nested ProgId. If we have a child, we should not have a parent. - if (null == parent) + case "Extension": + this.ParseExtensionElement(child, componentId, advertise, progId); + foundExtension = true; + break; + case "ProgId": + // Only allow one nested ProgId. If we have a child, we should not have a parent. + if (null == parent) + { + if (YesNoType.Yes == advertise) { - if (YesNoType.Yes == advertise) - { - this.ParseProgIdElement(child, componentId, advertise, null, description, progId, ref foundExtension, firstProgIdForNestedClass); - } - else if (YesNoType.No == advertise) - { - this.ParseProgIdElement(child, componentId, advertise, classId, description, progId, ref foundExtension, firstProgIdForNestedClass); - } - - firstProgIdForNestedClass = YesNoType.No; // any ProgId after this one is definitely not the first. + this.ParseProgIdElement(child, componentId, advertise, null, description, progId, ref foundExtension, firstProgIdForNestedClass); } - else + else if (YesNoType.No == advertise) { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); - this.Core.Write(ErrorMessages.ProgIdNestedTooDeep(childSourceLineNumbers)); + this.ParseProgIdElement(child, componentId, advertise, classId, description, progId, ref foundExtension, firstProgIdForNestedClass); } - break; - default: - this.Core.UnexpectedElement(node, child); - break; + + firstProgIdForNestedClass = YesNoType.No; // any ProgId after this one is definitely not the first. + } + else + { + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + this.Core.Write(ErrorMessages.ProgIdNestedTooDeep(childSourceLineNumbers)); + } + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -12214,45 +12210,45 @@ namespace WixToolset.Core /// Element to parse. private void ParsePropertyElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - bool admin = false; - bool complianceCheck = false; - bool hidden = false; - bool secure = false; - YesNoType suppressModularization = YesNoType.NotSet; + var admin = false; + var complianceCheck = false; + var hidden = false; + var secure = false; + var suppressModularization = YesNoType.NotSet; string value = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Admin": - admin = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "ComplianceCheck": - complianceCheck = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Hidden": - hidden = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Secure": - secure = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "SuppressModularization": - suppressModularization = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Value": - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Admin": + admin = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "ComplianceCheck": + complianceCheck = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Hidden": + hidden = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Secure": + secure = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "SuppressModularization": + suppressModularization = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Value": + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -12275,7 +12271,7 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.CannotAuthorSpecialProperties(sourceLineNumbers, id.Id)); } - string innerText = this.Core.GetTrimmedInnerText(node); + var innerText = this.Core.GetTrimmedInnerText(node); if (null != value) { // cannot specify both the value attribute and inner text @@ -12294,27 +12290,27 @@ namespace WixToolset.Core this.Core.CreateSimpleReference(sourceLineNumbers, "Dialog", value); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { { switch (child.Name.LocalName) { - case "ProductSearch": - this.ParseProductSearchElement(child, id.Id); - secure = true; - break; - default: - // let ParseSearchSignatures handle standard AppSearch children and unknown elements - break; + case "ProductSearch": + this.ParseProductSearchElement(child, id.Id); + secure = true; + break; + default: + // let ParseSearchSignatures handle standard AppSearch children and unknown elements + break; } } } } // see if this property is used for appSearch - List signatures = this.ParseSearchSignatures(node); + var signatures = this.ParseSearchSignatures(node); // If we're doing CCP then there must be a signature. if (complianceCheck && 0 == signatures.Count) @@ -12322,7 +12318,7 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.SearchElementRequiredWithAttribute(sourceLineNumbers, node.Name.LocalName, "ComplianceCheck", "yes")); } - foreach (string sig in signatures) + foreach (var sig in signatures) { if (complianceCheck && !this.Core.EncounteredError) { @@ -12374,73 +12370,73 @@ namespace WixToolset.Core "Furthermore, there is no security hole here, as the strings won't need to make a round trip")] private YesNoType ParseRegistryKeyElement(XElement node, string componentId, int root, string parentKey, bool win64Component, out string possibleKeyPath) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - string key = parentKey; // default to parent key path + var key = parentKey; // default to parent key path string action = null; - bool forceCreateOnInstall = false; - bool forceDeleteOnUninstall = false; - Wix.RegistryKey.ActionType actionType = Wix.RegistryKey.ActionType.NotSet; - YesNoType keyPath = YesNoType.NotSet; + var forceCreateOnInstall = false; + var forceDeleteOnUninstall = false; + var actionType = Wix.RegistryKey.ActionType.NotSet; + var keyPath = YesNoType.NotSet; possibleKeyPath = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Action": - this.Core.Write(WarningMessages.DeprecatedRegistryKeyActionAttribute(sourceLineNumbers)); - action = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < action.Length) - { - actionType = Wix.RegistryKey.ParseActionType(action); - switch (actionType) - { - case Wix.RegistryKey.ActionType.create: - forceCreateOnInstall = true; - break; - case Wix.RegistryKey.ActionType.createAndRemoveOnUninstall: - forceCreateOnInstall = true; - forceDeleteOnUninstall = true; - break; - case Wix.RegistryKey.ActionType.none: - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, action, "create", "createAndRemoveOnUninstall", "none")); - break; - } - } - break; - case "ForceCreateOnInstall": - forceCreateOnInstall = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "ForceDeleteOnUninstall": - forceDeleteOnUninstall = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Key": - key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (null != parentKey) - { - key = Path.Combine(parentKey, key); - } - break; - case "Root": - if (CompilerConstants.IntegerNotSet != root) + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Action": + this.Core.Write(WarningMessages.DeprecatedRegistryKeyActionAttribute(sourceLineNumbers)); + action = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < action.Length) + { + actionType = Wix.RegistryKey.ParseActionType(action); + switch (actionType) { - this.Core.Write(ErrorMessages.RegistryRootInvalid(sourceLineNumbers)); + case Wix.RegistryKey.ActionType.create: + forceCreateOnInstall = true; + break; + case Wix.RegistryKey.ActionType.createAndRemoveOnUninstall: + forceCreateOnInstall = true; + forceDeleteOnUninstall = true; + break; + case Wix.RegistryKey.ActionType.none: + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, action, "create", "createAndRemoveOnUninstall", "none")); + break; } + } + break; + case "ForceCreateOnInstall": + forceCreateOnInstall = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "ForceDeleteOnUninstall": + forceDeleteOnUninstall = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Key": + key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (null != parentKey) + { + key = Path.Combine(parentKey, key); + } + break; + case "Root": + if (CompilerConstants.IntegerNotSet != root) + { + this.Core.Write(ErrorMessages.RegistryRootInvalid(sourceLineNumbers)); + } - root = this.Core.GetAttributeMsidbRegistryRootValue(sourceLineNumbers, attrib, true); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + root = this.Core.GetAttributeMsidbRegistryRootValue(sourceLineNumbers, attrib, true); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -12449,7 +12445,7 @@ namespace WixToolset.Core } } - string name = forceCreateOnInstall ? (forceDeleteOnUninstall ? "*" : "+") : (forceDeleteOnUninstall ? "-" : null); + var name = forceCreateOnInstall ? (forceDeleteOnUninstall ? "*" : "+") : (forceDeleteOnUninstall ? "-" : null); if (forceCreateOnInstall || forceDeleteOnUninstall) // generates a Registry row, so an Id must be present { @@ -12479,7 +12475,7 @@ namespace WixToolset.Core key = String.Empty; // set the key to something to prevent null reference exceptions } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { @@ -12487,60 +12483,60 @@ namespace WixToolset.Core switch (child.Name.LocalName) { - case "RegistryKey": - if (YesNoType.Yes == this.ParseRegistryKeyElement(child, componentId, root, key, win64Component, out possibleChildKeyPath)) - { - if (YesNoType.Yes == keyPath) - { - this.Core.Write(ErrorMessages.ComponentMultipleKeyPaths(sourceLineNumbers, child.Name.LocalName, "KeyPath", "yes", "File", "RegistryValue", "ODBCDataSource")); - } - - possibleKeyPath = possibleChildKeyPath; // the child is the key path - keyPath = YesNoType.Yes; - } - else if (null == possibleKeyPath && null != possibleChildKeyPath) + case "RegistryKey": + if (YesNoType.Yes == this.ParseRegistryKeyElement(child, componentId, root, key, win64Component, out possibleChildKeyPath)) + { + if (YesNoType.Yes == keyPath) { - possibleKeyPath = possibleChildKeyPath; + this.Core.Write(ErrorMessages.ComponentMultipleKeyPaths(sourceLineNumbers, child.Name.LocalName, "KeyPath", "yes", "File", "RegistryValue", "ODBCDataSource")); } - break; - case "RegistryValue": - if (YesNoType.Yes == this.ParseRegistryValueElement(child, componentId, root, key, win64Component, out possibleChildKeyPath)) - { - if (YesNoType.Yes == keyPath) - { - this.Core.Write(ErrorMessages.ComponentMultipleKeyPaths(sourceLineNumbers, child.Name.LocalName, "KeyPath", "yes", "File", "RegistryValue", "ODBCDataSource")); - } - possibleKeyPath = possibleChildKeyPath; // the child is the key path - keyPath = YesNoType.Yes; - } - else if (null == possibleKeyPath && null != possibleChildKeyPath) - { - possibleKeyPath = possibleChildKeyPath; - } - break; - case "Permission": - if (!forceCreateOnInstall) - { - this.Core.Write(ErrorMessages.UnexpectedElementWithAttributeValue(sourceLineNumbers, node.Name.LocalName, child.Name.LocalName, "ForceCreateOnInstall", "yes")); - } - this.ParsePermissionElement(child, id.Id, "Registry"); - break; - case "PermissionEx": - if (!forceCreateOnInstall) + possibleKeyPath = possibleChildKeyPath; // the child is the key path + keyPath = YesNoType.Yes; + } + else if (null == possibleKeyPath && null != possibleChildKeyPath) + { + possibleKeyPath = possibleChildKeyPath; + } + break; + case "RegistryValue": + if (YesNoType.Yes == this.ParseRegistryValueElement(child, componentId, root, key, win64Component, out possibleChildKeyPath)) + { + if (YesNoType.Yes == keyPath) { - this.Core.Write(ErrorMessages.UnexpectedElementWithAttributeValue(sourceLineNumbers, node.Name.LocalName, child.Name.LocalName, "ForceCreateOnInstall", "yes")); + this.Core.Write(ErrorMessages.ComponentMultipleKeyPaths(sourceLineNumbers, child.Name.LocalName, "KeyPath", "yes", "File", "RegistryValue", "ODBCDataSource")); } - this.ParsePermissionExElement(child, id.Id, "Registry"); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + + possibleKeyPath = possibleChildKeyPath; // the child is the key path + keyPath = YesNoType.Yes; + } + else if (null == possibleKeyPath && null != possibleChildKeyPath) + { + possibleKeyPath = possibleChildKeyPath; + } + break; + case "Permission": + if (!forceCreateOnInstall) + { + this.Core.Write(ErrorMessages.UnexpectedElementWithAttributeValue(sourceLineNumbers, node.Name.LocalName, child.Name.LocalName, "ForceCreateOnInstall", "yes")); + } + this.ParsePermissionElement(child, id.Id, "Registry"); + break; + case "PermissionEx": + if (!forceCreateOnInstall) + { + this.Core.Write(ErrorMessages.UnexpectedElementWithAttributeValue(sourceLineNumbers, node.Name.LocalName, child.Name.LocalName, "ForceCreateOnInstall", "yes")); + } + this.ParsePermissionExElement(child, id.Id, "Registry"); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else { - Dictionary context = new Dictionary() { { "RegistryId", id.Id }, { "ComponentId", componentId }, { "Win64", win64Component.ToString() } }; + var context = new Dictionary() { { "RegistryId", id.Id }, { "ComponentId", componentId }, { "Win64", win64Component.ToString() } }; this.Core.ParseExtensionElement(node, child, context); } } @@ -12574,83 +12570,83 @@ namespace WixToolset.Core "Furthermore, there is no security hole here, as the strings won't need to make a round trip")] private YesNoType ParseRegistryValueElement(XElement node, string componentId, int root, string parentKey, bool win64Component, out string possibleKeyPath) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - string key = parentKey; // default to parent key path + var key = parentKey; // default to parent key path string name = null; string value = null; string type = null; - Wix.RegistryValue.TypeType typeType = Wix.RegistryValue.TypeType.NotSet; + var typeType = Wix.RegistryValue.TypeType.NotSet; string action = null; - Wix.RegistryValue.ActionType actionType = Wix.RegistryValue.ActionType.NotSet; - YesNoType keyPath = YesNoType.NotSet; - bool couldBeKeyPath = true; // assume that this is a regular registry key that could become the key path + var actionType = Wix.RegistryValue.ActionType.NotSet; + var keyPath = YesNoType.NotSet; + var couldBeKeyPath = true; // assume that this is a regular registry key that could become the key path possibleKeyPath = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Action": - action = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < action.Length) + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Action": + action = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < action.Length) + { + if (!Wix.RegistryValue.TryParseActionType(action, out actionType)) { - if (!Wix.RegistryValue.TryParseActionType(action, out actionType)) - { - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, action, "append", "prepend", "write")); - } + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, action, "append", "prepend", "write")); } - break; - case "Key": - key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (null != parentKey) + } + break; + case "Key": + key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (null != parentKey) + { + if (parentKey.EndsWith("\\", StringComparison.Ordinal)) { - if (parentKey.EndsWith("\\", StringComparison.Ordinal)) - { - key = String.Concat(parentKey, key); - } - else - { - key = String.Concat(parentKey, "\\", key); - } + key = String.Concat(parentKey, key); } - break; - case "KeyPath": - keyPath = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Name": - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Root": - if (CompilerConstants.IntegerNotSet != root) + else { - this.Core.Write(ErrorMessages.RegistryRootInvalid(sourceLineNumbers)); + key = String.Concat(parentKey, "\\", key); } + } + break; + case "KeyPath": + keyPath = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Root": + if (CompilerConstants.IntegerNotSet != root) + { + this.Core.Write(ErrorMessages.RegistryRootInvalid(sourceLineNumbers)); + } - root = this.Core.GetAttributeMsidbRegistryRootValue(sourceLineNumbers, attrib, true); - break; - case "Type": - type = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < type.Length) + root = this.Core.GetAttributeMsidbRegistryRootValue(sourceLineNumbers, attrib, true); + break; + case "Type": + type = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < type.Length) + { + if (!Wix.RegistryValue.TryParseTypeType(type, out typeType)) { - if (!Wix.RegistryValue.TryParseTypeType(type, out typeType)) - { - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, type, "binary", "expandable", "integer", "multiString", "string")); - } + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, type, "binary", "expandable", "integer", "multiString", "string")); } - break; - case "Value": - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + case "Value": + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -12686,40 +12682,40 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Type")); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "MultiStringValue": - if (Wix.RegistryValue.TypeType.multiString != typeType && null != value) - { - this.Core.Write(ErrorMessages.RegistryMultipleValuesWithoutMultiString(sourceLineNumbers, node.Name.LocalName, "Value", child.Name.LocalName, "Type")); - } - else if (null == value) - { - value = Common.GetInnerText(child); - } - else - { - value = String.Concat(value, "[~]", Common.GetInnerText(child)); - } - break; - case "Permission": - this.ParsePermissionElement(child, id.Id, "Registry"); - break; - case "PermissionEx": - this.ParsePermissionExElement(child, id.Id, "Registry"); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "MultiStringValue": + if (Wix.RegistryValue.TypeType.multiString != typeType && null != value) + { + this.Core.Write(ErrorMessages.RegistryMultipleValuesWithoutMultiString(sourceLineNumbers, node.Name.LocalName, "Value", child.Name.LocalName, "Type")); + } + else if (null == value) + { + value = Common.GetInnerText(child); + } + else + { + value = String.Concat(value, "[~]", Common.GetInnerText(child)); + } + break; + case "Permission": + this.ParsePermissionElement(child, id.Id, "Registry"); + break; + case "PermissionEx": + this.ParsePermissionExElement(child, id.Id, "Registry"); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else { - Dictionary context = new Dictionary() { { "RegistryId", id.Id }, { "ComponentId", componentId }, { "Win64", win64Component.ToString() } }; + var context = new Dictionary() { { "RegistryId", id.Id }, { "ComponentId", componentId }, { "Win64", win64Component.ToString() } }; this.Core.ParseExtensionElement(node, child, context); } } @@ -12727,40 +12723,40 @@ namespace WixToolset.Core switch (typeType) { - case Wix.RegistryValue.TypeType.binary: - value = String.Concat("#x", value); - break; - case Wix.RegistryValue.TypeType.expandable: - value = String.Concat("#%", value); - break; - case Wix.RegistryValue.TypeType.integer: - value = String.Concat("#", value); + case Wix.RegistryValue.TypeType.binary: + value = String.Concat("#x", value); + break; + case Wix.RegistryValue.TypeType.expandable: + value = String.Concat("#%", value); + break; + case Wix.RegistryValue.TypeType.integer: + value = String.Concat("#", value); + break; + case Wix.RegistryValue.TypeType.multiString: + switch (actionType) + { + case Wix.RegistryValue.ActionType.append: + value = String.Concat("[~]", value); break; - case Wix.RegistryValue.TypeType.multiString: - switch (actionType) - { - case Wix.RegistryValue.ActionType.append: - value = String.Concat("[~]", value); - break; - case Wix.RegistryValue.ActionType.prepend: - value = String.Concat(value, "[~]"); - break; - case Wix.RegistryValue.ActionType.write: - default: - if (null != value && -1 == value.IndexOf("[~]", StringComparison.Ordinal)) - { - value = String.Format(CultureInfo.InvariantCulture, "[~]{0}[~]", value); - } - break; - } + case Wix.RegistryValue.ActionType.prepend: + value = String.Concat(value, "[~]"); break; - case Wix.RegistryValue.TypeType.@string: - // escape the leading '#' character for string registry keys - if (null != value && value.StartsWith("#", StringComparison.Ordinal)) + case Wix.RegistryValue.ActionType.write: + default: + if (null != value && -1 == value.IndexOf("[~]", StringComparison.Ordinal)) { - value = String.Concat("#", value); + value = String.Format(CultureInfo.InvariantCulture, "[~]{0}[~]", value); } break; + } + break; + case Wix.RegistryValue.TypeType.@string: + // escape the leading '#' character for string registry keys + if (null != value && value.StartsWith("#", StringComparison.Ordinal)) + { + value = String.Concat("#", value); + } + break; } // value may be set by child MultiStringValue elements, so it must be checked here @@ -12804,42 +12800,42 @@ namespace WixToolset.Core "Furthermore, there is no security hole here, as the strings won't need to make a round trip")] private void ParseRemoveRegistryKeyElement(XElement node, string componentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string action = null; - Wix.RemoveRegistryKey.ActionType actionType = Wix.RemoveRegistryKey.ActionType.NotSet; + var actionType = Wix.RemoveRegistryKey.ActionType.NotSet; string key = null; - string name = "-"; - int root = CompilerConstants.IntegerNotSet; + var name = "-"; + var root = CompilerConstants.IntegerNotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Action": - action = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < action.Length) + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Action": + action = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < action.Length) + { + if (!Wix.RemoveRegistryKey.TryParseActionType(action, out actionType)) { - if (!Wix.RemoveRegistryKey.TryParseActionType(action, out actionType)) - { - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, action, "removeOnInstall", "removeOnUninstall")); - } + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, action, "removeOnInstall", "removeOnUninstall")); } - break; - case "Key": - key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Root": - root = this.Core.GetAttributeMsidbRegistryRootValue(sourceLineNumbers, attrib, true); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + case "Key": + key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Root": + root = this.Core.GetAttributeMsidbRegistryRootValue(sourceLineNumbers, attrib, true); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -12899,33 +12895,33 @@ namespace WixToolset.Core "Furthermore, there is no security hole here, as the strings won't need to make a round trip")] private void ParseRemoveRegistryValueElement(XElement node, string componentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string key = null; string name = null; - int root = CompilerConstants.IntegerNotSet; + var root = CompilerConstants.IntegerNotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Key": - key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Name": - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Root": - root = this.Core.GetAttributeMsidbRegistryRootValue(sourceLineNumbers, attrib, true); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Key": + key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Root": + root = this.Core.GetAttributeMsidbRegistryRootValue(sourceLineNumbers, attrib, true); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -12970,56 +12966,56 @@ namespace WixToolset.Core /// Identifier of the parent component's directory. private void ParseRemoveFileElement(XElement node, string componentId, string parentDirectory) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string directory = null; string name = null; - int on = CompilerConstants.IntegerNotSet; + var on = CompilerConstants.IntegerNotSet; string property = null; string shortName = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Directory": - directory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, parentDirectory); - break; - case "Name": - name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, true); - break; - case "On": - Wix.InstallUninstallType onValue = this.Core.GetAttributeInstallUninstallValue(sourceLineNumbers, attrib); - switch (onValue) - { - case Wix.InstallUninstallType.install: - on = 1; - break; - case Wix.InstallUninstallType.uninstall: - on = 2; - break; - case Wix.InstallUninstallType.both: - on = 3; - break; - default: - on = CompilerConstants.IllegalInteger; - break; - } + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Directory": + directory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, parentDirectory); + break; + case "Name": + name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, true); + break; + case "On": + var onValue = this.Core.GetAttributeInstallUninstallValue(sourceLineNumbers, attrib); + switch (onValue) + { + case Wix.InstallUninstallType.install: + on = 1; break; - case "Property": - property = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + case Wix.InstallUninstallType.uninstall: + on = 2; break; - case "ShortName": - shortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, true); + case Wix.InstallUninstallType.both: + on = 3; break; default: - this.Core.UnexpectedAttribute(node, attrib); + on = CompilerConstants.IllegalInteger; break; + } + break; + case "Property": + property = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "ShortName": + shortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, true); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -13074,7 +13070,7 @@ namespace WixToolset.Core { var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.RemoveFile, id); row.Set(1, componentId); - row.Set(2, GetMsiFilenameValue(shortName, name)); + row.Set(2, this.GetMsiFilenameValue(shortName, name)); if (null != directory) { row.Set(3, directory); @@ -13099,48 +13095,48 @@ namespace WixToolset.Core /// Identifier of parent component's directory. private void ParseRemoveFolderElement(XElement node, string componentId, string parentDirectory) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string directory = null; - int on = CompilerConstants.IntegerNotSet; + var on = CompilerConstants.IntegerNotSet; string property = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Directory": - directory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, parentDirectory); + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Directory": + directory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, parentDirectory); + break; + case "On": + var onValue = this.Core.GetAttributeInstallUninstallValue(sourceLineNumbers, attrib); + switch (onValue) + { + case Wix.InstallUninstallType.install: + on = 1; break; - case "On": - Wix.InstallUninstallType onValue = this.Core.GetAttributeInstallUninstallValue(sourceLineNumbers, attrib); - switch (onValue) - { - case Wix.InstallUninstallType.install: - on = 1; - break; - case Wix.InstallUninstallType.uninstall: - on = 2; - break; - case Wix.InstallUninstallType.both: - on = 3; - break; - default: - on = CompilerConstants.IllegalInteger; - break; - } + case Wix.InstallUninstallType.uninstall: + on = 2; break; - case "Property": - property = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + case Wix.InstallUninstallType.both: + on = 3; break; default: - this.Core.UnexpectedAttribute(node, attrib); + on = CompilerConstants.IllegalInteger; break; + } + break; + case "Property": + property = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -13196,32 +13192,32 @@ namespace WixToolset.Core /// Optional and default identifier of referenced directory. private void ParseReserveCostElement(XElement node, string componentId, string directoryId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - int runFromSource = CompilerConstants.IntegerNotSet; - int runLocal = CompilerConstants.IntegerNotSet; + var runFromSource = CompilerConstants.IntegerNotSet; + var runLocal = CompilerConstants.IntegerNotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Directory": - directoryId = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, directoryId); - break; - case "RunFromSource": - runFromSource = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); - break; - case "RunLocal": - runLocal = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Directory": + directoryId = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, directoryId); + break; + case "RunFromSource": + runFromSource = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int32.MaxValue); + break; + case "RunLocal": + runLocal = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int32.MaxValue); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -13271,109 +13267,109 @@ namespace WixToolset.Core } // Parse each action in the sequence. - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); - string actionName = child.Name.LocalName; + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + var actionName = child.Name.LocalName; string afterAction = null; string beforeAction = null; string condition = null; - bool customAction = "Custom" == actionName; - bool overridable = false; - int exitSequence = CompilerConstants.IntegerNotSet; - int sequence = CompilerConstants.IntegerNotSet; - bool showDialog = "Show" == actionName; - bool specialAction = "InstallExecute" == actionName || "InstallExecuteAgain" == actionName || "RemoveExistingProducts" == actionName || "DisableRollback" == actionName || "ScheduleReboot" == actionName || "ForceReboot" == actionName || "ResolveSource" == actionName; - bool specialStandardAction = "AppSearch" == actionName || "CCPSearch" == actionName || "RMCCPSearch" == actionName || "LaunchConditions" == actionName || "FindRelatedProducts" == actionName; - bool suppress = false; + var customAction = "Custom" == actionName; + var overridable = false; + var exitSequence = CompilerConstants.IntegerNotSet; + var sequence = CompilerConstants.IntegerNotSet; + var showDialog = "Show" == actionName; + var specialAction = "InstallExecute" == actionName || "InstallExecuteAgain" == actionName || "RemoveExistingProducts" == actionName || "DisableRollback" == actionName || "ScheduleReboot" == actionName || "ForceReboot" == actionName || "ResolveSource" == actionName; + var specialStandardAction = "AppSearch" == actionName || "CCPSearch" == actionName || "RMCCPSearch" == actionName || "LaunchConditions" == actionName || "FindRelatedProducts" == actionName; + var suppress = false; - foreach (XAttribute attrib in child.Attributes()) + foreach (var attrib in child.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Action": - if (customAction) - { - actionName = this.Core.GetAttributeIdentifierValue(childSourceLineNumbers, attrib); - this.Core.CreateSimpleReference(childSourceLineNumbers, "CustomAction", actionName); - } - else - { - this.Core.UnexpectedAttribute(child, attrib); - } - break; - case "After": - if (customAction || showDialog || specialAction || specialStandardAction) - { - afterAction = this.Core.GetAttributeIdentifierValue(childSourceLineNumbers, attrib); - this.Core.CreateSimpleReference(childSourceLineNumbers, "WixAction", sequenceTable, afterAction); - } - else - { - this.Core.UnexpectedAttribute(child, attrib); - } - break; - case "Before": - if (customAction || showDialog || specialAction || specialStandardAction) - { - beforeAction = this.Core.GetAttributeIdentifierValue(childSourceLineNumbers, attrib); - this.Core.CreateSimpleReference(childSourceLineNumbers, "WixAction", sequenceTable, beforeAction); - } - else - { - this.Core.UnexpectedAttribute(child, attrib); - } - break; - case "Dialog": - if (showDialog) - { - actionName = this.Core.GetAttributeIdentifierValue(childSourceLineNumbers, attrib); - this.Core.CreateSimpleReference(childSourceLineNumbers, "Dialog", actionName); - } - else - { - this.Core.UnexpectedAttribute(child, attrib); - } - break; - case "OnExit": - if (customAction || showDialog || specialAction) - { - Wix.ExitType exitValue = this.Core.GetAttributeExitValue(childSourceLineNumbers, attrib); - switch (exitValue) - { - case Wix.ExitType.success: - exitSequence = -1; - break; - case Wix.ExitType.cancel: - exitSequence = -2; - break; - case Wix.ExitType.error: - exitSequence = -3; - break; - case Wix.ExitType.suspend: - exitSequence = -4; - break; - } - } - else + case "Action": + if (customAction) + { + actionName = this.Core.GetAttributeIdentifierValue(childSourceLineNumbers, attrib); + this.Core.CreateSimpleReference(childSourceLineNumbers, "CustomAction", actionName); + } + else + { + this.Core.UnexpectedAttribute(child, attrib); + } + break; + case "After": + if (customAction || showDialog || specialAction || specialStandardAction) + { + afterAction = this.Core.GetAttributeIdentifierValue(childSourceLineNumbers, attrib); + this.Core.CreateSimpleReference(childSourceLineNumbers, "WixAction", sequenceTable, afterAction); + } + else + { + this.Core.UnexpectedAttribute(child, attrib); + } + break; + case "Before": + if (customAction || showDialog || specialAction || specialStandardAction) + { + beforeAction = this.Core.GetAttributeIdentifierValue(childSourceLineNumbers, attrib); + this.Core.CreateSimpleReference(childSourceLineNumbers, "WixAction", sequenceTable, beforeAction); + } + else + { + this.Core.UnexpectedAttribute(child, attrib); + } + break; + case "Dialog": + if (showDialog) + { + actionName = this.Core.GetAttributeIdentifierValue(childSourceLineNumbers, attrib); + this.Core.CreateSimpleReference(childSourceLineNumbers, "Dialog", actionName); + } + else + { + this.Core.UnexpectedAttribute(child, attrib); + } + break; + case "OnExit": + if (customAction || showDialog || specialAction) + { + var exitValue = this.Core.GetAttributeExitValue(childSourceLineNumbers, attrib); + switch (exitValue) { - this.Core.UnexpectedAttribute(child, attrib); + case Wix.ExitType.success: + exitSequence = -1; + break; + case Wix.ExitType.cancel: + exitSequence = -2; + break; + case Wix.ExitType.error: + exitSequence = -3; + break; + case Wix.ExitType.suspend: + exitSequence = -4; + break; } - break; - case "Overridable": - overridable = YesNoType.Yes == this.Core.GetAttributeYesNoValue(childSourceLineNumbers, attrib); - break; - case "Sequence": - sequence = this.Core.GetAttributeIntegerValue(childSourceLineNumbers, attrib, 1, short.MaxValue); - break; - case "Suppress": - suppress = YesNoType.Yes == this.Core.GetAttributeYesNoValue(childSourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + else + { + this.Core.UnexpectedAttribute(child, attrib); + } + break; + case "Overridable": + overridable = YesNoType.Yes == this.Core.GetAttributeYesNoValue(childSourceLineNumbers, attrib); + break; + case "Sequence": + sequence = this.Core.GetAttributeIntegerValue(childSourceLineNumbers, attrib, 1, Int16.MaxValue); + break; + case "Suppress": + suppress = YesNoType.Yes == this.Core.GetAttributeYesNoValue(childSourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -13480,119 +13476,119 @@ namespace WixToolset.Core /// Optional element containing parent's service name. private void ParseServiceConfigElement(XElement node, string componentId, string serviceName) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string delayedAutoStart = null; string failureActionsWhen = null; - int events = 0; - string name = serviceName; + var events = 0; + var name = serviceName; string preShutdownDelay = null; string requiredPrivileges = null; string sid = null; this.Core.Write(WarningMessages.ServiceConfigFamilyNotSupported(sourceLineNumbers, node.Name.LocalName)); - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "DelayedAutoStart": - delayedAutoStart = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < delayedAutoStart.Length) - { - switch (delayedAutoStart) - { - case "no": - delayedAutoStart = "0"; - break; - case "yes": - delayedAutoStart = "1"; - break; - default: - // allow everything else to pass through that are hopefully "formatted" Properties. - break; - } - } - break; - case "FailureActionsWhen": - failureActionsWhen = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < failureActionsWhen.Length) - { - switch (failureActionsWhen) - { - case "failedToStop": - failureActionsWhen = "0"; - break; - case "failedToStopOrReturnedError": - failureActionsWhen = "1"; - break; - default: - // allow everything else to pass through that are hopefully "formatted" Properties. - break; - } - } - break; - case "OnInstall": - YesNoType install = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - if (YesNoType.Yes == install) - { - events |= MsiInterop.MsidbServiceConfigEventInstall; - } - break; - case "OnReinstall": - YesNoType reinstall = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - if (YesNoType.Yes == reinstall) - { - events |= MsiInterop.MsidbServiceConfigEventReinstall; - } - break; - case "OnUninstall": - YesNoType uninstall = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - if (YesNoType.Yes == uninstall) + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "DelayedAutoStart": + delayedAutoStart = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < delayedAutoStart.Length) + { + switch (delayedAutoStart) { - events |= MsiInterop.MsidbServiceConfigEventUninstall; + case "no": + delayedAutoStart = "0"; + break; + case "yes": + delayedAutoStart = "1"; + break; + default: + // allow everything else to pass through that are hopefully "formatted" Properties. + break; } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; - case "PreShutdownDelay": - preShutdownDelay = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); - break; - case "ServiceName": - if (!String.IsNullOrEmpty(serviceName)) + } + break; + case "FailureActionsWhen": + failureActionsWhen = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < failureActionsWhen.Length) + { + switch (failureActionsWhen) { - this.Core.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ServiceInstall")); + case "failedToStop": + failureActionsWhen = "0"; + break; + case "failedToStopOrReturnedError": + failureActionsWhen = "1"; + break; + default: + // allow everything else to pass through that are hopefully "formatted" Properties. + break; } + } + break; + case "OnInstall": + var install = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + if (YesNoType.Yes == install) + { + events |= MsiInterop.MsidbServiceConfigEventInstall; + } + break; + case "OnReinstall": + var reinstall = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + if (YesNoType.Yes == reinstall) + { + events |= MsiInterop.MsidbServiceConfigEventReinstall; + } + break; + case "OnUninstall": + var uninstall = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + if (YesNoType.Yes == uninstall) + { + events |= MsiInterop.MsidbServiceConfigEventUninstall; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; + case "PreShutdownDelay": + preShutdownDelay = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); + break; + case "ServiceName": + if (!String.IsNullOrEmpty(serviceName)) + { + this.Core.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ServiceInstall")); + } - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "ServiceSid": - sid = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < sid.Length) + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "ServiceSid": + sid = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < sid.Length) + { + switch (sid) { - switch (sid) - { - case "none": - sid = "0"; - break; - case "restricted": - sid = "3"; - break; - case "unrestricted": - sid = "1"; - break; - default: - // allow everything else to pass through that are hopefully "formatted" Properties. - break; - } + case "none": + sid = "0"; + break; + case "restricted": + sid = "3"; + break; + case "unrestricted": + sid = "1"; + break; + default: + // allow everything else to pass through that are hopefully "formatted" Properties. + break; } - break; + } + break; } } else @@ -13602,139 +13598,139 @@ namespace WixToolset.Core } // Get the ServiceConfig required privilegs. - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "RequiredPrivilege": - string 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); + 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: - this.Core.UnexpectedElement(node, child); + // allow everything else to pass through that are hopefully "formatted" Properties. break; + } + + if (null != requiredPrivileges) + { + requiredPrivileges = String.Concat(requiredPrivileges, "[~]"); + } + requiredPrivileges = String.Concat(requiredPrivileges, privilege); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -13824,11 +13820,11 @@ namespace WixToolset.Core /// Optional element containing parent's service name. private void ParseServiceConfigFailureActionsElement(XElement node, string componentId, string serviceName) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - int events = 0; - string name = serviceName; - int resetPeriod = CompilerConstants.IntegerNotSet; + var events = 0; + var name = serviceName; + var resetPeriod = CompilerConstants.IntegerNotSet; string rebootMessage = null; string command = null; string actions = null; @@ -13836,56 +13832,56 @@ namespace WixToolset.Core this.Core.Write(WarningMessages.ServiceConfigFamilyNotSupported(sourceLineNumbers, node.Name.LocalName)); - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Command": - command = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); - break; - case "OnInstall": - YesNoType install = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - if (YesNoType.Yes == install) - { - events |= MsiInterop.MsidbServiceConfigEventInstall; - } - break; - case "OnReinstall": - YesNoType reinstall = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - if (YesNoType.Yes == reinstall) - { - events |= MsiInterop.MsidbServiceConfigEventReinstall; - } - break; - case "OnUninstall": - YesNoType uninstall = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - if (YesNoType.Yes == uninstall) - { - events |= MsiInterop.MsidbServiceConfigEventUninstall; - } - break; - case "RebootMessage": - rebootMessage = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); - break; - case "ResetPeriod": - resetPeriod = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); - break; - case "ServiceName": - if (!String.IsNullOrEmpty(serviceName)) - { - this.Core.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ServiceInstall")); - } + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Command": + command = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); + break; + case "OnInstall": + var install = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + if (YesNoType.Yes == install) + { + events |= MsiInterop.MsidbServiceConfigEventInstall; + } + break; + case "OnReinstall": + var reinstall = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + if (YesNoType.Yes == reinstall) + { + events |= MsiInterop.MsidbServiceConfigEventReinstall; + } + break; + case "OnUninstall": + var uninstall = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + if (YesNoType.Yes == uninstall) + { + events |= MsiInterop.MsidbServiceConfigEventUninstall; + } + break; + case "RebootMessage": + rebootMessage = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); + break; + case "ResetPeriod": + resetPeriod = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int32.MaxValue); + break; + case "ServiceName": + if (!String.IsNullOrEmpty(serviceName)) + { + this.Core.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ServiceInstall")); + } - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -13895,79 +13891,79 @@ namespace WixToolset.Core } // Get the ServiceConfigFailureActions actions. - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Failure": - string action = null; - string delay = null; - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + case "Failure": + string action = null; + string delay = null; + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); - foreach (XAttribute childAttrib in child.Attributes()) + foreach (var childAttrib in child.Attributes()) + { + if (String.IsNullOrEmpty(childAttrib.Name.NamespaceName) || CompilerCore.WixNamespace == childAttrib.Name.Namespace) { - if (String.IsNullOrEmpty(childAttrib.Name.NamespaceName) || CompilerCore.WixNamespace == childAttrib.Name.Namespace) + switch (childAttrib.Name.LocalName) { - switch (childAttrib.Name.LocalName) + case "Action": + action = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib); + switch (action) { - case "Action": - action = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib); - switch (action) - { - case "none": - action = "0"; - break; - case "restartComputer": - action = "2"; - break; - case "restartService": - action = "1"; - break; - case "runCommand": - action = "3"; - break; - default: - // allow everything else to pass through that are hopefully "formatted" Properties. - break; - } - break; - case "Delay": - delay = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib); - break; - default: - this.Core.UnexpectedAttribute(child, childAttrib); - break; + case "none": + action = "0"; + break; + case "restartComputer": + action = "2"; + break; + case "restartService": + action = "1"; + break; + case "runCommand": + action = "3"; + break; + default: + // allow everything else to pass through that are hopefully "formatted" Properties. + break; } + break; + case "Delay": + delay = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib); + break; + default: + this.Core.UnexpectedAttribute(child, childAttrib); + break; } } + } - if (String.IsNullOrEmpty(action)) - { - this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, child.Name.LocalName, "Action")); - } + if (String.IsNullOrEmpty(action)) + { + this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, child.Name.LocalName, "Action")); + } - if (String.IsNullOrEmpty(delay)) - { - this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, child.Name.LocalName, "Delay")); - } + if (String.IsNullOrEmpty(delay)) + { + this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, child.Name.LocalName, "Delay")); + } - if (!String.IsNullOrEmpty(actions)) - { - actions = String.Concat(actions, "[~]"); - } - actions = String.Concat(actions, action); + if (!String.IsNullOrEmpty(actions)) + { + actions = String.Concat(actions, "[~]"); + } + actions = String.Concat(actions, action); - if (!String.IsNullOrEmpty(actionsDelays)) - { - actionsDelays = String.Concat(actionsDelays, "[~]"); - } - actionsDelays = String.Concat(actionsDelays, delay); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + if (!String.IsNullOrEmpty(actionsDelays)) + { + actionsDelays = String.Concat(actionsDelays, "[~]"); + } + actionsDelays = String.Concat(actionsDelays, delay); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -14014,76 +14010,76 @@ namespace WixToolset.Core /// Identifier of parent component. private void ParseServiceControlElement(XElement node, string componentId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string arguments = null; - int events = 0; // default is to do nothing + var events = 0; // default is to do nothing Identifier id = null; string name = null; - YesNoType wait = YesNoType.NotSet; + var wait = YesNoType.NotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Remove": + var removeValue = this.Core.GetAttributeInstallUninstallValue(sourceLineNumbers, attrib); + switch (removeValue) + { + case Wix.InstallUninstallType.install: + events |= MsiInterop.MsidbServiceControlEventDelete; break; - case "Name": - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + case Wix.InstallUninstallType.uninstall: + events |= MsiInterop.MsidbServiceControlEventUninstallDelete; break; - case "Remove": - Wix.InstallUninstallType removeValue = this.Core.GetAttributeInstallUninstallValue(sourceLineNumbers, attrib); - switch (removeValue) - { - case Wix.InstallUninstallType.install: - events |= MsiInterop.MsidbServiceControlEventDelete; - break; - case Wix.InstallUninstallType.uninstall: - events |= MsiInterop.MsidbServiceControlEventUninstallDelete; - break; - case Wix.InstallUninstallType.both: - events |= MsiInterop.MsidbServiceControlEventDelete | MsiInterop.MsidbServiceControlEventUninstallDelete; - break; - } + case Wix.InstallUninstallType.both: + events |= MsiInterop.MsidbServiceControlEventDelete | MsiInterop.MsidbServiceControlEventUninstallDelete; break; - case "Start": - Wix.InstallUninstallType startValue = this.Core.GetAttributeInstallUninstallValue(sourceLineNumbers, attrib); - switch (startValue) - { - case Wix.InstallUninstallType.install: - events |= MsiInterop.MsidbServiceControlEventStart; - break; - case Wix.InstallUninstallType.uninstall: - events |= MsiInterop.MsidbServiceControlEventUninstallStart; - break; - case Wix.InstallUninstallType.both: - events |= MsiInterop.MsidbServiceControlEventStart | MsiInterop.MsidbServiceControlEventUninstallStart; - break; - } + } + break; + case "Start": + var startValue = this.Core.GetAttributeInstallUninstallValue(sourceLineNumbers, attrib); + switch (startValue) + { + case Wix.InstallUninstallType.install: + events |= MsiInterop.MsidbServiceControlEventStart; break; - case "Stop": - Wix.InstallUninstallType stopValue = this.Core.GetAttributeInstallUninstallValue(sourceLineNumbers, attrib); - switch (stopValue) - { - case Wix.InstallUninstallType.install: - events |= MsiInterop.MsidbServiceControlEventStop; - break; - case Wix.InstallUninstallType.uninstall: - events |= MsiInterop.MsidbServiceControlEventUninstallStop; - break; - case Wix.InstallUninstallType.both: - events |= MsiInterop.MsidbServiceControlEventStop | MsiInterop.MsidbServiceControlEventUninstallStop; - break; - } + case Wix.InstallUninstallType.uninstall: + events |= MsiInterop.MsidbServiceControlEventUninstallStart; break; - case "Wait": - wait = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + case Wix.InstallUninstallType.both: + events |= MsiInterop.MsidbServiceControlEventStart | MsiInterop.MsidbServiceControlEventUninstallStart; break; - default: - this.Core.UnexpectedAttribute(node, attrib); + } + break; + case "Stop": + var stopValue = this.Core.GetAttributeInstallUninstallValue(sourceLineNumbers, attrib); + switch (stopValue) + { + case Wix.InstallUninstallType.install: + events |= MsiInterop.MsidbServiceControlEventStop; + break; + case Wix.InstallUninstallType.uninstall: + events |= MsiInterop.MsidbServiceControlEventUninstallStop; break; + case Wix.InstallUninstallType.both: + events |= MsiInterop.MsidbServiceControlEventStop | MsiInterop.MsidbServiceControlEventUninstallStop; + break; + } + break; + case "Wait": + wait = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -14103,22 +14099,22 @@ namespace WixToolset.Core } // get the ServiceControl arguments - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "ServiceArgument": - if (null != arguments) - { - arguments = String.Concat(arguments, "[~]"); - } - arguments = String.Concat(arguments, this.Core.GetTrimmedInnerText(child)); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "ServiceArgument": + if (null != arguments) + { + arguments = String.Concat(arguments, "[~]"); + } + arguments = String.Concat(arguments, this.Core.GetTrimmedInnerText(child)); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -14148,25 +14144,25 @@ namespace WixToolset.Core /// Parsed sevice dependency name. private string ParseServiceDependencyElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string dependency = null; - bool group = false; + var group = false; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - dependency = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Group": - group = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + dependency = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Group": + group = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -14192,140 +14188,140 @@ namespace WixToolset.Core /// Identifier of parent component. private void ParseServiceInstallElement(XElement node, string componentId, bool win64Component) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string account = null; string arguments = null; string dependencies = null; string description = null; string displayName = null; - bool eraseDescription = false; - int errorbits = 0; + var eraseDescription = false; + var errorbits = 0; string loadOrderGroup = null; string name = null; string password = null; - int startType = 0; - int typebits = 0; + var startType = 0; + var typebits = 0; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Account": - account = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Arguments": - arguments = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Description": - description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "DisplayName": - displayName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "EraseDescription": - eraseDescription = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "ErrorControl": - string errorControlValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < errorControlValue.Length) - { - Wix.ServiceInstall.ErrorControlType errorControlType = Wix.ServiceInstall.ParseErrorControlType(errorControlValue); - switch (errorControlType) - { - case Wix.ServiceInstall.ErrorControlType.ignore: - errorbits |= MsiInterop.MsidbServiceInstallErrorIgnore; - break; - case Wix.ServiceInstall.ErrorControlType.normal: - errorbits |= MsiInterop.MsidbServiceInstallErrorNormal; - break; - case Wix.ServiceInstall.ErrorControlType.critical: - errorbits |= MsiInterop.MsidbServiceInstallErrorCritical; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, errorControlValue, "ignore", "normal", "critical")); - break; - } - } - break; - case "Interactive": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - typebits |= MsiInterop.MsidbServiceInstallInteractive; - } - break; - case "LoadOrderGroup": - loadOrderGroup = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Name": - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Password": - password = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Start": - string startValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < startValue.Length) + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Account": + account = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Arguments": + arguments = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Description": + description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DisplayName": + displayName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "EraseDescription": + eraseDescription = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "ErrorControl": + var errorControlValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < errorControlValue.Length) + { + var errorControlType = Wix.ServiceInstall.ParseErrorControlType(errorControlValue); + switch (errorControlType) { - Wix.ServiceInstall.StartType start = Wix.ServiceInstall.ParseStartType(startValue); - switch (start) - { - case Wix.ServiceInstall.StartType.auto: - startType = MsiInterop.MsidbServiceInstallAutoStart; - break; - case Wix.ServiceInstall.StartType.demand: - startType = MsiInterop.MsidbServiceInstallDemandStart; - break; - case Wix.ServiceInstall.StartType.disabled: - startType = MsiInterop.MsidbServiceInstallDisabled; - break; - case Wix.ServiceInstall.StartType.boot: - case Wix.ServiceInstall.StartType.system: - this.Core.Write(ErrorMessages.ValueNotSupported(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, startValue)); - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, startValue, "auto", "demand", "disabled")); - break; - } + case Wix.ServiceInstall.ErrorControlType.ignore: + errorbits |= MsiInterop.MsidbServiceInstallErrorIgnore; + break; + case Wix.ServiceInstall.ErrorControlType.normal: + errorbits |= MsiInterop.MsidbServiceInstallErrorNormal; + break; + case Wix.ServiceInstall.ErrorControlType.critical: + errorbits |= MsiInterop.MsidbServiceInstallErrorCritical; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, errorControlValue, "ignore", "normal", "critical")); + break; } - break; - case "Type": - string typeValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < typeValue.Length) + } + break; + case "Interactive": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + typebits |= MsiInterop.MsidbServiceInstallInteractive; + } + break; + case "LoadOrderGroup": + loadOrderGroup = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Password": + password = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Start": + var startValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < startValue.Length) + { + var start = Wix.ServiceInstall.ParseStartType(startValue); + switch (start) { - Wix.ServiceInstall.TypeType typeType = Wix.ServiceInstall.ParseTypeType(typeValue); - switch (typeType) - { - case Wix.ServiceInstall.TypeType.ownProcess: - typebits |= MsiInterop.MsidbServiceInstallOwnProcess; - break; - case Wix.ServiceInstall.TypeType.shareProcess: - typebits |= MsiInterop.MsidbServiceInstallShareProcess; - break; - case Wix.ServiceInstall.TypeType.kernelDriver: - case Wix.ServiceInstall.TypeType.systemDriver: - this.Core.Write(ErrorMessages.ValueNotSupported(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, typeValue)); - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, node.Name.LocalName, typeValue, "ownProcess", "shareProcess")); - break; - } + case Wix.ServiceInstall.StartType.auto: + startType = MsiInterop.MsidbServiceInstallAutoStart; + break; + case Wix.ServiceInstall.StartType.demand: + startType = MsiInterop.MsidbServiceInstallDemandStart; + break; + case Wix.ServiceInstall.StartType.disabled: + startType = MsiInterop.MsidbServiceInstallDisabled; + break; + case Wix.ServiceInstall.StartType.boot: + case Wix.ServiceInstall.StartType.system: + this.Core.Write(ErrorMessages.ValueNotSupported(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, startValue)); + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, startValue, "auto", "demand", "disabled")); + break; } - break; - case "Vital": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + } + break; + case "Type": + var typeValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < typeValue.Length) + { + var typeType = Wix.ServiceInstall.ParseTypeType(typeValue); + switch (typeType) { - errorbits |= MsiInterop.MsidbServiceInstallErrorControlVital; + case Wix.ServiceInstall.TypeType.ownProcess: + typebits |= MsiInterop.MsidbServiceInstallOwnProcess; + break; + case Wix.ServiceInstall.TypeType.shareProcess: + typebits |= MsiInterop.MsidbServiceInstallShareProcess; + break; + case Wix.ServiceInstall.TypeType.kernelDriver: + case Wix.ServiceInstall.TypeType.systemDriver: + this.Core.Write(ErrorMessages.ValueNotSupported(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, typeValue)); + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, node.Name.LocalName, typeValue, "ownProcess", "shareProcess")); + break; } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + case "Vital": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + errorbits |= MsiInterop.MsidbServiceInstallErrorControlVital; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -14354,32 +14350,32 @@ namespace WixToolset.Core } // get the ServiceInstall dependencies and config - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "PermissionEx": - this.ParsePermissionExElement(child, id.Id, "ServiceInstall"); - break; - case "ServiceConfig": - this.ParseServiceConfigElement(child, componentId, name); - break; - case "ServiceConfigFailureActions": - this.ParseServiceConfigFailureActionsElement(child, componentId, name); - break; - case "ServiceDependency": - dependencies = String.Concat(dependencies, this.ParseServiceDependencyElement(child), "[~]"); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "PermissionEx": + this.ParsePermissionExElement(child, id.Id, "ServiceInstall"); + break; + case "ServiceConfig": + this.ParseServiceConfigElement(child, componentId, name); + break; + case "ServiceConfigFailureActions": + this.ParseServiceConfigFailureActionsElement(child, componentId, name); + break; + case "ServiceDependency": + dependencies = String.Concat(dependencies, this.ParseServiceDependencyElement(child), "[~]"); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else { - Dictionary context = new Dictionary() { { "ServiceInstallId", id.Id }, { "ServiceInstallName", name }, { "ServiceInstallComponentId", componentId }, { "Win64", win64Component.ToString() } }; + var context = new Dictionary() { { "ServiceInstallId", id.Id }, { "ServiceInstallName", name }, { "ServiceInstallComponentId", componentId }, { "Win64", win64Component.ToString() } }; this.Core.ParseExtensionElement(node, child, context); } } @@ -14413,59 +14409,59 @@ namespace WixToolset.Core /// Element to parse. private void ParseSetDirectoryElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string actionName = null; string id = null; string condition = null; - string[] sequences = new string[] { "InstallUISequence", "InstallExecuteSequence" }; // default to "both" - int extraBits = 0; + var sequences = new string[] { "InstallUISequence", "InstallExecuteSequence" }; // default to "both" + var extraBits = 0; string value = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Action": - actionName = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "Directory", id); - break; - case "Sequence": - string sequenceValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < sequenceValue.Length) + case "Action": + actionName = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "Directory", id); + break; + case "Sequence": + var sequenceValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < sequenceValue.Length) + { + var sequenceType = Wix.Enums.ParseSequenceType(sequenceValue); + switch (sequenceType) { - Wix.SequenceType sequenceType = Wix.Enums.ParseSequenceType(sequenceValue); - switch (sequenceType) - { - case Wix.SequenceType.execute: - sequences = new string[] { "InstallExecuteSequence" }; - break; - case Wix.SequenceType.ui: - sequences = new string[] { "InstallUISequence" }; - break; - case Wix.SequenceType.first: - extraBits = MsiInterop.MsidbCustomActionTypeFirstSequence; - // default puts it in both sequence which is what we want - break; - case Wix.SequenceType.both: - // default so no work necessary. - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, sequenceValue, "execute", "ui", "both")); - break; - } + case Wix.SequenceType.execute: + sequences = new string[] { "InstallExecuteSequence" }; + break; + case Wix.SequenceType.ui: + sequences = new string[] { "InstallUISequence" }; + break; + case Wix.SequenceType.first: + extraBits = MsiInterop.MsidbCustomActionTypeFirstSequence; + // default puts it in both sequence which is what we want + break; + case Wix.SequenceType.both: + // default so no work necessary. + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, sequenceValue, "execute", "ui", "both")); + break; } - break; - case "Value": - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + case "Value": + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -14500,7 +14496,7 @@ namespace WixToolset.Core row.Set(2, id); row.Set(3, value); - foreach (string sequence in sequences) + foreach (var sequence in sequences) { var sequenceRow = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.WixAction); sequenceRow.Set(0, sequence); @@ -14520,66 +14516,66 @@ namespace WixToolset.Core /// Element to parse. private void ParseSetPropertyElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string actionName = null; string id = null; string afterAction = null; string beforeAction = null; string condition = null; - string[] sequences = new string[] { "InstallUISequence", "InstallExecuteSequence" }; // default to "both" - int extraBits = 0; + var sequences = new string[] { "InstallUISequence", "InstallExecuteSequence" }; // default to "both" + var extraBits = 0; string value = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Action": - actionName = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "After": - afterAction = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "Before": - beforeAction = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "Sequence": - string sequenceValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (0 < sequenceValue.Length) + case "Action": + actionName = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "After": + afterAction = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "Before": + beforeAction = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "Sequence": + var sequenceValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (0 < sequenceValue.Length) + { + var sequenceType = Wix.Enums.ParseSequenceType(sequenceValue); + switch (sequenceType) { - Wix.SequenceType sequenceType = Wix.Enums.ParseSequenceType(sequenceValue); - switch (sequenceType) - { - case Wix.SequenceType.execute: - sequences = new string[] { "InstallExecuteSequence" }; - break; - case Wix.SequenceType.ui: - sequences = new string[] { "InstallUISequence" }; - break; - case Wix.SequenceType.first: - extraBits = MsiInterop.MsidbCustomActionTypeFirstSequence; - // default puts it in both sequence which is what we want - break; - case Wix.SequenceType.both: - // default so no work necessary. - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, sequenceValue, "execute", "ui", "both")); - break; - } + case Wix.SequenceType.execute: + sequences = new string[] { "InstallExecuteSequence" }; + break; + case Wix.SequenceType.ui: + sequences = new string[] { "InstallUISequence" }; + break; + case Wix.SequenceType.first: + extraBits = MsiInterop.MsidbCustomActionTypeFirstSequence; + // default puts it in both sequence which is what we want + break; + case Wix.SequenceType.both: + // default so no work necessary. + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, sequenceValue, "execute", "ui", "both")); + break; } - break; - case "Value": - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + case "Value": + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -14633,7 +14629,7 @@ namespace WixToolset.Core row.Set(2, id); row.Set(3, value); - foreach (string sequence in sequences) + foreach (var sequence in sequences) { var sequenceRow = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.WixAction, new Identifier(AccessModifier.Public, sequence, actionName)); sequenceRow.Set(0, sequence); @@ -14678,21 +14674,21 @@ namespace WixToolset.Core /// Parent SFPCatalog. private void ParseSFPFileElement(XElement node, string parentSFPCatalog) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -14723,31 +14719,31 @@ namespace WixToolset.Core /// Parent SFPCatalog. private void ParseSFPCatalogElement(XElement node, ref string parentSFPCatalog) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string parentName = null; string dependency = null; string name = null; string sourceFile = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Dependency": - dependency = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Name": - name = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false); - parentSFPCatalog = name; - break; - case "SourceFile": - sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Dependency": + dependency = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false); + parentSFPCatalog = name; + break; + case "SourceFile": + sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -14766,26 +14762,26 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "SourceFile")); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "SFPCatalog": - this.ParseSFPCatalogElement(child, ref parentName); - if (null != dependency && parentName == dependency) - { - this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Dependency")); - } - dependency = parentName; - break; - case "SFPFile": - this.ParseSFPFileElement(child, name); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "SFPCatalog": + this.ParseSFPCatalogElement(child, ref parentName); + if (null != dependency && parentName == dependency) + { + this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Dependency")); + } + dependency = parentName; + break; + case "SFPFile": + this.ParseSFPFileElement(child, name); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -14818,110 +14814,110 @@ namespace WixToolset.Core /// Flag to indicate whether the parent element is the keypath of a component or not (will only be true for file parent elements). private void ParseShortcutElement(XElement node, string componentId, string parentElementLocalName, string defaultTarget, YesNoType parentKeyPath) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - bool advertise = false; + var advertise = false; string arguments = null; string description = null; string descriptionResourceDll = null; - int descriptionResourceId = CompilerConstants.IntegerNotSet; + var descriptionResourceId = CompilerConstants.IntegerNotSet; string directory = null; string displayResourceDll = null; - int displayResourceId = CompilerConstants.IntegerNotSet; - int hotkey = CompilerConstants.IntegerNotSet; + var displayResourceId = CompilerConstants.IntegerNotSet; + var hotkey = CompilerConstants.IntegerNotSet; string icon = null; - int iconIndex = CompilerConstants.IntegerNotSet; + var iconIndex = CompilerConstants.IntegerNotSet; string name = null; string shortName = null; - int show = CompilerConstants.IntegerNotSet; + var show = CompilerConstants.IntegerNotSet; string target = null; string workingDirectory = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Advertise": - advertise = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Arguments": - arguments = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Description": - description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "DescriptionResourceDll": - descriptionResourceDll = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "DescriptionResourceId": - descriptionResourceId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "Directory": - directory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null); - break; - case "DisplayResourceDll": - displayResourceDll = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "DisplayResourceId": - displayResourceId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "Hotkey": - hotkey = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "Icon": - icon = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "Icon", icon); - break; - case "IconIndex": - iconIndex = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, short.MinValue + 1, short.MaxValue); - break; - case "Name": - name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); - break; - case "ShortName": - shortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false); - break; - case "Show": - string showValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (showValue.Length == 0) + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Advertise": + advertise = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Arguments": + arguments = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Description": + description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DescriptionResourceDll": + descriptionResourceDll = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DescriptionResourceId": + descriptionResourceId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "Directory": + directory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null); + break; + case "DisplayResourceDll": + displayResourceDll = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DisplayResourceId": + displayResourceId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "Hotkey": + hotkey = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "Icon": + icon = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "Icon", icon); + break; + case "IconIndex": + iconIndex = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, Int16.MinValue + 1, Int16.MaxValue); + break; + case "Name": + name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); + break; + case "ShortName": + shortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false); + break; + case "Show": + var showValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (showValue.Length == 0) + { + show = CompilerConstants.IllegalInteger; + } + else + { + var showType = Wix.Shortcut.ParseShowType(showValue); + switch (showType) { + case Wix.Shortcut.ShowType.normal: + show = 1; + break; + case Wix.Shortcut.ShowType.maximized: + show = 3; + break; + case Wix.Shortcut.ShowType.minimized: + show = 7; + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Show", showValue, "normal", "maximized", "minimized")); show = CompilerConstants.IllegalInteger; + break; } - else - { - Wix.Shortcut.ShowType showType = Wix.Shortcut.ParseShowType(showValue); - switch (showType) - { - case Wix.Shortcut.ShowType.normal: - show = 1; - break; - case Wix.Shortcut.ShowType.maximized: - show = 3; - break; - case Wix.Shortcut.ShowType.minimized: - show = 7; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Show", showValue, "normal", "maximized", "minimized")); - show = CompilerConstants.IllegalInteger; - break; - } - } - break; - case "Target": - target = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "WorkingDirectory": - workingDirectory = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + } + break; + case "Target": + target = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "WorkingDirectory": + workingDirectory = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -15011,21 +15007,21 @@ namespace WixToolset.Core id = this.Core.CreateIdentifier("sct", directory, LowercaseOrNull(name) ?? LowercaseOrNull(shortName)); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Icon": - icon = this.ParseIconElement(child); - break; - case "ShortcutProperty": - this.ParseShortcutPropertyElement(child, id.Id); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "Icon": + icon = this.ParseIconElement(child); + break; + case "ShortcutProperty": + this.ParseShortcutPropertyElement(child, id.Id); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -15038,7 +15034,7 @@ namespace WixToolset.Core { var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.Shortcut, id); row.Set(1, directory); - row.Set(2, GetMsiFilenameValue(shortName, name)); + row.Set(2, this.GetMsiFilenameValue(shortName, name)); row.Set(3, componentId); if (advertise) { @@ -15096,29 +15092,29 @@ namespace WixToolset.Core /// Element to parse. private void ParseShortcutPropertyElement(XElement node, string shortcutId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string key = null; string value = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Key": - key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Value": - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Key": + key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Value": + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -15136,7 +15132,7 @@ namespace WixToolset.Core id = this.Core.CreateIdentifier("scp", shortcutId, key.ToUpperInvariant()); } - string innerText = this.Core.GetTrimmedInnerText(node); + var innerText = this.Core.GetTrimmedInnerText(node); if (!String.IsNullOrEmpty(innerText)) { if (String.IsNullOrEmpty(value)) @@ -15174,78 +15170,78 @@ namespace WixToolset.Core /// true if the component is 64-bit. private void ParseTypeLibElement(XElement node, string componentId, string fileServer, bool win64Component) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - YesNoType advertise = YesNoType.NotSet; - int cost = CompilerConstants.IntegerNotSet; + var advertise = YesNoType.NotSet; + var cost = CompilerConstants.IntegerNotSet; string description = null; - int flags = 0; + var flags = 0; string helpDirectory = null; - int language = CompilerConstants.IntegerNotSet; - int majorVersion = CompilerConstants.IntegerNotSet; - int minorVersion = CompilerConstants.IntegerNotSet; - long resourceId = CompilerConstants.LongNotSet; + var language = CompilerConstants.IntegerNotSet; + var majorVersion = CompilerConstants.IntegerNotSet; + var minorVersion = CompilerConstants.IntegerNotSet; + var resourceId = CompilerConstants.LongNotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - case "Advertise": - advertise = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Control": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - flags |= 2; - } - break; - case "Cost": - cost = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); - break; - case "Description": - description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "HasDiskImage": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - flags |= 8; - } - break; - case "HelpDirectory": - helpDirectory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null); - break; - case "Hidden": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - flags |= 4; - } - break; - case "Language": - language = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "MajorVersion": - majorVersion = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, ushort.MaxValue); - break; - case "MinorVersion": - minorVersion = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, byte.MaxValue); - break; - case "ResourceId": - resourceId = this.Core.GetAttributeLongValue(sourceLineNumbers, attrib, int.MinValue, int.MaxValue); - break; - case "Restricted": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - flags |= 1; - } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + case "Advertise": + advertise = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Control": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + flags |= 2; + } + break; + case "Cost": + cost = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int32.MaxValue); + break; + case "Description": + description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "HasDiskImage": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + flags |= 8; + } + break; + case "HelpDirectory": + helpDirectory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null); + break; + case "Hidden": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + flags |= 4; + } + break; + case "Language": + language = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "MajorVersion": + majorVersion = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, UInt16.MaxValue); + break; + case "MinorVersion": + minorVersion = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Byte.MaxValue); + break; + case "ResourceId": + resourceId = this.Core.GetAttributeLongValue(sourceLineNumbers, attrib, Int32.MinValue, Int32.MaxValue); + break; + case "Restricted": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + flags |= 1; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -15294,24 +15290,24 @@ namespace WixToolset.Core advertise = YesNoType.No; } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "AppId": - this.ParseAppIdElement(child, componentId, YesNoType.NotSet, fileServer, id, registryVersion); - break; - case "Class": - this.ParseClassElement(child, componentId, YesNoType.NotSet, fileServer, id, registryVersion, null); - break; - case "Interface": - this.ParseInterfaceElement(child, componentId, null, null, id, registryVersion); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "AppId": + this.ParseAppIdElement(child, componentId, YesNoType.NotSet, fileServer, id, registryVersion); + break; + case "Class": + this.ParseClassElement(child, componentId, YesNoType.NotSet, fileServer, id, registryVersion, null); + break; + case "Interface": + this.ParseInterfaceElement(child, componentId, null, null, id, registryVersion); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -15391,7 +15387,7 @@ namespace WixToolset.Core this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Format(CultureInfo.InvariantCulture, @"TypeLib\{0}\{1}", id, registryVersion), null, description, componentId); // HKCR\TypeLib\[ID]\[MajorVersion].[MinorVersion]\[Language]\[win16|win32|win64], (Default) = [TypeLibPath]\[ResourceId] - string path = String.Concat("[#", fileServer, "]"); + var path = String.Concat("[#", fileServer, "]"); if (CompilerConstants.LongNotSet != resourceId) { path = String.Concat(path, Path.DirectorySeparatorChar, resourceId.ToString(CultureInfo.InvariantCulture.NumberFormat)); @@ -15415,55 +15411,55 @@ namespace WixToolset.Core /// Element to parse. private void ParseEmbeddedChainerElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string commandLine = null; string condition = null; string source = null; - int type = 0; + var type = 0; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "BinarySource": - if (null != source) - { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "FileSource", "PropertySource")); - } - source = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - type = MsiInterop.MsidbCustomActionTypeExe + MsiInterop.MsidbCustomActionTypeBinaryData; - this.Core.CreateSimpleReference(sourceLineNumbers, "Binary", source); // add a reference to the appropriate Binary - break; - case "CommandLine": - commandLine = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "FileSource": - if (null != source) - { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinarySource", "PropertySource")); - } - source = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - type = MsiInterop.MsidbCustomActionTypeExe + MsiInterop.MsidbCustomActionTypeSourceFile; - this.Core.CreateSimpleReference(sourceLineNumbers, "File", source); // add a reference to the appropriate File - break; - case "PropertySource": - if (null != source) - { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinarySource", "FileSource")); - } - source = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - type = MsiInterop.MsidbCustomActionTypeExe + MsiInterop.MsidbCustomActionTypeProperty; - // cannot add a reference to a Property because it may be created at runtime. - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "BinarySource": + if (null != source) + { + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "FileSource", "PropertySource")); + } + source = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + type = MsiInterop.MsidbCustomActionTypeExe + MsiInterop.MsidbCustomActionTypeBinaryData; + this.Core.CreateSimpleReference(sourceLineNumbers, "Binary", source); // add a reference to the appropriate Binary + break; + case "CommandLine": + commandLine = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "FileSource": + if (null != source) + { + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinarySource", "PropertySource")); + } + source = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + type = MsiInterop.MsidbCustomActionTypeExe + MsiInterop.MsidbCustomActionTypeSourceFile; + this.Core.CreateSimpleReference(sourceLineNumbers, "File", source); // add a reference to the appropriate File + break; + case "PropertySource": + if (null != source) + { + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinarySource", "FileSource")); + } + source = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + type = MsiInterop.MsidbCustomActionTypeExe + MsiInterop.MsidbCustomActionTypeProperty; + // cannot add a reference to a Property because it may be created at runtime. + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -15501,22 +15497,22 @@ namespace WixToolset.Core /// Element to parse. private void ParseUIElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - int embeddedUICount = 0; + var embeddedUICount = 0; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -15525,85 +15521,85 @@ namespace WixToolset.Core } } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "BillboardAction": - this.ParseBillboardActionElement(child); - break; - case "ComboBox": - this.ParseControlGroupElement(child, TupleDefinitionType.ComboBox, "ListItem"); - break; - case "Dialog": - this.ParseDialogElement(child); - break; - case "DialogRef": - this.ParseSimpleRefElement(child, "Dialog"); - break; - case "EmbeddedUI": - if (0 < embeddedUICount) // there can be only one embedded UI - { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); - this.Core.Write(ErrorMessages.TooManyChildren(childSourceLineNumbers, node.Name.LocalName, child.Name.LocalName)); - } - this.ParseEmbeddedUIElement(child); - ++embeddedUICount; - break; - case "Error": - this.ParseErrorElement(child); - break; - case "ListBox": - this.ParseControlGroupElement(child, TupleDefinitionType.ListBox, "ListItem"); - break; - case "ListView": - this.ParseControlGroupElement(child, TupleDefinitionType.ListView, "ListItem"); - break; - case "ProgressText": - this.ParseActionTextElement(child); - break; - case "Publish": - int order = 0; - this.ParsePublishElement(child, null, null, ref order); - break; - case "RadioButtonGroup": - RadioButtonType radioButtonType = this.ParseRadioButtonGroupElement(child, null, RadioButtonType.NotSet); - if (RadioButtonType.Bitmap == radioButtonType || RadioButtonType.Icon == radioButtonType) - { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); - this.Core.Write(ErrorMessages.RadioButtonBitmapAndIconDisallowed(childSourceLineNumbers)); - } - break; - case "TextStyle": - this.ParseTextStyleElement(child); - break; - case "UIText": - this.ParseUITextElement(child); - break; + case "BillboardAction": + this.ParseBillboardActionElement(child); + break; + case "ComboBox": + this.ParseControlGroupElement(child, TupleDefinitionType.ComboBox, "ListItem"); + break; + case "Dialog": + this.ParseDialogElement(child); + break; + case "DialogRef": + this.ParseSimpleRefElement(child, "Dialog"); + break; + case "EmbeddedUI": + if (0 < embeddedUICount) // there can be only one embedded UI + { + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + this.Core.Write(ErrorMessages.TooManyChildren(childSourceLineNumbers, node.Name.LocalName, child.Name.LocalName)); + } + this.ParseEmbeddedUIElement(child); + ++embeddedUICount; + break; + case "Error": + this.ParseErrorElement(child); + break; + case "ListBox": + this.ParseControlGroupElement(child, TupleDefinitionType.ListBox, "ListItem"); + break; + case "ListView": + this.ParseControlGroupElement(child, TupleDefinitionType.ListView, "ListItem"); + break; + case "ProgressText": + this.ParseActionTextElement(child); + break; + case "Publish": + var order = 0; + this.ParsePublishElement(child, null, null, ref order); + break; + case "RadioButtonGroup": + var radioButtonType = this.ParseRadioButtonGroupElement(child, null, RadioButtonType.NotSet); + if (RadioButtonType.Bitmap == radioButtonType || RadioButtonType.Icon == radioButtonType) + { + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + this.Core.Write(ErrorMessages.RadioButtonBitmapAndIconDisallowed(childSourceLineNumbers)); + } + break; + case "TextStyle": + this.ParseTextStyleElement(child); + break; + case "UIText": + this.ParseUITextElement(child); + break; - // the following are available indentically under the UI and Product elements for document organization use only - case "AdminUISequence": - case "InstallUISequence": - this.ParseSequenceElement(child, child.Name.LocalName); - break; - case "Binary": - this.ParseBinaryElement(child); - break; - case "Property": - this.ParsePropertyElement(child); - break; - case "PropertyRef": - this.ParseSimpleRefElement(child, "Property"); - break; - case "UIRef": - this.ParseSimpleRefElement(child, "WixUI"); - break; + // the following are available indentically under the UI and Product elements for document organization use only + case "AdminUISequence": + case "InstallUISequence": + this.ParseSequenceElement(child, child.Name.LocalName); + break; + case "Binary": + this.ParseBinaryElement(child); + break; + case "Property": + this.ParsePropertyElement(child); + break; + case "PropertyRef": + this.ParseSimpleRefElement(child, "Property"); + break; + case "UIRef": + this.ParseSimpleRefElement(child, "WixUI"); + break; - default: - this.Core.UnexpectedElement(node, child); - break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -15627,37 +15623,37 @@ namespace WixToolset.Core /// Relative order of list items. private void ParseListItemElement(XElement node, TupleDefinitionType tableName, string property, ref int order) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string icon = null; string text = null; string value = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Icon": - if (TupleDefinitionType.ListView == tableName) - { - icon = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "Binary", icon); - } - else - { - this.Core.Write(ErrorMessages.IllegalAttributeExceptOnElement(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ListView")); - } - break; - case "Text": - text = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Value": - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Icon": + if (TupleDefinitionType.ListView == tableName) + { + icon = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "Binary", icon); + } + else + { + this.Core.Write(ErrorMessages.IllegalAttributeExceptOnElement(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "ListView")); + } + break; + case "Text": + text = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Value": + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -15696,8 +15692,8 @@ namespace WixToolset.Core /// Type of this radio button. private RadioButtonType ParseRadioButtonElement(XElement node, string property, ref int order) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - RadioButtonType type = RadioButtonType.NotSet; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var type = RadioButtonType.NotSet; string value = null; string x = null; string y = null; @@ -15707,62 +15703,62 @@ namespace WixToolset.Core string tooltip = null; string help = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Bitmap": - if (RadioButtonType.NotSet != type) - { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Icon", "Text")); - } - text = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "Binary", text); - type = RadioButtonType.Bitmap; - break; - case "Height": - height = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "Help": - help = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Icon": - if (RadioButtonType.NotSet != type) - { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Bitmap", "Text")); - } - text = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "Binary", text); - type = RadioButtonType.Icon; - break; - case "Text": - if (RadioButtonType.NotSet != type) - { - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Bitmap", "Icon")); - } - text = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - type = RadioButtonType.Text; - break; - case "ToolTip": - tooltip = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Value": - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Width": - width = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "X": - x = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "Y": - y = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Bitmap": + if (RadioButtonType.NotSet != type) + { + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Icon", "Text")); + } + text = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "Binary", text); + type = RadioButtonType.Bitmap; + break; + case "Height": + height = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "Help": + help = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Icon": + if (RadioButtonType.NotSet != type) + { + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttributes(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Bitmap", "Text")); + } + text = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "Binary", text); + type = RadioButtonType.Icon; + break; + case "Text": + if (RadioButtonType.NotSet != type) + { + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "Bitmap", "Icon")); + } + text = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + type = RadioButtonType.Text; + break; + case "ToolTip": + tooltip = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Value": + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Width": + width = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "X": + x = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "Y": + y = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -15824,23 +15820,23 @@ namespace WixToolset.Core /// Element to parse. private void ParseBillboardActionElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string action = null; - int order = 0; + var order = 0; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - action = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "WixAction", "InstallExecuteSequence", action); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + action = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "WixAction", "InstallExecuteSequence", action); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -15854,19 +15850,19 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Billboard": - order = order + 1; - this.ParseBillboardElement(child, action, order); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "Billboard": + order = order + 1; + this.ParseBillboardElement(child, action, order); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -15884,26 +15880,26 @@ namespace WixToolset.Core /// Order of the billboard. private void ParseBillboardElement(XElement node, string action, int order) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string feature = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Feature": - feature = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "Feature", feature); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Feature": + feature = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "Feature", feature); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -15917,24 +15913,24 @@ namespace WixToolset.Core id = this.Core.CreateIdentifier("bil", action, order.ToString(), feature); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Control": - // These are all thrown away. - IntermediateTuple lastTabRow = null; - string firstControl = null; - string defaultControl = null; - string cancelControl = null; + case "Control": + // These are all thrown away. + IntermediateTuple lastTabRow = null; + string firstControl = null; + string defaultControl = null; + string cancelControl = null; - this.ParseControlElement(child, id.Id, TupleDefinitionType.BBControl, ref lastTabRow, ref firstControl, ref defaultControl, ref cancelControl, false); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + this.ParseControlElement(child, id.Id, TupleDefinitionType.BBControl, ref lastTabRow, ref firstControl, ref defaultControl, ref cancelControl, false); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -15961,22 +15957,22 @@ namespace WixToolset.Core /// Expected child elements. private void ParseControlGroupElement(XElement node, TupleDefinitionType tableName, string childTag) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - int order = 0; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var order = 0; string property = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Property": - property = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Property": + property = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -15990,7 +15986,7 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Property")); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { @@ -16001,15 +15997,15 @@ namespace WixToolset.Core switch (child.Name.LocalName) { - case "ListItem": - this.ParseListItemElement(child, tableName, property, ref order); - break; - case "Property": - this.ParsePropertyElement(child); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "ListItem": + this.ParseListItemElement(child, tableName, property, ref order); + break; + case "Property": + this.ParsePropertyElement(child); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -16029,22 +16025,22 @@ namespace WixToolset.Core /// The current type of radio buttons in the group. private RadioButtonType ParseRadioButtonGroupElement(XElement node, string property, RadioButtonType groupType) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - int order = 0; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var order = 0; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Property": - property = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "Property", property); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Property": + property = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "Property", property); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -16058,27 +16054,27 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Property")); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "RadioButton": - RadioButtonType type = this.ParseRadioButtonElement(child, property, ref order); - if (RadioButtonType.NotSet == groupType) - { - groupType = type; - } - else if (groupType != type) - { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); - this.Core.Write(ErrorMessages.RadioButtonTypeInconsistent(childSourceLineNumbers)); - } - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "RadioButton": + var type = this.ParseRadioButtonElement(child, property, ref order); + if (RadioButtonType.NotSet == groupType) + { + groupType = type; + } + else if (groupType != type) + { + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + this.Core.Write(ErrorMessages.RadioButtonTypeInconsistent(childSourceLineNumbers)); + } + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -16097,25 +16093,25 @@ namespace WixToolset.Core /// Element to parse. private void ParseActionTextElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string action = null; string template = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Action": - action = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Template": - template = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Action": + action = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Template": + template = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -16146,22 +16142,22 @@ namespace WixToolset.Core /// Element to parse. private void ParseUITextElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string text = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -16192,104 +16188,104 @@ namespace WixToolset.Core /// Element to parse. private void ParseTextStyleElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - int bits = 0; - int color = CompilerConstants.IntegerNotSet; + var bits = 0; + var color = CompilerConstants.IntegerNotSet; string faceName = null; - string size = "0"; + var size = "0"; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; - // RGB Values - case "Red": - int redColor = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, byte.MaxValue); - if (CompilerConstants.IllegalInteger != redColor) - { - if (CompilerConstants.IntegerNotSet == color) - { - color = redColor; - } - else - { - color += redColor; - } - } - break; - case "Green": - int greenColor = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, byte.MaxValue); - if (CompilerConstants.IllegalInteger != greenColor) + // RGB Values + case "Red": + var redColor = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Byte.MaxValue); + if (CompilerConstants.IllegalInteger != redColor) + { + if (CompilerConstants.IntegerNotSet == color) { - if (CompilerConstants.IntegerNotSet == color) - { - color = greenColor * 256; - } - else - { - color += greenColor * 256; - } + color = redColor; } - break; - case "Blue": - int blueColor = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, byte.MaxValue); - if (CompilerConstants.IllegalInteger != blueColor) + else { - if (CompilerConstants.IntegerNotSet == color) - { - color = blueColor * 65536; - } - else - { - color += blueColor * 65536; - } + color += redColor; } - break; - - // Style values - case "Bold": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + } + break; + case "Green": + var greenColor = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Byte.MaxValue); + if (CompilerConstants.IllegalInteger != greenColor) + { + if (CompilerConstants.IntegerNotSet == color) { - bits |= MsiInterop.MsidbTextStyleStyleBitsBold; + color = greenColor * 256; } - break; - case "Italic": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + else { - bits |= MsiInterop.MsidbTextStyleStyleBitsItalic; + color += greenColor * 256; } - break; - case "Strike": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + } + break; + case "Blue": + var blueColor = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Byte.MaxValue); + if (CompilerConstants.IllegalInteger != blueColor) + { + if (CompilerConstants.IntegerNotSet == color) { - bits |= MsiInterop.MsidbTextStyleStyleBitsStrike; + color = blueColor * 65536; } - break; - case "Underline": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + else { - bits |= MsiInterop.MsidbTextStyleStyleBitsUnderline; + color += blueColor * 65536; } - break; + } + break; - // Font values - case "FaceName": - faceName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Size": - size = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; + // Style values + case "Bold": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits |= MsiInterop.MsidbTextStyleStyleBitsBold; + } + break; + case "Italic": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits |= MsiInterop.MsidbTextStyleStyleBitsItalic; + } + break; + case "Strike": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits |= MsiInterop.MsidbTextStyleStyleBitsStrike; + } + break; + case "Underline": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits |= MsiInterop.MsidbTextStyleStyleBitsUnderline; + } + break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + // Font values + case "FaceName": + faceName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Size": + size = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -16333,112 +16329,112 @@ namespace WixToolset.Core /// Element to parse. private void ParseDialogElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - int bits = MsiInterop.MsidbDialogAttributesVisible | MsiInterop.MsidbDialogAttributesModal | MsiInterop.MsidbDialogAttributesMinimize; - int height = 0; + var bits = MsiInterop.MsidbDialogAttributesVisible | MsiInterop.MsidbDialogAttributesModal | MsiInterop.MsidbDialogAttributesMinimize; + var height = 0; string title = null; - bool trackDiskSpace = false; - int width = 0; - int x = 50; - int y = 50; + var trackDiskSpace = false; + var width = 0; + var x = 50; + var y = 50; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Height": - height = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "Title": - title = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Width": - width = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "X": - x = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, 100); - break; - case "Y": - y = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, 100); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Height": + height = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "Title": + title = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Width": + width = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "X": + x = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, 100); + break; + case "Y": + y = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, 100); + break; - case "CustomPalette": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits ^= MsiInterop.MsidbDialogAttributesUseCustomPalette; - } - break; - case "ErrorDialog": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits ^= MsiInterop.MsidbDialogAttributesError; - } - break; - case "Hidden": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits ^= MsiInterop.MsidbDialogAttributesVisible; - } - break; - case "KeepModeless": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits ^= MsiInterop.MsidbDialogAttributesKeepModeless; - } - break; - case "LeftScroll": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits ^= MsiInterop.MsidbDialogAttributesLeftScroll; - } - break; - case "Modeless": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits ^= MsiInterop.MsidbDialogAttributesModal; - } - break; - case "NoMinimize": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits ^= MsiInterop.MsidbDialogAttributesMinimize; - } - break; - case "RightAligned": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits ^= MsiInterop.MsidbDialogAttributesRightAligned; - } - break; - case "RightToLeft": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits ^= MsiInterop.MsidbDialogAttributesRTLRO; - } - break; - case "SystemModal": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits ^= MsiInterop.MsidbDialogAttributesSysModal; - } - break; - case "TrackDiskSpace": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - bits ^= MsiInterop.MsidbDialogAttributesTrackDiskSpace; - trackDiskSpace = true; - } - break; + case "CustomPalette": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits ^= MsiInterop.MsidbDialogAttributesUseCustomPalette; + } + break; + case "ErrorDialog": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits ^= MsiInterop.MsidbDialogAttributesError; + } + break; + case "Hidden": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits ^= MsiInterop.MsidbDialogAttributesVisible; + } + break; + case "KeepModeless": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits ^= MsiInterop.MsidbDialogAttributesKeepModeless; + } + break; + case "LeftScroll": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits ^= MsiInterop.MsidbDialogAttributesLeftScroll; + } + break; + case "Modeless": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits ^= MsiInterop.MsidbDialogAttributesModal; + } + break; + case "NoMinimize": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits ^= MsiInterop.MsidbDialogAttributesMinimize; + } + break; + case "RightAligned": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits ^= MsiInterop.MsidbDialogAttributesRightAligned; + } + break; + case "RightToLeft": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits ^= MsiInterop.MsidbDialogAttributesRTLRO; + } + break; + case "SystemModal": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits ^= MsiInterop.MsidbDialogAttributesSysModal; + } + break; + case "TrackDiskSpace": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + bits ^= MsiInterop.MsidbDialogAttributesTrackDiskSpace; + trackDiskSpace = true; + } + break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -16458,18 +16454,18 @@ namespace WixToolset.Core string defaultControl = null; string firstControl = null; - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Control": - this.ParseControlElement(child, id.Id, TupleDefinitionType.Control, ref lastTabRow, ref firstControl, ref defaultControl, ref cancelControl, trackDiskSpace); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "Control": + this.ParseControlElement(child, id.Id, TupleDefinitionType.Control, ref lastTabRow, ref firstControl, ref defaultControl, ref cancelControl, trackDiskSpace); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -16510,153 +16506,153 @@ namespace WixToolset.Core /// /// Parses an EmbeddedUI element. /// - /// Element to parse. - private void ParseEmbeddedUIElement(XElement node) - { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - Identifier id = null; - string name = null; - int attributes = MsiInterop.MsidbEmbeddedUI; // by default this is the primary DLL that does not support basic UI. - int messageFilter = MsiInterop.INSTALLLOGMODE_FATALEXIT | MsiInterop.INSTALLLOGMODE_ERROR | MsiInterop.INSTALLLOGMODE_WARNING | MsiInterop.INSTALLLOGMODE_USER - | MsiInterop.INSTALLLOGMODE_INFO | MsiInterop.INSTALLLOGMODE_FILESINUSE | MsiInterop.INSTALLLOGMODE_RESOLVESOURCE - | MsiInterop.INSTALLLOGMODE_OUTOFDISKSPACE | MsiInterop.INSTALLLOGMODE_ACTIONSTART | MsiInterop.INSTALLLOGMODE_ACTIONDATA - | MsiInterop.INSTALLLOGMODE_PROGRESS | MsiInterop.INSTALLLOGMODE_COMMONDATA | MsiInterop.INSTALLLOGMODE_INITIALIZE - | MsiInterop.INSTALLLOGMODE_TERMINATE | MsiInterop.INSTALLLOGMODE_SHOWDIALOG | MsiInterop.INSTALLLOGMODE_RMFILESINUSE - | MsiInterop.INSTALLLOGMODE_INSTALLSTART | MsiInterop.INSTALLLOGMODE_INSTALLEND; - string sourceFile = null; - - foreach (XAttribute attrib in node.Attributes()) - { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Name": - name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); - break; - case "IgnoreFatalExit": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - messageFilter ^= MsiInterop.INSTALLLOGMODE_FATALEXIT; - } - break; - case "IgnoreError": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - messageFilter ^= MsiInterop.INSTALLLOGMODE_ERROR; - } - break; - case "IgnoreWarning": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - messageFilter ^= MsiInterop.INSTALLLOGMODE_WARNING; - } - break; - case "IgnoreUser": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - messageFilter ^= MsiInterop.INSTALLLOGMODE_USER; - } - break; - case "IgnoreInfo": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - messageFilter ^= MsiInterop.INSTALLLOGMODE_INFO; - } - break; - case "IgnoreFilesInUse": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - messageFilter ^= MsiInterop.INSTALLLOGMODE_FILESINUSE; - } - break; - case "IgnoreResolveSource": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - messageFilter ^= MsiInterop.INSTALLLOGMODE_RESOLVESOURCE; - } - break; - case "IgnoreOutOfDiskSpace": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - messageFilter ^= MsiInterop.INSTALLLOGMODE_OUTOFDISKSPACE; - } - break; - case "IgnoreActionStart": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - messageFilter ^= MsiInterop.INSTALLLOGMODE_ACTIONSTART; - } - break; - case "IgnoreActionData": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - messageFilter ^= MsiInterop.INSTALLLOGMODE_ACTIONDATA; - } - break; - case "IgnoreProgress": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - messageFilter ^= MsiInterop.INSTALLLOGMODE_PROGRESS; - } - break; - case "IgnoreCommonData": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - messageFilter ^= MsiInterop.INSTALLLOGMODE_COMMONDATA; - } - break; - case "IgnoreInitialize": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - messageFilter ^= MsiInterop.INSTALLLOGMODE_INITIALIZE; - } - break; - case "IgnoreTerminate": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - messageFilter ^= MsiInterop.INSTALLLOGMODE_TERMINATE; - } - break; - case "IgnoreShowDialog": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - messageFilter ^= MsiInterop.INSTALLLOGMODE_SHOWDIALOG; - } - break; - case "IgnoreRMFilesInUse": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - messageFilter ^= MsiInterop.INSTALLLOGMODE_RMFILESINUSE; - } - break; - case "IgnoreInstallStart": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - messageFilter ^= MsiInterop.INSTALLLOGMODE_INSTALLSTART; - } - break; - case "IgnoreInstallEnd": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - messageFilter ^= MsiInterop.INSTALLLOGMODE_INSTALLEND; - } - break; - case "SourceFile": - sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "SupportBasicUI": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= MsiInterop.MsidbEmbeddedHandlesBasic; - } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + /// Element to parse. + private void ParseEmbeddedUIElement(XElement node) + { + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + Identifier id = null; + string name = null; + var attributes = MsiInterop.MsidbEmbeddedUI; // by default this is the primary DLL that does not support basic UI. + var messageFilter = MsiInterop.INSTALLLOGMODE_FATALEXIT | MsiInterop.INSTALLLOGMODE_ERROR | MsiInterop.INSTALLLOGMODE_WARNING | MsiInterop.INSTALLLOGMODE_USER + | MsiInterop.INSTALLLOGMODE_INFO | MsiInterop.INSTALLLOGMODE_FILESINUSE | MsiInterop.INSTALLLOGMODE_RESOLVESOURCE + | MsiInterop.INSTALLLOGMODE_OUTOFDISKSPACE | MsiInterop.INSTALLLOGMODE_ACTIONSTART | MsiInterop.INSTALLLOGMODE_ACTIONDATA + | MsiInterop.INSTALLLOGMODE_PROGRESS | MsiInterop.INSTALLLOGMODE_COMMONDATA | MsiInterop.INSTALLLOGMODE_INITIALIZE + | MsiInterop.INSTALLLOGMODE_TERMINATE | MsiInterop.INSTALLLOGMODE_SHOWDIALOG | MsiInterop.INSTALLLOGMODE_RMFILESINUSE + | MsiInterop.INSTALLLOGMODE_INSTALLSTART | MsiInterop.INSTALLLOGMODE_INSTALLEND; + string sourceFile = null; + + foreach (var attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); + break; + case "IgnoreFatalExit": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + messageFilter ^= MsiInterop.INSTALLLOGMODE_FATALEXIT; + } + break; + case "IgnoreError": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + messageFilter ^= MsiInterop.INSTALLLOGMODE_ERROR; + } + break; + case "IgnoreWarning": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + messageFilter ^= MsiInterop.INSTALLLOGMODE_WARNING; + } + break; + case "IgnoreUser": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + messageFilter ^= MsiInterop.INSTALLLOGMODE_USER; + } + break; + case "IgnoreInfo": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + messageFilter ^= MsiInterop.INSTALLLOGMODE_INFO; + } + break; + case "IgnoreFilesInUse": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + messageFilter ^= MsiInterop.INSTALLLOGMODE_FILESINUSE; + } + break; + case "IgnoreResolveSource": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + messageFilter ^= MsiInterop.INSTALLLOGMODE_RESOLVESOURCE; + } + break; + case "IgnoreOutOfDiskSpace": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + messageFilter ^= MsiInterop.INSTALLLOGMODE_OUTOFDISKSPACE; + } + break; + case "IgnoreActionStart": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + messageFilter ^= MsiInterop.INSTALLLOGMODE_ACTIONSTART; + } + break; + case "IgnoreActionData": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + messageFilter ^= MsiInterop.INSTALLLOGMODE_ACTIONDATA; + } + break; + case "IgnoreProgress": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + messageFilter ^= MsiInterop.INSTALLLOGMODE_PROGRESS; + } + break; + case "IgnoreCommonData": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + messageFilter ^= MsiInterop.INSTALLLOGMODE_COMMONDATA; + } + break; + case "IgnoreInitialize": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + messageFilter ^= MsiInterop.INSTALLLOGMODE_INITIALIZE; + } + break; + case "IgnoreTerminate": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + messageFilter ^= MsiInterop.INSTALLLOGMODE_TERMINATE; + } + break; + case "IgnoreShowDialog": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + messageFilter ^= MsiInterop.INSTALLLOGMODE_SHOWDIALOG; + } + break; + case "IgnoreRMFilesInUse": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + messageFilter ^= MsiInterop.INSTALLLOGMODE_RMFILESINUSE; + } + break; + case "IgnoreInstallStart": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + messageFilter ^= MsiInterop.INSTALLLOGMODE_INSTALLSTART; + } + break; + case "IgnoreInstallEnd": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + messageFilter ^= MsiInterop.INSTALLLOGMODE_INSTALLEND; + } + break; + case "SourceFile": + sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "SupportBasicUI": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= MsiInterop.MsidbEmbeddedHandlesBasic; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -16704,18 +16700,18 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.InvalidEmbeddedUIFileName(sourceLineNumbers, name)); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "EmbeddedUIResource": - this.ParseEmbeddedUIResourceElement(child); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "EmbeddedUIResource": + this.ParseEmbeddedUIResourceElement(child); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -16741,29 +16737,29 @@ namespace WixToolset.Core /// Identifier of parent EmbeddedUI element. private void ParseEmbeddedUIResourceElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string name = null; string sourceFile = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Name": - name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); - break; - case "SourceFile": - sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false); + break; + case "SourceFile": + sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -16831,32 +16827,32 @@ namespace WixToolset.Core /// True if the containing dialog tracks disk space. private void ParseControlElement(XElement node, string dialog, TupleDefinitionType tableName, ref IntermediateTuple lastTabRow, ref string firstControl, ref string defaultControl, ref string cancelControl, bool trackDiskSpace) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - BitArray bits = new BitArray(32); - int attributes = 0; + var bits = new BitArray(32); + var attributes = 0; string checkBoxPropertyRef = null; string checkboxValue = null; string controlType = null; - bool disabled = false; + var disabled = false; string height = null; string help = null; - bool isCancel = false; - bool isDefault = false; - bool notTabbable = false; + var isCancel = false; + var isDefault = false; + var notTabbable = false; string property = null; - int publishOrder = 0; + var publishOrder = 0; string[] specialAttributes = null; string sourceFile = null; string text = null; string tooltip = null; - RadioButtonType radioButtonsType = RadioButtonType.NotSet; + var radioButtonsType = RadioButtonType.NotSet; string width = null; string x = null; string y = null; // The rest of the method relies on the control's Type, so we have to get that first. - XAttribute typeAttribute = node.Attribute("Type"); + var typeAttribute = node.Attribute("Type"); if (null == typeAttribute) { this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Type")); @@ -16868,186 +16864,186 @@ namespace WixToolset.Core switch (controlType) { - case "Billboard": - specialAttributes = null; - notTabbable = true; - disabled = true; - - this.Core.EnsureTable(sourceLineNumbers, "Billboard"); - break; - case "Bitmap": - specialAttributes = MsiInterop.BitmapControlAttributes; - notTabbable = true; - disabled = true; - break; - case "CheckBox": - specialAttributes = MsiInterop.CheckboxControlAttributes; - break; - case "ComboBox": - specialAttributes = MsiInterop.ComboboxControlAttributes; - break; - case "DirectoryCombo": - specialAttributes = MsiInterop.VolumeControlAttributes; - break; - case "DirectoryList": - specialAttributes = null; - break; - case "Edit": - specialAttributes = MsiInterop.EditControlAttributes; - break; - case "GroupBox": - specialAttributes = null; - notTabbable = true; - break; - case "Hyperlink": - specialAttributes = MsiInterop.HyperlinkControlAttributes; - break; - case "Icon": - specialAttributes = MsiInterop.IconControlAttributes; - notTabbable = true; - disabled = true; - break; - case "Line": - specialAttributes = null; - notTabbable = true; - disabled = true; - break; - case "ListBox": - specialAttributes = MsiInterop.ListboxControlAttributes; - break; - case "ListView": - specialAttributes = MsiInterop.ListviewControlAttributes; - break; - case "MaskedEdit": - specialAttributes = MsiInterop.EditControlAttributes; - break; - case "PathEdit": - specialAttributes = MsiInterop.EditControlAttributes; - break; - case "ProgressBar": - specialAttributes = MsiInterop.ProgressControlAttributes; - notTabbable = true; - disabled = true; - break; - case "PushButton": - specialAttributes = MsiInterop.ButtonControlAttributes; - break; - case "RadioButtonGroup": - specialAttributes = MsiInterop.RadioControlAttributes; - break; - case "ScrollableText": - specialAttributes = null; - break; - case "SelectionTree": - specialAttributes = null; - break; - case "Text": - specialAttributes = MsiInterop.TextControlAttributes; - notTabbable = true; - break; - case "VolumeCostList": - specialAttributes = MsiInterop.VolumeControlAttributes; - notTabbable = true; - break; - case "VolumeSelectCombo": - specialAttributes = MsiInterop.VolumeControlAttributes; - break; - default: - specialAttributes = null; - notTabbable = true; - break; - } - - foreach (XAttribute attrib in node.Attributes()) + case "Billboard": + specialAttributes = null; + notTabbable = true; + disabled = true; + + this.Core.EnsureTable(sourceLineNumbers, "Billboard"); + break; + case "Bitmap": + specialAttributes = MsiInterop.BitmapControlAttributes; + notTabbable = true; + disabled = true; + break; + case "CheckBox": + specialAttributes = MsiInterop.CheckboxControlAttributes; + break; + case "ComboBox": + specialAttributes = MsiInterop.ComboboxControlAttributes; + break; + case "DirectoryCombo": + specialAttributes = MsiInterop.VolumeControlAttributes; + break; + case "DirectoryList": + specialAttributes = null; + break; + case "Edit": + specialAttributes = MsiInterop.EditControlAttributes; + break; + case "GroupBox": + specialAttributes = null; + notTabbable = true; + break; + case "Hyperlink": + specialAttributes = MsiInterop.HyperlinkControlAttributes; + break; + case "Icon": + specialAttributes = MsiInterop.IconControlAttributes; + notTabbable = true; + disabled = true; + break; + case "Line": + specialAttributes = null; + notTabbable = true; + disabled = true; + break; + case "ListBox": + specialAttributes = MsiInterop.ListboxControlAttributes; + break; + case "ListView": + specialAttributes = MsiInterop.ListviewControlAttributes; + break; + case "MaskedEdit": + specialAttributes = MsiInterop.EditControlAttributes; + break; + case "PathEdit": + specialAttributes = MsiInterop.EditControlAttributes; + break; + case "ProgressBar": + specialAttributes = MsiInterop.ProgressControlAttributes; + notTabbable = true; + disabled = true; + break; + case "PushButton": + specialAttributes = MsiInterop.ButtonControlAttributes; + break; + case "RadioButtonGroup": + specialAttributes = MsiInterop.RadioControlAttributes; + break; + case "ScrollableText": + specialAttributes = null; + break; + case "SelectionTree": + specialAttributes = null; + break; + case "Text": + specialAttributes = MsiInterop.TextControlAttributes; + notTabbable = true; + break; + case "VolumeCostList": + specialAttributes = MsiInterop.VolumeControlAttributes; + notTabbable = true; + break; + case "VolumeSelectCombo": + specialAttributes = MsiInterop.VolumeControlAttributes; + break; + default: + specialAttributes = null; + notTabbable = true; + break; + } + + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Type": // already processed - break; - case "Cancel": - isCancel = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "CheckBoxPropertyRef": - checkBoxPropertyRef = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "CheckBoxValue": - checkboxValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Default": - isDefault = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Height": - height = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "Help": - help = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "IconSize": - string iconSizeValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (null != specialAttributes) + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Type": // already processed + break; + case "Cancel": + isCancel = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "CheckBoxPropertyRef": + checkBoxPropertyRef = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "CheckBoxValue": + checkboxValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Default": + isDefault = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Height": + height = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "Help": + help = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "IconSize": + var iconSizeValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (null != specialAttributes) + { + if (0 < iconSizeValue.Length) { - if (0 < iconSizeValue.Length) + var iconsSizeType = Wix.Control.ParseIconSizeType(iconSizeValue); + switch (iconsSizeType) { - Wix.Control.IconSizeType iconsSizeType = Wix.Control.ParseIconSizeType(iconSizeValue); - switch (iconsSizeType) - { - case Wix.Control.IconSizeType.Item16: - this.Core.TrySetBitFromName(specialAttributes, "Icon16", YesNoType.Yes, bits, 16); - break; - case Wix.Control.IconSizeType.Item32: - this.Core.TrySetBitFromName(specialAttributes, "Icon32", YesNoType.Yes, bits, 16); - break; - case Wix.Control.IconSizeType.Item48: - this.Core.TrySetBitFromName(specialAttributes, "Icon16", YesNoType.Yes, bits, 16); - this.Core.TrySetBitFromName(specialAttributes, "Icon32", YesNoType.Yes, bits, 16); - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, iconSizeValue, "16", "32", "48")); - break; - } + case Wix.Control.IconSizeType.Item16: + this.Core.TrySetBitFromName(specialAttributes, "Icon16", YesNoType.Yes, bits, 16); + break; + case Wix.Control.IconSizeType.Item32: + this.Core.TrySetBitFromName(specialAttributes, "Icon32", YesNoType.Yes, bits, 16); + break; + case Wix.Control.IconSizeType.Item48: + this.Core.TrySetBitFromName(specialAttributes, "Icon16", YesNoType.Yes, bits, 16); + this.Core.TrySetBitFromName(specialAttributes, "Icon32", YesNoType.Yes, bits, 16); + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, iconSizeValue, "16", "32", "48")); + break; } } - else - { - this.Core.Write(ErrorMessages.IllegalAttributeValueWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, iconSizeValue, "Type")); - } - break; - case "Property": - property = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "TabSkip": - notTabbable = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Text": - text = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "ToolTip": - tooltip = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Width": - width = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "X": - x = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - case "Y": - y = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue); - break; - default: - YesNoType attribValue = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - if (!this.Core.TrySetBitFromName(MsiInterop.CommonControlAttributes, attrib.Name.LocalName, attribValue, bits, 0)) + } + else + { + this.Core.Write(ErrorMessages.IllegalAttributeValueWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, iconSizeValue, "Type")); + } + break; + case "Property": + property = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "TabSkip": + notTabbable = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Text": + text = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "ToolTip": + tooltip = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Width": + width = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "X": + x = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + case "Y": + y = this.Core.GetAttributeLocalizableIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue); + break; + default: + var attribValue = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + if (!this.Core.TrySetBitFromName(MsiInterop.CommonControlAttributes, attrib.Name.LocalName, attribValue, bits, 0)) + { + if (null == specialAttributes || !this.Core.TrySetBitFromName(specialAttributes, attrib.Name.LocalName, attribValue, bits, 16)) { - if (null == specialAttributes || !this.Core.TrySetBitFromName(specialAttributes, attrib.Name.LocalName, attribValue, bits, 16)) - { - this.Core.UnexpectedAttribute(node, attrib); - } + this.Core.UnexpectedAttribute(node, attrib); } - break; + } + break; } } else @@ -17098,70 +17094,70 @@ namespace WixToolset.Core defaultControl = id.Id; } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); switch (child.Name.LocalName) { - case "Binary": - this.ParseBinaryElement(child); - break; - case "ComboBox": - this.ParseControlGroupElement(child, TupleDefinitionType.ComboBox, "ListItem"); - break; - case "Condition": - this.ParseConditionElement(child, node.Name.LocalName, id.Id, dialog); - break; - case "ListBox": - this.ParseControlGroupElement(child, TupleDefinitionType.ListBox, "ListItem"); - break; - case "ListView": - this.ParseControlGroupElement(child, TupleDefinitionType.ListView, "ListItem"); - break; - case "Property": - this.ParsePropertyElement(child); - break; - case "Publish": - this.ParsePublishElement(child, dialog ?? String.Empty, id.Id, ref publishOrder); - break; - case "RadioButtonGroup": - radioButtonsType = this.ParseRadioButtonGroupElement(child, property, radioButtonsType); - break; - case "Subscribe": - this.ParseSubscribeElement(child, dialog, id.Id); - break; - case "Text": - foreach (XAttribute attrib in child.Attributes()) + case "Binary": + this.ParseBinaryElement(child); + break; + case "ComboBox": + this.ParseControlGroupElement(child, TupleDefinitionType.ComboBox, "ListItem"); + break; + case "Condition": + this.ParseConditionElement(child, node.Name.LocalName, id.Id, dialog); + break; + case "ListBox": + this.ParseControlGroupElement(child, TupleDefinitionType.ListBox, "ListItem"); + break; + case "ListView": + this.ParseControlGroupElement(child, TupleDefinitionType.ListView, "ListItem"); + break; + case "Property": + this.ParsePropertyElement(child); + break; + case "Publish": + this.ParsePublishElement(child, dialog ?? String.Empty, id.Id, ref publishOrder); + break; + case "RadioButtonGroup": + radioButtonsType = this.ParseRadioButtonGroupElement(child, property, radioButtonsType); + break; + case "Subscribe": + this.ParseSubscribeElement(child, dialog, id.Id); + break; + case "Text": + foreach (var attrib in child.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "SourceFile": - sourceFile = this.Core.GetAttributeValue(childSourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(child, attrib); - break; - } - } - else + switch (attrib.Name.LocalName) { - this.Core.ParseExtensionAttribute(child, attrib); + case "SourceFile": + sourceFile = this.Core.GetAttributeValue(childSourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(child, attrib); + break; } } - - text = Common.GetInnerText(child); - if (!String.IsNullOrEmpty(text) && null != sourceFile) + else { - this.Core.Write(ErrorMessages.IllegalAttributeWithInnerText(childSourceLineNumbers, child.Name.LocalName, "SourceFile")); + this.Core.ParseExtensionAttribute(child, attrib); } - break; - default: - this.Core.UnexpectedElement(node, child); - break; + } + + text = Common.GetInnerText(child); + if (!String.IsNullOrEmpty(text) && null != sourceFile) + { + this.Core.Write(ErrorMessages.IllegalAttributeWithInnerText(childSourceLineNumbers, child.Name.LocalName, "SourceFile")); + } + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -17173,15 +17169,15 @@ namespace WixToolset.Core // If the radio buttons have icons, then we need to add the icon attribute. switch (radioButtonsType) { - case RadioButtonType.Bitmap: - attributes |= MsiInterop.MsidbControlAttributesBitmap; - break; - case RadioButtonType.Icon: - attributes |= MsiInterop.MsidbControlAttributesIcon; - break; - case RadioButtonType.Text: - // Text is the default so nothing needs to be added bits - break; + case RadioButtonType.Bitmap: + attributes |= MsiInterop.MsidbControlAttributesBitmap; + break; + case RadioButtonType.Icon: + attributes |= MsiInterop.MsidbControlAttributesIcon; + break; + case RadioButtonType.Text: + // Text is the default so nothing needs to be added bits + break; } // If we're tracking disk space, and this is a non-FormatSize Text control, and the text attribute starts with @@ -17295,7 +17291,7 @@ namespace WixToolset.Core /// Relative order of controls. private void ParsePublishElement(XElement node, string dialog, string control, ref int order) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string argument = null; string condition = null; string controlEvent = null; @@ -17304,42 +17300,42 @@ namespace WixToolset.Core // give this control event a unique ordering order++; - foreach (XAttribute attrib in node.Attributes()) - { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) - { - switch (attrib.Name.LocalName) - { - case "Control": - if (null != control) - { - this.Core.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, node.Parent.Name.LocalName)); - } - control = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "Dialog": - if (null != dialog) - { - this.Core.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, node.Parent.Name.LocalName)); - } - dialog = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "Dialog", dialog); - break; - case "Event": - controlEvent = Compiler.UppercaseFirstChar(this.Core.GetAttributeValue(sourceLineNumbers, attrib)); - break; - case "Order": - order = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, 2147483647); - break; - case "Property": - property = String.Concat("[", this.Core.GetAttributeValue(sourceLineNumbers, attrib), "]"); - break; - case "Value": - argument = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + foreach (var attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) + { + switch (attrib.Name.LocalName) + { + case "Control": + if (null != control) + { + this.Core.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, node.Parent.Name.LocalName)); + } + control = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "Dialog": + if (null != dialog) + { + this.Core.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, node.Parent.Name.LocalName)); + } + dialog = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "Dialog", dialog); + break; + case "Event": + controlEvent = Compiler.UppercaseFirstChar(this.Core.GetAttributeValue(sourceLineNumbers, attrib)); + break; + case "Order": + order = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, 2147483647); + break; + case "Property": + property = String.Concat("[", this.Core.GetAttributeValue(sourceLineNumbers, attrib), "]"); + break; + case "Value": + argument = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -17420,25 +17416,25 @@ namespace WixToolset.Core /// Identifier of control. private void ParseSubscribeElement(XElement node, string dialog, string control) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string controlAttribute = null; string eventMapping = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Attribute": - controlAttribute = Compiler.UppercaseFirstChar(this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib)); - break; - case "Event": - eventMapping = Compiler.UppercaseFirstChar(this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib)); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Attribute": + controlAttribute = Compiler.UppercaseFirstChar(this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib)); + break; + case "Event": + eventMapping = Compiler.UppercaseFirstChar(this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib)); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -17465,21 +17461,21 @@ namespace WixToolset.Core /// Element to parse. private void ParseUpgradeElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -17494,24 +17490,24 @@ namespace WixToolset.Core } // process the UpgradeVersion children here - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); switch (child.Name.LocalName) { - case "Property": - this.ParsePropertyElement(child); - this.Core.Write(WarningMessages.DeprecatedUpgradeProperty(childSourceLineNumbers)); - break; - case "UpgradeVersion": - this.ParseUpgradeVersionElement(child, id); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "Property": + this.ParsePropertyElement(child); + this.Core.Write(WarningMessages.DeprecatedUpgradeProperty(childSourceLineNumbers)); + break; + case "UpgradeVersion": + this.ParseUpgradeVersionElement(child, id); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -17530,75 +17526,75 @@ namespace WixToolset.Core /// Upgrade code. private void ParseUpgradeVersionElement(XElement node, string upgradeId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string actionProperty = null; string language = null; string maximum = null; string minimum = null; - int options = 256; + var options = 256; string removeFeatures = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "ExcludeLanguages": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - options |= MsiInterop.MsidbUpgradeAttributesLanguagesExclusive; - } - break; - case "IgnoreRemoveFailure": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - options |= MsiInterop.MsidbUpgradeAttributesIgnoreRemoveFailure; - } - break; - case "IncludeMaximum": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - options |= MsiInterop.MsidbUpgradeAttributesVersionMaxInclusive; - } - break; - case "IncludeMinimum": // this is "yes" by default - if (YesNoType.No == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - options &= ~MsiInterop.MsidbUpgradeAttributesVersionMinInclusive; - } - break; - case "Language": - language = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Minimum": - minimum = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); - break; - case "Maximum": - maximum = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); - break; - case "MigrateFeatures": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - options |= MsiInterop.MsidbUpgradeAttributesMigrateFeatures; - } - break; - case "OnlyDetect": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - options |= MsiInterop.MsidbUpgradeAttributesOnlyDetect; - } - break; - case "Property": - actionProperty = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - case "RemoveFeatures": - removeFeatures = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "ExcludeLanguages": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + options |= MsiInterop.MsidbUpgradeAttributesLanguagesExclusive; + } + break; + case "IgnoreRemoveFailure": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + options |= MsiInterop.MsidbUpgradeAttributesIgnoreRemoveFailure; + } + break; + case "IncludeMaximum": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + options |= MsiInterop.MsidbUpgradeAttributesVersionMaxInclusive; + } + break; + case "IncludeMinimum": // this is "yes" by default + if (YesNoType.No == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + options &= ~MsiInterop.MsidbUpgradeAttributesVersionMinInclusive; + } + break; + case "Language": + language = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Minimum": + minimum = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); + break; + case "Maximum": + maximum = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); + break; + case "MigrateFeatures": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + options |= MsiInterop.MsidbUpgradeAttributesMigrateFeatures; + } + break; + case "OnlyDetect": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + options |= MsiInterop.MsidbUpgradeAttributesOnlyDetect; + } + break; + case "Property": + actionProperty = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + case "RemoveFeatures": + removeFeatures = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -17656,47 +17652,47 @@ namespace WixToolset.Core /// Flag if verb is advertised. private void ParseVerbElement(XElement node, string extension, string progId, string componentId, YesNoType advertise) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; string argument = null; string command = null; - int sequence = CompilerConstants.IntegerNotSet; + var sequence = CompilerConstants.IntegerNotSet; string target = null; string targetFile = null; string targetProperty = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Argument": - argument = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Command": - command = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Sequence": - sequence = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue); - break; - case "Target": - target = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "TargetFile", "TargetProperty")); - break; - case "TargetFile": - targetFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "File", targetFile); - break; - case "TargetProperty": - targetProperty = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Argument": + argument = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Command": + command = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Sequence": + sequence = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, Int16.MaxValue); + break; + case "Target": + target = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "TargetFile", "TargetProperty")); + break; + case "TargetFile": + targetFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "File", targetFile); + break; + case "TargetProperty": + targetProperty = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -17787,7 +17783,7 @@ namespace WixToolset.Core target = String.Concat(target, " ", argument); } - string prefix = (null != progId ? progId : String.Concat(".", extension)); + var prefix = (null != progId ? progId : String.Concat(".", extension)); if (null != command) { @@ -17805,33 +17801,33 @@ namespace WixToolset.Core /// Element to parse private void ParseApprovedExeForElevation(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string key = null; string valueName = null; - YesNoType win64 = YesNoType.NotSet; + var win64 = YesNoType.NotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Key": - key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Value": - valueName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Win64": - win64 = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Key": + key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Value": + valueName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Win64": + win64 = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -17850,7 +17846,7 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Key")); } - BundleApprovedExeForElevationAttributes attributes = BundleApprovedExeForElevationAttributes.None; + var attributes = BundleApprovedExeForElevationAttributes.None; if (win64 == YesNoType.Yes) { @@ -17874,12 +17870,12 @@ namespace WixToolset.Core /// Element to parse private void ParseBundleElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string copyright = null; string aboutUrl = null; - YesNoDefaultType compressed = YesNoDefaultType.Default; - int disableModify = -1; - YesNoType disableRemove = YesNoType.NotSet; + var compressed = YesNoDefaultType.Default; + var disableModify = -1; + var disableRemove = YesNoType.NotSet; string helpTelephone = null; string helpUrl = null; string manufacturer = null; @@ -17897,84 +17893,84 @@ namespace WixToolset.Core string splashScreenSourceFile = null; // Process only standard attributes until the active section is initialized. - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "AboutUrl": - aboutUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Compressed": - compressed = this.Core.GetAttributeYesNoDefaultValue(sourceLineNumbers, attrib); - break; - case "Condition": - condition = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Copyright": - copyright = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "DisableModify": - string value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - switch (value) - { - case "button": - disableModify = 2; - break; - case "yes": - disableModify = 1; - break; - case "no": - disableModify = 0; - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, value, "button", "yes", "no")); - break; - } - break; - case "DisableRemove": - disableRemove = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "DisableRepair": - this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); - break; - case "HelpTelephone": - helpTelephone = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "HelpUrl": - helpUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Manufacturer": - manufacturer = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "IconSourceFile": - iconSourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Name": - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "ParentName": - parentName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "SplashScreenSourceFile": - splashScreenSourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Tag": - tag = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "UpdateUrl": - updateUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + case "AboutUrl": + aboutUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Compressed": + compressed = this.Core.GetAttributeYesNoDefaultValue(sourceLineNumbers, attrib); + break; + case "Condition": + condition = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Copyright": + copyright = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DisableModify": + var value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + switch (value) + { + case "button": + disableModify = 2; break; - case "UpgradeCode": - upgradeCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + case "yes": + disableModify = 1; break; - case "Version": - version = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); + case "no": + disableModify = 0; break; default: - this.Core.UnexpectedAttribute(node, attrib); + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, value, "button", "yes", "no")); break; + } + break; + case "DisableRemove": + disableRemove = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "DisableRepair": + this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + break; + case "HelpTelephone": + helpTelephone = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "HelpUrl": + helpUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Manufacturer": + manufacturer = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "IconSourceFile": + iconSourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "ParentName": + parentName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "SplashScreenSourceFile": + splashScreenSourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Tag": + tag = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "UpdateUrl": + updateUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "UpgradeCode": + upgradeCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + case "Version": + version = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } } @@ -18020,7 +18016,7 @@ namespace WixToolset.Core this.Core.CreateActiveSection(this.activeName, SectionType.Bundle, 0, this.Context.CompilationId); // Now that the active section is initialized, process only extension attributes. - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (!String.IsNullOrEmpty(attrib.Name.NamespaceName) && CompilerCore.WixNamespace != attrib.Name.Namespace) { @@ -18028,82 +18024,82 @@ namespace WixToolset.Core } } - bool baSeen = false; - bool chainSeen = false; - bool logSeen = false; + var baSeen = false; + var chainSeen = false; + var logSeen = false; - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "ApprovedExeForElevation": - this.ParseApprovedExeForElevation(child); - break; - case "BootstrapperApplication": - if (baSeen) - { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); - this.Core.Write(ErrorMessages.TooManyChildren(childSourceLineNumbers, node.Name.LocalName, "BootstrapperApplication")); - } - this.ParseBootstrapperApplicationElement(child); - baSeen = true; - break; - case "BootstrapperApplicationRef": - this.ParseBootstrapperApplicationRefElement(child); - break; - case "OptionalUpdateRegistration": - this.ParseOptionalUpdateRegistrationElement(child, manufacturer, parentName, name); - break; - case "Catalog": - this.ParseCatalogElement(child); - break; - case "Chain": - if (chainSeen) - { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); - this.Core.Write(ErrorMessages.TooManyChildren(childSourceLineNumbers, node.Name.LocalName, "Chain")); - } - this.ParseChainElement(child); - chainSeen = true; - break; - case "Container": - this.ParseContainerElement(child); - break; - case "ContainerRef": - this.ParseSimpleRefElement(child, "WixBundleContainer"); - break; - case "Log": - if (logSeen) - { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); - this.Core.Write(ErrorMessages.TooManyChildren(childSourceLineNumbers, node.Name.LocalName, "Log")); - } - logVariablePrefixAndExtension = this.ParseLogElement(child, fileSystemSafeBundleName); - logSeen = true; - break; - case "PayloadGroup": - this.ParsePayloadGroupElement(child, ComplexReferenceParentType.Layout, "BundleLayoutOnlyPayloads"); - break; - case "PayloadGroupRef": - this.ParsePayloadGroupRefElement(child, ComplexReferenceParentType.Layout, "BundleLayoutOnlyPayloads", ComplexReferenceChildType.Unknown, null); - break; - case "RelatedBundle": - this.ParseRelatedBundleElement(child); - break; - case "Update": - this.ParseUpdateElement(child); - break; - case "Variable": - this.ParseVariableElement(child); - break; - case "WixVariable": - this.ParseWixVariableElement(child); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "ApprovedExeForElevation": + this.ParseApprovedExeForElevation(child); + break; + case "BootstrapperApplication": + if (baSeen) + { + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + this.Core.Write(ErrorMessages.TooManyChildren(childSourceLineNumbers, node.Name.LocalName, "BootstrapperApplication")); + } + this.ParseBootstrapperApplicationElement(child); + baSeen = true; + break; + case "BootstrapperApplicationRef": + this.ParseBootstrapperApplicationRefElement(child); + break; + case "OptionalUpdateRegistration": + this.ParseOptionalUpdateRegistrationElement(child, manufacturer, parentName, name); + break; + case "Catalog": + this.ParseCatalogElement(child); + break; + case "Chain": + if (chainSeen) + { + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + this.Core.Write(ErrorMessages.TooManyChildren(childSourceLineNumbers, node.Name.LocalName, "Chain")); + } + this.ParseChainElement(child); + chainSeen = true; + break; + case "Container": + this.ParseContainerElement(child); + break; + case "ContainerRef": + this.ParseSimpleRefElement(child, "WixBundleContainer"); + break; + case "Log": + if (logSeen) + { + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + this.Core.Write(ErrorMessages.TooManyChildren(childSourceLineNumbers, node.Name.LocalName, "Log")); + } + logVariablePrefixAndExtension = this.ParseLogElement(child, fileSystemSafeBundleName); + logSeen = true; + break; + case "PayloadGroup": + this.ParsePayloadGroupElement(child, ComplexReferenceParentType.Layout, "BundleLayoutOnlyPayloads"); + break; + case "PayloadGroupRef": + this.ParsePayloadGroupRefElement(child, ComplexReferenceParentType.Layout, "BundleLayoutOnlyPayloads", ComplexReferenceChildType.Unknown, null); + break; + case "RelatedBundle": + this.ParseRelatedBundleElement(child); + break; + case "Update": + this.ParseUpdateElement(child); + break; + case "Variable": + this.ParseVariableElement(child); + break; + case "WixVariable": + this.ParseWixVariableElement(child); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -18193,33 +18189,33 @@ namespace WixToolset.Core /// Element to parse private string ParseLogElement(XElement node, string fileSystemSafeBundleName) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - YesNoType disableLog = YesNoType.NotSet; - string variable = "WixBundleLog"; - string logPrefix = fileSystemSafeBundleName ?? "Setup"; - string logExtension = ".log"; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var disableLog = YesNoType.NotSet; + var variable = "WixBundleLog"; + var logPrefix = fileSystemSafeBundleName ?? "Setup"; + var logExtension = ".log"; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Disable": - disableLog = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "PathVariable": - variable = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); - break; - case "Prefix": - logPrefix = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Extension": - logExtension = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Disable": + disableLog = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "PathVariable": + variable = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); + break; + case "Prefix": + logPrefix = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Extension": + logExtension = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -18244,25 +18240,25 @@ namespace WixToolset.Core /// Element to parse private void ParseCatalogElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string sourceFile = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "SourceFile": - sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "SourceFile": + sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } } @@ -18295,37 +18291,37 @@ namespace WixToolset.Core /// Element to parse private void ParseContainerElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string downloadUrl = null; string name = null; - ContainerType type = ContainerType.Detached; + var type = ContainerType.Detached; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "DownloadUrl": - downloadUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Name": - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Type": - string typeString = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (!Enum.TryParse(typeString, out type)) - { - this.Core.Write(ErrorMessages.IllegalAttributeValueWithLegalList(sourceLineNumbers, node.Name.LocalName, "Type", typeString, "attached, detached")); - } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "DownloadUrl": + downloadUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Type": + var typeString = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (!Enum.TryParse(typeString, out type)) + { + this.Core.Write(ErrorMessages.IllegalAttributeValueWithLegalList(sourceLineNumbers, node.Name.LocalName, "Type", typeString, "attached, detached")); + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -18361,18 +18357,18 @@ namespace WixToolset.Core this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "DownloadUrl", "Type", "attached")); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "PackageGroupRef": - this.ParsePackageGroupRefElement(child, ComplexReferenceParentType.Container, id.Id); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "PackageGroupRef": + this.ParsePackageGroupRefElement(child, ComplexReferenceParentType.Container, id.Id); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -18397,10 +18393,10 @@ namespace WixToolset.Core /// Element to parse private void ParseBootstrapperApplicationElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; string previousId = null; - ComplexReferenceChildType previousType = ComplexReferenceChildType.Unknown; + var previousType = ComplexReferenceChildType.Unknown; // The BootstrapperApplication element acts like a Payload element so delegate to the "Payload" attribute parsing code to parse and create a Payload entry. id = this.ParsePayloadElementContent(node, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId, false); @@ -18410,23 +18406,23 @@ namespace WixToolset.Core previousType = ComplexReferenceChildType.Payload; } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Payload": - previousId = this.ParsePayloadElement(child, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId); - previousType = ComplexReferenceChildType.Payload; - break; - case "PayloadGroupRef": - previousId = this.ParsePayloadGroupRefElement(child, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId); - previousType = ComplexReferenceChildType.PayloadGroup; - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "Payload": + previousId = this.ParsePayloadElement(child, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId); + previousType = ComplexReferenceChildType.Payload; + break; + case "PayloadGroupRef": + previousId = this.ParsePayloadGroupRefElement(child, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId); + previousType = ComplexReferenceChildType.PayloadGroup; + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -18465,23 +18461,23 @@ namespace WixToolset.Core /// Element to parse private void ParseBootstrapperApplicationRefElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; string previousId = null; - ComplexReferenceChildType previousType = ComplexReferenceChildType.Unknown; + var previousType = ComplexReferenceChildType.Unknown; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -18490,23 +18486,23 @@ namespace WixToolset.Core } } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Payload": - previousId = this.ParsePayloadElement(child, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId); - previousType = ComplexReferenceChildType.Payload; - break; - case "PayloadGroupRef": - previousId = this.ParsePayloadGroupRefElement(child, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId); - previousType = ComplexReferenceChildType.PayloadGroup; - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "Payload": + previousId = this.ParsePayloadElement(child, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId); + previousType = ComplexReferenceChildType.Payload; + break; + case "PayloadGroupRef": + previousId = this.ParsePayloadGroupRefElement(child, ComplexReferenceParentType.Container, Compiler.BurnUXContainerId, previousType, previousId); + previousType = ComplexReferenceChildType.PayloadGroup; + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -18537,37 +18533,37 @@ namespace WixToolset.Core { const string defaultClassification = "Update"; - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string manufacturer = null; string department = null; string productFamily = null; string name = null; - string classification = defaultClassification; + var classification = defaultClassification; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Manufacturer": - manufacturer = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Department": - department = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "ProductFamily": - productFamily = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Name": - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Classification": - classification = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Manufacturer": + manufacturer = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Department": + department = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "ProductFamily": + productFamily = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Classification": + classification = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -18637,19 +18633,21 @@ namespace WixToolset.Core Debug.Assert(ComplexReferenceParentType.PayloadGroup == parentType || ComplexReferenceParentType.Package == parentType || ComplexReferenceParentType.Container == parentType); Debug.Assert(ComplexReferenceChildType.Unknown == previousType || ComplexReferenceChildType.PayloadGroup == previousType || ComplexReferenceChildType.Payload == previousType); - string id = ParsePayloadElementContent(node, parentType, parentId, previousType, previousId, true); - Dictionary context = new Dictionary(); - context["Id"] = id; + var id = this.ParsePayloadElementContent(node, parentType, parentId, previousType, previousId, true); + var context = new Dictionary + { + ["Id"] = id + }; - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - default: - this.Core.UnexpectedElement(node, child); - break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -18671,9 +18669,9 @@ namespace WixToolset.Core { Debug.Assert(ComplexReferenceParentType.PayloadGroup == parentType || ComplexReferenceParentType.Package == parentType || ComplexReferenceParentType.Container == parentType); - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - YesNoDefaultType compressed = YesNoDefaultType.Default; - YesNoType enableSignatureVerification = YesNoType.No; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var compressed = YesNoDefaultType.Default; + var enableSignatureVerification = YesNoType.No; Identifier id = null; string name = null; string sourceFile = null; @@ -18682,35 +18680,35 @@ namespace WixToolset.Core // This list lets us evaluate extension attributes *after* all core attributes // have been parsed and dealt with, regardless of authoring order. - List extensionAttributes = new List(); + var extensionAttributes = new List(); - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Compressed": - compressed = this.Core.GetAttributeYesNoDefaultValue(sourceLineNumbers, attrib); - break; - case "Name": - name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false, true); - break; - case "SourceFile": - sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "DownloadUrl": - downloadUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "EnableSignatureVerification": - enableSignatureVerification = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Compressed": + compressed = this.Core.GetAttributeYesNoDefaultValue(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false, true); + break; + case "SourceFile": + sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DownloadUrl": + downloadUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "EnableSignatureVerification": + enableSignatureVerification = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -18731,18 +18729,20 @@ namespace WixToolset.Core } // Now that the PayloadId is known, we can parse the extension attributes. - Dictionary context = new Dictionary(); - context["Id"] = id.Id; + var context = new Dictionary + { + ["Id"] = id.Id + }; - foreach (XAttribute extensionAttribute in extensionAttributes) + foreach (var extensionAttribute in extensionAttributes) { this.Core.ParseExtensionAttribute(node, extensionAttribute, context); } // We only handle the elements we care about. Let caller handle other children. - foreach (XElement child in node.Elements(CompilerCore.WixNamespace + "RemotePayload")) + foreach (var child in node.Elements(CompilerCore.WixNamespace + "RemotePayload")) { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); if (CompilerCore.WixNamespace == node.Name.Namespace && node.Name.LocalName != "ExePackage") { @@ -18780,7 +18780,7 @@ namespace WixToolset.Core { if (compressed == YesNoDefaultType.No) { - Core.Write(WarningMessages.UxPayloadsOnlySupportEmbedding(sourceLineNumbers, sourceFile)); + this.Core.Write(WarningMessages.UxPayloadsOnlySupportEmbedding(sourceLineNumbers, sourceFile)); } compressed = YesNoDefaultType.Yes; @@ -18793,39 +18793,39 @@ namespace WixToolset.Core private Wix.RemotePayload ParseRemotePayloadElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - Wix.RemotePayload remotePayload = new Wix.RemotePayload(); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var remotePayload = new Wix.RemotePayload(); - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "CertificatePublicKey": - remotePayload.CertificatePublicKey = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "CertificateThumbprint": - remotePayload.CertificateThumbprint = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Description": - remotePayload.Description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Hash": - remotePayload.Hash = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "ProductName": - remotePayload.ProductName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Size": - remotePayload.Size = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); - break; - case "Version": - remotePayload.Version = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "CertificatePublicKey": + remotePayload.CertificatePublicKey = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "CertificateThumbprint": + remotePayload.CertificateThumbprint = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Description": + remotePayload.Description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Hash": + remotePayload.Hash = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "ProductName": + remotePayload.ProductName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Size": + remotePayload.Size = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int32.MaxValue); + break; + case "Version": + remotePayload.Version = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -18913,21 +18913,21 @@ namespace WixToolset.Core { Debug.Assert(ComplexReferenceParentType.Unknown == parentType || ComplexReferenceParentType.Layout == parentType || ComplexReferenceParentType.PayloadGroup == parentType); - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -18942,25 +18942,25 @@ namespace WixToolset.Core id = Identifier.Invalid; } - ComplexReferenceChildType previousType = ComplexReferenceChildType.Unknown; + var previousType = ComplexReferenceChildType.Unknown; string previousId = null; - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Payload": - previousId = this.ParsePayloadElement(child, ComplexReferenceParentType.PayloadGroup, id.Id, previousType, previousId); - previousType = ComplexReferenceChildType.Payload; - break; - case "PayloadGroupRef": - previousId = this.ParsePayloadGroupRefElement(child, ComplexReferenceParentType.PayloadGroup, id.Id, previousType, previousId); - previousType = ComplexReferenceChildType.PayloadGroup; - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "Payload": + previousId = this.ParsePayloadElement(child, ComplexReferenceParentType.PayloadGroup, id.Id, previousType, previousId); + previousType = ComplexReferenceChildType.Payload; + break; + case "PayloadGroupRef": + previousId = this.ParsePayloadGroupRefElement(child, ComplexReferenceParentType.PayloadGroup, id.Id, previousType, previousId); + previousType = ComplexReferenceChildType.PayloadGroup; + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -18989,22 +18989,22 @@ namespace WixToolset.Core Debug.Assert(ComplexReferenceParentType.Layout == parentType || ComplexReferenceParentType.PayloadGroup == parentType || ComplexReferenceParentType.Package == parentType || ComplexReferenceParentType.Container == parentType); Debug.Assert(ComplexReferenceChildType.Unknown == previousType || ComplexReferenceChildType.PayloadGroup == previousType || ComplexReferenceChildType.Payload == previousType); - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "WixBundlePayloadGroup", id); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "WixBundlePayloadGroup", id); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -19058,29 +19058,29 @@ namespace WixToolset.Core /// Id of parent element private void ParseExitCodeElement(XElement node, string packageId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); var value = CompilerConstants.IntegerNotSet; var behavior = ExitCodeBehaviorType.NotSet; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Value": - value = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, int.MinValue + 2, int.MaxValue); - break; - case "Behavior": - string behaviorString = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - if (!Enum.TryParse(behaviorString, true, out behavior)) - { - this.Core.Write(ErrorMessages.IllegalAttributeValueWithLegalList(sourceLineNumbers, node.Name.LocalName, "Behavior", behaviorString, "success, error, scheduleReboot, forceReboot")); - } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Value": + value = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, Int32.MinValue + 2, Int32.MaxValue); + break; + case "Behavior": + var behaviorString = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + if (!Enum.TryParse(behaviorString, true, out behavior)) + { + this.Core.Write(ErrorMessages.IllegalAttributeValueWithLegalList(sourceLineNumbers, node.Name.LocalName, "Behavior", behaviorString, "success, error, scheduleReboot, forceReboot")); + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -19111,36 +19111,36 @@ namespace WixToolset.Core /// Element to parse private void ParseChainElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); var attributes = WixChainAttributes.None; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "DisableRollback": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= WixChainAttributes.DisableRollback; - } - break; - case "DisableSystemRestore": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= WixChainAttributes.DisableSystemRestore; - } - break; - case "ParallelCache": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - attributes |= WixChainAttributes.ParallelCache; - } - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "DisableRollback": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= WixChainAttributes.DisableRollback; + } + break; + case "DisableSystemRestore": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= WixChainAttributes.DisableSystemRestore; + } + break; + case "ParallelCache": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + attributes |= WixChainAttributes.ParallelCache; + } + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -19152,42 +19152,42 @@ namespace WixToolset.Core // Ensure there is always a rollback boundary at the beginning of the chain. this.CreateRollbackBoundary(sourceLineNumbers, new Identifier("WixDefaultBoundary", AccessModifier.Public), YesNoType.Yes, YesNoType.No, ComplexReferenceParentType.PackageGroup, "WixChain", ComplexReferenceChildType.Unknown, null); - string previousId = "WixDefaultBoundary"; - ComplexReferenceChildType previousType = ComplexReferenceChildType.Package; + var previousId = "WixDefaultBoundary"; + var previousType = ComplexReferenceChildType.Package; - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "MsiPackage": - previousId = this.ParseMsiPackageElement(child, ComplexReferenceParentType.PackageGroup, "WixChain", previousType, previousId); - previousType = ComplexReferenceChildType.Package; - break; - case "MspPackage": - previousId = this.ParseMspPackageElement(child, ComplexReferenceParentType.PackageGroup, "WixChain", previousType, previousId); - previousType = ComplexReferenceChildType.Package; - break; - case "MsuPackage": - previousId = this.ParseMsuPackageElement(child, ComplexReferenceParentType.PackageGroup, "WixChain", previousType, previousId); - previousType = ComplexReferenceChildType.Package; - break; - case "ExePackage": - previousId = this.ParseExePackageElement(child, ComplexReferenceParentType.PackageGroup, "WixChain", previousType, previousId); - previousType = ComplexReferenceChildType.Package; - break; - case "RollbackBoundary": - previousId = this.ParseRollbackBoundaryElement(child, ComplexReferenceParentType.PackageGroup, "WixChain", previousType, previousId); - previousType = ComplexReferenceChildType.Package; - break; - case "PackageGroupRef": - previousId = this.ParsePackageGroupRefElement(child, ComplexReferenceParentType.PackageGroup, "WixChain", previousType, previousId); - previousType = ComplexReferenceChildType.PackageGroup; - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "MsiPackage": + previousId = this.ParseMsiPackageElement(child, ComplexReferenceParentType.PackageGroup, "WixChain", previousType, previousId); + previousType = ComplexReferenceChildType.Package; + break; + case "MspPackage": + previousId = this.ParseMspPackageElement(child, ComplexReferenceParentType.PackageGroup, "WixChain", previousType, previousId); + previousType = ComplexReferenceChildType.Package; + break; + case "MsuPackage": + previousId = this.ParseMsuPackageElement(child, ComplexReferenceParentType.PackageGroup, "WixChain", previousType, previousId); + previousType = ComplexReferenceChildType.Package; + break; + case "ExePackage": + previousId = this.ParseExePackageElement(child, ComplexReferenceParentType.PackageGroup, "WixChain", previousType, previousId); + previousType = ComplexReferenceChildType.Package; + break; + case "RollbackBoundary": + previousId = this.ParseRollbackBoundaryElement(child, ComplexReferenceParentType.PackageGroup, "WixChain", previousType, previousId); + previousType = ComplexReferenceChildType.Package; + break; + case "PackageGroupRef": + previousId = this.ParsePackageGroupRefElement(child, ComplexReferenceParentType.PackageGroup, "WixChain", previousType, previousId); + previousType = ComplexReferenceChildType.PackageGroup; + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -19220,7 +19220,7 @@ namespace WixToolset.Core /// Identifier for package element. private string ParseMsiPackageElement(XElement node, ComplexReferenceParentType parentType, string parentId, ComplexReferenceChildType previousType, string previousId) { - return ParseChainPackage(node, WixBundlePackageType.Msi, parentType, parentId, previousType, previousId); + return this.ParseChainPackage(node, WixBundlePackageType.Msi, parentType, parentId, previousType, previousId); } /// @@ -19234,7 +19234,7 @@ namespace WixToolset.Core /// Identifier for package element. private string ParseMspPackageElement(XElement node, ComplexReferenceParentType parentType, string parentId, ComplexReferenceChildType previousType, string previousId) { - return ParseChainPackage(node, WixBundlePackageType.Msp, parentType, parentId, previousType, previousId); + return this.ParseChainPackage(node, WixBundlePackageType.Msp, parentType, parentId, previousType, previousId); } /// @@ -19248,7 +19248,7 @@ namespace WixToolset.Core /// Identifier for package element. private string ParseMsuPackageElement(XElement node, ComplexReferenceParentType parentType, string parentId, ComplexReferenceChildType previousType, string previousId) { - return ParseChainPackage(node, WixBundlePackageType.Msu, parentType, parentId, previousType, previousId); + return this.ParseChainPackage(node, WixBundlePackageType.Msu, parentType, parentId, previousType, previousId); } /// @@ -19262,7 +19262,7 @@ namespace WixToolset.Core /// Identifier for package element. private string ParseExePackageElement(XElement node, ComplexReferenceParentType parentType, string parentId, ComplexReferenceChildType previousType, string previousId) { - return ParseChainPackage(node, WixBundlePackageType.Exe, parentType, parentId, previousType, previousId); + return this.ParseChainPackage(node, WixBundlePackageType.Exe, parentType, parentId, previousType, previousId); } /// @@ -19279,34 +19279,34 @@ namespace WixToolset.Core Debug.Assert(ComplexReferenceParentType.PackageGroup == parentType); Debug.Assert(ComplexReferenceChildType.Unknown == previousType || ComplexReferenceChildType.PackageGroup == previousType || ComplexReferenceChildType.Package == previousType); - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - YesNoType vital = YesNoType.Yes; - YesNoType transaction = YesNoType.No; + var vital = YesNoType.Yes; + var transaction = YesNoType.No; // This list lets us evaluate extension attributes *after* all core attributes // have been parsed and dealt with, regardless of authoring order. - List extensionAttributes = new List(); + var extensionAttributes = new List(); - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { - bool allowed = true; + var allowed = true; switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Vital": - vital = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Transaction": - transaction = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - default: - allowed = false; - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Vital": + vital = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Transaction": + transaction = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + default: + allowed = false; + break; } if (!allowed) @@ -19340,9 +19340,11 @@ namespace WixToolset.Core } // Now that the rollback identifier is known, we can parse the extension attributes... - Dictionary contextValues = new Dictionary(); - contextValues["RollbackBoundaryId"] = id.Id; - foreach (XAttribute attribute in extensionAttributes) + var contextValues = new Dictionary + { + ["RollbackBoundaryId"] = id.Id + }; + foreach (var attribute in extensionAttributes) { this.Core.ParseExtensionAttribute(node, attribute, contextValues); } @@ -19374,165 +19376,165 @@ namespace WixToolset.Core Debug.Assert(ComplexReferenceParentType.PackageGroup == parentType); Debug.Assert(ComplexReferenceChildType.Unknown == previousType || ComplexReferenceChildType.PackageGroup == previousType || ComplexReferenceChildType.Package == previousType); - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; string name = null; string sourceFile = null; string downloadUrl = null; string after = null; string installCondition = null; - YesNoAlwaysType cache = YesNoAlwaysType.Yes; // the default is to cache everything in tradeoff for stability over disk space. + var cache = YesNoAlwaysType.Yes; // the default is to cache everything in tradeoff for stability over disk space. string cacheId = null; string description = null; string displayName = null; - string logPathVariable = (packageType == WixBundlePackageType.Msu) ? String.Empty : null; - string rollbackPathVariable = (packageType == WixBundlePackageType.Msu) ? String.Empty : null; - YesNoType permanent = YesNoType.NotSet; - YesNoType visible = YesNoType.NotSet; - YesNoType vital = YesNoType.Yes; + var logPathVariable = (packageType == WixBundlePackageType.Msu) ? String.Empty : null; + var rollbackPathVariable = (packageType == WixBundlePackageType.Msu) ? String.Empty : null; + var permanent = YesNoType.NotSet; + var visible = YesNoType.NotSet; + var vital = YesNoType.Yes; string installCommand = null; string repairCommand = null; - YesNoType repairable = YesNoType.NotSet; + var repairable = YesNoType.NotSet; string uninstallCommand = null; - YesNoDefaultType perMachine = YesNoDefaultType.NotSet; + var perMachine = YesNoDefaultType.NotSet; string detectCondition = null; string protocol = null; - int installSize = CompilerConstants.IntegerNotSet; + var installSize = CompilerConstants.IntegerNotSet; string msuKB = null; - YesNoType suppressLooseFilePayloadGeneration = YesNoType.NotSet; - YesNoType enableSignatureVerification = YesNoType.No; - YesNoDefaultType compressed = YesNoDefaultType.Default; - YesNoType displayInternalUI = YesNoType.NotSet; - YesNoType enableFeatureSelection = YesNoType.NotSet; - YesNoType forcePerMachine = YesNoType.NotSet; + var suppressLooseFilePayloadGeneration = YesNoType.NotSet; + var enableSignatureVerification = YesNoType.No; + var compressed = YesNoDefaultType.Default; + var displayInternalUI = YesNoType.NotSet; + var enableFeatureSelection = YesNoType.NotSet; + var forcePerMachine = YesNoType.NotSet; Wix.RemotePayload remotePayload = null; - YesNoType slipstream = YesNoType.NotSet; - - string[] expectedNetFx4Args = new string[] { "/q", "/norestart", "/chainingpackage" }; - - // This list lets us evaluate extension attributes *after* all core attributes - // have been parsed and dealt with, regardless of authoring order. - List extensionAttributes = new List(); - - foreach (XAttribute attrib in node.Attributes()) - { - if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) - { - bool allowed = true; - switch (attrib.Name.LocalName) - { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Name": - name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false, true); - if (!this.Core.IsValidLongFilename(name, false, true)) - { - this.Core.Write(ErrorMessages.IllegalLongFilename(sourceLineNumbers, node.Name.LocalName, "Name", name)); - } - break; - case "SourceFile": - sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "DownloadUrl": - downloadUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "After": - after = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "InstallCondition": - installCondition = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Cache": - cache = this.Core.GetAttributeYesNoAlwaysValue(sourceLineNumbers, attrib); - break; - case "CacheId": - cacheId = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Description": - description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "DisplayName": - displayName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "DisplayInternalUI": - displayInternalUI = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - allowed = (packageType == WixBundlePackageType.Msi || packageType == WixBundlePackageType.Msp); - break; - case "EnableFeatureSelection": - enableFeatureSelection = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - allowed = (packageType == WixBundlePackageType.Msi); - break; - case "ForcePerMachine": - forcePerMachine = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - allowed = (packageType == WixBundlePackageType.Msi); - break; - case "LogPathVariable": - logPathVariable = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); - break; - case "RollbackLogPathVariable": - rollbackPathVariable = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); - break; - case "Permanent": - permanent = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Visible": - visible = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - allowed = (packageType == WixBundlePackageType.Msi); - break; - case "Vital": - vital = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "InstallCommand": - installCommand = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - allowed = (packageType == WixBundlePackageType.Exe); - break; - case "RepairCommand": - repairCommand = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); - repairable = YesNoType.Yes; - allowed = (packageType == WixBundlePackageType.Exe); - break; - case "UninstallCommand": - uninstallCommand = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - allowed = (packageType == WixBundlePackageType.Exe); - break; - case "PerMachine": - perMachine = this.Core.GetAttributeYesNoDefaultValue(sourceLineNumbers, attrib); - allowed = (packageType == WixBundlePackageType.Exe || packageType == WixBundlePackageType.Msp); - break; - case "DetectCondition": - detectCondition = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - allowed = (packageType == WixBundlePackageType.Exe || packageType == WixBundlePackageType.Msu); - break; - case "Protocol": - protocol = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - allowed = (packageType == WixBundlePackageType.Exe); - break; - case "InstallSize": - installSize = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); - break; - case "KB": - msuKB = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - allowed = (packageType == WixBundlePackageType.Msu); - break; - case "Compressed": - compressed = this.Core.GetAttributeYesNoDefaultValue(sourceLineNumbers, attrib); - break; - case "SuppressLooseFilePayloadGeneration": - this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); - suppressLooseFilePayloadGeneration = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - allowed = (packageType == WixBundlePackageType.Msi); - break; - case "EnableSignatureVerification": - enableSignatureVerification = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - break; - case "Slipstream": - slipstream = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); - allowed = (packageType == WixBundlePackageType.Msp); - break; - default: - allowed = false; - break; + var slipstream = YesNoType.NotSet; + + var expectedNetFx4Args = new string[] { "/q", "/norestart", "/chainingpackage" }; + + // This list lets us evaluate extension attributes *after* all core attributes + // have been parsed and dealt with, regardless of authoring order. + var extensionAttributes = new List(); + + foreach (var attrib in node.Attributes()) + { + if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) + { + var allowed = true; + switch (attrib.Name.LocalName) + { + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Name": + name = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false, true); + if (!this.Core.IsValidLongFilename(name, false, true)) + { + this.Core.Write(ErrorMessages.IllegalLongFilename(sourceLineNumbers, node.Name.LocalName, "Name", name)); + } + break; + case "SourceFile": + sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DownloadUrl": + downloadUrl = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "After": + after = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "InstallCondition": + installCondition = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Cache": + cache = this.Core.GetAttributeYesNoAlwaysValue(sourceLineNumbers, attrib); + break; + case "CacheId": + cacheId = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Description": + description = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DisplayName": + displayName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "DisplayInternalUI": + displayInternalUI = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + allowed = (packageType == WixBundlePackageType.Msi || packageType == WixBundlePackageType.Msp); + break; + case "EnableFeatureSelection": + enableFeatureSelection = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + allowed = (packageType == WixBundlePackageType.Msi); + break; + case "ForcePerMachine": + forcePerMachine = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + allowed = (packageType == WixBundlePackageType.Msi); + break; + case "LogPathVariable": + logPathVariable = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); + break; + case "RollbackLogPathVariable": + rollbackPathVariable = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); + break; + case "Permanent": + permanent = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Visible": + visible = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + allowed = (packageType == WixBundlePackageType.Msi); + break; + case "Vital": + vital = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "InstallCommand": + installCommand = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + allowed = (packageType == WixBundlePackageType.Exe); + break; + case "RepairCommand": + repairCommand = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); + repairable = YesNoType.Yes; + allowed = (packageType == WixBundlePackageType.Exe); + break; + case "UninstallCommand": + uninstallCommand = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + allowed = (packageType == WixBundlePackageType.Exe); + break; + case "PerMachine": + perMachine = this.Core.GetAttributeYesNoDefaultValue(sourceLineNumbers, attrib); + allowed = (packageType == WixBundlePackageType.Exe || packageType == WixBundlePackageType.Msp); + break; + case "DetectCondition": + detectCondition = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + allowed = (packageType == WixBundlePackageType.Exe || packageType == WixBundlePackageType.Msu); + break; + case "Protocol": + protocol = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + allowed = (packageType == WixBundlePackageType.Exe); + break; + case "InstallSize": + installSize = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int32.MaxValue); + break; + case "KB": + msuKB = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + allowed = (packageType == WixBundlePackageType.Msu); + break; + case "Compressed": + compressed = this.Core.GetAttributeYesNoDefaultValue(sourceLineNumbers, attrib); + break; + case "SuppressLooseFilePayloadGeneration": + this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName)); + suppressLooseFilePayloadGeneration = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + allowed = (packageType == WixBundlePackageType.Msi); + break; + case "EnableSignatureVerification": + enableSignatureVerification = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + break; + case "Slipstream": + slipstream = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib); + allowed = (packageType == WixBundlePackageType.Msp); + break; + default: + allowed = false; + break; } if (!allowed) @@ -19548,9 +19550,9 @@ namespace WixToolset.Core } // We need to handle RemotePayload up front because it effects value of sourceFile which is used in Id generation. Id is needed by other child elements. - foreach (XElement child in node.Elements(CompilerCore.WixNamespace + "RemotePayload")) + foreach (var child in node.Elements(CompilerCore.WixNamespace + "RemotePayload")) { - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child); if (CompilerCore.WixNamespace == node.Name.Namespace && node.Name.LocalName != "ExePackage" && node.Name.LocalName != "MsuPackage") { @@ -19643,7 +19645,7 @@ namespace WixToolset.Core if (!String.IsNullOrEmpty(protocol) && protocol.Equals("netfx4", StringComparison.Ordinal)) { - foreach (string expectedArgument in expectedNetFx4Args) + foreach (var expectedArgument in expectedNetFx4Args) { if (null == installCommand || -1 == installCommand.IndexOf(expectedArgument, StringComparison.OrdinalIgnoreCase)) { @@ -19669,59 +19671,59 @@ namespace WixToolset.Core } // Now that the package ID is known, we can parse the extension attributes... - Dictionary contextValues = new Dictionary() { { "PackageId", id.Id } }; - foreach (XAttribute attribute in extensionAttributes) + var contextValues = new Dictionary() { { "PackageId", id.Id } }; + foreach (var attribute in extensionAttributes) { this.Core.ParseExtensionAttribute(node, attribute, contextValues); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { - bool allowed = true; + var allowed = true; switch (child.Name.LocalName) { - case "SlipstreamMsp": - allowed = (packageType == WixBundlePackageType.Msi); - if (allowed) - { - this.ParseSlipstreamMspElement(child, id.Id); - } - break; - case "MsiProperty": - allowed = (packageType == WixBundlePackageType.Msi || packageType == WixBundlePackageType.Msp); - if (allowed) - { - this.ParseMsiPropertyElement(child, id.Id); - } - break; - case "Payload": - this.ParsePayloadElement(child, ComplexReferenceParentType.Package, id.Id, ComplexReferenceChildType.Unknown, null); - break; - case "PayloadGroupRef": - this.ParsePayloadGroupRefElement(child, ComplexReferenceParentType.Package, id.Id, ComplexReferenceChildType.Unknown, null); - break; - case "ExitCode": - allowed = (packageType == WixBundlePackageType.Exe); - if (allowed) - { - this.ParseExitCodeElement(child, id.Id); - } - break; - case "CommandLine": - allowed = (packageType == WixBundlePackageType.Exe); - if (allowed) - { - this.ParseCommandLineElement(child, id.Id); - } - break; - case "RemotePayload": - // Handled previously - break; - default: - allowed = false; - break; + case "SlipstreamMsp": + allowed = (packageType == WixBundlePackageType.Msi); + if (allowed) + { + this.ParseSlipstreamMspElement(child, id.Id); + } + break; + case "MsiProperty": + allowed = (packageType == WixBundlePackageType.Msi || packageType == WixBundlePackageType.Msp); + if (allowed) + { + this.ParseMsiPropertyElement(child, id.Id); + } + break; + case "Payload": + this.ParsePayloadElement(child, ComplexReferenceParentType.Package, id.Id, ComplexReferenceChildType.Unknown, null); + break; + case "PayloadGroupRef": + this.ParsePayloadGroupRefElement(child, ComplexReferenceParentType.Package, id.Id, ComplexReferenceChildType.Unknown, null); + break; + case "ExitCode": + allowed = (packageType == WixBundlePackageType.Exe); + if (allowed) + { + this.ParseExitCodeElement(child, id.Id); + } + break; + case "CommandLine": + allowed = (packageType == WixBundlePackageType.Exe); + if (allowed) + { + this.ParseCommandLineElement(child, id.Id); + } + break; + case "RemotePayload": + // Handled previously + break; + default: + allowed = false; + break; } if (!allowed) @@ -19731,7 +19733,7 @@ namespace WixToolset.Core } else { - Dictionary context = new Dictionary() { { "Id", id.Id } }; + var context = new Dictionary() { { "Id", id.Id } }; this.Core.ParseExtensionElement(node, child, context); } } @@ -19782,44 +19784,44 @@ namespace WixToolset.Core switch (packageType) { - case WixBundlePackageType.Exe: - WixBundleExePackageAttributes exeAttributes = 0; - exeAttributes |= (YesNoType.Yes == repairable) ? WixBundleExePackageAttributes.Repairable : 0; - - var exeRow = (WixBundleExePackageTuple)this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.WixBundleExePackage, id); - exeRow.Attributes = exeAttributes; - exeRow.DetectCondition = detectCondition; - exeRow.InstallCommand = installCommand; - exeRow.RepairCommand = repairCommand; - exeRow.UninstallCommand = uninstallCommand; - exeRow.ExeProtocol = protocol; - break; + case WixBundlePackageType.Exe: + WixBundleExePackageAttributes exeAttributes = 0; + exeAttributes |= (YesNoType.Yes == repairable) ? WixBundleExePackageAttributes.Repairable : 0; + + var exeRow = (WixBundleExePackageTuple)this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.WixBundleExePackage, id); + exeRow.Attributes = exeAttributes; + exeRow.DetectCondition = detectCondition; + exeRow.InstallCommand = installCommand; + exeRow.RepairCommand = repairCommand; + exeRow.UninstallCommand = uninstallCommand; + exeRow.ExeProtocol = protocol; + break; - case WixBundlePackageType.Msi: - WixBundleMsiPackageAttributes msiAttributes = 0; - msiAttributes |= (YesNoType.Yes == displayInternalUI) ? WixBundleMsiPackageAttributes.DisplayInternalUI : 0; - msiAttributes |= (YesNoType.Yes == enableFeatureSelection) ? WixBundleMsiPackageAttributes.EnableFeatureSelection : 0; - msiAttributes |= (YesNoType.Yes == forcePerMachine) ? WixBundleMsiPackageAttributes.ForcePerMachine : 0; - msiAttributes |= (YesNoType.Yes == suppressLooseFilePayloadGeneration) ? WixBundleMsiPackageAttributes.SuppressLooseFilePayloadGeneration : 0; + case WixBundlePackageType.Msi: + WixBundleMsiPackageAttributes msiAttributes = 0; + msiAttributes |= (YesNoType.Yes == displayInternalUI) ? WixBundleMsiPackageAttributes.DisplayInternalUI : 0; + msiAttributes |= (YesNoType.Yes == enableFeatureSelection) ? WixBundleMsiPackageAttributes.EnableFeatureSelection : 0; + msiAttributes |= (YesNoType.Yes == forcePerMachine) ? WixBundleMsiPackageAttributes.ForcePerMachine : 0; + msiAttributes |= (YesNoType.Yes == suppressLooseFilePayloadGeneration) ? WixBundleMsiPackageAttributes.SuppressLooseFilePayloadGeneration : 0; - var msiRow = (WixBundleMsiPackageTuple)this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.WixBundleMsiPackage, id); - msiRow.Attributes = msiAttributes; - break; + var msiRow = (WixBundleMsiPackageTuple)this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.WixBundleMsiPackage, id); + msiRow.Attributes = msiAttributes; + break; - case WixBundlePackageType.Msp: - WixBundleMspPackageAttributes mspAttributes = 0; - mspAttributes |= (YesNoType.Yes == displayInternalUI) ? WixBundleMspPackageAttributes.DisplayInternalUI : 0; - mspAttributes |= (YesNoType.Yes == slipstream) ? WixBundleMspPackageAttributes.Slipstream : 0; + case WixBundlePackageType.Msp: + WixBundleMspPackageAttributes mspAttributes = 0; + mspAttributes |= (YesNoType.Yes == displayInternalUI) ? WixBundleMspPackageAttributes.DisplayInternalUI : 0; + mspAttributes |= (YesNoType.Yes == slipstream) ? WixBundleMspPackageAttributes.Slipstream : 0; - var mspRow = (WixBundleMspPackageTuple)this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.WixBundleMspPackage, id); - mspRow.Attributes = mspAttributes; - break; + var mspRow = (WixBundleMspPackageTuple)this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.WixBundleMspPackage, id); + mspRow.Attributes = mspAttributes; + break; - case WixBundlePackageType.Msu: - var msuRow = (WixBundleMsuPackageTuple)this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.WixBundleMsuPackage, id); - msuRow.DetectCondition = detectCondition; - msuRow.MsuKB = msuKB; - break; + case WixBundlePackageType.Msu: + var msuRow = (WixBundleMsuPackageTuple)this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.WixBundleMsuPackage, id); + msuRow.DetectCondition = detectCondition; + msuRow.MsuKB = msuKB; + break; } this.CreateChainPackageMetaRows(sourceLineNumbers, parentType, parentId, ComplexReferenceChildType.Package, id.Id, previousType, previousId, after); @@ -19834,33 +19836,33 @@ namespace WixToolset.Core /// Element to parse private void ParseCommandLineElement(XElement node, string packageId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string installArgument = null; string uninstallArgument = null; string repairArgument = null; string condition = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "InstallArgument": - installArgument = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "UninstallArgument": - uninstallArgument = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "RepairArgument": - repairArgument = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Condition": - condition = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "InstallArgument": + installArgument = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "UninstallArgument": + uninstallArgument = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "RepairArgument": + repairArgument = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Condition": + condition = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -19893,21 +19895,21 @@ namespace WixToolset.Core /// Element to parse private void ParsePackageGroupElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -19922,41 +19924,41 @@ namespace WixToolset.Core id = Identifier.Invalid; } - ComplexReferenceChildType previousType = ComplexReferenceChildType.Unknown; + var previousType = ComplexReferenceChildType.Unknown; string previousId = null; - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "MsiPackage": - previousId = this.ParseMsiPackageElement(child, ComplexReferenceParentType.PackageGroup, id.Id, previousType, previousId); - previousType = ComplexReferenceChildType.Package; - break; - case "MspPackage": - previousId = this.ParseMspPackageElement(child, ComplexReferenceParentType.PackageGroup, id.Id, previousType, previousId); - previousType = ComplexReferenceChildType.Package; - break; - case "MsuPackage": - previousId = this.ParseMsuPackageElement(child, ComplexReferenceParentType.PackageGroup, id.Id, previousType, previousId); - previousType = ComplexReferenceChildType.Package; - break; - case "ExePackage": - previousId = this.ParseExePackageElement(child, ComplexReferenceParentType.PackageGroup, id.Id, previousType, previousId); - previousType = ComplexReferenceChildType.Package; - break; - case "RollbackBoundary": - previousId = this.ParseRollbackBoundaryElement(child, ComplexReferenceParentType.PackageGroup, id.Id, previousType, previousId); - previousType = ComplexReferenceChildType.Package; - break; - case "PackageGroupRef": - previousId = this.ParsePackageGroupRefElement(child, ComplexReferenceParentType.PackageGroup, id.Id, previousType, previousId); - previousType = ComplexReferenceChildType.PackageGroup; - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "MsiPackage": + previousId = this.ParseMsiPackageElement(child, ComplexReferenceParentType.PackageGroup, id.Id, previousType, previousId); + previousType = ComplexReferenceChildType.Package; + break; + case "MspPackage": + previousId = this.ParseMspPackageElement(child, ComplexReferenceParentType.PackageGroup, id.Id, previousType, previousId); + previousType = ComplexReferenceChildType.Package; + break; + case "MsuPackage": + previousId = this.ParseMsuPackageElement(child, ComplexReferenceParentType.PackageGroup, id.Id, previousType, previousId); + previousType = ComplexReferenceChildType.Package; + break; + case "ExePackage": + previousId = this.ParseExePackageElement(child, ComplexReferenceParentType.PackageGroup, id.Id, previousType, previousId); + previousType = ComplexReferenceChildType.Package; + break; + case "RollbackBoundary": + previousId = this.ParseRollbackBoundaryElement(child, ComplexReferenceParentType.PackageGroup, id.Id, previousType, previousId); + previousType = ComplexReferenceChildType.Package; + break; + case "PackageGroupRef": + previousId = this.ParsePackageGroupRefElement(child, ComplexReferenceParentType.PackageGroup, id.Id, previousType, previousId); + previousType = ComplexReferenceChildType.PackageGroup; + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -19998,26 +20000,26 @@ namespace WixToolset.Core Debug.Assert(ComplexReferenceParentType.Unknown == parentType || ComplexReferenceParentType.PackageGroup == parentType || ComplexReferenceParentType.Container == parentType); Debug.Assert(ComplexReferenceChildType.Unknown == previousType || ComplexReferenceChildType.PackageGroup == previousType || ComplexReferenceChildType.Package == previousType); - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; string after = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "WixBundlePackageGroup", id); - break; - case "After": - after = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "WixBundlePackageGroup", id); + break; + case "After": + after = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -20129,29 +20131,29 @@ namespace WixToolset.Core /// Id of parent element private void ParseMsiPropertyElement(XElement node, string packageId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string name = null; string value = null; string condition = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Name": - name = this.Core.GetAttributeMsiPropertyNameValue(sourceLineNumbers, attrib); - break; - case "Value": - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - case "Condition": - condition = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Name": + name = this.Core.GetAttributeMsiPropertyNameValue(sourceLineNumbers, attrib); + break; + case "Value": + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + case "Condition": + condition = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -20193,22 +20195,22 @@ namespace WixToolset.Core /// Id of parent element private void ParseSlipstreamMspElement(XElement node, string packageId) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); - this.Core.CreateSimpleReference(sourceLineNumbers, "WixBundlePackage", id); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); + this.Core.CreateSimpleReference(sourceLineNumbers, "WixBundlePackage", id); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -20238,26 +20240,26 @@ namespace WixToolset.Core /// Element to parse private void ParseRelatedBundleElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string id = null; string action = null; - Wix.RelatedBundle.ActionType actionType = Wix.RelatedBundle.ActionType.Detect; + var actionType = Wix.RelatedBundle.ActionType.Detect; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); - break; - case "Action": - action = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false); + break; + case "Action": + action = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -20276,17 +20278,17 @@ namespace WixToolset.Core actionType = Wix.RelatedBundle.ParseActionType(action); switch (actionType) { - case Wix.RelatedBundle.ActionType.Detect: - break; - case Wix.RelatedBundle.ActionType.Upgrade: - break; - case Wix.RelatedBundle.ActionType.Addon: - break; - case Wix.RelatedBundle.ActionType.Patch: - break; - default: - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Action", action, "Detect", "Upgrade", "Addon", "Patch")); - break; + case Wix.RelatedBundle.ActionType.Detect: + break; + case Wix.RelatedBundle.ActionType.Upgrade: + break; + case Wix.RelatedBundle.ActionType.Addon: + break; + case Wix.RelatedBundle.ActionType.Patch: + break; + default: + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Action", action, "Detect", "Upgrade", "Addon", "Patch")); + break; } } @@ -20306,21 +20308,21 @@ namespace WixToolset.Core /// Element to parse private void ParseUpdateElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string location = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Location": - location = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Location": + location = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -20349,43 +20351,43 @@ namespace WixToolset.Core /// Element to parse private void ParseVariableElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); - bool hidden = false; + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var hidden = false; string name = null; - bool persisted = false; + var persisted = false; string value = null; string type = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Hidden": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - hidden = true; - } - break; - case "Name": - name = this.Core.GetAttributeBundleVariableValue(sourceLineNumbers, attrib); - break; - case "Persisted": - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) - { - persisted = true; - } - break; - case "Value": - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); - break; - case "Type": - type = this.Core.GetAttributeValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Hidden": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + hidden = true; + } + break; + case "Name": + name = this.Core.GetAttributeBundleVariableValue(sourceLineNumbers, attrib); + break; + case "Persisted": + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) + { + persisted = true; + } + break; + case "Value": + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); + break; + case "Type": + type = this.Core.GetAttributeValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -20410,8 +20412,7 @@ namespace WixToolset.Core { // Version constructor does not support simple "v#" syntax so check to see if the value is // non-negative real quick. - Int32 number; - if (Int32.TryParse(value.Substring(1), NumberStyles.None, CultureInfo.InvariantCulture.NumberFormat, out number)) + if (Int32.TryParse(value.Substring(1), NumberStyles.None, CultureInfo.InvariantCulture.NumberFormat, out var number)) { type = "version"; } @@ -20420,7 +20421,7 @@ namespace WixToolset.Core // Sadly, Version doesn't have a TryParse() method until .NET 4, so we have to try/catch to see if it parses. try { - Version version = new Version(value.Substring(1)); + var version = new Version(value.Substring(1)); type = "version"; } catch (Exception) @@ -20432,8 +20433,7 @@ namespace WixToolset.Core // Not a version, check for numeric. if (null == type) { - Int64 number; - if (Int64.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture.NumberFormat, out number)) + if (Int64.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture.NumberFormat, out var number)) { type = "numeric"; } @@ -20470,21 +20470,21 @@ namespace WixToolset.Core /// Element to parse. private void ParseWixElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); string requiredVersion = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "RequiredVersion": - requiredVersion = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "RequiredVersion": + requiredVersion = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else @@ -20498,33 +20498,33 @@ namespace WixToolset.Core this.Core.VerifyRequiredVersion(sourceLineNumbers, requiredVersion); } - foreach (XElement child in node.Elements()) + foreach (var child in node.Elements()) { if (CompilerCore.WixNamespace == child.Name.Namespace) { switch (child.Name.LocalName) { - case "Bundle": - this.ParseBundleElement(child); - break; - case "Fragment": - this.ParseFragmentElement(child); - break; - case "Module": - this.ParseModuleElement(child); - break; - case "PatchCreation": - this.ParsePatchCreationElement(child); - break; - case "Product": - this.ParseProductElement(child); - break; - case "Patch": - this.ParsePatchElement(child); - break; - default: - this.Core.UnexpectedElement(node, child); - break; + case "Bundle": + this.ParseBundleElement(child); + break; + case "Fragment": + this.ParseFragmentElement(child); + break; + case "Module": + this.ParseModuleElement(child); + break; + case "PatchCreation": + this.ParsePatchCreationElement(child); + break; + case "Product": + this.ParseProductElement(child); + break; + case "Patch": + this.ParsePatchElement(child); + break; + default: + this.Core.UnexpectedElement(node, child); + break; } } else @@ -20540,29 +20540,29 @@ namespace WixToolset.Core /// Element to parse. private void ParseWixVariableElement(XElement node) { - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); Identifier id = null; - bool overridable = false; + var overridable = false; string value = null; - foreach (XAttribute attrib in node.Attributes()) + foreach (var attrib in node.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace) { switch (attrib.Name.LocalName) { - case "Id": - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); - break; - case "Overridable": - overridable = (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)); - break; - case "Value": - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); - break; - default: - this.Core.UnexpectedAttribute(node, attrib); - break; + case "Id": + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); + break; + case "Overridable": + overridable = (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)); + break; + case "Value": + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); + break; + default: + this.Core.UnexpectedAttribute(node, attrib); + break; } } else diff --git a/src/WixToolset.Core/Localizer.cs b/src/WixToolset.Core/Localizer.cs index a545f844..94fa6ff7 100644 --- a/src/WixToolset.Core/Localizer.cs +++ b/src/WixToolset.Core/Localizer.cs @@ -26,7 +26,7 @@ namespace WixToolset.Core public Localization ParseLocalizationFile(string path) { var document = XDocument.Load(path); - return ParseLocalizationFile(document); + return this.ParseLocalizationFile(document); } public Localization ParseLocalizationFile(XDocument document) diff --git a/src/WixToolset.Core/Preprocessor.cs b/src/WixToolset.Core/Preprocessor.cs index 5a9cf115..a829f7c4 100644 --- a/src/WixToolset.Core/Preprocessor.cs +++ b/src/WixToolset.Core/Preprocessor.cs @@ -133,7 +133,7 @@ namespace WixToolset.Core this.Context = context; this.Context.CurrentSourceLineNumber = new SourceLineNumber(context.SourcePath); - this.Context.Variables = this.Context.Variables == null ? new Dictionary() : new Dictionary(this.Context.Variables); + this.Context.Variables = (this.Context.Variables == null) ? new Dictionary() : new Dictionary(this.Context.Variables); this.PreProcess(); -- cgit v1.2.3-55-g6feb