diff options
Diffstat (limited to 'src/wixext/DependencyCompiler.cs')
-rw-r--r-- | src/wixext/DependencyCompiler.cs | 263 |
1 files changed, 130 insertions, 133 deletions
diff --git a/src/wixext/DependencyCompiler.cs b/src/wixext/DependencyCompiler.cs index a138c047..f866b589 100644 --- a/src/wixext/DependencyCompiler.cs +++ b/src/wixext/DependencyCompiler.cs | |||
@@ -1,6 +1,6 @@ | |||
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. | 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 | 2 | ||
3 | namespace WixToolset.Extensions | 3 | namespace WixToolset.Dependency |
4 | { | 4 | { |
5 | using System; | 5 | using System; |
6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
@@ -9,11 +9,12 @@ namespace WixToolset.Extensions | |||
9 | using System.Xml.Linq; | 9 | using System.Xml.Linq; |
10 | using WixToolset.Data; | 10 | using WixToolset.Data; |
11 | using WixToolset.Extensibility; | 11 | using WixToolset.Extensibility; |
12 | using WixToolset.Extensibility.Data; | ||
12 | 13 | ||
13 | /// <summary> | 14 | /// <summary> |
14 | /// The compiler for the WiX toolset dependency extension. | 15 | /// The compiler for the WiX Toolset Dependency Extension. |
15 | /// </summary> | 16 | /// </summary> |
16 | public sealed class DependencyCompiler : CompilerExtension | 17 | public sealed class DependencyCompiler : BaseCompilerExtension |
17 | { | 18 | { |
18 | /// <summary> | 19 | /// <summary> |
19 | /// Package type when parsing the Provides element. | 20 | /// Package type when parsing the Provides element. |
@@ -27,10 +28,7 @@ namespace WixToolset.Extensions | |||
27 | MsuPackage | 28 | MsuPackage |
28 | } | 29 | } |
29 | 30 | ||
30 | public DependencyCompiler() | 31 | public override XNamespace Namespace => "http://wixtoolset.org/schemas/v4/wxs/dependency"; |
31 | { | ||
32 | this.Namespace = "http://wixtoolset.org/schemas/v4/wxs/dependency"; | ||
33 | } | ||
34 | 32 | ||
35 | /// <summary> | 33 | /// <summary> |
36 | /// Processes an attribute for the Compiler. | 34 | /// Processes an attribute for the Compiler. |
@@ -38,24 +36,24 @@ namespace WixToolset.Extensions | |||
38 | /// <param name="sourceLineNumbers">Source line number for the parent element.</param> | 36 | /// <param name="sourceLineNumbers">Source line number for the parent element.</param> |
39 | /// <param name="parentElement">Parent element of attribute.</param> | 37 | /// <param name="parentElement">Parent element of attribute.</param> |
40 | /// <param name="attribute">Attribute to process.</param> | 38 | /// <param name="attribute">Attribute to process.</param> |
41 | public override void ParseAttribute(XElement parentElement, XAttribute attribute, IDictionary<string, string> context) | 39 | public override void ParseAttribute(Intermediate intermediate, IntermediateSection section, XElement parentElement, XAttribute attribute, IDictionary<string, string> context) |
42 | { | 40 | { |
43 | SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(parentElement); | 41 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(parentElement); |
44 | switch (parentElement.Name.LocalName) | 42 | switch (parentElement.Name.LocalName) |
45 | { | 43 | { |
46 | case "Bundle": | 44 | case "Bundle": |
47 | switch (attribute.Name.LocalName) | 45 | switch (attribute.Name.LocalName) |
48 | { | 46 | { |
49 | case "ProviderKey": | 47 | case "ProviderKey": |
50 | this.ParseProviderKeyAttribute(sourceLineNumbers, parentElement, attribute); | 48 | this.ParseProviderKeyAttribute(section, sourceLineNumbers, parentElement, attribute); |
51 | break; | 49 | break; |
52 | default: | 50 | default: |
53 | this.Core.UnexpectedAttribute(parentElement, attribute); | 51 | this.ParseHelper.UnexpectedAttribute(parentElement, attribute); |
54 | break; | 52 | break; |
55 | } | 53 | } |
56 | break; | 54 | break; |
57 | default: | 55 | default: |
58 | this.Core.UnexpectedAttribute(parentElement, attribute); | 56 | this.ParseHelper.UnexpectedAttribute(parentElement, attribute); |
59 | break; | 57 | break; |
60 | } | 58 | } |
61 | } | 59 | } |
@@ -67,7 +65,7 @@ namespace WixToolset.Extensions | |||
67 | /// <param name="parentElement">Parent element of element to process.</param> | 65 | /// <param name="parentElement">Parent element of element to process.</param> |
68 | /// <param name="element">Element to process.</param> | 66 | /// <param name="element">Element to process.</param> |
69 | /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param> | 67 | /// <param name="contextValues">Extra information about the context in which this element is being parsed.</param> |
70 | public override void ParseElement(XElement parentElement, XElement element, IDictionary<string, string> context) | 68 | public override void ParseElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context) |
71 | { | 69 | { |
72 | PackageType packageType = PackageType.None; | 70 | PackageType packageType = PackageType.None; |
73 | 71 | ||
@@ -80,10 +78,10 @@ namespace WixToolset.Extensions | |||
80 | switch (element.Name.LocalName) | 78 | switch (element.Name.LocalName) |
81 | { | 79 | { |
82 | case "Requires": | 80 | case "Requires": |
83 | this.ParseRequiresElement(element, null, false); | 81 | this.ParseRequiresElement(intermediate, section, element, null, false); |
84 | break; | 82 | break; |
85 | default: | 83 | default: |
86 | this.Core.UnexpectedElement(parentElement, element); | 84 | this.ParseHelper.UnexpectedElement(parentElement, element); |
87 | break; | 85 | break; |
88 | } | 86 | } |
89 | break; | 87 | break; |
@@ -100,7 +98,7 @@ namespace WixToolset.Extensions | |||
100 | packageType = PackageType.MsuPackage; | 98 | packageType = PackageType.MsuPackage; |
101 | break; | 99 | break; |
102 | default: | 100 | default: |
103 | this.Core.UnexpectedElement(parentElement, element); | 101 | this.ParseHelper.UnexpectedElement(parentElement, element); |
104 | break; | 102 | break; |
105 | } | 103 | } |
106 | 104 | ||
@@ -111,10 +109,10 @@ namespace WixToolset.Extensions | |||
111 | switch (element.Name.LocalName) | 109 | switch (element.Name.LocalName) |
112 | { | 110 | { |
113 | case "Provides": | 111 | case "Provides": |
114 | this.ParseProvidesElement(element, packageType, packageId); | 112 | this.ParseProvidesElement(intermediate, section, element, packageType, packageId); |
115 | break; | 113 | break; |
116 | default: | 114 | default: |
117 | this.Core.UnexpectedElement(parentElement, element); | 115 | this.ParseHelper.UnexpectedElement(parentElement, element); |
118 | break; | 116 | break; |
119 | } | 117 | } |
120 | } | 118 | } |
@@ -127,9 +125,9 @@ namespace WixToolset.Extensions | |||
127 | /// <param name="element">Element to process.</param> | 125 | /// <param name="element">Element to process.</param> |
128 | /// <param name="context">Extra information about the context in which this element is being parsed.</param> | 126 | /// <param name="context">Extra information about the context in which this element is being parsed.</param> |
129 | /// <returns>The component key path type if set.</returns> | 127 | /// <returns>The component key path type if set.</returns> |
130 | public override ComponentKeyPath ParsePossibleKeyPathElement(XElement parentElement, XElement element, IDictionary<string, string> context) | 128 | public override ComponentKeyPath ParsePossibleKeyPathElement(Intermediate intermediate, IntermediateSection section, XElement parentElement, XElement element, IDictionary<string, string> context) |
131 | { | 129 | { |
132 | SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(parentElement); | 130 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(parentElement); |
133 | ComponentKeyPath keyPath = null; | 131 | ComponentKeyPath keyPath = null; |
134 | 132 | ||
135 | switch (parentElement.Name.LocalName) | 133 | switch (parentElement.Name.LocalName) |
@@ -146,18 +144,18 @@ namespace WixToolset.Extensions | |||
146 | case "Provides": | 144 | case "Provides": |
147 | if (win64) | 145 | if (win64) |
148 | { | 146 | { |
149 | this.Core.OnMessage(DependencyWarnings.Win64Component(sourceLineNumbers, componentId)); | 147 | this.Messaging.Write(DependencyWarnings.Win64Component(sourceLineNumbers, componentId)); |
150 | } | 148 | } |
151 | 149 | ||
152 | keyPath = this.ParseProvidesElement(element, PackageType.None, componentId); | 150 | keyPath = this.ParseProvidesElement(intermediate, section, element, PackageType.None, componentId); |
153 | break; | 151 | break; |
154 | default: | 152 | default: |
155 | this.Core.UnexpectedElement(parentElement, element); | 153 | this.ParseHelper.UnexpectedElement(parentElement, element); |
156 | break; | 154 | break; |
157 | } | 155 | } |
158 | break; | 156 | break; |
159 | default: | 157 | default: |
160 | this.Core.UnexpectedElement(parentElement, element); | 158 | this.ParseHelper.UnexpectedElement(parentElement, element); |
161 | break; | 159 | break; |
162 | } | 160 | } |
163 | 161 | ||
@@ -170,7 +168,7 @@ namespace WixToolset.Extensions | |||
170 | /// <param name="sourceLineNumbers">Source line number for the parent element.</param> | 168 | /// <param name="sourceLineNumbers">Source line number for the parent element.</param> |
171 | /// <param name="parentElement">Parent element of attribute.</param> | 169 | /// <param name="parentElement">Parent element of attribute.</param> |
172 | /// <param name="attribute">The XML attribute for the ProviderKey attribute.</param> | 170 | /// <param name="attribute">The XML attribute for the ProviderKey attribute.</param> |
173 | private void ParseProviderKeyAttribute(SourceLineNumber sourceLineNumbers, XElement parentElement, XAttribute attribute) | 171 | private void ParseProviderKeyAttribute(IntermediateSection section, SourceLineNumber sourceLineNumbers, XElement parentElement, XAttribute attribute) |
174 | { | 172 | { |
175 | Identifier id = null; | 173 | Identifier id = null; |
176 | string providerKey = null; | 174 | string providerKey = null; |
@@ -179,41 +177,41 @@ namespace WixToolset.Extensions | |||
179 | switch (attribute.Name.LocalName) | 177 | switch (attribute.Name.LocalName) |
180 | { | 178 | { |
181 | case "ProviderKey": | 179 | case "ProviderKey": |
182 | providerKey = this.Core.GetAttributeValue(sourceLineNumbers, attribute); | 180 | providerKey = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attribute); |
183 | break; | 181 | break; |
184 | default: | 182 | default: |
185 | this.Core.UnexpectedAttribute(parentElement, attribute); | 183 | this.ParseHelper.UnexpectedAttribute(parentElement, attribute); |
186 | break; | 184 | break; |
187 | } | 185 | } |
188 | 186 | ||
189 | // Make sure the key does not contain any illegal characters or values. | 187 | // Make sure the key does not contain any illegal characters or values. |
190 | if (String.IsNullOrEmpty(providerKey)) | 188 | if (String.IsNullOrEmpty(providerKey)) |
191 | { | 189 | { |
192 | this.Core.OnMessage(WixErrors.IllegalEmptyAttributeValue(sourceLineNumbers, parentElement.Name.LocalName, attribute.Name.LocalName)); | 190 | this.Messaging.Write(ErrorMessages.IllegalEmptyAttributeValue(sourceLineNumbers, parentElement.Name.LocalName, attribute.Name.LocalName)); |
193 | } | 191 | } |
194 | else if (0 <= (illegalChar = providerKey.IndexOfAny(DependencyCommon.InvalidCharacters))) | 192 | else if (0 <= (illegalChar = providerKey.IndexOfAny(DependencyCommon.InvalidCharacters))) |
195 | { | 193 | { |
196 | StringBuilder sb = new StringBuilder(DependencyCommon.InvalidCharacters.Length * 2); | 194 | StringBuilder sb = new StringBuilder(DependencyCommon.InvalidCharacters.Length * 2); |
197 | Array.ForEach<char>(DependencyCommon.InvalidCharacters, c => sb.Append(c).Append(" ")); | 195 | Array.ForEach<char>(DependencyCommon.InvalidCharacters, c => sb.Append(c).Append(" ")); |
198 | 196 | ||
199 | this.Core.OnMessage(DependencyErrors.IllegalCharactersInProvider(sourceLineNumbers, "ProviderKey", providerKey[illegalChar], sb.ToString())); | 197 | this.Messaging.Write(DependencyErrors.IllegalCharactersInProvider(sourceLineNumbers, "ProviderKey", providerKey[illegalChar], sb.ToString())); |
200 | } | 198 | } |
201 | else if ("ALL" == providerKey) | 199 | else if ("ALL" == providerKey) |
202 | { | 200 | { |
203 | this.Core.OnMessage(DependencyErrors.ReservedValue(sourceLineNumbers, parentElement.Name.LocalName, "ProviderKey", providerKey)); | 201 | this.Messaging.Write(DependencyErrors.ReservedValue(sourceLineNumbers, parentElement.Name.LocalName, "ProviderKey", providerKey)); |
204 | } | 202 | } |
205 | 203 | ||
206 | // Generate the primary key for the row. | 204 | // Generate the primary key for the row. |
207 | id = this.Core.CreateIdentifier("dep", attribute.Name.LocalName, providerKey); | 205 | id = this.ParseHelper.CreateIdentifier("dep", attribute.Name.LocalName, providerKey); |
208 | 206 | ||
209 | if (!this.Core.EncounteredError) | 207 | if (!this.Messaging.EncounteredError) |
210 | { | 208 | { |
211 | // Create the provider row for the bundle. The Component_ field is required | 209 | // Create the provider row for the bundle. The Component_ field is required |
212 | // in the table definition but unused for bundles, so just set it to the valid ID. | 210 | // in the table definition but unused for bundles, so just set it to the valid ID. |
213 | Row row = this.Core.CreateRow(sourceLineNumbers, "WixDependencyProvider", id); | 211 | var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixDependencyProvider", id); |
214 | row[1] = id.Id; | 212 | row.Set(1, id.Id); |
215 | row[2] = providerKey; | 213 | row.Set(2, providerKey); |
216 | row[5] = DependencyCommon.ProvidesAttributesBundle; | 214 | row.Set(5, DependencyCommon.ProvidesAttributesBundle); |
217 | } | 215 | } |
218 | } | 216 | } |
219 | 217 | ||
@@ -225,9 +223,9 @@ namespace WixToolset.Extensions | |||
225 | /// <param name="keyPath">Explicit key path.</param> | 223 | /// <param name="keyPath">Explicit key path.</param> |
226 | /// <param name="parentId">The identifier of the parent component or package.</param> | 224 | /// <param name="parentId">The identifier of the parent component or package.</param> |
227 | /// <returns>The type of key path if set.</returns> | 225 | /// <returns>The type of key path if set.</returns> |
228 | private ComponentKeyPath ParseProvidesElement(XElement node, PackageType packageType, string parentId) | 226 | private ComponentKeyPath ParseProvidesElement(Intermediate intermediate, IntermediateSection section, XElement node, PackageType packageType, string parentId) |
229 | { | 227 | { |
230 | SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); | 228 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); |
231 | ComponentKeyPath keyPath = null; | 229 | ComponentKeyPath keyPath = null; |
232 | Identifier id = null; | 230 | Identifier id = null; |
233 | string key = null; | 231 | string key = null; |
@@ -243,25 +241,25 @@ namespace WixToolset.Extensions | |||
243 | switch (attrib.Name.LocalName) | 241 | switch (attrib.Name.LocalName) |
244 | { | 242 | { |
245 | case "Id": | 243 | case "Id": |
246 | id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); | 244 | id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); |
247 | break; | 245 | break; |
248 | case "Key": | 246 | case "Key": |
249 | key = this.Core.GetAttributeValue(sourceLineNumbers, attrib); | 247 | key = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
250 | break; | 248 | break; |
251 | case "Version": | 249 | case "Version": |
252 | version = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); | 250 | version = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); |
253 | break; | 251 | break; |
254 | case "DisplayName": | 252 | case "DisplayName": |
255 | displayName = this.Core.GetAttributeValue(sourceLineNumbers, attrib); | 253 | displayName = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
256 | break; | 254 | break; |
257 | default: | 255 | default: |
258 | this.Core.UnexpectedAttribute(node, attrib); | 256 | this.ParseHelper.UnexpectedAttribute(node, attrib); |
259 | break; | 257 | break; |
260 | } | 258 | } |
261 | } | 259 | } |
262 | else | 260 | else |
263 | { | 261 | { |
264 | this.Core.ParseExtensionAttribute(node, attrib); | 262 | this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); |
265 | } | 263 | } |
266 | } | 264 | } |
267 | 265 | ||
@@ -275,22 +273,22 @@ namespace WixToolset.Extensions | |||
275 | StringBuilder sb = new StringBuilder(DependencyCommon.InvalidCharacters.Length * 2); | 273 | StringBuilder sb = new StringBuilder(DependencyCommon.InvalidCharacters.Length * 2); |
276 | Array.ForEach<char>(DependencyCommon.InvalidCharacters, c => sb.Append(c).Append(" ")); | 274 | Array.ForEach<char>(DependencyCommon.InvalidCharacters, c => sb.Append(c).Append(" ")); |
277 | 275 | ||
278 | this.Core.OnMessage(DependencyErrors.IllegalCharactersInProvider(sourceLineNumbers, "Key", key[illegalChar], sb.ToString())); | 276 | this.Messaging.Write(DependencyErrors.IllegalCharactersInProvider(sourceLineNumbers, "Key", key[illegalChar], sb.ToString())); |
279 | } | 277 | } |
280 | else if ("ALL" == key) | 278 | else if ("ALL" == key) |
281 | { | 279 | { |
282 | this.Core.OnMessage(DependencyErrors.ReservedValue(sourceLineNumbers, node.Name.LocalName, "Key", key)); | 280 | this.Messaging.Write(DependencyErrors.ReservedValue(sourceLineNumbers, node.Name.LocalName, "Key", key)); |
283 | } | 281 | } |
284 | } | 282 | } |
285 | else if (PackageType.ExePackage == packageType || PackageType.MsuPackage == packageType) | 283 | else if (PackageType.ExePackage == packageType || PackageType.MsuPackage == packageType) |
286 | { | 284 | { |
287 | // Must specify the provider key when authored for a package. | 285 | // Must specify the provider key when authored for a package. |
288 | this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Key")); | 286 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Key")); |
289 | } | 287 | } |
290 | else if (PackageType.None == packageType) | 288 | else if (PackageType.None == packageType) |
291 | { | 289 | { |
292 | // Make sure the ProductCode is authored and set the key. | 290 | // Make sure the ProductCode is authored and set the key. |
293 | this.Core.CreateSimpleReference(sourceLineNumbers, "Property", "ProductCode"); | 291 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "Property", "ProductCode"); |
294 | key = "!(bind.property.ProductCode)"; | 292 | key = "!(bind.property.ProductCode)"; |
295 | } | 293 | } |
296 | 294 | ||
@@ -300,23 +298,23 @@ namespace WixToolset.Extensions | |||
300 | switch (packageType) | 298 | switch (packageType) |
301 | { | 299 | { |
302 | case PackageType.None: | 300 | case PackageType.None: |
303 | this.Core.OnMessage(DependencyWarnings.DiscouragedVersionAttribute(sourceLineNumbers)); | 301 | this.Messaging.Write(DependencyWarnings.DiscouragedVersionAttribute(sourceLineNumbers)); |
304 | break; | 302 | break; |
305 | case PackageType.MsiPackage: | 303 | case PackageType.MsiPackage: |
306 | this.Core.OnMessage(DependencyWarnings.DiscouragedVersionAttribute(sourceLineNumbers, parentId)); | 304 | this.Messaging.Write(DependencyWarnings.DiscouragedVersionAttribute(sourceLineNumbers, parentId)); |
307 | break; | 305 | break; |
308 | } | 306 | } |
309 | } | 307 | } |
310 | else if (PackageType.MspPackage == packageType || PackageType.MsuPackage == packageType) | 308 | else if (PackageType.MspPackage == packageType || PackageType.MsuPackage == packageType) |
311 | { | 309 | { |
312 | // Must specify the Version when authored for packages that do not contain a version. | 310 | // Must specify the Version when authored for packages that do not contain a version. |
313 | this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Version")); | 311 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Version")); |
314 | } | 312 | } |
315 | 313 | ||
316 | // Need the element ID for child element processing, so generate now if not authored. | 314 | // Need the element ID for child element processing, so generate now if not authored. |
317 | if (null == id) | 315 | if (null == id) |
318 | { | 316 | { |
319 | id = this.Core.CreateIdentifier("dep", node.Name.LocalName, parentId, key); | 317 | id = this.ParseHelper.CreateIdentifier("dep", node.Name.LocalName, parentId, key); |
320 | } | 318 | } |
321 | 319 | ||
322 | foreach (XElement child in node.Elements()) | 320 | foreach (XElement child in node.Elements()) |
@@ -326,94 +324,93 @@ namespace WixToolset.Extensions | |||
326 | switch (child.Name.LocalName) | 324 | switch (child.Name.LocalName) |
327 | { | 325 | { |
328 | case "Requires": | 326 | case "Requires": |
329 | this.ParseRequiresElement(child, id.Id, PackageType.None == packageType); | 327 | this.ParseRequiresElement(intermediate, section, child, id.Id, PackageType.None == packageType); |
330 | break; | 328 | break; |
331 | case "RequiresRef": | 329 | case "RequiresRef": |
332 | this.ParseRequiresRefElement(child, id.Id, PackageType.None == packageType); | 330 | this.ParseRequiresRefElement(intermediate, section, child, id.Id, PackageType.None == packageType); |
333 | break; | 331 | break; |
334 | default: | 332 | default: |
335 | this.Core.UnexpectedElement(node, child); | 333 | this.ParseHelper.UnexpectedElement(node, child); |
336 | break; | 334 | break; |
337 | } | 335 | } |
338 | } | 336 | } |
339 | else | 337 | else |
340 | { | 338 | { |
341 | this.Core.ParseExtensionElement(node, child); | 339 | this.ParseHelper.ParseExtensionElement(this.Context.Extensions, intermediate, section, node, child); |
342 | } | 340 | } |
343 | } | 341 | } |
344 | 342 | ||
345 | if (!this.Core.EncounteredError) | 343 | if (!this.Messaging.EncounteredError) |
346 | { | 344 | { |
347 | // Create the row in the provider table. | 345 | // Create the row in the provider table. |
348 | Row row = this.Core.CreateRow(sourceLineNumbers, "WixDependencyProvider", id); | 346 | var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixDependencyProvider", id); |
349 | row[1] = parentId; | 347 | row.Set(1, parentId); |
350 | row[2] = key; | 348 | row.Set(2, key); |
351 | 349 | ||
352 | if (!String.IsNullOrEmpty(version)) | 350 | if (!String.IsNullOrEmpty(version)) |
353 | { | 351 | { |
354 | row[3] = version; | 352 | row.Set(3, version); |
355 | } | 353 | } |
356 | 354 | ||
357 | if (!String.IsNullOrEmpty(displayName)) | 355 | if (!String.IsNullOrEmpty(displayName)) |
358 | { | 356 | { |
359 | row[4] = displayName; | 357 | row.Set(4, displayName); |
360 | } | 358 | } |
361 | 359 | ||
362 | if (0 != attributes) | 360 | if (0 != attributes) |
363 | { | 361 | { |
364 | row[5] = attributes; | 362 | row.Set(5, attributes); |
365 | } | 363 | } |
366 | 364 | ||
367 | if (PackageType.None == packageType) | 365 | if (PackageType.None == packageType) |
368 | { | 366 | { |
369 | // Reference the Check custom action to check for dependencies on the current provider. | 367 | // Reference the Check custom action to check for dependencies on the current provider. |
370 | if (Platform.ARM == this.Core.CurrentPlatform) | 368 | if (Platform.ARM == this.Context.Platform) |
371 | { | 369 | { |
372 | // Ensure the ARM version of the CA is referenced. | 370 | // Ensure the ARM version of the CA is referenced. |
373 | this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "WixDependencyCheck_ARM"); | 371 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixDependencyCheck_ARM"); |
374 | } | 372 | } |
375 | else | 373 | else |
376 | { | 374 | { |
377 | // All other supported platforms use x86. | 375 | // All other supported platforms use x86. |
378 | this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "WixDependencyCheck"); | 376 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixDependencyCheck"); |
379 | } | 377 | } |
380 | 378 | ||
381 | // Generate registry rows for the provider using binder properties. | 379 | // Generate registry rows for the provider using binder properties. |
382 | string keyProvides = String.Concat(DependencyCommon.RegistryRoot, key); | 380 | string keyProvides = String.Concat(DependencyCommon.RegistryRoot, key); |
383 | 381 | ||
384 | row = this.Core.CreateRow(sourceLineNumbers, "Registry", this.Core.CreateIdentifier("reg", id.Id, "(Default)")); | 382 | row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "Registry", this.ParseHelper.CreateIdentifier("reg", id.Id, "(Default)")); |
385 | row[1] = -1; | 383 | row.Set(1, -1); |
386 | row[2] = keyProvides; | 384 | row.Set(2, keyProvides); |
387 | row[3] = null; | 385 | row.Set(4, "[ProductCode]"); |
388 | row[4] = "[ProductCode]"; | 386 | row.Set(5, parentId); |
389 | row[5] = parentId; | ||
390 | 387 | ||
391 | // Use the Version registry value and use that as a potential key path. | 388 | // Use the Version registry value and use that as a potential key path. |
392 | Identifier idVersion = this.Core.CreateIdentifier("reg", id.Id, "Version"); | 389 | Identifier idVersion = this.ParseHelper.CreateIdentifier("reg", id.Id, "Version"); |
393 | keyPath = new ComponentKeyPath() { Id = idVersion.Id, Explicit = false, Type = ComponentKeyPathType.Registry }; | 390 | keyPath = new ComponentKeyPath() { Id = idVersion.Id, Explicit = false, Type = ComponentKeyPathType.Registry }; |
394 | 391 | ||
395 | row = this.Core.CreateRow(sourceLineNumbers, "Registry", idVersion); | 392 | row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "Registry", idVersion); |
396 | row[1] = -1; | 393 | row.Set(1, -1); |
397 | row[2] = keyProvides; | 394 | row.Set(2, keyProvides); |
398 | row[3] = "Version"; | 395 | row.Set(3, "Version"); |
399 | row[4] = !String.IsNullOrEmpty(version) ? version : "[ProductVersion]"; | 396 | row.Set(4, !String.IsNullOrEmpty(version) ? version : "[ProductVersion]"); |
400 | row[5] = parentId; | 397 | row.Set(5, parentId); |
401 | 398 | ||
402 | row = this.Core.CreateRow(sourceLineNumbers, "Registry", this.Core.CreateIdentifier("reg", id.Id, "DisplayName")); | 399 | row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "Registry", this.ParseHelper.CreateIdentifier("reg", id.Id, "DisplayName")); |
403 | row[1] = -1; | 400 | row.Set(1, -1); |
404 | row[2] = keyProvides; | 401 | row.Set(2, keyProvides); |
405 | row[3] = "DisplayName"; | 402 | row.Set(3, "DisplayName"); |
406 | row[4] = !String.IsNullOrEmpty(displayName) ? displayName : "[ProductName]"; | 403 | row.Set(4, !String.IsNullOrEmpty(displayName) ? displayName : "[ProductName]"); |
407 | row[5] = parentId; | 404 | row.Set(5, parentId); |
408 | 405 | ||
409 | if (0 != attributes) | 406 | if (0 != attributes) |
410 | { | 407 | { |
411 | row = this.Core.CreateRow(sourceLineNumbers, "Registry", this.Core.CreateIdentifier("reg", id.Id, "Attributes")); | 408 | row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "Registry", this.ParseHelper.CreateIdentifier("reg", id.Id, "Attributes")); |
412 | row[1] = -1; | 409 | row.Set(1, -1); |
413 | row[2] = keyProvides; | 410 | row.Set(2, keyProvides); |
414 | row[3] = "Attributes"; | 411 | row.Set(3, "Attributes"); |
415 | row[4] = String.Concat("#", attributes.ToString(CultureInfo.InvariantCulture.NumberFormat)); | 412 | row.Set(4, String.Concat("#", attributes.ToString(CultureInfo.InvariantCulture.NumberFormat))); |
416 | row[5] = parentId; | 413 | row.Set(5, parentId); |
417 | } | 414 | } |
418 | } | 415 | } |
419 | } | 416 | } |
@@ -427,9 +424,9 @@ namespace WixToolset.Extensions | |||
427 | /// <param name="node">The XML node for the Requires element.</param> | 424 | /// <param name="node">The XML node for the Requires element.</param> |
428 | /// <param name="providerId">The parent provider identifier.</param> | 425 | /// <param name="providerId">The parent provider identifier.</param> |
429 | /// <param name="requiresAction">Whether the Requires custom action should be referenced.</param> | 426 | /// <param name="requiresAction">Whether the Requires custom action should be referenced.</param> |
430 | private void ParseRequiresElement(XElement node, string providerId, bool requiresAction) | 427 | private void ParseRequiresElement(Intermediate intermediate, IntermediateSection section, XElement node, string providerId, bool requiresAction) |
431 | { | 428 | { |
432 | SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); | 429 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); |
433 | Identifier id = null; | 430 | Identifier id = null; |
434 | string providerKey = null; | 431 | string providerKey = null; |
435 | string minVersion = null; | 432 | string minVersion = null; |
@@ -444,41 +441,41 @@ namespace WixToolset.Extensions | |||
444 | switch (attrib.Name.LocalName) | 441 | switch (attrib.Name.LocalName) |
445 | { | 442 | { |
446 | case "Id": | 443 | case "Id": |
447 | id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib); | 444 | id = this.ParseHelper.GetAttributeIdentifier(sourceLineNumbers, attrib); |
448 | break; | 445 | break; |
449 | case "ProviderKey": | 446 | case "ProviderKey": |
450 | providerKey = this.Core.GetAttributeValue(sourceLineNumbers, attrib); | 447 | providerKey = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); |
451 | break; | 448 | break; |
452 | case "Minimum": | 449 | case "Minimum": |
453 | minVersion = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); | 450 | minVersion = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); |
454 | break; | 451 | break; |
455 | case "Maximum": | 452 | case "Maximum": |
456 | maxVersion = this.Core.GetAttributeVersionValue(sourceLineNumbers, attrib); | 453 | maxVersion = this.ParseHelper.GetAttributeVersionValue(sourceLineNumbers, attrib); |
457 | break; | 454 | break; |
458 | case "IncludeMinimum": | 455 | case "IncludeMinimum": |
459 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 456 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
460 | { | 457 | { |
461 | attributes |= DependencyCommon.RequiresAttributesMinVersionInclusive; | 458 | attributes |= DependencyCommon.RequiresAttributesMinVersionInclusive; |
462 | } | 459 | } |
463 | break; | 460 | break; |
464 | case "IncludeMaximum": | 461 | case "IncludeMaximum": |
465 | if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) | 462 | if (YesNoType.Yes == this.ParseHelper.GetAttributeYesNoValue(sourceLineNumbers, attrib)) |
466 | { | 463 | { |
467 | attributes |= DependencyCommon.RequiresAttributesMaxVersionInclusive; | 464 | attributes |= DependencyCommon.RequiresAttributesMaxVersionInclusive; |
468 | } | 465 | } |
469 | break; | 466 | break; |
470 | default: | 467 | default: |
471 | this.Core.UnexpectedAttribute(node, attrib); | 468 | this.ParseHelper.UnexpectedAttribute(node, attrib); |
472 | break; | 469 | break; |
473 | } | 470 | } |
474 | } | 471 | } |
475 | else | 472 | else |
476 | { | 473 | { |
477 | this.Core.ParseExtensionAttribute(node, attrib); | 474 | this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); |
478 | } | 475 | } |
479 | } | 476 | } |
480 | 477 | ||
481 | this.Core.ParseForExtensionElements(node); | 478 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); |
482 | 479 | ||
483 | if (null == id) | 480 | if (null == id) |
484 | { | 481 | { |
@@ -486,18 +483,18 @@ namespace WixToolset.Extensions | |||
486 | // element will be necessary and the Id attribute will be required. | 483 | // element will be necessary and the Id attribute will be required. |
487 | if (!String.IsNullOrEmpty(providerId)) | 484 | if (!String.IsNullOrEmpty(providerId)) |
488 | { | 485 | { |
489 | id = this.Core.CreateIdentifier("dep", node.Name.LocalName, providerKey); | 486 | id = this.ParseHelper.CreateIdentifier("dep", node.Name.LocalName, providerKey); |
490 | } | 487 | } |
491 | else | 488 | else |
492 | { | 489 | { |
493 | this.Core.OnMessage(WixErrors.ExpectedAttributeWhenElementNotUnderElement(sourceLineNumbers, node.Name.LocalName, "Id", "Provides")); | 490 | this.Messaging.Write(ErrorMessages.ExpectedAttributeWhenElementNotUnderElement(sourceLineNumbers, node.Name.LocalName, "Id", "Provides")); |
494 | id = Identifier.Invalid; | 491 | id = Identifier.Invalid; |
495 | } | 492 | } |
496 | } | 493 | } |
497 | 494 | ||
498 | if (String.IsNullOrEmpty(providerKey)) | 495 | if (String.IsNullOrEmpty(providerKey)) |
499 | { | 496 | { |
500 | this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "ProviderKey")); | 497 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "ProviderKey")); |
501 | } | 498 | } |
502 | // Make sure the key does not contain any illegal characters. | 499 | // Make sure the key does not contain any illegal characters. |
503 | else if (0 <= (illegalChar = providerKey.IndexOfAny(DependencyCommon.InvalidCharacters))) | 500 | else if (0 <= (illegalChar = providerKey.IndexOfAny(DependencyCommon.InvalidCharacters))) |
@@ -505,44 +502,44 @@ namespace WixToolset.Extensions | |||
505 | StringBuilder sb = new StringBuilder(DependencyCommon.InvalidCharacters.Length * 2); | 502 | StringBuilder sb = new StringBuilder(DependencyCommon.InvalidCharacters.Length * 2); |
506 | Array.ForEach<char>(DependencyCommon.InvalidCharacters, c => sb.Append(c).Append(" ")); | 503 | Array.ForEach<char>(DependencyCommon.InvalidCharacters, c => sb.Append(c).Append(" ")); |
507 | 504 | ||
508 | this.Core.OnMessage(DependencyErrors.IllegalCharactersInProvider(sourceLineNumbers, "ProviderKey", providerKey[illegalChar], sb.ToString())); | 505 | this.Messaging.Write(DependencyErrors.IllegalCharactersInProvider(sourceLineNumbers, "ProviderKey", providerKey[illegalChar], sb.ToString())); |
509 | } | 506 | } |
510 | 507 | ||
511 | 508 | ||
512 | if (!this.Core.EncounteredError) | 509 | if (!this.Messaging.EncounteredError) |
513 | { | 510 | { |
514 | // Reference the Require custom action if required. | 511 | // Reference the Require custom action if required. |
515 | if (requiresAction) | 512 | if (requiresAction) |
516 | { | 513 | { |
517 | if (Platform.ARM == this.Core.CurrentPlatform) | 514 | if (Platform.ARM == this.Context.Platform) |
518 | { | 515 | { |
519 | // Ensure the ARM version of the CA is referenced. | 516 | // Ensure the ARM version of the CA is referenced. |
520 | this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "WixDependencyRequire_ARM"); | 517 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixDependencyRequire_ARM"); |
521 | } | 518 | } |
522 | else | 519 | else |
523 | { | 520 | { |
524 | // All other supported platforms use x86. | 521 | // All other supported platforms use x86. |
525 | this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "WixDependencyRequire"); | 522 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixDependencyRequire"); |
526 | } | 523 | } |
527 | } | 524 | } |
528 | 525 | ||
529 | Row row = this.Core.CreateRow(sourceLineNumbers, "WixDependency", id); | 526 | var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixDependency", id); |
530 | row[1] = providerKey; | 527 | row.Set(1, providerKey); |
531 | row[2] = minVersion; | 528 | row.Set(2, minVersion); |
532 | row[3] = maxVersion; | 529 | row.Set(3, maxVersion); |
533 | 530 | ||
534 | if (0 != attributes) | 531 | if (0 != attributes) |
535 | { | 532 | { |
536 | row[4] = attributes; | 533 | row.Set(4, attributes); |
537 | } | 534 | } |
538 | 535 | ||
539 | // Create the relationship between this WixDependency row and the WixDependencyProvider row. | 536 | // Create the relationship between this WixDependency row and the WixDependencyProvider row. |
540 | if (!String.IsNullOrEmpty(providerId)) | 537 | if (!String.IsNullOrEmpty(providerId)) |
541 | { | 538 | { |
542 | // Create the relationship between the WixDependency row and the parent WixDependencyProvider row. | 539 | // Create the relationship between the WixDependency row and the parent WixDependencyProvider row. |
543 | row = this.Core.CreateRow(sourceLineNumbers, "WixDependencyRef"); | 540 | row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixDependencyRef"); |
544 | row[0] = providerId; | 541 | row.Set(0, providerId); |
545 | row[1] = id.Id; | 542 | row.Set(1, id.Id); |
546 | } | 543 | } |
547 | } | 544 | } |
548 | } | 545 | } |
@@ -553,9 +550,9 @@ namespace WixToolset.Extensions | |||
553 | /// <param name="node">The XML node for the RequiresRef element.</param> | 550 | /// <param name="node">The XML node for the RequiresRef element.</param> |
554 | /// <param name="providerId">The parent provider identifier.</param> | 551 | /// <param name="providerId">The parent provider identifier.</param> |
555 | /// <param name="requiresAction">Whether the Requires custom action should be referenced.</param> | 552 | /// <param name="requiresAction">Whether the Requires custom action should be referenced.</param> |
556 | private void ParseRequiresRefElement(XElement node, string providerId, bool requiresAction) | 553 | private void ParseRequiresRefElement(Intermediate intermediate, IntermediateSection section, XElement node, string providerId, bool requiresAction) |
557 | { | 554 | { |
558 | SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node); | 555 | SourceLineNumber sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(node); |
559 | string id = null; | 556 | string id = null; |
560 | 557 | ||
561 | foreach (XAttribute attrib in node.Attributes()) | 558 | foreach (XAttribute attrib in node.Attributes()) |
@@ -565,50 +562,50 @@ namespace WixToolset.Extensions | |||
565 | switch (attrib.Name.LocalName) | 562 | switch (attrib.Name.LocalName) |
566 | { | 563 | { |
567 | case "Id": | 564 | case "Id": |
568 | id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib); | 565 | id = this.ParseHelper.GetAttributeIdentifierValue(sourceLineNumbers, attrib); |
569 | break; | 566 | break; |
570 | default: | 567 | default: |
571 | this.Core.UnexpectedAttribute(node, attrib); | 568 | this.ParseHelper.UnexpectedAttribute(node, attrib); |
572 | break; | 569 | break; |
573 | } | 570 | } |
574 | } | 571 | } |
575 | else | 572 | else |
576 | { | 573 | { |
577 | this.Core.ParseExtensionAttribute(node, attrib); | 574 | this.ParseHelper.ParseExtensionAttribute(this.Context.Extensions, intermediate, section, node, attrib); |
578 | } | 575 | } |
579 | } | 576 | } |
580 | 577 | ||
581 | this.Core.ParseForExtensionElements(node); | 578 | this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, node); |
582 | 579 | ||
583 | if (String.IsNullOrEmpty(id)) | 580 | if (String.IsNullOrEmpty(id)) |
584 | { | 581 | { |
585 | this.Core.OnMessage(WixErrors.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); | 582 | this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); |
586 | } | 583 | } |
587 | 584 | ||
588 | if (!this.Core.EncounteredError) | 585 | if (!this.Messaging.EncounteredError) |
589 | { | 586 | { |
590 | // Reference the Require custom action if required. | 587 | // Reference the Require custom action if required. |
591 | if (requiresAction) | 588 | if (requiresAction) |
592 | { | 589 | { |
593 | if (Platform.ARM == this.Core.CurrentPlatform) | 590 | if (Platform.ARM == this.Context.Platform) |
594 | { | 591 | { |
595 | // Ensure the ARM version of the CA is referenced. | 592 | // Ensure the ARM version of the CA is referenced. |
596 | this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "WixDependencyRequire_ARM"); | 593 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixDependencyRequire_ARM"); |
597 | } | 594 | } |
598 | else | 595 | else |
599 | { | 596 | { |
600 | // All other supported platforms use x86. | 597 | // All other supported platforms use x86. |
601 | this.Core.CreateSimpleReference(sourceLineNumbers, "CustomAction", "WixDependencyRequire"); | 598 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "CustomAction", "WixDependencyRequire"); |
602 | } | 599 | } |
603 | } | 600 | } |
604 | 601 | ||
605 | // Create a link dependency on the row that contains information we'll need during bind. | 602 | // Create a link dependency on the row that contains information we'll need during bind. |
606 | this.Core.CreateSimpleReference(sourceLineNumbers, "WixDependency", id); | 603 | this.ParseHelper.CreateSimpleReference(section, sourceLineNumbers, "WixDependency", id); |
607 | 604 | ||
608 | // Create the relationship between the WixDependency row and the parent WixDependencyProvider row. | 605 | // Create the relationship between the WixDependency row and the parent WixDependencyProvider row. |
609 | Row row = this.Core.CreateRow(sourceLineNumbers, "WixDependencyRef"); | 606 | var row = this.ParseHelper.CreateRow(section, sourceLineNumbers, "WixDependencyRef"); |
610 | row[0] = providerId; | 607 | row.Set(0, providerId); |
611 | row[1] = id; | 608 | row.Set(1, id); |
612 | } | 609 | } |
613 | } | 610 | } |
614 | } | 611 | } |