aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2017-12-29 21:47:48 -0800
committerRob Mensching <rob@firegiant.com>2017-12-29 21:47:48 -0800
commit0731fa5ca035f0ca9d5cb28f5e3ef07d98f9a7ae (patch)
tree01891c6ce98b5c1ba586204734261dc57e44bda4
parent59004832767115df136c553169e992577e5981d6 (diff)
downloadwix-0731fa5ca035f0ca9d5cb28f5e3ef07d98f9a7ae.tar.gz
wix-0731fa5ca035f0ca9d5cb28f5e3ef07d98f9a7ae.tar.bz2
wix-0731fa5ca035f0ca9d5cb28f5e3ef07d98f9a7ae.zip
Implement IParseHelper.GetAttributeMsidbRegistryRootValue()
Diffstat (limited to '')
-rw-r--r--src/WixToolset.Core/CompilerCore.cs64
-rw-r--r--src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs60
2 files changed, 61 insertions, 63 deletions
diff --git a/src/WixToolset.Core/CompilerCore.cs b/src/WixToolset.Core/CompilerCore.cs
index 7cb7b703..651c80a3 100644
--- a/src/WixToolset.Core/CompilerCore.cs
+++ b/src/WixToolset.Core/CompilerCore.cs
@@ -831,42 +831,6 @@ namespace WixToolset.Core
831 } 831 }
832 832
833 /// <summary> 833 /// <summary>
834 /// Gets a RegistryRoot value and displays an error for an illegal value.
835 /// </summary>
836 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
837 /// <param name="attribute">The attribute containing the value to get.</param>
838 /// <param name="allowHkmu">Whether HKMU is considered a valid value.</param>
839 /// <returns>The attribute's RegisitryRootType value.</returns>
840 [SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes")]
841 public Wix.RegistryRootType GetAttributeRegistryRootValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool allowHkmu)
842 {
843 Wix.RegistryRootType registryRoot = Wix.RegistryRootType.NotSet;
844 string value = this.GetAttributeValue(sourceLineNumbers, attribute);
845
846 if (0 < value.Length)
847 {
848 registryRoot = Wix.Enums.ParseRegistryRootType(value);
849
850 if (Wix.RegistryRootType.IllegalValue == registryRoot || (!allowHkmu && Wix.RegistryRootType.HKMU == registryRoot))
851 {
852 // TODO: Find a way to expose the valid values programatically!
853 if (allowHkmu)
854 {
855 this.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value,
856 "HKMU", "HKCR", "HKCU", "HKLM", "HKU"));
857 }
858 else
859 {
860 this.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, attribute.Parent.Name.LocalName, attribute.Name.LocalName, value,
861 "HKCR", "HKCU", "HKLM", "HKU"));
862 }
863 }
864 }
865
866 return registryRoot;
867 }
868
869 /// <summary>
870 /// Gets a RegistryRoot as a MsiInterop.MsidbRegistryRoot value and displays an error for an illegal value. 834 /// Gets a RegistryRoot as a MsiInterop.MsidbRegistryRoot value and displays an error for an illegal value.
871 /// </summary> 835 /// </summary>
872 /// <param name="sourceLineNumbers">Source line information about the owner element.</param> 836 /// <param name="sourceLineNumbers">Source line information about the owner element.</param>
@@ -876,33 +840,7 @@ namespace WixToolset.Core
876 [SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes")] 840 [SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes")]
877 public int GetAttributeMsidbRegistryRootValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool allowHkmu) 841 public int GetAttributeMsidbRegistryRootValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, bool allowHkmu)
878 { 842 {
879 Wix.RegistryRootType registryRoot = this.GetAttributeRegistryRootValue(sourceLineNumbers, attribute, allowHkmu); 843 return this.parseHelper.GetAttributeMsidbRegistryRootValue(sourceLineNumbers, attribute, allowHkmu);
880
881 switch (registryRoot)
882 {
883 case Wix.RegistryRootType.NotSet:
884 return CompilerConstants.IntegerNotSet;
885 case Wix.RegistryRootType.HKCR:
886 return Core.Native.MsiInterop.MsidbRegistryRootClassesRoot;
887 case Wix.RegistryRootType.HKCU:
888 return Core.Native.MsiInterop.MsidbRegistryRootCurrentUser;
889 case Wix.RegistryRootType.HKLM:
890 return Core.Native.MsiInterop.MsidbRegistryRootLocalMachine;
891 case Wix.RegistryRootType.HKU:
892 return Core.Native.MsiInterop.MsidbRegistryRootUsers;
893 case Wix.RegistryRootType.HKMU:
894 // This is gross, but there was *one* registry root parsing instance
895 // (in Compiler.ParseRegistrySearchElement()) that did not explicitly
896 // handle HKMU and it fell through to the default error case. The
897 // others treated it as -1, which is what we do here.
898 if (allowHkmu)
899 {
900 return -1;
901 }
902 break;
903 }
904
905 return CompilerConstants.IntegerNotSet;
906 } 844 }
907 845
908 /// <summary> 846 /// <summary>
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;