diff options
Diffstat (limited to 'src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs')
-rw-r--r-- | src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs b/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs index d2486890..b65abdfb 100644 --- a/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs +++ b/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs | |||
@@ -12,6 +12,7 @@ namespace WixToolset.Core.ExtensibilityServices | |||
12 | using System.Text.RegularExpressions; | 12 | using System.Text.RegularExpressions; |
13 | using System.Xml.Linq; | 13 | using System.Xml.Linq; |
14 | using WixToolset.Data; | 14 | using WixToolset.Data; |
15 | using Wix = WixToolset.Data.Serialize; | ||
15 | using WixToolset.Data.Tuples; | 16 | using WixToolset.Data.Tuples; |
16 | using WixToolset.Extensibility; | 17 | using WixToolset.Extensibility; |
17 | using WixToolset.Extensibility.Services; | 18 | using WixToolset.Extensibility.Services; |
@@ -571,6 +572,37 @@ namespace WixToolset.Core.ExtensibilityServices | |||
571 | return Common.GetAttributeValue(this.Messaging, sourceLineNumbers, attribute, emptyRule); | 572 | return Common.GetAttributeValue(this.Messaging, sourceLineNumbers, attribute, emptyRule); |
572 | } | 573 | } |
573 | 574 | ||
575 | public int GetAttributeMsidbRegistryRootValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool allowHkmu) | ||
576 | { | ||
577 | Wix.RegistryRootType registryRoot = this.GetAttributeRegistryRootValue(sourceLineNumbers, attribute, allowHkmu); | ||
578 | |||
579 | switch (registryRoot) | ||
580 | { | ||
581 | case Wix.RegistryRootType.NotSet: | ||
582 | return CompilerConstants.IntegerNotSet; | ||
583 | case Wix.RegistryRootType.HKCR: | ||
584 | return Core.Native.MsiInterop.MsidbRegistryRootClassesRoot; | ||
585 | case Wix.RegistryRootType.HKCU: | ||
586 | return Core.Native.MsiInterop.MsidbRegistryRootCurrentUser; | ||
587 | case Wix.RegistryRootType.HKLM: | ||
588 | return Core.Native.MsiInterop.MsidbRegistryRootLocalMachine; | ||
589 | case Wix.RegistryRootType.HKU: | ||
590 | return Core.Native.MsiInterop.MsidbRegistryRootUsers; | ||
591 | case Wix.RegistryRootType.HKMU: | ||
592 | // This is gross, but there was *one* registry root parsing instance | ||
593 | // (in Compiler.ParseRegistrySearchElement()) that did not explicitly | ||
594 | // handle HKMU and it fell through to the default error case. The | ||
595 | // others treated it as -1, which is what we do here. | ||
596 | if (allowHkmu) | ||
597 | { | ||
598 | return -1; | ||
599 | } | ||
600 | break; | ||
601 | } | ||
602 | |||
603 | return CompilerConstants.IntegerNotSet; | ||
604 | } | ||
605 | |||
574 | public string GetAttributeVersionValue(SourceLineNumber sourceLineNumbers, XAttribute attribute) | 606 | public string GetAttributeVersionValue(SourceLineNumber sourceLineNumbers, XAttribute attribute) |
575 | { | 607 | { |
576 | var value = this.GetAttributeValue(sourceLineNumbers, attribute); | 608 | var value = this.GetAttributeValue(sourceLineNumbers, attribute); |
@@ -814,6 +846,34 @@ namespace WixToolset.Core.ExtensibilityServices | |||
814 | return row; | 846 | return row; |
815 | } | 847 | } |
816 | 848 | ||
849 | private Wix.RegistryRootType GetAttributeRegistryRootValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool allowHkmu) | ||
850 | { | ||
851 | Wix.RegistryRootType registryRoot = Wix.RegistryRootType.NotSet; | ||
852 | string value = this.GetAttributeValue(sourceLineNumbers, attribute); | ||
853 | |||
854 | if (0 < value.Length) | ||
855 | { | ||
856 | registryRoot = Wix.Enums.ParseRegistryRootType(value); | ||
857 | |||
858 | if (Wix.RegistryRootType.IllegalValue == registryRoot || (!allowHkmu && Wix.RegistryRootType.HKMU == registryRoot)) | ||
859 | { | ||
860 | // TODO: Find a way to expose the valid values programatically! | ||
861 | if (allowHkmu) | ||
862 | { | ||
863 | this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value, | ||
864 | "HKMU", "HKCR", "HKCU", "HKLM", "HKU")); | ||
865 | } | ||
866 | else | ||
867 | { | ||
868 | this.Messaging.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value, | ||
869 | "HKCR", "HKCU", "HKLM", "HKU")); | ||
870 | } | ||
871 | } | ||
872 | } | ||
873 | |||
874 | return registryRoot; | ||
875 | } | ||
876 | |||
817 | private static bool TryFindExtension(IEnumerable<ICompilerExtension> extensions, XNamespace ns, out ICompilerExtension extension) | 877 | private static bool TryFindExtension(IEnumerable<ICompilerExtension> extensions, XNamespace ns, out ICompilerExtension extension) |
818 | { | 878 | { |
819 | extension = null; | 879 | extension = null; |