Add CreateCustomActionReference method
...to simplify creating custom action references following naming conventions.
Bob Arnson committed
Mar 3, 2020 at 16:08 UTC
c6456e5a41709997f62656e2406017321b346e48
2 files changed
+79
src/WixToolset.Core/ExtensibilityServices/CustomActionPlatforms.cs
new
+31
@@ -0,0 +1,31 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Core.ExtensibilityServices
4
+{
5
+ using System;
6
+
7
+ /// <summary>
8
+ /// Platforms supported by custom actions.
9
+ /// </summary>
10
+ [Flags]
11
+ public enum CustomActionPlatforms
12
+ {
13
+ /// <summary>Not specified.</summary>
14
+ None = 0,
15
+
16
+ /// <summary>x86.</summary>
17
+ X86 = 0x1,
18
+
19
+ /// <summary>x64.</summary>
20
+ X64 = 0x2,
21
+
22
+ /// <summary>ia64.</summary>
23
+ IA64 = 0x4,
24
+
25
+ /// <summary>arm.</summary>
26
+ ARM = 0x8,
27
+
28
+ /// <summary>arm64.</summary>
29
+ ARM64 = 0x10
30
+ }
31
+}
src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs
+48
@@ -892,6 +892,54 @@ namespace WixToolset.Core.ExtensibilityServices
892
return actionTuple;
893
}
894
895
+ /// <summary>
896
+ /// Create a reference in the specified section for a custom action specialized for specific platforms,
897
+ /// given standard prefixes for naming and suffixes for platforms.
898
+ /// </summary>
899
+ /// <param name="sourceLineNumbers">Source line information.</param>
900
+ /// <param name="customAction">The custom action base name.</param>
901
+ /// <param name="supportedPlatforms">The platforms for which there are specialized custom actions.</param>
902
+ public void CreateCustomActionReference(SourceLineNumber sourceLineNumbers, IntermediateSection section, string customAction, Platform platform, CustomActionPlatforms supportedPlatforms)
903
+ {
904
+ if (!this.Messaging.EncounteredError)
905
+ {
906
+ var name = String.Concat("Wix4", customAction);
907
+
908
+ switch (platform)
909
+ {
910
+ case Platform.X86:
911
+ if ((supportedPlatforms & CustomActionPlatforms.X86) == CustomActionPlatforms.X86)
912
+ {
913
+ name = String.Concat(customAction, "_X86");
914
+ }
915
+ break;
916
+ case Platform.X64:
917
+ if ((supportedPlatforms & CustomActionPlatforms.X64) == CustomActionPlatforms.X64)
918
+ {
919
+ name = String.Concat(customAction, "_X64");
920
+ }
921
+ break;
922
+ case Platform.ARM:
923
+ if ((supportedPlatforms & CustomActionPlatforms.ARM) == CustomActionPlatforms.ARM)
924
+ {
925
+ name = String.Concat(customAction, "_A32");
926
+ }
927
+ break;
928
+ case Platform.ARM64:
929
+ if ((supportedPlatforms & CustomActionPlatforms.ARM64) == CustomActionPlatforms.ARM64)
930
+ {
931
+ name = String.Concat(customAction, "_A64");
932
+ }
933
+ break;
934
+ case Platform.IA64:
935
+ // yeah, no
936
+ break;
937
+ }
938
+
939
+ this.CreateSimpleReference(section, sourceLineNumbers, nameof(TupleDefinitionType.CustomAction), name);
940
+ }
941
+ }
942
+
943
public void UnexpectedAttribute(XElement element, XAttribute attribute)
944
{
945
var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(element);