diff options
Diffstat (limited to 'src/ext/DifxApp/wixext/DifxAppCompiler.cs')
-rw-r--r-- | src/ext/DifxApp/wixext/DifxAppCompiler.cs | 155 |
1 files changed, 0 insertions, 155 deletions
diff --git a/src/ext/DifxApp/wixext/DifxAppCompiler.cs b/src/ext/DifxApp/wixext/DifxAppCompiler.cs deleted file mode 100644 index 6f32a60b..00000000 --- a/src/ext/DifxApp/wixext/DifxAppCompiler.cs +++ /dev/null | |||
@@ -1,155 +0,0 @@ | |||
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.DifxApp | ||
4 | { | ||
5 | using System; | ||
6 | using System.Collections.Generic; | ||
7 | using System.Xml.Linq; | ||
8 | using WixToolset.Data; | ||
9 | using WixToolset.DifxApp.Symbols; | ||
10 | using WixToolset.Extensibility; | ||
11 | |||
12 | /// <summary> | ||
13 | /// The compiler for the WiX Toolset Driver Install Frameworks for Applications Extension. | ||
14 | /// </summary> | ||
15 | public sealed class DifxAppCompiler : BaseCompilerExtension | ||
16 | { | ||
17 | private HashSet<string> components; | ||
18 | |||
19 | public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/difxapp"; | ||
20 | /// <summary> | ||
21 | /// Instantiate a new DifxAppCompiler. | ||
22 | /// </summary> | ||
23 | public DifxAppCompiler() | ||
24 | { | ||
25 | this.components = new HashSet<string>(); | ||
26 | } | ||
27 | |||
28 | /// <summary> | ||
29 | /// Processes an element for the Compiler. | ||
30 | /// </summary> | ||
31 | /// <param name="sourceLineNumbers">Source line number for the parent element.</param> | ||
32 | /// <param name="parentElement">Parent element of element to process.</param> | ||
33 | /// <param name="element">Element to process.</param> | ||
34 | /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param> | ||
35 | public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context) | ||
36 | { | ||
37 | switch (parentElement.Name.LocalName) | ||
38 | { | ||
39 | case "Component": | ||
40 | var componentId = context["ComponentId"]; | ||
41 | var componentWin64 = Boolean.Parse(context["Win64"]); | ||
42 | |||
43 | switch (element.Name.LocalName) | ||
44 | { | ||
45 | case "Driver": | ||
46 | this.ParseDriverElement(intermediate, section, element, componentId, componentWin64); | ||
47 | break; | ||
48 | default: | ||
49 | this.ParseHelper.UnexpectedElement(parentElement, element); | ||
50 | break; | ||
51 | } | ||
52 | break; | ||
53 | default: | ||
54 | this.ParseHelper.UnexpectedElement(parentElement, element); | ||
55 | break; | ||
56 | } | ||
57 | } | ||
58 | |||
59 | /// <summary> | ||
60 | /// Parses a Driver element. | ||
61 | /// </summary> | ||
62 | /// <param name="node">Element to parse.</param> | ||
63 | /// <param name="componentId">Identifier for parent component.</param> | ||
64 | private void ParseDriverElement(Intermediate intermediate, IntermediateSection section, XElement node, string componentId, bool win64) | ||
65 | { | ||
66 | var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); | ||
67 | int attributes = 0; | ||
68 | var sequence = CompilerConstants.IntegerNotSet; | ||
69 | |||
70 | // See https://github.com/wixtoolset/issues/issues/6648. DifxApp is deprecated so warn the user. | ||
71 | this.Messaging.Write(WarningMessages.DeprecatedElement(sourceLineNumbers, node.Name.LocalName)); | ||
72 | |||
73 | // check the number of times a Driver element has been nested under this Component element | ||
74 | if (null != componentId) | ||
75 | { | ||
76 | if (this.components.Contains(componentId)) | ||
77 | { | ||
78 | this.Messaging.Write(ErrorMessages.TooManyElements(sourceLineNumbers, "Component", node.Name.LocalName, 1)); | ||
79 | } | ||
80 | else | ||
81 | { | ||
82 | this.components.Add(componentId); | ||
83 | } | ||
84 | } | ||
85 | |||
86 | foreach (var attrib in node.Attributes()) | ||
87 | { | ||
88 | if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) | ||
89 | { | ||
90 | switch (attrib.Name.LocalName) | ||
91 | { | ||
92 | case "AddRemovePrograms": | ||
93 | if (YesNoType.No == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | ||
94 | { | ||
95 | attributes |= 0x4; | ||
96 | } | ||
97 | break; | ||
98 | case "DeleteFiles": | ||
99 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | ||
100 | { | ||
101 | attributes |= 0x10; | ||
102 | } | ||
103 | break; | ||
104 | case "ForceInstall": | ||
105 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | ||
106 | { | ||
107 | attributes |= 0x1; | ||
108 | } | ||
109 | break; | ||
110 | case "Legacy": | ||
111 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | ||
112 | { | ||
113 | attributes |= 0x8; | ||
114 | } | ||
115 | break; | ||
116 | case "PlugAndPlayPrompt": | ||
117 | if (YesNoType.No == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | ||
118 | { | ||
119 | attributes |= 0x2; | ||
120 | } | ||
121 | break; | ||
122 | case "Sequence": | ||
123 | sequence = this.ParseHelper.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue); | ||
124 | break; | ||
125 | default: | ||
126 | this.ParseHelper.UnexpectedAttribute(node, attrib); | ||
127 | break; | ||
128 | } | ||
129 | } | ||
130 | else | ||
131 | { | ||
132 | this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); | ||
133 | } | ||
134 | } | ||
135 | |||
136 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); | ||
137 | |||
138 | if (!this.Messaging.EncounteredError) | ||
139 | { | ||
140 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, SymbolDefinitions.CustomAction, "MsiProcessDrivers"); | ||
141 | |||
142 | var symbol = section.AddSymbol(new MsiDriverPackagesSymbol(sourceLineNumbers) | ||
143 | { | ||
144 | ComponentRef = componentId, | ||
145 | Flags = attributes, | ||
146 | }); | ||
147 | |||
148 | if (CompilerConstants.IntegerNotSet != sequence) | ||
149 | { | ||
150 | symbol.Sequence = sequence; | ||
151 | } | ||
152 | } | ||
153 | } | ||
154 | } | ||
155 | } | ||