@joebigelow / wix / commits / 0ecb2ac1

Minor code clean up to match .editorconfig

Rob Mensching committed Oct 24, 2018 at 21:00 UTC 0ecb2ac1ba28d33b0b3d17a2d7134d2f5485814d
8 files changed +8230 -8296
src/WixToolset.Core.WindowsInstaller/Rows/WixActionRowCollection.cs
+1
@@ -13,6 +13,7 @@ namespace WixToolset.Core.WindowsInstaller.Rows
13 /// <summary>
14 /// A collection of action rows sorted by their sequence table and action name.
15 /// </summary>
16 + // TODO: Remove this
17 internal sealed class WixActionRowCollection : ICollection
18 {
19 private SortedList collection;
src/WixToolset.Core.WindowsInstaller/Unbind/ExtractCabinetsCommand.cs
+21 -13
@@ -1,10 +1,10 @@
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
3 namespace WixToolset.Core.WindowsInstaller.Unbind
4 {
5 using System;
6 using System.Collections;
7 - using System.Collections.Specialized;
7 + using System.Collections.Generic;
8 using System.Globalization;
9 using System.IO;
10 using WixToolset.Core.Native;
@@ -24,6 +24,8 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
24 this.IntermediateFolder = intermediateFolder;
25 }
26
27 + public string[] ExtractedFiles { get; private set; }
28 +
29 private Output Output { get; }
30
31 private Database Database { get; }
@@ -36,9 +38,9 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
38
39 public void Execute()
40 {
39 - string databaseBasePath = Path.GetDirectoryName(this.InputFilePath);
40 - StringCollection cabinetFiles = new StringCollection();
41 - SortedList embeddedCabinets = new SortedList();
41 + var databaseBasePath = Path.GetDirectoryName(this.InputFilePath);
42 + var cabinetFiles = new List<string>();
43 + var embeddedCabinets = new SortedList();
44
45 // index all of the cabinet files
46 if (OutputType.Module == this.Output.Type)
@@ -70,31 +72,31 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
72 // extract the embedded cabinet files from the database
73 if (0 < embeddedCabinets.Count)
74 {
73 - using (View streamsView = this.Database.OpenView("SELECT `Data` FROM `_Streams` WHERE `Name` = ?"))
75 + using (var streamsView = this.Database.OpenView("SELECT `Data` FROM `_Streams` WHERE `Name` = ?"))
76 {
77 foreach (int diskId in embeddedCabinets.Keys)
78 {
77 - using (Record record = new Record(1))
79 + using (var record = new Record(1))
80 {
81 record.SetString(1, (string)embeddedCabinets[diskId]);
82 streamsView.Execute(record);
83 }
84
83 - using (Record record = streamsView.Fetch())
85 + using (var record = streamsView.Fetch())
86 {
87 if (null != record)
88 {
89 // since the cabinets are stored in case-sensitive streams inside the msi, but the file system is not case-sensitive,
90 // embedded cabinets must be extracted to a canonical file name (like their diskid) to ensure extraction will always work
89 - string cabinetFile = Path.Combine(this.IntermediateFolder, String.Concat("Media", Path.DirectorySeparatorChar, diskId.ToString(CultureInfo.InvariantCulture), ".cab"));
91 + var cabinetFile = Path.Combine(this.IntermediateFolder, String.Concat("Media", Path.DirectorySeparatorChar, diskId.ToString(CultureInfo.InvariantCulture), ".cab"));
92
93 // ensure the parent directory exists
94 Directory.CreateDirectory(Path.GetDirectoryName(cabinetFile));
95
94 - using (FileStream fs = File.Create(cabinetFile))
96 + using (var fs = File.Create(cabinetFile))
97 {
98 int bytesRead;
97 - byte[] buffer = new byte[512];
99 + var buffer = new byte[512];
100
101 while (0 != (bytesRead = record.GetStream(1, buffer, buffer.Length)))
102 {
@@ -116,7 +118,7 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
118 // extract the cabinet files
119 if (0 < cabinetFiles.Count)
120 {
119 - string fileDirectory = Path.Combine(this.ExportBasePath, "File");
121 + var fileDirectory = Path.Combine(this.ExportBasePath, "File");
122
123 // delete the directory and its files to prevent cab extraction due to an existing file
124 if (Directory.Exists(fileDirectory))
@@ -127,7 +129,7 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
129 // ensure the directory exists or extraction will fail
130 Directory.CreateDirectory(fileDirectory);
131
130 - foreach (string cabinetFile in cabinetFiles)
132 + foreach (var cabinetFile in cabinetFiles)
133 {
134 try
135 {
@@ -139,6 +141,12 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
141 throw new WixException(ErrorMessages.FileNotFound(new SourceLineNumber(this.InputFilePath), cabinetFile));
142 }
143 }
144 +
145 + this.ExtractedFiles = Directory.GetFiles(fileDirectory);
146 + }
147 + else
148 + {
149 + this.ExtractedFiles = new string[0];
150 }
151 }
152 }
src/WixToolset.Core.WindowsInstaller/Unbind/UnbindDatabaseCommand.cs
+231 -229
@@ -1,4 +1,4 @@
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
3 namespace WixToolset.Core.WindowsInstaller.Unbind
4 {
@@ -57,21 +57,23 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
57 public Output Execute()
58 {
59 string modularizationGuid = null;
60 - Output output = new Output(new SourceLineNumber(this.DatabasePath));
60 + var output = new Output(new SourceLineNumber(this.DatabasePath));
61 View validationView = null;
62
63 // set the output type
64 output.Type = this.OutputType;
65
66 + Directory.CreateDirectory(this.IntermediateFolder);
67 +
68 // get the codepage
69 this.Database.Export("_ForceCodepage", this.IntermediateFolder, "_ForceCodepage.idt");
68 - using (StreamReader sr = File.OpenText(Path.Combine(this.IntermediateFolder, "_ForceCodepage.idt")))
70 + using (var sr = File.OpenText(Path.Combine(this.IntermediateFolder, "_ForceCodepage.idt")))
71 {
72 string line;
73
74 while (null != (line = sr.ReadLine()))
75 {
74 - string[] data = line.Split('\t');
76 + var data = line.Split('\t');
77
78 if (2 == data.Length)
79 {
@@ -83,17 +85,17 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
85 // get the summary information table if it exists; it won't if unbinding a transform
86 if (!this.SkipSummaryInfo)
87 {
86 - using (SummaryInformation summaryInformation = new SummaryInformation(this.Database))
88 + using (var summaryInformation = new SummaryInformation(this.Database))
89 {
88 - Table table = new Table(this.TableDefinitions["_SummaryInformation"]);
90 + var table = new Table(this.TableDefinitions["_SummaryInformation"]);
91
90 - for (int i = 1; 19 >= i; i++)
92 + for (var i = 1; 19 >= i; i++)
93 {
92 - string value = summaryInformation.GetProperty(i);
94 + var value = summaryInformation.GetProperty(i);
95
96 if (0 < value.Length)
97 {
96 - Row row = table.CreateRow(output.SourceLineNumbers);
98 + var row = table.CreateRow(output.SourceLineNumbers);
99 row[0] = i;
100 row[1] = value;
101 }
@@ -112,51 +114,51 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
114 }
115
116 // get the normal tables
115 - using (View tablesView = this.Database.OpenExecuteView("SELECT * FROM _Tables"))
117 + using (var tablesView = this.Database.OpenExecuteView("SELECT * FROM _Tables"))
118 {
119 while (true)
120 {
119 - using (Record tableRecord = tablesView.Fetch())
121 + using (var tableRecord = tablesView.Fetch())
122 {
123 if (null == tableRecord)
124 {
125 break;
126 }
127
126 - string tableName = tableRecord.GetString(1);
128 + var tableName = tableRecord.GetString(1);
129
128 - using (View tableView = this.Database.OpenExecuteView(String.Format(CultureInfo.InvariantCulture, "SELECT * FROM `{0}`", tableName)))
130 + using (var tableView = this.Database.OpenExecuteView(String.Format(CultureInfo.InvariantCulture, "SELECT * FROM `{0}`", tableName)))
131 {
132 ColumnDefinition[] columns;
133 using (Record columnNameRecord = tableView.GetColumnInfo(MsiInterop.MSICOLINFONAMES),
134 columnTypeRecord = tableView.GetColumnInfo(MsiInterop.MSICOLINFOTYPES))
135 {
136 // index the primary keys
135 - HashSet<string> tablePrimaryKeys = new HashSet<string>();
136 - using (Record primaryKeysRecord = this.Database.PrimaryKeys(tableName))
137 + var tablePrimaryKeys = new HashSet<string>();
138 + using (var primaryKeysRecord = this.Database.PrimaryKeys(tableName))
139 {
138 - int primaryKeysFieldCount = primaryKeysRecord.GetFieldCount();
140 + var primaryKeysFieldCount = primaryKeysRecord.GetFieldCount();
141
140 - for (int i = 1; i <= primaryKeysFieldCount; i++)
142 + for (var i = 1; i <= primaryKeysFieldCount; i++)
143 {
144 tablePrimaryKeys.Add(primaryKeysRecord.GetString(i));
145 }
146 }
147
146 - int columnCount = columnNameRecord.GetFieldCount();
148 + var columnCount = columnNameRecord.GetFieldCount();
149 columns = new ColumnDefinition[columnCount];
148 - for (int i = 1; i <= columnCount; i++)
150 + for (var i = 1; i <= columnCount; i++)
151 {
150 - string columnName = columnNameRecord.GetString(i);
151 - string idtType = columnTypeRecord.GetString(i);
152 + var columnName = columnNameRecord.GetString(i);
153 + var idtType = columnTypeRecord.GetString(i);
154
155 ColumnType columnType;
156 int length;
157 bool nullable;
158
157 - ColumnCategory columnCategory = ColumnCategory.Unknown;
158 - ColumnModularizeType columnModularizeType = ColumnModularizeType.None;
159 - bool primary = tablePrimaryKeys.Contains(columnName);
159 + var columnCategory = ColumnCategory.Unknown;
160 + var columnModularizeType = ColumnModularizeType.None;
161 + var primary = tablePrimaryKeys.Contains(columnName);
162 int? minValue = null;
163 int? maxValue = null;
164 string keyTable = null;
@@ -168,22 +170,22 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
170 // get the column type, length, and whether its nullable
171 switch (Char.ToLower(idtType[0], CultureInfo.InvariantCulture))
172 {
171 - case 'i':
172 - columnType = ColumnType.Number;
173 - break;
174 - case 'l':
175 - columnType = ColumnType.Localized;
176 - break;
177 - case 's':
178 - columnType = ColumnType.String;
179 - break;
180 - case 'v':
181 - columnType = ColumnType.Object;
182 - break;
183 - default:
184 - // TODO: error
185 - columnType = ColumnType.Unknown;
186 - break;
173 + case 'i':
174 + columnType = ColumnType.Number;
175 + break;
176 + case 'l':
177 + columnType = ColumnType.Localized;
178 + break;
179 + case 's':
180 + columnType = ColumnType.String;
181 + break;
182 + case 'v':
183 + columnType = ColumnType.Object;
184 + break;
185 + default:
186 + // TODO: error
187 + columnType = ColumnType.Unknown;
188 + break;
189 }
190 length = Convert.ToInt32(idtType.Substring(1), CultureInfo.InvariantCulture);
191 nullable = Char.IsUpper(idtType[0]);
@@ -191,7 +193,7 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
193 // try to get validation information
194 if (null != validationView)
195 {
194 - using (Record validationRecord = new Record(2))
196 + using (var validationRecord = new Record(2))
197 {
198 validationRecord.SetString(1, tableName);
199 validationRecord.SetString(2, columnName);
@@ -199,11 +201,11 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
201 validationView.Execute(validationRecord);
202 }
203
202 - using (Record validationRecord = validationView.Fetch())
204 + using (var validationRecord = validationView.Fetch())
205 {
206 if (null != validationRecord)
207 {
206 - string validationNullable = validationRecord.GetString(3);
208 + var validationNullable = validationRecord.GetString(3);
209 minValue = validationRecord.IsNull(4) ? null : (int?)validationRecord.GetInteger(4);
210 maxValue = validationRecord.IsNull(5) ? null : (int?)validationRecord.GetInteger(5);
211 keyTable = validationRecord.IsNull(6) ? null : validationRecord.GetString(6);
@@ -264,7 +266,7 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
266 }
267 }
268
267 - TableDefinition tableDefinition = new TableDefinition(tableName, columns, false, false);
269 + var tableDefinition = new TableDefinition(tableName, columns, false, false);
270
271 // use our table definitions if core properties are the same; this allows us to take advantage
272 // of wix concepts like localizable columns which current code assumes
@@ -273,21 +275,21 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
275 tableDefinition = this.TableDefinitions[tableName];
276 }
277
276 - Table table = new Table(tableDefinition);
278 + var table = new Table(tableDefinition);
279
280 while (true)
281 {
280 - using (Record rowRecord = tableView.Fetch())
282 + using (var rowRecord = tableView.Fetch())
283 {
284 if (null == rowRecord)
285 {
286 break;
287 }
288
287 - int recordCount = rowRecord.GetFieldCount();
288 - Row row = table.CreateRow(output.SourceLineNumbers);
289 + var recordCount = rowRecord.GetFieldCount();
290 + var row = table.CreateRow(output.SourceLineNumbers);
291
290 - for (int i = 0; recordCount > i && row.Fields.Length > i; i++)
292 + for (var i = 0; recordCount > i && row.Fields.Length > i; i++)
293 {
294 if (rowRecord.IsNull(i + 1))
295 {
@@ -303,87 +305,87 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
305 {
306 switch (row.Fields[i].Column.Type)
307 {
306 - case ColumnType.Number:
307 - bool success = false;
308 - int intValue = rowRecord.GetInteger(i + 1);
309 - if (row.Fields[i].Column.IsLocalizable)
310 - {
311 - success = row.BestEffortSetField(i, Convert.ToString(intValue, CultureInfo.InvariantCulture));
312 - }
313 - else
314 - {
315 - success = row.BestEffortSetField(i, intValue);
316 - }
308 + case ColumnType.Number:
309 + var success = false;
310 + var intValue = rowRecord.GetInteger(i + 1);
311 + if (row.Fields[i].Column.IsLocalizable)
312 + {
313 + success = row.BestEffortSetField(i, Convert.ToString(intValue, CultureInfo.InvariantCulture));
314 + }
315 + else
316 + {
317 + success = row.BestEffortSetField(i, intValue);
318 + }
319
318 - if (!success)
319 - {
320 - this.Messaging.Write(WarningMessages.BadColumnDataIgnored(row.SourceLineNumbers, Convert.ToString(intValue, CultureInfo.InvariantCulture), tableName, row.Fields[i].Column.Name));
321 - }
322 - break;
323 - case ColumnType.Object:
324 - string sourceFile = "FILE NOT EXPORTED, USE THE dark.exe -x OPTION TO EXPORT BINARIES";
320 + if (!success)
321 + {
322 + this.Messaging.Write(WarningMessages.BadColumnDataIgnored(row.SourceLineNumbers, Convert.ToString(intValue, CultureInfo.InvariantCulture), tableName, row.Fields[i].Column.Name));
323 + }
324 + break;
325 + case ColumnType.Object:
326 + var sourceFile = "FILE NOT EXPORTED, USE THE dark.exe -x OPTION TO EXPORT BINARIES";
327
326 - if (null != this.ExportBasePath)
327 - {
328 - string relativeSourceFile = Path.Combine(tableName, row.GetPrimaryKey('.'));
329 - sourceFile = Path.Combine(this.ExportBasePath, relativeSourceFile);
328 + if (null != this.ExportBasePath)
329 + {
330 + var relativeSourceFile = Path.Combine(tableName, row.GetPrimaryKey('.'));
331 + sourceFile = Path.Combine(this.ExportBasePath, relativeSourceFile);
332
331 - // ensure the parent directory exists
332 - System.IO.Directory.CreateDirectory(Path.Combine(this.ExportBasePath, tableName));
333 + // ensure the parent directory exists
334 + System.IO.Directory.CreateDirectory(Path.Combine(this.ExportBasePath, tableName));
335
334 - using (FileStream fs = System.IO.File.Create(sourceFile))
335 - {
336 - int bytesRead;
337 - byte[] buffer = new byte[512];
336 + using (var fs = System.IO.File.Create(sourceFile))
337 + {
338 + int bytesRead;
339 + var buffer = new byte[512];
340
339 - while (0 != (bytesRead = rowRecord.GetStream(i + 1, buffer, buffer.Length)))
340 - {
341 - fs.Write(buffer, 0, bytesRead);
342 - }
341 + while (0 != (bytesRead = rowRecord.GetStream(i + 1, buffer, buffer.Length)))
342 + {
343 + fs.Write(buffer, 0, bytesRead);
344 }
345 }
346 + }
347
346 - row[i] = sourceFile;
348 + row[i] = sourceFile;
349 + break;
350 + default:
351 + var value = rowRecord.GetString(i + 1);
352 +
353 + switch (row.Fields[i].Column.Category)
354 + {
355 + case ColumnCategory.Guid:
356 + value = value.ToUpper(CultureInfo.InvariantCulture);
357 break;
348 - default:
349 - string value = rowRecord.GetString(i + 1);
358 + }
359
351 - switch (row.Fields[i].Column.Category)
352 - {
353 - case ColumnCategory.Guid:
354 - value = value.ToUpper(CultureInfo.InvariantCulture);
355 - break;
356 - }
360 + // de-modularize
361 + if (!this.SuppressDemodularization && OutputType.Module == output.Type && ColumnModularizeType.None != row.Fields[i].Column.ModularizeType)
362 + {
363 + var modularization = new Regex(@"\.[0-9A-Fa-f]{8}_[0-9A-Fa-f]{4}_[0-9A-Fa-f]{4}_[0-9A-Fa-f]{4}_[0-9A-Fa-f]{12}");
364
358 - // de-modularize
359 - if (!this.SuppressDemodularization && OutputType.Module == output.Type && ColumnModularizeType.None != row.Fields[i].Column.ModularizeType)
365 + if (null == modularizationGuid)
366 {
361 - Regex modularization = new Regex(@"\.[0-9A-Fa-f]{8}_[0-9A-Fa-f]{4}_[0-9A-Fa-f]{4}_[0-9A-Fa-f]{4}_[0-9A-Fa-f]{12}");
362 -
363 - if (null == modularizationGuid)
367 + var match = modularization.Match(value);
368 + if (match.Success)
369 {
365 - Match match = modularization.Match(value);
366 - if (match.Success)
367 - {
368 - modularizationGuid = String.Concat('{', match.Value.Substring(1).Replace('_', '-'), '}');
369 - }
370 + modularizationGuid = String.Concat('{', match.Value.Substring(1).Replace('_', '-'), '}');
371 }
371 -
372 - value = modularization.Replace(value, String.Empty);
372 }
373
375 - // escape "$(" for the preprocessor
376 - value = value.Replace("$(", "$$(");
374 + value = modularization.Replace(value, String.Empty);
375 + }
376
378 - // escape things that look like wix variables
379 - MatchCollection matches = Common.WixVariableRegex.Matches(value);
380 - for (int j = matches.Count - 1; 0 <= j; j--)
381 - {
382 - value = value.Insert(matches[j].Index, "!");
383 - }
377 + // escape "$(" for the preprocessor
378 + value = value.Replace("$(", "$$(");
379
385 - row[i] = value;
386 - break;
380 + // escape things that look like wix variables
381 + var matches = Common.WixVariableRegex.Matches(value);
382 + for (var j = matches.Count - 1; 0 <= j; j--)
383 + {
384 + value = value.Insert(matches[j].Index, "!");
385 + }
386 +
387 + row[i] = value;
388 + break;
389 }
390 }
391 }
@@ -408,9 +410,9 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
410 // set the modularization guid as the PackageCode
411 if (null != modularizationGuid)
412 {
411 - Table table = output.Tables["_SummaryInformation"];
413 + var table = output.Tables["_SummaryInformation"];
414
413 - foreach (Row row in table.Rows)
415 + foreach (var row in table.Rows)
416 {
417 if (9 == (int)row[0]) // PID_REVNUMBER
418 {
@@ -421,8 +423,8 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
423
424 if (this.IsAdminImage)
425 {
424 - GenerateWixFileTable(this.DatabasePath, output);
425 - GenerateSectionIds(output);
426 + this.GenerateWixFileTable(this.DatabasePath, output);
427 + this.GenerateSectionIds(output);
428 }
429
430 return output;
@@ -435,21 +437,21 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
437 /// <param name="output">The Output that represents the msi database.</param>
438 private void GenerateWixFileTable(string databaseFile, Output output)
439 {
438 - string adminRootPath = Path.GetDirectoryName(databaseFile);
440 + var adminRootPath = Path.GetDirectoryName(databaseFile);
441
440 - Hashtable componentDirectoryIndex = new Hashtable();
441 - Table componentTable = output.Tables["Component"];
442 - foreach (Row row in componentTable.Rows)
442 + var componentDirectoryIndex = new Hashtable();
443 + var componentTable = output.Tables["Component"];
444 + foreach (var row in componentTable.Rows)
445 {
446 componentDirectoryIndex.Add(row[0], row[2]);
447 }
448
449 // Index full source paths for all directories
448 - Hashtable directoryDirectoryParentIndex = new Hashtable();
449 - Hashtable directoryFullPathIndex = new Hashtable();
450 - Hashtable directorySourceNameIndex = new Hashtable();
451 - Table directoryTable = output.Tables["Directory"];
452 - foreach (Row row in directoryTable.Rows)
450 + var directoryDirectoryParentIndex = new Hashtable();
451 + var directoryFullPathIndex = new Hashtable();
452 + var directorySourceNameIndex = new Hashtable();
453 + var directoryTable = output.Tables["Directory"];
454 + foreach (var row in directoryTable.Rows)
455 {
456 directoryDirectoryParentIndex.Add(row[0], row[1]);
457 if (null == row[1])
@@ -466,15 +468,15 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
468 {
469 if (!directoryFullPathIndex.ContainsKey(directoryEntry.Key))
470 {
469 - GetAdminFullPath((string)directoryEntry.Key, directoryDirectoryParentIndex, directorySourceNameIndex, directoryFullPathIndex);
471 + this.GetAdminFullPath((string)directoryEntry.Key, directoryDirectoryParentIndex, directorySourceNameIndex, directoryFullPathIndex);
472 }
473 }
474
473 - Table fileTable = output.Tables["File"];
474 - Table wixFileTable = output.EnsureTable(this.TableDefinitions["WixFile"]);
475 - foreach (Row row in fileTable.Rows)
475 + var fileTable = output.Tables["File"];
476 + var wixFileTable = output.EnsureTable(this.TableDefinitions["WixFile"]);
477 + foreach (var row in fileTable.Rows)
478 {
477 - WixFileRow wixFileRow = new WixFileRow(null, this.TableDefinitions["WixFile"]);
479 + var wixFileRow = new WixFileRow(null, this.TableDefinitions["WixFile"]);
480 wixFileRow.File = (string)row[0];
481 wixFileRow.Directory = (string)componentDirectoryIndex[(string)row[1]];
482 wixFileRow.Source = Path.Combine((string)directoryFullPathIndex[wixFileRow.Directory], GetAdminSourceName((string)row[2]));
@@ -498,8 +500,8 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
500 /// <returns>The full path to the directory.</returns>
501 private string GetAdminFullPath(string directory, Hashtable directoryDirectoryParentIndex, Hashtable directorySourceNameIndex, Hashtable directoryFullPathIndex)
502 {
501 - string parent = (string)directoryDirectoryParentIndex[directory];
502 - string sourceName = (string)directorySourceNameIndex[directory];
503 + var parent = (string)directoryDirectoryParentIndex[directory];
504 + var sourceName = (string)directorySourceNameIndex[directory];
505
506 string parentFullPath;
507 if (directoryFullPathIndex.ContainsKey(parent))
@@ -508,7 +510,7 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
510 }
511 else
512 {
511 - parentFullPath = GetAdminFullPath(parent, directoryDirectoryParentIndex, directorySourceNameIndex, directoryFullPathIndex);
513 + parentFullPath = this.GetAdminFullPath(parent, directoryDirectoryParentIndex, directorySourceNameIndex, directoryFullPathIndex);
514 }
515
516 if (null == sourceName)
@@ -516,7 +518,7 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
518 sourceName = String.Empty;
519 }
520
519 - string fullPath = Path.Combine(parentFullPath, sourceName);
521 + var fullPath = Path.Combine(parentFullPath, sourceName);
522 directoryFullPathIndex.Add(directory, fullPath);
523
524 return fullPath;
@@ -596,104 +598,104 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
598 private void GenerateSectionIds(Output output)
599 {
600 // First assign and index section ids for the tables that are in their own sections.
599 - AssignSectionIdsToTable(output.Tables["Binary"], 0);
600 - Hashtable componentSectionIdIndex = AssignSectionIdsToTable(output.Tables["Component"], 0);
601 - Hashtable customActionSectionIdIndex = AssignSectionIdsToTable(output.Tables["CustomAction"], 0);
602 - AssignSectionIdsToTable(output.Tables["Directory"], 0);
603 - Hashtable featureSectionIdIndex = AssignSectionIdsToTable(output.Tables["Feature"], 0);
604 - AssignSectionIdsToTable(output.Tables["Icon"], 0);
605 - Hashtable digitalCertificateSectionIdIndex = AssignSectionIdsToTable(output.Tables["MsiDigitalCertificate"], 0);
606 - AssignSectionIdsToTable(output.Tables["Property"], 0);
601 + this.AssignSectionIdsToTable(output.Tables["Binary"], 0);
602 + var componentSectionIdIndex = this.AssignSectionIdsToTable(output.Tables["Component"], 0);
603 + var customActionSectionIdIndex = this.AssignSectionIdsToTable(output.Tables["CustomAction"], 0);
604 + this.AssignSectionIdsToTable(output.Tables["Directory"], 0);
605 + var featureSectionIdIndex = this.AssignSectionIdsToTable(output.Tables["Feature"], 0);
606 + this.AssignSectionIdsToTable(output.Tables["Icon"], 0);
607 + var digitalCertificateSectionIdIndex = this.AssignSectionIdsToTable(output.Tables["MsiDigitalCertificate"], 0);
608 + this.AssignSectionIdsToTable(output.Tables["Property"], 0);
609
610 // Now handle all the tables that rely on the first set of indexes but also produce their own indexes. Order matters here.
609 - Hashtable fileSectionIdIndex = ConnectTableToSectionAndIndex(output.Tables["File"], componentSectionIdIndex, 1, 0);
610 - Hashtable appIdSectionIdIndex = ConnectTableToSectionAndIndex(output.Tables["Class"], componentSectionIdIndex, 2, 5);
611 - Hashtable odbcDataSourceSectionIdIndex = ConnectTableToSectionAndIndex(output.Tables["ODBCDataSource"], componentSectionIdIndex, 1, 0);
612 - Hashtable odbcDriverSectionIdIndex = ConnectTableToSectionAndIndex(output.Tables["ODBCDriver"], componentSectionIdIndex, 1, 0);
613 - Hashtable registrySectionIdIndex = ConnectTableToSectionAndIndex(output.Tables["Registry"], componentSectionIdIndex, 5, 0);
614 - Hashtable serviceInstallSectionIdIndex = ConnectTableToSectionAndIndex(output.Tables["ServiceInstall"], componentSectionIdIndex, 11, 0);
611 + var fileSectionIdIndex = ConnectTableToSectionAndIndex(output.Tables["File"], componentSectionIdIndex, 1, 0);
612 + var appIdSectionIdIndex = ConnectTableToSectionAndIndex(output.Tables["Class"], componentSectionIdIndex, 2, 5);
613 + var odbcDataSourceSectionIdIndex = ConnectTableToSectionAndIndex(output.Tables["ODBCDataSource"], componentSectionIdIndex, 1, 0);
614 + var odbcDriverSectionIdIndex = ConnectTableToSectionAndIndex(output.Tables["ODBCDriver"], componentSectionIdIndex, 1, 0);
615 + var registrySectionIdIndex = ConnectTableToSectionAndIndex(output.Tables["Registry"], componentSectionIdIndex, 5, 0);
616 + var serviceInstallSectionIdIndex = ConnectTableToSectionAndIndex(output.Tables["ServiceInstall"], componentSectionIdIndex, 11, 0);
617
618 // Now handle all the tables which only rely on previous indexes and order does not matter.
617 - foreach (Table table in output.Tables)
619 + foreach (var table in output.Tables)
620 {
621 switch (table.Name)
622 {
621 - case "WixFile":
622 - case "MsiFileHash":
623 - ConnectTableToSection(table, fileSectionIdIndex, 0);
624 - break;
625 - case "MsiAssembly":
626 - case "MsiAssemblyName":
627 - ConnectTableToSection(table, componentSectionIdIndex, 0);
628 - break;
629 - case "MsiPackageCertificate":
630 - case "MsiPatchCertificate":
631 - ConnectTableToSection(table, digitalCertificateSectionIdIndex, 1);
632 - break;
633 - case "CreateFolder":
634 - case "FeatureComponents":
635 - case "MoveFile":
636 - case "ReserveCost":
637 - case "ODBCTranslator":
638 - ConnectTableToSection(table, componentSectionIdIndex, 1);
639 - break;
640 - case "TypeLib":
641 - ConnectTableToSection(table, componentSectionIdIndex, 2);
642 - break;
643 - case "Shortcut":
644 - case "Environment":
645 - ConnectTableToSection(table, componentSectionIdIndex, 3);
646 - break;
647 - case "RemoveRegistry":
648 - ConnectTableToSection(table, componentSectionIdIndex, 4);
649 - break;
650 - case "ServiceControl":
651 - ConnectTableToSection(table, componentSectionIdIndex, 5);
652 - break;
653 - case "IniFile":
654 - case "RemoveIniFile":
655 - ConnectTableToSection(table, componentSectionIdIndex, 7);
656 - break;
657 - case "AppId":
658 - ConnectTableToSection(table, appIdSectionIdIndex, 0);
659 - break;
660 - case "Condition":
661 - ConnectTableToSection(table, featureSectionIdIndex, 0);
662 - break;
663 - case "ODBCSourceAttribute":
664 - ConnectTableToSection(table, odbcDataSourceSectionIdIndex, 0);
665 - break;
666 - case "ODBCAttribute":
667 - ConnectTableToSection(table, odbcDriverSectionIdIndex, 0);
668 - break;
669 - case "AdminExecuteSequence":
670 - case "AdminUISequence":
671 - case "AdvtExecuteSequence":
672 - case "AdvtUISequence":
673 - case "InstallExecuteSequence":
674 - case "InstallUISequence":
675 - ConnectTableToSection(table, customActionSectionIdIndex, 0);
676 - break;
677 - case "LockPermissions":
678 - case "MsiLockPermissions":
679 - foreach (Row row in table.Rows)
623 + case "WixFile":
624 + case "MsiFileHash":
625 + ConnectTableToSection(table, fileSectionIdIndex, 0);
626 + break;
627 + case "MsiAssembly":
628 + case "MsiAssemblyName":
629 + ConnectTableToSection(table, componentSectionIdIndex, 0);
630 + break;
631 + case "MsiPackageCertificate":
632 + case "MsiPatchCertificate":
633 + ConnectTableToSection(table, digitalCertificateSectionIdIndex, 1);
634 + break;
635 + case "CreateFolder":
636 + case "FeatureComponents":
637 + case "MoveFile":
638 + case "ReserveCost":
639 + case "ODBCTranslator":
640 + ConnectTableToSection(table, componentSectionIdIndex, 1);
641 + break;
642 + case "TypeLib":
643 + ConnectTableToSection(table, componentSectionIdIndex, 2);
644 + break;
645 + case "Shortcut":
646 + case "Environment":
647 + ConnectTableToSection(table, componentSectionIdIndex, 3);
648 + break;
649 + case "RemoveRegistry":
650 + ConnectTableToSection(table, componentSectionIdIndex, 4);
651 + break;
652 + case "ServiceControl":
653 + ConnectTableToSection(table, componentSectionIdIndex, 5);
654 + break;
655 + case "IniFile":
656 + case "RemoveIniFile":
657 + ConnectTableToSection(table, componentSectionIdIndex, 7);
658 + break;
659 + case "AppId":
660 + ConnectTableToSection(table, appIdSectionIdIndex, 0);
661 + break;
662 + case "Condition":
663 + ConnectTableToSection(table, featureSectionIdIndex, 0);
664 + break;
665 + case "ODBCSourceAttribute":
666 + ConnectTableToSection(table, odbcDataSourceSectionIdIndex, 0);
667 + break;
668 + case "ODBCAttribute":
669 + ConnectTableToSection(table, odbcDriverSectionIdIndex, 0);
670 + break;
671 + case "AdminExecuteSequence":
672 + case "AdminUISequence":
673 + case "AdvtExecuteSequence":
674 + case "AdvtUISequence":
675 + case "InstallExecuteSequence":
676 + case "InstallUISequence":
677 + ConnectTableToSection(table, customActionSectionIdIndex, 0);
678 + break;
679 + case "LockPermissions":
680 + case "MsiLockPermissions":
681 + foreach (var row in table.Rows)
682 + {
683 + var lockObject = (string)row[0];
684 + var tableName = (string)row[1];
685 + switch (tableName)
686 {
681 - string lockObject = (string)row[0];
682 - string tableName = (string)row[1];
683 - switch (tableName)
684 - {
685 - case "File":
686 - row.SectionId = (string)fileSectionIdIndex[lockObject];
687 - break;
688 - case "Registry":
689 - row.SectionId = (string)registrySectionIdIndex[lockObject];
690 - break;
691 - case "ServiceInstall":
692 - row.SectionId = (string)serviceInstallSectionIdIndex[lockObject];
693 - break;
694 - }
687 + case "File":
688 + row.SectionId = (string)fileSectionIdIndex[lockObject];
689 + break;
690 + case "Registry":
691 + row.SectionId = (string)registrySectionIdIndex[lockObject];
692 + break;
693 + case "ServiceInstall":
694 + row.SectionId = (string)serviceInstallSectionIdIndex[lockObject];
695 + break;
696 }
696 - break;
697 + }
698 + break;
699 }
700 }
701
@@ -712,12 +714,12 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
714 /// <returns>A Hashtable containing the tables key for each row paired with its assigned section id.</returns>
715 private Hashtable AssignSectionIdsToTable(Table table, int rowPrimaryKeyIndex)
716 {
715 - Hashtable hashtable = new Hashtable();
717 + var hashtable = new Hashtable();
718 if (null != table)
719 {
718 - foreach (Row row in table.Rows)
720 + foreach (var row in table.Rows)
721 {
720 - row.SectionId = GetNewSectionId();
722 + row.SectionId = this.GetNewSectionId();
723 hashtable.Add(row[rowPrimaryKeyIndex], row.SectionId);
724 }
725 }
@@ -734,7 +736,7 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
736 {
737 if (null != table)
738 {
737 - foreach (Row row in table.Rows)
739 + foreach (var row in table.Rows)
740 {
741 if (sectionIdIndex.ContainsKey(row[rowIndex]))
742 {
@@ -754,10 +756,10 @@ namespace WixToolset.Core.WindowsInstaller.Unbind
756 /// <returns>A Hashtable containing the tables key for each row paired with its assigned section id.</returns>
757 private static Hashtable ConnectTableToSectionAndIndex(Table table, Hashtable sectionIdIndex, int rowIndex, int rowPrimaryKeyIndex)
758 {
757 - Hashtable newHashTable = new Hashtable();
759 + var newHashTable = new Hashtable();
760 if (null != table)
761 {
760 - foreach (Row row in table.Rows)
762 + foreach (var row in table.Rows)
763 {
764 if (!sectionIdIndex.ContainsKey(row[rowIndex]))
765 {
src/WixToolset.Core.WindowsInstaller/WixToolset.Core.WindowsInstaller.csproj
+1 -1
@@ -24,7 +24,7 @@
24 </ItemGroup>
25
26 <ItemGroup>
27 - <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63102-01" PrivateAssets="All"/>
27 + <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63102-01" PrivateAssets="All" />
28 <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="all" />
29 </ItemGroup>
30 </Project>
src/WixToolset.Core/Common.cs
+16 -93
@@ -21,6 +21,12 @@ namespace WixToolset.Core
21 /// </summary>
22 public static class Common
23 {
24 + // TODO: Find a place to put all of these so they doesn't have to be public and exposed by WixToolset.Core.dll
25 + public const string UpgradeDetectedProperty = "WIX_UPGRADE_DETECTED";
26 + public const string UpgradePreventedCondition = "NOT WIX_UPGRADE_DETECTED";
27 + public const string DowngradeDetectedProperty = "WIX_DOWNGRADE_DETECTED";
28 + public const string DowngradePreventedCondition = "NOT WIX_DOWNGRADE_DETECTED";
29 +
30 //-------------------------------------------------------------------------------------------------
31 // Layout of an Access Mask (from http://technet.microsoft.com/en-us/library/cc783530(WS.10).aspx)
32 //
@@ -45,7 +51,8 @@ namespace WixToolset.Core
51 // GENERIC_EXECUTE (0x20000000L)
52 // GENERIC_WRITE (0x40000000L)
53 // GENERIC_READ (0x80000000L)
48 - internal static readonly string[] GenericPermissions = { "GenericAll", "GenericExecute", "GenericWrite", "GenericRead" };
54 + // TODO: Find a place to put this that it doesn't have to be public and exposed by WixToolset.Core.dll
55 + public static readonly string[] GenericPermissions = { "GenericAll", "GenericExecute", "GenericWrite", "GenericRead" };
56
57 // Standard Access Rights (per WinNT.h)
58 // ----------------------
@@ -54,7 +61,8 @@ namespace WixToolset.Core
61 // WRITE_DAC (0x00040000L)
62 // WRITE_OWNER (0x00080000L)
63 // SYNCHRONIZE (0x00100000L)
57 - internal static readonly string[] StandardPermissions = { "Delete", "ReadPermission", "ChangePermission", "TakeOwnership", "Synchronize" };
64 + // TODO: Find a place to put this that it doesn't have to be public and exposed by WixToolset.Core.dll
65 + public static readonly string[] StandardPermissions = { "Delete", "ReadPermission", "ChangePermission", "TakeOwnership", "Synchronize" };
66
67 // Object-Specific Access Rights
68 // =============================
@@ -69,11 +77,13 @@ namespace WixToolset.Core
77 // FILE_DELETE_CHILD ( 0x0040 )
78 // FILE_READ_ATTRIBUTES ( 0x0080 )
79 // FILE_WRITE_ATTRIBUTES ( 0x0100 )
72 - internal static readonly string[] FolderPermissions = { "Read", "CreateFile", "CreateChild", "ReadExtendedAttributes", "WriteExtendedAttributes", "Traverse", "DeleteChild", "ReadAttributes", "WriteAttributes" };
80 + // TODO: Find a place to put this that it doesn't have to be public and exposed by WixToolset.Core.dll
81 + public static readonly string[] FolderPermissions = { "Read", "CreateFile", "CreateChild", "ReadExtendedAttributes", "WriteExtendedAttributes", "Traverse", "DeleteChild", "ReadAttributes", "WriteAttributes" };
82
83 // Registry Access Rights (per TODO)
84 // ----------------------
76 - internal static readonly string[] RegistryPermissions = { "Read", "Write", "CreateSubkeys", "EnumerateSubkeys", "Notify", "CreateLink" };
85 + // TODO: Find a place to put this that it doesn't have to be public and exposed by WixToolset.Core.dll
86 + public static readonly string[] RegistryPermissions = { "Read", "Write", "CreateSubkeys", "EnumerateSubkeys", "Notify", "CreateLink" };
87
88 // File Access Rights (per WinNT.h)
89 // ------------------
@@ -89,7 +99,8 @@ namespace WixToolset.Core
99 //
100 // STANDARD_RIGHTS_REQUIRED (0x000F0000L)
101 // FILE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF)
92 - internal static readonly string[] FilePermissions = { "Read", "Write", "Append", "ReadExtendedAttributes", "WriteExtendedAttributes", "Execute", "FileAllRights", "ReadAttributes", "WriteAttributes" };
102 + // TODO: Find a place to put this that it doesn't have to be public and exposed by WixToolset.Core.dll
103 + public static readonly string[] FilePermissions = { "Read", "Write", "Append", "ReadExtendedAttributes", "WriteExtendedAttributes", "Execute", "FileAllRights", "ReadAttributes", "WriteAttributes" };
104
105 public static readonly Regex WixVariableRegex = new Regex(@"(\!|\$)\((?<namespace>loc|wix|bind|bindpath)\.(?<fullname>(?<name>[_A-Za-z][0-9A-Za-z_]+)(\.(?<scope>[_A-Za-z][0-9A-Za-z_\.]*))?)(\=(?<value>.+?))?\)", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.ExplicitCapture);
106
@@ -106,58 +117,6 @@ namespace WixToolset.Core
117 private const string LegalWildcardShortFilenameCharacters = @"[^\\|><:/""\+,;=\[\]\. ]"; // illegal: \ | > < : / " + , ; = [ ] . (space)
118 private static readonly Regex LegalWildcardShortFilename = new Regex(String.Concat("^", LegalWildcardShortFilenameCharacters, @"{1,16}(\.", LegalWildcardShortFilenameCharacters, "{0,6})?$"));
119
109 - /// <summary>
110 - /// Cleans up the temp files.
111 - /// </summary>
112 - /// <param name="path">The temporary directory to delete.</param>
113 - /// <param name="messageHandler">The message handler.</param>
114 - /// <returns>True if all files were deleted, false otherwise.</returns>
115 - internal static bool DeleteTempFiles(string path, IMessaging messageHandler)
116 - {
117 - // try three times and give up with a warning if the temp files aren't gone by then
118 - int retryLimit = 3;
119 - bool removedReadOnly = false;
120 -
121 - for (int i = 0; i < retryLimit; i++)
122 - {
123 - try
124 - {
125 - Directory.Delete(path, true); // toast the whole temp directory
126 - break; // no exception means we got success the first time
127 - }
128 - catch (UnauthorizedAccessException)
129 - {
130 - if (!removedReadOnly) // should only need to unmark readonly once - there's no point in doing it again and again
131 - {
132 - removedReadOnly = true;
133 - RecursiveFileAttributes(path, FileAttributes.ReadOnly, false, messageHandler); // toasting will fail if any files are read-only. Try changing them to not be.
134 - }
135 - else
136 - {
137 - messageHandler.Write(WarningMessages.AccessDeniedForDeletion(null, path));
138 - return false;
139 - }
140 - }
141 - catch (DirectoryNotFoundException)
142 - {
143 - // if the path doesn't exist, then there is nothing for us to worry about
144 - break;
145 - }
146 - catch (IOException) // directory in use
147 - {
148 - if (i == (retryLimit - 1)) // last try failed still, give up
149 - {
150 - messageHandler.Write(WarningMessages.DirectoryInUse(null, path));
151 - return false;
152 - }
153 -
154 - System.Threading.Thread.Sleep(300); // sleep a bit before trying again
155 - }
156 - }
157 -
158 - return true;
159 - }
160 -
120 /// <summary>
121 /// Gets a valid code page from the given web name or integer value.
122 /// </summary>
@@ -315,30 +274,6 @@ namespace WixToolset.Core
274 return match.Success && ("bind" == match.Groups["namespace"].Value || "wix" == match.Groups["namespace"].Value);
275 }
276
318 - /// <summary>
319 - /// Get the value of an attribute with type YesNoType.
320 - /// </summary>
321 - /// <param name="sourceLineNumbers">Source information for the value.</param>
322 - /// <param name="elementName">Name of the element for this attribute, used for a possible exception.</param>
323 - /// <param name="attributeName">Name of the attribute.</param>
324 - /// <param name="value">Value to process.</param>
325 - /// <returns>Returns true for a value of 'yes' and false for a value of 'no'.</returns>
326 - /// <exception cref="WixException">Thrown when the attribute's value is not 'yes' or 'no'.</exception>
327 - internal static bool IsYes(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value)
328 - {
329 - switch (value)
330 - {
331 - case "no":
332 - case "false":
333 - return false;
334 - case "yes":
335 - case "true":
336 - return true;
337 - default:
338 - throw new WixException(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, elementName, attributeName, value, "no", "yes"));
339 - }
340 - }
341 -
277 /// <summary>
278 /// Verifies the given string is a valid module or bundle version.
279 /// </summary>
@@ -471,18 +406,6 @@ namespace WixToolset.Core
406 }
407 }
408
474 - public static string GetFileHash(string path)
475 - {
476 - using (SHA1Managed managed = new SHA1Managed())
477 - {
478 - using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Delete | FileShare.Read))
479 - {
480 - byte[] hash = managed.ComputeHash(stream);
481 - return BitConverter.ToString(hash).Replace("-", String.Empty);
482 - }
483 - }
484 - }
485 -
409 /// <summary>
410 /// Takes an id, and demodularizes it (if possible).
411 /// </summary>
src/WixToolset.Core/Compiler.cs
+7958 -7958
@@ -24,10 +24,6 @@ namespace WixToolset.Core
24 /// </summary>
25 internal class Compiler : ICompiler
26 {
27 - public const string UpgradeDetectedProperty = "WIX_UPGRADE_DETECTED";
28 - public const string UpgradePreventedCondition = "NOT WIX_UPGRADE_DETECTED";
29 - public const string DowngradeDetectedProperty = "WIX_DOWNGRADE_DETECTED";
30 - public const string DowngradePreventedCondition = "NOT WIX_DOWNGRADE_DETECTED";
27 public const string DefaultComponentIdPlaceholderFormat = "WixComponentIdPlaceholder{0}";
28 public const string DefaultComponentIdPlaceholderWixVariableFormat = "!(wix.{0})";
29 public const string BurnUXContainerId = "WixUXContainer";
@@ -297,12 +293,12 @@ namespace WixToolset.Core
293
294 if (!String.IsNullOrEmpty(value))
295 {
300 - Regex regex = new Regex(@"\[(?<identifier>[a-zA-Z_][a-zA-Z0-9_\.]*)]", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.ExplicitCapture);
301 - MatchCollection matches = regex.Matches(value);
296 + var regex = new Regex(@"\[(?<identifier>[a-zA-Z_][a-zA-Z0-9_\.]*)]", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.ExplicitCapture);
297 + var matches = regex.Matches(value);
298
299 foreach (Match match in matches)
300 {
305 - Group group = match.Groups["identifier"];
301 + var group = match.Groups["identifier"];
302 if (group.Success)
303 {
304 this.Core.Write(WarningMessages.PropertyValueContainsPropertyReference(sourceLineNumbers, property.Id, group.Value));
@@ -317,7 +313,7 @@ namespace WixToolset.Core
313 // Add the row to a separate section if requested.
314 if (fragment)
315 {
320 - string id = String.Concat(this.Core.ActiveSection.Id, ".", property.Id);
316 + var id = String.Concat(this.Core.ActiveSection.Id, ".", property.Id);
317
318 section = this.Core.CreateSection(id, SectionType.Fragment, this.Core.ActiveSection.Codepage, this.Context.CompilationId);
319
@@ -384,53 +380,53 @@ namespace WixToolset.Core
380 /// <param name="typeLibVersion">Optional TypeLib Version for CLSID Interfaces (if any).</param>
381 private void ParseAppIdElement(XElement node, string componentId, YesNoType advertise, string fileServer, string typeLibId, string typeLibVersion)
382 {
387 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
383 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
384 string appId = null;
385 string remoteServerName = null;
386 string localService = null;
387 string serviceParameters = null;
388 string dllSurrogate = null;
393 - YesNoType activateAtStorage = YesNoType.NotSet;
394 - YesNoType appIdAdvertise = YesNoType.NotSet;
395 - YesNoType runAsInteractiveUser = YesNoType.NotSet;
389 + var activateAtStorage = YesNoType.NotSet;
390 + var appIdAdvertise = YesNoType.NotSet;
391 + var runAsInteractiveUser = YesNoType.NotSet;
392 string description = null;
393
398 - foreach (XAttribute attrib in node.Attributes())
394 + foreach (var attrib in node.Attributes())
395 {
396 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
397 {
398 switch (attrib.Name.LocalName)
399 {
404 - case "Id":
405 - appId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
406 - break;
407 - case "ActivateAtStorage":
408 - activateAtStorage = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
409 - break;
410 - case "Advertise":
411 - appIdAdvertise = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
412 - break;
413 - case "Description":
414 - description = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
415 - break;
416 - case "DllSurrogate":
417 - dllSurrogate = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty);
418 - break;
419 - case "LocalService":
420 - localService = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
421 - break;
422 - case "RemoteServerName":
423 - remoteServerName = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
424 - break;
425 - case "RunAsInteractiveUser":
426 - runAsInteractiveUser = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
427 - break;
428 - case "ServiceParameters":
429 - serviceParameters = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
430 - break;
431 - default:
432 - this.Core.UnexpectedAttribute(node, attrib);
433 - break;
400 + case "Id":
401 + appId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
402 + break;
403 + case "ActivateAtStorage":
404 + activateAtStorage = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
405 + break;
406 + case "Advertise":
407 + appIdAdvertise = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
408 + break;
409 + case "Description":
410 + description = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
411 + break;
412 + case "DllSurrogate":
413 + dllSurrogate = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty);
414 + break;
415 + case "LocalService":
416 + localService = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
417 + break;
418 + case "RemoteServerName":
419 + remoteServerName = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
420 + break;
421 + case "RunAsInteractiveUser":
422 + runAsInteractiveUser = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
423 + break;
424 + case "ServiceParameters":
425 + serviceParameters = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
426 + break;
427 + default:
428 + this.Core.UnexpectedAttribute(node, attrib);
429 + break;
430 }
431 }
432 else
@@ -459,18 +455,18 @@ namespace WixToolset.Core
455 advertise = YesNoType.No;
456 }
457
462 - foreach (XElement child in node.Elements())
458 + foreach (var child in node.Elements())
459 {
460 if (CompilerCore.WixNamespace == child.Name.Namespace)
461 {
462 switch (child.Name.LocalName)
463 {
468 - case "Class":
469 - this.ParseClassElement(child, componentId, advertise, fileServer, typeLibId, typeLibVersion, appId);
470 - break;
471 - default:
472 - this.Core.UnexpectedElement(node, child);
473 - break;
464 + case "Class":
465 + this.ParseClassElement(child, componentId, advertise, fileServer, typeLibId, typeLibVersion, appId);
466 + break;
467 + default:
468 + this.Core.UnexpectedElement(node, child);
469 + break;
470 }
471 }
472 else
@@ -555,25 +551,25 @@ namespace WixToolset.Core
551 /// <param name="componentId">Parent's component id.</param>
552 private void ParseAssemblyName(XElement node, string componentId)
553 {
558 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
554 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
555 string id = null;
556 string value = null;
557
562 - foreach (XAttribute attrib in node.Attributes())
558 + foreach (var attrib in node.Attributes())
559 {
560 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
561 {
562 switch (attrib.Name.LocalName)
563 {
568 - case "Id":
569 - id = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
570 - break;
571 - case "Value":
572 - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
573 - break;
574 - default:
575 - this.Core.UnexpectedAttribute(node, attrib);
576 - break;
564 + case "Id":
565 + id = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
566 + break;
567 + case "Value":
568 + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
569 + break;
570 + default:
571 + this.Core.UnexpectedAttribute(node, attrib);
572 + break;
573 }
574 }
575 else
@@ -606,39 +602,39 @@ namespace WixToolset.Core
602 [SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
603 private Identifier ParseBinaryElement(XElement node)
604 {
609 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
605 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
606 Identifier id = null;
607 string sourceFile = null;
612 - YesNoType suppressModularization = YesNoType.NotSet;
608 + var suppressModularization = YesNoType.NotSet;
609
614 - foreach (XAttribute attrib in node.Attributes())
610 + foreach (var attrib in node.Attributes())
611 {
612 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
613 {
614 switch (attrib.Name.LocalName)
615 {
620 - case "Id":
621 - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
622 - break;
623 - case "SourceFile":
624 - case "src":
625 - if (null != sourceFile)
626 - {
627 - this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "SourceFile", "src"));
628 - }
616 + case "Id":
617 + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
618 + break;
619 + case "SourceFile":
620 + case "src":
621 + if (null != sourceFile)
622 + {
623 + this.Core.Write(ErrorMessages.IllegalAttributeWithOtherAttribute(sourceLineNumbers, node.Name.LocalName, "SourceFile", "src"));
624 + }
625
630 - if ("src" == attrib.Name.LocalName)
631 - {
632 - this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "SourceFile"));
633 - }
634 - sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
635 - break;
636 - case "SuppressModularization":
637 - suppressModularization = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
638 - break;
639 - default:
640 - this.Core.UnexpectedAttribute(node, attrib);
641 - break;
626 + if ("src" == attrib.Name.LocalName)
627 + {
628 + this.Core.Write(WarningMessages.DeprecatedAttribute(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "SourceFile"));
629 + }
630 + sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
631 + break;
632 + case "SuppressModularization":
633 + suppressModularization = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
634 + break;
635 + default:
636 + this.Core.UnexpectedAttribute(node, attrib);
637 + break;
638 }
639 }
640 else
@@ -695,25 +691,25 @@ namespace WixToolset.Core
691 /// <returns>Identifier for the new row.</returns>
692 private string ParseIconElement(XElement node)
693 {
698 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
694 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
695 Identifier id = null;
696 string sourceFile = null;
697
702 - foreach (XAttribute attrib in node.Attributes())
698 + foreach (var attrib in node.Attributes())
699 {
700 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
701 {
702 switch (attrib.Name.LocalName)
703 {
708 - case "Id":
709 - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
710 - break;
711 - case "SourceFile":
712 - sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
713 - break;
714 - default:
715 - this.Core.UnexpectedAttribute(node, attrib);
716 - break;
704 + case "Id":
705 + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
706 + break;
707 + case "SourceFile":
708 + sourceFile = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
709 + break;
710 + default:
711 + this.Core.UnexpectedAttribute(node, attrib);
712 + break;
713 }
714 }
715 else
@@ -764,22 +760,22 @@ namespace WixToolset.Core
760 /// <param name="node">Element to parse.</param>
761 private void ParseInstanceTransformsElement(XElement node)
762 {
767 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
763 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
764 string property = null;
765
770 - foreach (XAttribute attrib in node.Attributes())
766 + foreach (var attrib in node.Attributes())
767 {
768 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
769 {
770 switch (attrib.Name.LocalName)
771 {
776 - case "Property":
777 - property = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
778 - this.Core.CreateSimpleReference(sourceLineNumbers, "Property", property);
779 - break;
780 - default:
781 - this.Core.UnexpectedAttribute(node, attrib);
782 - break;
772 + case "Property":
773 + property = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
774 + this.Core.CreateSimpleReference(sourceLineNumbers, "Property", property);
775 + break;
776 + default:
777 + this.Core.UnexpectedAttribute(node, attrib);
778 + break;
779 }
780 }
781 else
@@ -794,18 +790,18 @@ namespace WixToolset.Core
790 }
791
792 // find unexpected child elements
797 - foreach (XElement child in node.Elements())
793 + foreach (var child in node.Elements())
794 {
795 if (CompilerCore.WixNamespace == child.Name.Namespace)
796 {
797 switch (child.Name.LocalName)
798 {
803 - case "Instance":
804 - ParseInstanceElement(child, property);
805 - break;
806 - default:
807 - this.Core.UnexpectedElement(node, child);
808 - break;
799 + case "Instance":
800 + this.ParseInstanceElement(child, property);
801 + break;
802 + default:
803 + this.Core.UnexpectedElement(node, child);
804 + break;
805 }
806 }
807 else
@@ -822,33 +818,33 @@ namespace WixToolset.Core
818 /// <param name="componentId">Identifier of instance property.</param>
819 private void ParseInstanceElement(XElement node, string propertyId)
820 {
825 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
821 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
822 string id = null;
823 string productCode = null;
824 string productName = null;
825 string upgradeCode = null;
826
831 - foreach (XAttribute attrib in node.Attributes())
827 + foreach (var attrib in node.Attributes())
828 {
829 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
830 {
831 switch (attrib.Name.LocalName)
832 {
837 - case "Id":
838 - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
839 - break;
840 - case "ProductCode":
841 - productCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, true);
842 - break;
843 - case "ProductName":
844 - productName = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
845 - break;
846 - case "UpgradeCode":
847 - upgradeCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
848 - break;
849 - default:
850 - this.Core.UnexpectedAttribute(node, attrib);
851 - break;
833 + case "Id":
834 + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
835 + break;
836 + case "ProductCode":
837 + productCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, true);
838 + break;
839 + case "ProductName":
840 + productName = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
841 + break;
842 + case "UpgradeCode":
843 + upgradeCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
844 + break;
845 + default:
846 + this.Core.UnexpectedAttribute(node, attrib);
847 + break;
848 }
849 }
850 else
@@ -893,34 +889,34 @@ namespace WixToolset.Core
889 /// <param name="componentId">Identifier of parent component.</param>
890 private void ParseCategoryElement(XElement node, string componentId)
891 {
896 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
892 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
893 string id = null;
894 string appData = null;
895 string feature = null;
896 string qualifier = null;
897
902 - foreach (XAttribute attrib in node.Attributes())
898 + foreach (var attrib in node.Attributes())
899 {
900 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
901 {
902 switch (attrib.Name.LocalName)
903 {
908 - case "Id":
909 - id = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
910 - break;
911 - case "AppData":
912 - appData = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
913 - break;
914 - case "Feature":
915 - feature = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
916 - this.Core.CreateSimpleReference(sourceLineNumbers, "Feature", feature);
917 - break;
918 - case "Qualifier":
919 - qualifier = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
920 - break;
921 - default:
922 - this.Core.UnexpectedAttribute(node, attrib);
923 - break;
904 + case "Id":
905 + id = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
906 + break;
907 + case "AppData":
908 + appData = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
909 + break;
910 + case "Feature":
911 + feature = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
912 + this.Core.CreateSimpleReference(sourceLineNumbers, "Feature", feature);
913 + break;
914 + case "Qualifier":
915 + qualifier = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
916 + break;
917 + default:
918 + this.Core.UnexpectedAttribute(node, attrib);
919 + break;
920 }
921 }
922 else
@@ -971,105 +967,105 @@ namespace WixToolset.Core
967 /// <param name="parentAppId">Optional parent AppId.</param>
968 private void ParseClassElement(XElement node, string componentId, YesNoType advertise, string fileServer, string typeLibId, string typeLibVersion, string parentAppId)
969 {
974 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
970 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
971
972 string appId = null;
973 string argument = null;
978 - bool class16bit = false;
979 - bool class32bit = false;
974 + var class16bit = false;
975 + var class32bit = false;
976 string classId = null;
981 - YesNoType classAdvertise = YesNoType.NotSet;
982 - string[] contexts = new string[0];
977 + var classAdvertise = YesNoType.NotSet;
978 + var contexts = new string[0];
979 string formattedContextString = null;
984 - bool control = false;
980 + var control = false;
981 string defaultInprocHandler = null;
982 string defaultProgId = null;
983 string description = null;
984 string fileTypeMask = null;
985 string foreignServer = null;
986 string icon = null;
991 - int iconIndex = CompilerConstants.IntegerNotSet;
987 + var iconIndex = CompilerConstants.IntegerNotSet;
988 string insertable = null;
989 string localFileServer = null;
994 - bool programmable = false;
995 - YesNoType relativePath = YesNoType.NotSet;
996 - bool safeForInit = false;
997 - bool safeForScripting = false;
998 - bool shortServerPath = false;
990 + var programmable = false;
991 + var relativePath = YesNoType.NotSet;
992 + var safeForInit = false;
993 + var safeForScripting = false;
994 + var shortServerPath = false;
995 string threadingModel = null;
996 string version = null;
997
1002 - foreach (XAttribute attrib in node.Attributes())
998 + foreach (var attrib in node.Attributes())
999 {
1000 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
1001 {
1002 switch (attrib.Name.LocalName)
1003 {
1008 - case "Id":
1009 - classId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
1010 - break;
1011 - case "Advertise":
1012 - classAdvertise = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1013 - break;
1014 - case "AppId":
1015 - appId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
1016 - break;
1017 - case "Argument":
1018 - argument = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1019 - break;
1020 - case "Context":
1021 - contexts = this.Core.GetAttributeValue(sourceLineNumbers, attrib).Split("\r\n\t ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
1022 - break;
1023 - case "Control":
1024 - control = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1025 - break;
1026 - case "Description":
1027 - description = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1028 - break;
1029 - case "Handler":
1030 - defaultInprocHandler = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1031 - break;
1032 - case "Icon":
1033 - icon = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
1034 - break;
1035 - case "IconIndex":
1036 - iconIndex = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, short.MinValue + 1, short.MaxValue);
1037 - break;
1038 - case "RelativePath":
1039 - relativePath = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1040 - break;
1004 + case "Id":
1005 + classId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
1006 + break;
1007 + case "Advertise":
1008 + classAdvertise = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1009 + break;
1010 + case "AppId":
1011 + appId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
1012 + break;
1013 + case "Argument":
1014 + argument = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1015 + break;
1016 + case "Context":
1017 + contexts = this.Core.GetAttributeValue(sourceLineNumbers, attrib).Split("\r\n\t ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
1018 + break;
1019 + case "Control":
1020 + control = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1021 + break;
1022 + case "Description":
1023 + description = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1024 + break;
1025 + case "Handler":
1026 + defaultInprocHandler = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1027 + break;
1028 + case "Icon":
1029 + icon = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
1030 + break;
1031 + case "IconIndex":
1032 + iconIndex = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, Int16.MinValue + 1, Int16.MaxValue);
1033 + break;
1034 + case "RelativePath":
1035 + relativePath = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1036 + break;
1037
1042 - // The following attributes result in rows always added to the Registry table rather than the Class table
1043 - case "Insertable":
1044 - insertable = (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) ? "Insertable" : "NotInsertable";
1045 - break;
1046 - case "Programmable":
1047 - programmable = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1048 - break;
1049 - case "SafeForInitializing":
1050 - safeForInit = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1051 - break;
1052 - case "SafeForScripting":
1053 - safeForScripting = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1054 - break;
1055 - case "ForeignServer":
1056 - foreignServer = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1057 - break;
1058 - case "Server":
1059 - localFileServer = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1060 - break;
1061 - case "ShortPath":
1062 - shortServerPath = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1063 - break;
1064 - case "ThreadingModel":
1065 - threadingModel = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1066 - break;
1067 - case "Version":
1068 - version = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1069 - break;
1070 - default:
1071 - this.Core.UnexpectedAttribute(node, attrib);
1072 - break;
1038 + // The following attributes result in rows always added to the Registry table rather than the Class table
1039 + case "Insertable":
1040 + insertable = (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib)) ? "Insertable" : "NotInsertable";
1041 + break;
1042 + case "Programmable":
1043 + programmable = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1044 + break;
1045 + case "SafeForInitializing":
1046 + safeForInit = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1047 + break;
1048 + case "SafeForScripting":
1049 + safeForScripting = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1050 + break;
1051 + case "ForeignServer":
1052 + foreignServer = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1053 + break;
1054 + case "Server":
1055 + localFileServer = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1056 + break;
1057 + case "ShortPath":
1058 + shortServerPath = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1059 + break;
1060 + case "ThreadingModel":
1061 + threadingModel = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1062 + break;
1063 + case "Version":
1064 + version = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1065 + break;
1066 + default:
1067 + this.Core.UnexpectedAttribute(node, attrib);
1068 + break;
1069 }
1070 }
1071 else
@@ -1083,8 +1079,8 @@ namespace WixToolset.Core
1079 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id"));
1080 }
1081
1086 - HashSet<string> uniqueContexts = new HashSet<string>();
1087 - foreach (string context in contexts)
1082 + var uniqueContexts = new HashSet<string>();
1083 + foreach (var context in contexts)
1084 {
1085 if (uniqueContexts.Contains(context))
1086 {
@@ -1136,44 +1132,44 @@ namespace WixToolset.Core
1132 }
1133
1134 // Local variables used strictly for child node processing.
1139 - int fileTypeMaskIndex = 0;
1140 - YesNoType firstProgIdForClass = YesNoType.Yes;
1135 + var fileTypeMaskIndex = 0;
1136 + var firstProgIdForClass = YesNoType.Yes;
1137
1142 - foreach (XElement child in node.Elements())
1138 + foreach (var child in node.Elements())
1139 {
1140 if (CompilerCore.WixNamespace == child.Name.Namespace)
1141 {
1142 switch (child.Name.LocalName)
1143 {
1148 - case "FileTypeMask":
1149 - if (YesNoType.Yes == advertise)
1150 - {
1151 - fileTypeMask = String.Concat(fileTypeMask, null == fileTypeMask ? String.Empty : ";", this.ParseFileTypeMaskElement(child));
1152 - }
1153 - else if (YesNoType.No == advertise)
1154 - {
1155 - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child);
1156 - this.Core.CreateRegistryRow(childSourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("FileType\\", classId, "\\", fileTypeMaskIndex.ToString()), String.Empty, this.ParseFileTypeMaskElement(child), componentId);
1157 - fileTypeMaskIndex++;
1158 - }
1159 - break;
1160 - case "Interface":
1161 - this.ParseInterfaceElement(child, componentId, class16bit ? classId : null, class32bit ? classId : null, typeLibId, typeLibVersion);
1162 - break;
1163 - case "ProgId":
1164 - {
1165 - bool foundExtension = false;
1166 - string progId = this.ParseProgIdElement(child, componentId, advertise, classId, description, null, ref foundExtension, firstProgIdForClass);
1167 - if (null == defaultProgId)
1168 - {
1169 - defaultProgId = progId;
1170 - }
1171 - firstProgIdForClass = YesNoType.No;
1172 - }
1173 - break;
1174 - default:
1175 - this.Core.UnexpectedElement(node, child);
1176 - break;
1144 + case "FileTypeMask":
1145 + if (YesNoType.Yes == advertise)
1146 + {
1147 + fileTypeMask = String.Concat(fileTypeMask, null == fileTypeMask ? String.Empty : ";", this.ParseFileTypeMaskElement(child));
1148 + }
1149 + else if (YesNoType.No == advertise)
1150 + {
1151 + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child);
1152 + this.Core.CreateRegistryRow(childSourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("FileType\\", classId, "\\", fileTypeMaskIndex.ToString()), String.Empty, this.ParseFileTypeMaskElement(child), componentId);
1153 + fileTypeMaskIndex++;
1154 + }
1155 + break;
1156 + case "Interface":
1157 + this.ParseInterfaceElement(child, componentId, class16bit ? classId : null, class32bit ? classId : null, typeLibId, typeLibVersion);
1158 + break;
1159 + case "ProgId":
1160 + {
1161 + var foundExtension = false;
1162 + var progId = this.ParseProgIdElement(child, componentId, advertise, classId, description, null, ref foundExtension, firstProgIdForClass);
1163 + if (null == defaultProgId)
1164 + {
1165 + defaultProgId = progId;
1166 + }
1167 + firstProgIdForClass = YesNoType.No;
1168 + }
1169 + break;
1170 + default:
1171 + this.Core.UnexpectedElement(node, child);
1172 + break;
1173 }
1174 }
1175 else
@@ -1203,7 +1199,7 @@ namespace WixToolset.Core
1199 // add a Class row for each context
1200 if (!this.Core.EncounteredError)
1201 {
1206 - foreach (string context in contexts)
1202 + foreach (var context in contexts)
1203 {
1204 var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.Class);
1205 row.Set(0, classId);
@@ -1262,7 +1258,7 @@ namespace WixToolset.Core
1258 }
1259
1260 // add the core registry keys for each context in the class
1265 - foreach (string context in contexts)
1261 + foreach (var context in contexts)
1262 {
1263 if (context.StartsWith("InprocServer", StringComparison.Ordinal)) // dll server
1264 {
@@ -1338,19 +1334,19 @@ namespace WixToolset.Core
1334 {
1335 switch (defaultInprocHandler) // ClassId Default Inproc Handler
1336 {
1341 - case "1":
1342 - this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler"), String.Empty, "ole.dll", componentId);
1343 - break;
1344 - case "2":
1345 - this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler32"), String.Empty, "ole32.dll", componentId);
1346 - break;
1347 - case "3":
1348 - this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler"), String.Empty, "ole.dll", componentId);
1349 - this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler32"), String.Empty, "ole32.dll", componentId);
1350 - break;
1351 - default:
1352 - this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler32"), String.Empty, defaultInprocHandler, componentId);
1353 - break;
1337 + case "1":
1338 + this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler"), String.Empty, "ole.dll", componentId);
1339 + break;
1340 + case "2":
1341 + this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler32"), String.Empty, "ole32.dll", componentId);
1342 + break;
1343 + case "3":
1344 + this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler"), String.Empty, "ole.dll", componentId);
1345 + this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler32"), String.Empty, "ole32.dll", componentId);
1346 + break;
1347 + default:
1348 + this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\InprocHandler32"), String.Empty, defaultInprocHandler, componentId);
1349 + break;
1350 }
1351 }
1352
@@ -1365,7 +1361,7 @@ namespace WixToolset.Core
1361 threadingModel = Compiler.UppercaseFirstChar(threadingModel);
1362
1363 // add a threading model for each context in the class
1368 - foreach (string context in contexts)
1364 + foreach (var context in contexts)
1365 {
1366 this.Core.CreateRegistryRow(sourceLineNumbers, MsiInterop.MsidbRegistryRootClassesRoot, String.Concat("CLSID\\", classId, "\\", context), "ThreadingModel", threadingModel, componentId);
1367 }
@@ -1421,43 +1417,43 @@ namespace WixToolset.Core
1417 /// <param name="typelibVersion">Version of the TypeLib to which this interface belongs. Required if typeLibId is specified</param>
1418 private void ParseInterfaceElement(XElement node, string componentId, string proxyId, string proxyId32, string typeLibId, string typelibVersion)
1419 {
1424 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
1420 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
1421 string baseInterface = null;
1422 string interfaceId = null;
1423 string name = null;
1428 - int numMethods = CompilerConstants.IntegerNotSet;
1429 - bool versioned = true;
1424 + var numMethods = CompilerConstants.IntegerNotSet;
1425 + var versioned = true;
1426
1431 - foreach (XAttribute attrib in node.Attributes())
1427 + foreach (var attrib in node.Attributes())
1428 {
1429 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
1430 {
1431 switch (attrib.Name.LocalName)
1432 {
1437 - case "Id":
1438 - interfaceId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
1439 - break;
1440 - case "BaseInterface":
1441 - baseInterface = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
1442 - break;
1443 - case "Name":
1444 - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1445 - break;
1446 - case "NumMethods":
1447 - numMethods = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue);
1448 - break;
1449 - case "ProxyStubClassId":
1450 - proxyId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib);
1451 - break;
1452 - case "ProxyStubClassId32":
1453 - proxyId32 = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
1454 - break;
1455 - case "Versioned":
1456 - versioned = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1457 - break;
1458 - default:
1459 - this.Core.UnexpectedAttribute(node, attrib);
1460 - break;
1433 + case "Id":
1434 + interfaceId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
1435 + break;
1436 + case "BaseInterface":
1437 + baseInterface = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
1438 + break;
1439 + case "Name":
1440 + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1441 + break;
1442 + case "NumMethods":
1443 + numMethods = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int32.MaxValue);
1444 + break;
1445 + case "ProxyStubClassId":
1446 + proxyId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib);
1447 + break;
1448 + case "ProxyStubClassId32":
1449 + proxyId32 = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
1450 + break;
1451 + case "Versioned":
1452 + versioned = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1453 + break;
1454 + default:
1455 + this.Core.UnexpectedAttribute(node, attrib);
1456 + break;
1457 }
1458 }
1459 else
@@ -1516,30 +1512,30 @@ namespace WixToolset.Core
1512 /// <returns>String representing the file type mask elements.</returns>
1513 private string ParseFileTypeMaskElement(XElement node)
1514 {
1519 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
1520 - int cb = 0;
1521 - int offset = CompilerConstants.IntegerNotSet;
1515 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
1516 + var cb = 0;
1517 + var offset = CompilerConstants.IntegerNotSet;
1518 string mask = null;
1519 string value = null;
1520
1525 - foreach (XAttribute attrib in node.Attributes())
1521 + foreach (var attrib in node.Attributes())
1522 {
1523 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
1524 {
1525 switch (attrib.Name.LocalName)
1526 {
1531 - case "Mask":
1532 - mask = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1533 - break;
1534 - case "Offset":
1535 - offset = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, int.MaxValue);
1536 - break;
1537 - case "Value":
1538 - value = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1539 - break;
1540 - default:
1541 - this.Core.UnexpectedAttribute(node, attrib);
1542 - break;
1527 + case "Mask":
1528 + mask = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1529 + break;
1530 + case "Offset":
1531 + offset = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int32.MaxValue);
1532 + break;
1533 + case "Value":
1534 + value = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1535 + break;
1536 + default:
1537 + this.Core.UnexpectedAttribute(node, attrib);
1538 + break;
1539 }
1540 }
1541 else
@@ -1585,53 +1581,53 @@ namespace WixToolset.Core
1581 /// <returns>Signature for search element.</returns>
1582 private void ParseProductSearchElement(XElement node, string propertyId)
1583 {
1588 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
1584 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
1585
1586 string upgradeCode = null;
1587 string language = null;
1588 string maximum = null;
1589 string minimum = null;
1594 - int options = MsiInterop.MsidbUpgradeAttributesVersionMinInclusive | MsiInterop.MsidbUpgradeAttributesOnlyDetect;
1590 + var options = MsiInterop.MsidbUpgradeAttributesVersionMinInclusive | MsiInterop.MsidbUpgradeAttributesOnlyDetect;
1591
1596 - foreach (XAttribute attrib in node.Attributes())
1592 + foreach (var attrib in node.Attributes())
1593 {
1594 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
1595 {
1596 switch (attrib.Name.LocalName)
1597 {
1602 - case "ExcludeLanguages":
1603 - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
1604 - {
1605 - options |= MsiInterop.MsidbUpgradeAttributesLanguagesExclusive;
1606 - }
1607 - break;
1608 - case "IncludeMaximum":
1609 - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
1610 - {
1611 - options |= MsiInterop.MsidbUpgradeAttributesVersionMaxInclusive;
1612 - }
1613 - break;
1614 - case "IncludeMinimum": // this is "yes" by default
1615 - if (YesNoType.No == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
1616 - {
1617 - options &= ~MsiInterop.MsidbUpgradeAttributesVersionMinInclusive;
1618 - }
1619 - break;
1620 - case "Language":
1621 - language = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1622 - break;
1623 - case "Minimum":
1624 - minimum = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1625 - break;
1626 - case "Maximum":
1627 - maximum = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1628 - break;
1629 - case "UpgradeCode":
1630 - upgradeCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
1631 - break;
1632 - default:
1633 - this.Core.UnexpectedAttribute(node, attrib);
1634 - break;
1598 + case "ExcludeLanguages":
1599 + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
1600 + {
1601 + options |= MsiInterop.MsidbUpgradeAttributesLanguagesExclusive;
1602 + }
1603 + break;
1604 + case "IncludeMaximum":
1605 + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
1606 + {
1607 + options |= MsiInterop.MsidbUpgradeAttributesVersionMaxInclusive;
1608 + }
1609 + break;
1610 + case "IncludeMinimum": // this is "yes" by default
1611 + if (YesNoType.No == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
1612 + {
1613 + options &= ~MsiInterop.MsidbUpgradeAttributesVersionMinInclusive;
1614 + }
1615 + break;
1616 + case "Language":
1617 + language = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1618 + break;
1619 + case "Minimum":
1620 + minimum = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1621 + break;
1622 + case "Maximum":
1623 + maximum = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1624 + break;
1625 + case "UpgradeCode":
1626 + upgradeCode = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
1627 + break;
1628 + default:
1629 + this.Core.UnexpectedAttribute(node, attrib);
1630 + break;
1631 }
1632 }
1633 else
@@ -1666,63 +1662,63 @@ namespace WixToolset.Core
1662 /// <returns>Signature for search element.</returns>
1663 private string ParseRegistrySearchElement(XElement node)
1664 {
1669 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
1670 - bool explicitWin64 = false;
1665 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
1666 + var explicitWin64 = false;
1667 Identifier id = null;
1668 string key = null;
1669 string name = null;
1670 string signature = null;
1675 - int root = CompilerConstants.IntegerNotSet;
1676 - int type = CompilerConstants.IntegerNotSet;
1677 - bool search64bit = false;
1671 + var root = CompilerConstants.IntegerNotSet;
1672 + var type = CompilerConstants.IntegerNotSet;
1673 + var search64bit = false;
1674
1679 - foreach (XAttribute attrib in node.Attributes())
1675 + foreach (var attrib in node.Attributes())
1676 {
1677 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
1678 {
1679 switch (attrib.Name.LocalName)
1680 {
1685 - case "Id":
1686 - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
1687 - break;
1688 - case "Key":
1689 - key = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1690 - break;
1691 - case "Name":
1692 - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1693 - break;
1694 - case "Root":
1695 - root = this.Core.GetAttributeMsidbRegistryRootValue(sourceLineNumbers, attrib, false);
1696 - break;
1697 - case "Type":
1698 - string typeValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1699 - if (0 < typeValue.Length)
1681 + case "Id":
1682 + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
1683 + break;
1684 + case "Key":
1685 + key = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1686 + break;
1687 + case "Name":
1688 + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1689 + break;
1690 + case "Root":
1691 + root = this.Core.GetAttributeMsidbRegistryRootValue(sourceLineNumbers, attrib, false);
1692 + break;
1693 + case "Type":
1694 + var typeValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
1695 + if (0 < typeValue.Length)
1696 + {
1697 + var typeType = Wix.RegistrySearch.ParseTypeType(typeValue);
1698 + switch (typeType)
1699 {
1701 - Wix.RegistrySearch.TypeType typeType = Wix.RegistrySearch.ParseTypeType(typeValue);
1702 - switch (typeType)
1703 - {
1704 - case Wix.RegistrySearch.TypeType.directory:
1705 - type = 0;
1706 - break;
1707 - case Wix.RegistrySearch.TypeType.file:
1708 - type = 1;
1709 - break;
1710 - case Wix.RegistrySearch.TypeType.raw:
1711 - type = 2;
1712 - break;
1713 - default:
1714 - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Type", typeValue, "directory", "file", "raw"));
1715 - break;
1716 - }
1700 + case Wix.RegistrySearch.TypeType.directory:
1701 + type = 0;
1702 + break;
1703 + case Wix.RegistrySearch.TypeType.file:
1704 + type = 1;
1705 + break;
1706 + case Wix.RegistrySearch.TypeType.raw:
1707 + type = 2;
1708 + break;
1709 + default:
1710 + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Type", typeValue, "directory", "file", "raw"));
1711 + break;
1712 }
1718 - break;
1719 - case "Win64":
1720 - explicitWin64 = true;
1721 - search64bit = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1722 - break;
1723 - default:
1724 - this.Core.UnexpectedAttribute(node, attrib);
1725 - break;
1713 + }
1714 + break;
1715 + case "Win64":
1716 + explicitWin64 = true;
1717 + search64bit = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
1718 + break;
1719 + default:
1720 + this.Core.UnexpectedAttribute(node, attrib);
1721 + break;
1722 }
1723 }
1724 else
@@ -1757,53 +1753,53 @@ namespace WixToolset.Core
1753 }
1754
1755 signature = id.Id;
1760 - bool oneChild = false;
1761 - foreach (XElement child in node.Elements())
1756 + var oneChild = false;
1757 + foreach (var child in node.Elements())
1758 {
1759 if (CompilerCore.WixNamespace == child.Name.Namespace)
1760 {
1761 switch (child.Name.LocalName)
1762 {
1767 - case "DirectorySearch":
1768 - if (oneChild)
1769 - {
1770 - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
1771 - }
1772 - oneChild = true;
1763 + case "DirectorySearch":
1764 + if (oneChild)
1765 + {
1766 + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
1767 + }
1768 + oneChild = true;
1769
1774 - // directorysearch parentage should work like directory element, not the rest of the signature type because of the DrLocator.Parent column
1775 - signature = this.ParseDirectorySearchElement(child, id.Id);
1776 - break;
1777 - case "DirectorySearchRef":
1778 - if (oneChild)
1779 - {
1780 - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
1781 - }
1782 - oneChild = true;
1783 - signature = this.ParseDirectorySearchRefElement(child, id.Id);
1784 - break;
1785 - case "FileSearch":
1786 - if (oneChild)
1787 - {
1788 - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
1789 - }
1790 - oneChild = true;
1791 - signature = this.ParseFileSearchElement(child, id.Id, false, CompilerConstants.IntegerNotSet);
1792 - id = new Identifier(signature, AccessModifier.Private); // FileSearch signatures override parent signatures
1793 - break;
1794 - case "FileSearchRef":
1795 - if (oneChild)
1796 - {
1797 - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
1798 - }
1799 - oneChild = true;
1800 - string newId = this.ParseSimpleRefElement(child, "Signature"); // FileSearch signatures override parent signatures
1801 - id = new Identifier(newId, AccessModifier.Private);
1802 - signature = null;
1803 - break;
1804 - default:
1805 - this.Core.UnexpectedElement(node, child);
1806 - break;
1770 + // directorysearch parentage should work like directory element, not the rest of the signature type because of the DrLocator.Parent column
1771 + signature = this.ParseDirectorySearchElement(child, id.Id);
1772 + break;
1773 + case "DirectorySearchRef":
1774 + if (oneChild)
1775 + {
1776 + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
1777 + }
1778 + oneChild = true;
1779 + signature = this.ParseDirectorySearchRefElement(child, id.Id);
1780 + break;
1781 + case "FileSearch":
1782 + if (oneChild)
1783 + {
1784 + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
1785 + }
1786 + oneChild = true;
1787 + signature = this.ParseFileSearchElement(child, id.Id, false, CompilerConstants.IntegerNotSet);
1788 + id = new Identifier(signature, AccessModifier.Private); // FileSearch signatures override parent signatures
1789 + break;
1790 + case "FileSearchRef":
1791 + if (oneChild)
1792 + {
1793 + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
1794 + }
1795 + oneChild = true;
1796 + var newId = this.ParseSimpleRefElement(child, "Signature"); // FileSearch signatures override parent signatures
1797 + id = new Identifier(newId, AccessModifier.Private);
1798 + signature = null;
1799 + break;
1800 + default:
1801 + this.Core.UnexpectedElement(node, child);
1802 + break;
1803 }
1804 }
1805 else
@@ -1832,22 +1828,22 @@ namespace WixToolset.Core
1828 /// <returns>Signature of referenced search element.</returns>
1829 private string ParseRegistrySearchRefElement(XElement node)
1830 {
1835 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
1831 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
1832 string id = null;
1833
1838 - foreach (XAttribute attrib in node.Attributes())
1834 + foreach (var attrib in node.Attributes())
1835 {
1836 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
1837 {
1838 switch (attrib.Name.LocalName)
1839 {
1844 - case "Id":
1845 - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
1846 - this.Core.CreateSimpleReference(sourceLineNumbers, "RegLocator", id);
1847 - break;
1848 - default:
1849 - this.Core.UnexpectedAttribute(node, attrib);
1850 - break;
1840 + case "Id":
1841 + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
1842 + this.Core.CreateSimpleReference(sourceLineNumbers, "RegLocator", id);
1843 + break;
1844 + default:
1845 + this.Core.UnexpectedAttribute(node, attrib);
1846 + break;
1847 }
1848 }
1849 else
@@ -1873,42 +1869,42 @@ namespace WixToolset.Core
1869 /// <returns>Returns list of string signatures.</returns>
1870 private List<string> ParseSearchSignatures(XElement node)
1871 {
1876 - List<string> signatures = new List<string>();
1872 + var signatures = new List<string>();
1873
1878 - foreach (XElement child in node.Elements())
1874 + foreach (var child in node.Elements())
1875 {
1876 string signature = null;
1877 if (CompilerCore.WixNamespace == child.Name.Namespace)
1878 {
1879 switch (child.Name.LocalName)
1880 {
1885 - case "ComplianceDrive":
1886 - signature = this.ParseComplianceDriveElement(child);
1887 - break;
1888 - case "ComponentSearch":
1889 - signature = this.ParseComponentSearchElement(child);
1890 - break;
1891 - case "DirectorySearch":
1892 - signature = this.ParseDirectorySearchElement(child, String.Empty);
1893 - break;
1894 - case "DirectorySearchRef":
1895 - signature = this.ParseDirectorySearchRefElement(child, String.Empty);
1896 - break;
1897 - case "IniFileSearch":
1898 - signature = this.ParseIniFileSearchElement(child);
1899 - break;
1900 - case "ProductSearch":
1901 - // handled in ParsePropertyElement
1902 - break;
1903 - case "RegistrySearch":
1904 - signature = this.ParseRegistrySearchElement(child);
1905 - break;
1906 - case "RegistrySearchRef":
1907 - signature = this.ParseRegistrySearchRefElement(child);
1908 - break;
1909 - default:
1910 - this.Core.UnexpectedElement(node, child);
1911 - break;
1881 + case "ComplianceDrive":
1882 + signature = this.ParseComplianceDriveElement(child);
1883 + break;
1884 + case "ComponentSearch":
1885 + signature = this.ParseComponentSearchElement(child);
1886 + break;
1887 + case "DirectorySearch":
1888 + signature = this.ParseDirectorySearchElement(child, String.Empty);
1889 + break;
1890 + case "DirectorySearchRef":
1891 + signature = this.ParseDirectorySearchRefElement(child, String.Empty);
1892 + break;
1893 + case "IniFileSearch":
1894 + signature = this.ParseIniFileSearchElement(child);
1895 + break;
1896 + case "ProductSearch":
1897 + // handled in ParsePropertyElement
1898 + break;
1899 + case "RegistrySearch":
1900 + signature = this.ParseRegistrySearchElement(child);
1901 + break;
1902 + case "RegistrySearchRef":
1903 + signature = this.ParseRegistrySearchRefElement(child);
1904 + break;
1905 + default:
1906 + this.Core.UnexpectedElement(node, child);
1907 + break;
1908 }
1909 }
1910 else
@@ -1933,36 +1929,36 @@ namespace WixToolset.Core
1929 /// <returns>Signature of nested search elements.</returns>
1930 private string ParseComplianceDriveElement(XElement node)
1931 {
1936 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
1932 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
1933 string signature = null;
1934
1939 - bool oneChild = false;
1940 - foreach (XElement child in node.Elements())
1935 + var oneChild = false;
1936 + foreach (var child in node.Elements())
1937 {
1938 if (CompilerCore.WixNamespace == child.Name.Namespace)
1939 {
1944 - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
1940 + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
1941 switch (child.Name.LocalName)
1942 {
1947 - case "DirectorySearch":
1948 - if (oneChild)
1949 - {
1950 - this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName));
1951 - }
1952 - oneChild = true;
1953 - signature = this.ParseDirectorySearchElement(child, "CCP_DRIVE");
1954 - break;
1955 - case "DirectorySearchRef":
1956 - if (oneChild)
1957 - {
1958 - this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName));
1959 - }
1960 - oneChild = true;
1961 - signature = this.ParseDirectorySearchRefElement(child, "CCP_DRIVE");
1962 - break;
1963 - default:
1964 - this.Core.UnexpectedElement(node, child);
1965 - break;
1943 + case "DirectorySearch":
1944 + if (oneChild)
1945 + {
1946 + this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName));
1947 + }
1948 + oneChild = true;
1949 + signature = this.ParseDirectorySearchElement(child, "CCP_DRIVE");
1950 + break;
1951 + case "DirectorySearchRef":
1952 + if (oneChild)
1953 + {
1954 + this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName));
1955 + }
1956 + oneChild = true;
1957 + signature = this.ParseDirectorySearchRefElement(child, "CCP_DRIVE");
1958 + break;
1959 + default:
1960 + this.Core.UnexpectedElement(node, child);
1961 + break;
1962 }
1963 }
1964 else
@@ -1985,17 +1981,17 @@ namespace WixToolset.Core
1981 /// <param name="node">Element to parse.</param>
1982 private void ParseComplianceCheckElement(XElement node)
1983 {
1988 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
1984 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
1985
1990 - foreach (XAttribute attrib in node.Attributes())
1986 + foreach (var attrib in node.Attributes())
1987 {
1988 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
1989 {
1990 switch (attrib.Name.LocalName)
1991 {
1996 - default:
1997 - this.Core.UnexpectedAttribute(node, attrib);
1998 - break;
1992 + default:
1993 + this.Core.UnexpectedAttribute(node, attrib);
1994 + break;
1995 }
1996 }
1997 else
@@ -2007,8 +2003,8 @@ namespace WixToolset.Core
2003 string signature = null;
2004
2005 // see if this property is used for appSearch
2010 - List<string> signatures = this.ParseSearchSignatures(node);
2011 - foreach (string sig in signatures)
2006 + var signatures = this.ParseSearchSignatures(node);
2007 + foreach (var sig in signatures)
2008 {
2009 // if we haven't picked a signature for this ComplianceCheck pick
2010 // this one
@@ -2048,137 +2044,137 @@ namespace WixToolset.Core
2044 [SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
2045 private void ParseComponentElement(XElement node, ComplexReferenceParentType parentType, string parentId, string parentLanguage, int diskId, string directoryId, string srcPath)
2046 {
2051 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
2047 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
2048
2053 - int bits = 0;
2054 - int comPlusBits = CompilerConstants.IntegerNotSet;
2049 + var bits = 0;
2050 + var comPlusBits = CompilerConstants.IntegerNotSet;
2051 string condition = null;
2056 - bool encounteredODBCDataSource = false;
2057 - bool explicitWin64 = false;
2058 - int files = 0;
2059 - string guid = "*";
2060 - string componentIdPlaceholder = String.Format(Compiler.DefaultComponentIdPlaceholderFormat, this.componentIdPlaceholdersResolver.VariableCount); // placeholder id for defaulting Component/@Id to keypath id.
2061 - string componentIdPlaceholderWixVariable = String.Format(Compiler.DefaultComponentIdPlaceholderWixVariableFormat, componentIdPlaceholder);
2062 - Identifier id = new Identifier(componentIdPlaceholderWixVariable, AccessModifier.Private);
2063 - int keyBits = 0;
2064 - bool keyFound = false;
2052 + var encounteredODBCDataSource = false;
2053 + var explicitWin64 = false;
2054 + var files = 0;
2055 + var guid = "*";
2056 + var componentIdPlaceholder = String.Format(Compiler.DefaultComponentIdPlaceholderFormat, this.componentIdPlaceholdersResolver.VariableCount); // placeholder id for defaulting Component/@Id to keypath id.
2057 + var componentIdPlaceholderWixVariable = String.Format(Compiler.DefaultComponentIdPlaceholderWixVariableFormat, componentIdPlaceholder);
2058 + var id = new Identifier(componentIdPlaceholderWixVariable, AccessModifier.Private);
2059 + var keyBits = 0;
2060 + var keyFound = false;
2061 string keyPath = null;
2066 - bool shouldAddCreateFolder = false;
2067 - bool win64 = false;
2068 - bool multiInstance = false;
2069 - List<string> symbols = new List<string>();
2062 + var shouldAddCreateFolder = false;
2063 + var win64 = false;
2064 + var multiInstance = false;
2065 + var symbols = new List<string>();
2066 string feature = null;
2067
2072 - foreach (XAttribute attrib in node.Attributes())
2068 + foreach (var attrib in node.Attributes())
2069 {
2070 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
2071 {
2072 switch (attrib.Name.LocalName)
2073 {
2078 - case "Id":
2079 - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
2080 - break;
2081 - case "ComPlusFlags":
2082 - comPlusBits = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue);
2083 - break;
2084 - case "DisableRegistryReflection":
2085 - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
2086 - {
2087 - bits |= MsiInterop.MsidbComponentAttributesDisableRegistryReflection;
2088 - }
2089 - break;
2090 - case "Directory":
2091 - directoryId = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, directoryId);
2092 - break;
2093 - case "DiskId":
2094 - diskId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue);
2095 - break;
2096 - case "Feature":
2097 - feature = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
2098 - break;
2099 - case "Guid":
2100 - guid = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, true, true);
2101 - break;
2102 - case "KeyPath":
2103 - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
2104 - {
2105 - keyFound = true;
2106 - keyPath = null;
2107 - keyBits = 0;
2108 - shouldAddCreateFolder = true;
2109 - }
2110 - break;
2111 - case "Location":
2112 - string location = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
2113 - if (0 < location.Length)
2114 - {
2115 - Wix.Component.LocationType locationType = Wix.Component.ParseLocationType(location);
2116 - switch (locationType)
2117 - {
2118 - case Wix.Component.LocationType.either:
2119 - bits |= MsiInterop.MsidbComponentAttributesOptional;
2120 - break;
2121 - case Wix.Component.LocationType.local: // this is the default
2122 - break;
2123 - case Wix.Component.LocationType.source:
2124 - bits |= MsiInterop.MsidbComponentAttributesSourceOnly;
2125 - break;
2126 - default:
2127 - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "either", "local", "source"));
2128 - break;
2129 - }
2130 - }
2131 - break;
2132 - case "MultiInstance":
2133 - multiInstance = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
2134 - break;
2135 - case "NeverOverwrite":
2136 - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
2137 - {
2138 - bits |= MsiInterop.MsidbComponentAttributesNeverOverwrite;
2139 - }
2140 - break;
2141 - case "Permanent":
2142 - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
2143 - {
2144 - bits |= MsiInterop.MsidbComponentAttributesPermanent;
2145 - }
2146 - break;
2147 - case "Shared":
2148 - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
2149 - {
2150 - bits |= MsiInterop.MsidbComponentAttributesShared;
2151 - }
2152 - break;
2153 - case "SharedDllRefCount":
2154 - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
2155 - {
2156 - bits |= MsiInterop.MsidbComponentAttributesSharedDllRefCount;
2157 - }
2158 - break;
2159 - case "Transitive":
2160 - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
2161 - {
2162 - bits |= MsiInterop.MsidbComponentAttributesTransitive;
2163 - }
2164 - break;
2165 - case "UninstallWhenSuperseded":
2166 - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
2167 - {
2168 - bits |= MsiInterop.MsidbComponentAttributesUninstallOnSupersedence;
2169 - }
2170 - break;
2171 - case "Win64":
2172 - explicitWin64 = true;
2173 - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
2074 + case "Id":
2075 + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
2076 + break;
2077 + case "ComPlusFlags":
2078 + comPlusBits = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue);
2079 + break;
2080 + case "DisableRegistryReflection":
2081 + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
2082 + {
2083 + bits |= MsiInterop.MsidbComponentAttributesDisableRegistryReflection;
2084 + }
2085 + break;
2086 + case "Directory":
2087 + directoryId = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, directoryId);
2088 + break;
2089 + case "DiskId":
2090 + diskId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, Int16.MaxValue);
2091 + break;
2092 + case "Feature":
2093 + feature = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
2094 + break;
2095 + case "Guid":
2096 + guid = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, true, true);
2097 + break;
2098 + case "KeyPath":
2099 + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
2100 + {
2101 + keyFound = true;
2102 + keyPath = null;
2103 + keyBits = 0;
2104 + shouldAddCreateFolder = true;
2105 + }
2106 + break;
2107 + case "Location":
2108 + var location = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
2109 + if (0 < location.Length)
2110 + {
2111 + var locationType = Wix.Component.ParseLocationType(location);
2112 + switch (locationType)
2113 {
2175 - bits |= MsiInterop.MsidbComponentAttributes64bit;
2176 - win64 = true;
2114 + case Wix.Component.LocationType.either:
2115 + bits |= MsiInterop.MsidbComponentAttributesOptional;
2116 + break;
2117 + case Wix.Component.LocationType.local: // this is the default
2118 + break;
2119 + case Wix.Component.LocationType.source:
2120 + bits |= MsiInterop.MsidbComponentAttributesSourceOnly;
2121 + break;
2122 + default:
2123 + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "either", "local", "source"));
2124 + break;
2125 }
2178 - break;
2179 - default:
2180 - this.Core.UnexpectedAttribute(node, attrib);
2181 - break;
2126 + }
2127 + break;
2128 + case "MultiInstance":
2129 + multiInstance = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
2130 + break;
2131 + case "NeverOverwrite":
2132 + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
2133 + {
2134 + bits |= MsiInterop.MsidbComponentAttributesNeverOverwrite;
2135 + }
2136 + break;
2137 + case "Permanent":
2138 + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
2139 + {
2140 + bits |= MsiInterop.MsidbComponentAttributesPermanent;
2141 + }
2142 + break;
2143 + case "Shared":
2144 + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
2145 + {
2146 + bits |= MsiInterop.MsidbComponentAttributesShared;
2147 + }
2148 + break;
2149 + case "SharedDllRefCount":
2150 + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
2151 + {
2152 + bits |= MsiInterop.MsidbComponentAttributesSharedDllRefCount;
2153 + }
2154 + break;
2155 + case "Transitive":
2156 + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
2157 + {
2158 + bits |= MsiInterop.MsidbComponentAttributesTransitive;
2159 + }
2160 + break;
2161 + case "UninstallWhenSuperseded":
2162 + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
2163 + {
2164 + bits |= MsiInterop.MsidbComponentAttributesUninstallOnSupersedence;
2165 + }
2166 + break;
2167 + case "Win64":
2168 + explicitWin64 = true;
2169 + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
2170 + {
2171 + bits |= MsiInterop.MsidbComponentAttributes64bit;
2172 + win64 = true;
2173 + }
2174 + break;
2175 + default:
2176 + this.Core.UnexpectedAttribute(node, attrib);
2177 + break;
2178 }
2179 }
2180 else
@@ -2227,134 +2223,134 @@ namespace WixToolset.Core
2223 }
2224 }
2225
2230 - foreach (XElement child in node.Elements())
2226 + foreach (var child in node.Elements())
2227 {
2232 - YesNoType keyPathSet = YesNoType.NotSet;
2228 + var keyPathSet = YesNoType.NotSet;
2229 string keyPossible = null;
2234 - int keyBit = 0;
2230 + var keyBit = 0;
2231
2232 if (CompilerCore.WixNamespace == child.Name.Namespace)
2233 {
2234 switch (child.Name.LocalName)
2235 {
2240 - case "AppId":
2241 - this.ParseAppIdElement(child, id.Id, YesNoType.NotSet, null, null, null);
2242 - break;
2243 - case "Category":
2244 - this.ParseCategoryElement(child, id.Id);
2245 - break;
2246 - case "Class":
2247 - this.ParseClassElement(child, id.Id, YesNoType.NotSet, null, null, null, null);
2248 - break;
2249 - case "Condition":
2250 - if (null != condition)
2251 - {
2252 - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
2253 - this.Core.Write(ErrorMessages.TooManyChildren(childSourceLineNumbers, node.Name.LocalName, child.Name.LocalName));
2254 - }
2255 - condition = this.ParseConditionElement(child, node.Name.LocalName, null, null);
2256 - break;
2257 - case "CopyFile":
2258 - this.ParseCopyFileElement(child, id.Id, null);
2259 - break;
2260 - case "CreateFolder":
2261 - string createdFolder = this.ParseCreateFolderElement(child, id.Id, directoryId, win64);
2262 - if (directoryId == createdFolder)
2263 - {
2264 - shouldAddCreateFolder = false;
2265 - }
2266 - break;
2267 - case "Environment":
2268 - this.ParseEnvironmentElement(child, id.Id);
2269 - break;
2270 - case "Extension":
2271 - this.ParseExtensionElement(child, id.Id, YesNoType.NotSet, null);
2272 - break;
2273 - case "File":
2274 - keyPathSet = this.ParseFileElement(child, id.Id, directoryId, diskId, srcPath, out keyPossible, win64, guid);
2275 - if (null != keyPossible)
2276 - {
2277 - keyBit = 0;
2278 - }
2279 - files++;
2280 - break;
2281 - case "IniFile":
2282 - this.ParseIniFileElement(child, id.Id);
2283 - break;
2284 - case "Interface":
2285 - this.ParseInterfaceElement(child, id.Id, null, null, null, null);
2286 - break;
2287 - case "IsolateComponent":
2288 - this.ParseIsolateComponentElement(child, id.Id);
2289 - break;
2290 - case "ODBCDataSource":
2291 - keyPathSet = this.ParseODBCDataSource(child, id.Id, null, out keyPossible);
2292 - keyBit = MsiInterop.MsidbComponentAttributesODBCDataSource;
2293 - encounteredODBCDataSource = true;
2294 - break;
2295 - case "ODBCDriver":
2296 - this.ParseODBCDriverOrTranslator(child, id.Id, null, TupleDefinitionType.ODBCDriver);
2297 - break;
2298 - case "ODBCTranslator":
2299 - this.ParseODBCDriverOrTranslator(child, id.Id, null, TupleDefinitionType.ODBCTranslator);
2300 - break;
2301 - case "ProgId":
2302 - bool foundExtension = false;
2303 - this.ParseProgIdElement(child, id.Id, YesNoType.NotSet, null, null, null, ref foundExtension, YesNoType.NotSet);
2304 - break;
2305 - case "RegistryKey":
2306 - keyPathSet = this.ParseRegistryKeyElement(child, id.Id, CompilerConstants.IntegerNotSet, null, win64, out keyPossible);
2307 - keyBit = MsiInterop.MsidbComponentAttributesRegistryKeyPath;
2308 - break;
2309 - case "RegistryValue":
2310 - keyPathSet = this.ParseRegistryValueElement(child, id.Id, CompilerConstants.IntegerNotSet, null, win64, out keyPossible);
2311 - keyBit = MsiInterop.MsidbComponentAttributesRegistryKeyPath;
2312 - break;
2313 - case "RemoveFile":
2314 - this.ParseRemoveFileElement(child, id.Id, directoryId);
2315 - break;
2316 - case "RemoveFolder":
2317 - this.ParseRemoveFolderElement(child, id.Id, directoryId);
2318 - break;
2319 - case "RemoveRegistryKey":
2320 - this.ParseRemoveRegistryKeyElement(child, id.Id);
2321 - break;
2322 - case "RemoveRegistryValue":
2323 - this.ParseRemoveRegistryValueElement(child, id.Id);
2324 - break;
2325 - case "ReserveCost":
2326 - this.ParseReserveCostElement(child, id.Id, directoryId);
2327 - break;
2328 - case "ServiceConfig":
2329 - this.ParseServiceConfigElement(child, id.Id, null);
2330 - break;
2331 - case "ServiceConfigFailureActions":
2332 - this.ParseServiceConfigFailureActionsElement(child, id.Id, null);
2333 - break;
2334 - case "ServiceControl":
2335 - this.ParseServiceControlElement(child, id.Id);
2336 - break;
2337 - case "ServiceInstall":
2338 - this.ParseServiceInstallElement(child, id.Id, win64);
2339 - break;
2340 - case "Shortcut":
2341 - this.ParseShortcutElement(child, id.Id, node.Name.LocalName, directoryId, YesNoType.No);
2342 - break;
2343 - case "SymbolPath":
2344 - symbols.Add(this.ParseSymbolPathElement(child));
2345 - break;
2346 - case "TypeLib":
2347 - this.ParseTypeLibElement(child, id.Id, null, win64);
2348 - break;
2349 - default:
2350 - this.Core.UnexpectedElement(node, child);
2351 - break;
2236 + case "AppId":
2237 + this.ParseAppIdElement(child, id.Id, YesNoType.NotSet, null, null, null);
2238 + break;
2239 + case "Category":
2240 + this.ParseCategoryElement(child, id.Id);
2241 + break;
2242 + case "Class":
2243 + this.ParseClassElement(child, id.Id, YesNoType.NotSet, null, null, null, null);
2244 + break;
2245 + case "Condition":
2246 + if (null != condition)
2247 + {
2248 + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
2249 + this.Core.Write(ErrorMessages.TooManyChildren(childSourceLineNumbers, node.Name.LocalName, child.Name.LocalName));
2250 + }
2251 + condition = this.ParseConditionElement(child, node.Name.LocalName, null, null);
2252 + break;
2253 + case "CopyFile":
2254 + this.ParseCopyFileElement(child, id.Id, null);
2255 + break;
2256 + case "CreateFolder":
2257 + var createdFolder = this.ParseCreateFolderElement(child, id.Id, directoryId, win64);
2258 + if (directoryId == createdFolder)
2259 + {
2260 + shouldAddCreateFolder = false;
2261 + }
2262 + break;
2263 + case "Environment":
2264 + this.ParseEnvironmentElement(child, id.Id);
2265 + break;
2266 + case "Extension":
2267 + this.ParseExtensionElement(child, id.Id, YesNoType.NotSet, null);
2268 + break;
2269 + case "File":
2270 + keyPathSet = this.ParseFileElement(child, id.Id, directoryId, diskId, srcPath, out keyPossible, win64, guid);
2271 + if (null != keyPossible)
2272 + {
2273 + keyBit = 0;
2274 + }
2275 + files++;
2276 + break;
2277 + case "IniFile":
2278 + this.ParseIniFileElement(child, id.Id);
2279 + break;
2280 + case "Interface":
2281 + this.ParseInterfaceElement(child, id.Id, null, null, null, null);
2282 + break;
2283 + case "IsolateComponent":
2284 + this.ParseIsolateComponentElement(child, id.Id);
2285 + break;
2286 + case "ODBCDataSource":
2287 + keyPathSet = this.ParseODBCDataSource(child, id.Id, null, out keyPossible);
2288 + keyBit = MsiInterop.MsidbComponentAttributesODBCDataSource;
2289 + encounteredODBCDataSource = true;
2290 + break;
2291 + case "ODBCDriver":
2292 + this.ParseODBCDriverOrTranslator(child, id.Id, null, TupleDefinitionType.ODBCDriver);
2293 + break;
2294 + case "ODBCTranslator":
2295 + this.ParseODBCDriverOrTranslator(child, id.Id, null, TupleDefinitionType.ODBCTranslator);
2296 + break;
2297 + case "ProgId":
2298 + var foundExtension = false;
2299 + this.ParseProgIdElement(child, id.Id, YesNoType.NotSet, null, null, null, ref foundExtension, YesNoType.NotSet);
2300 + break;
2301 + case "RegistryKey":
2302 + keyPathSet = this.ParseRegistryKeyElement(child, id.Id, CompilerConstants.IntegerNotSet, null, win64, out keyPossible);
2303 + keyBit = MsiInterop.MsidbComponentAttributesRegistryKeyPath;
2304 + break;
2305 + case "RegistryValue":
2306 + keyPathSet = this.ParseRegistryValueElement(child, id.Id, CompilerConstants.IntegerNotSet, null, win64, out keyPossible);
2307 + keyBit = MsiInterop.MsidbComponentAttributesRegistryKeyPath;
2308 + break;
2309 + case "RemoveFile":
2310 + this.ParseRemoveFileElement(child, id.Id, directoryId);
2311 + break;
2312 + case "RemoveFolder":
2313 + this.ParseRemoveFolderElement(child, id.Id, directoryId);
2314 + break;
2315 + case "RemoveRegistryKey":
2316 + this.ParseRemoveRegistryKeyElement(child, id.Id);
2317 + break;
2318 + case "RemoveRegistryValue":
2319 + this.ParseRemoveRegistryValueElement(child, id.Id);
2320 + break;
2321 + case "ReserveCost":
2322 + this.ParseReserveCostElement(child, id.Id, directoryId);
2323 + break;
2324 + case "ServiceConfig":
2325 + this.ParseServiceConfigElement(child, id.Id, null);
2326 + break;
2327 + case "ServiceConfigFailureActions":
2328 + this.ParseServiceConfigFailureActionsElement(child, id.Id, null);
2329 + break;
2330 + case "ServiceControl":
2331 + this.ParseServiceControlElement(child, id.Id);
2332 + break;
2333 + case "ServiceInstall":
2334 + this.ParseServiceInstallElement(child, id.Id, win64);
2335 + break;
2336 + case "Shortcut":
2337 + this.ParseShortcutElement(child, id.Id, node.Name.LocalName, directoryId, YesNoType.No);
2338 + break;
2339 + case "SymbolPath":
2340 + symbols.Add(this.ParseSymbolPathElement(child));
2341 + break;
2342 + case "TypeLib":
2343 + this.ParseTypeLibElement(child, id.Id, null, win64);
2344 + break;
2345 + default:
2346 + this.Core.UnexpectedElement(node, child);
2347 + break;
2348 }
2349 }
2350 else
2351 {
2356 - Dictionary<string, string> context = new Dictionary<string, string>() { { "ComponentId", id.Id }, { "DirectoryId", directoryId }, { "Win64", win64.ToString() }, };
2357 - ComponentKeyPath possibleKeyPath = this.Core.ParsePossibleKeyPathExtensionElement(node, child, context);
2352 + var context = new Dictionary<string, string>() { { "ComponentId", id.Id }, { "DirectoryId", directoryId }, { "Win64", win64.ToString() }, };
2353 + var possibleKeyPath = this.Core.ParsePossibleKeyPathExtensionElement(node, child, context);
2354 if (null != possibleKeyPath)
2355 {
2356 if (ComponentKeyPathType.None == possibleKeyPath.Type)
@@ -2407,7 +2403,7 @@ namespace WixToolset.Core
2403 }
2404
2405 // check for conditions that exclude this component from using generated guids
2410 - bool isGeneratableGuidOk = "*" == guid;
2406 + var isGeneratableGuidOk = "*" == guid;
2407 if (isGeneratableGuidOk)
2408 {
2409 if (encounteredODBCDataSource)
@@ -2501,31 +2497,31 @@ namespace WixToolset.Core
2497 [SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
2498 private void ParseComponentGroupElement(XElement node, ComplexReferenceParentType parentType, string parentId)
2499 {
2504 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
2500 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
2501 Identifier id = null;
2502 string directoryId = null;
2503 string source = null;
2504
2509 - foreach (XAttribute attrib in node.Attributes())
2505 + foreach (var attrib in node.Attributes())
2506 {
2507 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
2508 {
2509 switch (attrib.Name.LocalName)
2510 {
2515 - case "Id":
2516 - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
2517 - break;
2518 - case "Directory":
2519 - // If the inline syntax is invalid it returns null. Use a static error identifier so the null
2520 - // directory identifier here doesn't trickle down false errors into child elements.
2521 - directoryId = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null) ?? "ErrorParsingInlineSyntax";
2522 - break;
2523 - case "Source":
2524 - source = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
2525 - break;
2526 - default:
2527 - this.Core.UnexpectedAttribute(node, attrib);
2528 - break;
2511 + case "Id":
2512 + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
2513 + break;
2514 + case "Directory":
2515 + // If the inline syntax is invalid it returns null. Use a static error identifier so the null
2516 + // directory identifier here doesn't trickle down false errors into child elements.
2517 + directoryId = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null) ?? "ErrorParsingInlineSyntax";
2518 + break;
2519 + case "Source":
2520 + source = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
2521 + break;
2522 + default:
2523 + this.Core.UnexpectedAttribute(node, attrib);
2524 + break;
2525 }
2526 }
2527 else
@@ -2545,24 +2541,24 @@ namespace WixToolset.Core
2541 source = String.Concat(source, Path.DirectorySeparatorChar);
2542 }
2543
2548 - foreach (XElement child in node.Elements())
2544 + foreach (var child in node.Elements())
2545 {
2546 if (CompilerCore.WixNamespace == child.Name.Namespace)
2547 {
2548 switch (child.Name.LocalName)
2549 {
2554 - case "ComponentGroupRef":
2555 - this.ParseComponentGroupRefElement(child, ComplexReferenceParentType.ComponentGroup, id.Id, null);
2556 - break;
2557 - case "ComponentRef":
2558 - this.ParseComponentRefElement(child, ComplexReferenceParentType.ComponentGroup, id.Id, null);
2559 - break;
2560 - case "Component":
2561 - this.ParseComponentElement(child, ComplexReferenceParentType.ComponentGroup, id.Id, null, CompilerConstants.IntegerNotSet, directoryId, source);
2562 - break;
2563 - default:
2564 - this.Core.UnexpectedElement(node, child);
2565 - break;
2550 + case "ComponentGroupRef":
2551 + this.ParseComponentGroupRefElement(child, ComplexReferenceParentType.ComponentGroup, id.Id, null);
2552 + break;
2553 + case "ComponentRef":
2554 + this.ParseComponentRefElement(child, ComplexReferenceParentType.ComponentGroup, id.Id, null);
2555 + break;
2556 + case "Component":
2557 + this.ParseComponentElement(child, ComplexReferenceParentType.ComponentGroup, id.Id, null, CompilerConstants.IntegerNotSet, directoryId, source);
2558 + break;
2559 + default:
2560 + this.Core.UnexpectedElement(node, child);
2561 + break;
2562 }
2563 }
2564 else
@@ -2591,26 +2587,26 @@ namespace WixToolset.Core
2587 {
2588 Debug.Assert(ComplexReferenceParentType.ComponentGroup == parentType || ComplexReferenceParentType.FeatureGroup == parentType || ComplexReferenceParentType.Feature == parentType || ComplexReferenceParentType.Module == parentType);
2589
2594 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
2590 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
2591 string id = null;
2596 - YesNoType primary = YesNoType.NotSet;
2592 + var primary = YesNoType.NotSet;
2593
2598 - foreach (XAttribute attrib in node.Attributes())
2594 + foreach (var attrib in node.Attributes())
2595 {
2596 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
2597 {
2598 switch (attrib.Name.LocalName)
2599 {
2604 - case "Id":
2605 - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
2606 - this.Core.CreateSimpleReference(sourceLineNumbers, "WixComponentGroup", id);
2607 - break;
2608 - case "Primary":
2609 - primary = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
2610 - break;
2611 - default:
2612 - this.Core.UnexpectedAttribute(node, attrib);
2613 - break;
2600 + case "Id":
2601 + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
2602 + this.Core.CreateSimpleReference(sourceLineNumbers, "WixComponentGroup", id);
2603 + break;
2604 + case "Primary":
2605 + primary = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
2606 + break;
2607 + default:
2608 + this.Core.UnexpectedAttribute(node, attrib);
2609 + break;
2610 }
2611 }
2612 else
@@ -2640,26 +2636,26 @@ namespace WixToolset.Core
2636 {
2637 Debug.Assert(ComplexReferenceParentType.FeatureGroup == parentType || ComplexReferenceParentType.ComponentGroup == parentType || ComplexReferenceParentType.Feature == parentType || ComplexReferenceParentType.Module == parentType);
2638
2643 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
2639 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
2640 string id = null;
2645 - YesNoType primary = YesNoType.NotSet;
2641 + var primary = YesNoType.NotSet;
2642
2647 - foreach (XAttribute attrib in node.Attributes())
2643 + foreach (var attrib in node.Attributes())
2644 {
2645 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
2646 {
2647 switch (attrib.Name.LocalName)
2648 {
2653 - case "Id":
2654 - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
2655 - this.Core.CreateSimpleReference(sourceLineNumbers, "Component", id);
2656 - break;
2657 - case "Primary":
2658 - primary = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
2659 - break;
2660 - default:
2661 - this.Core.UnexpectedAttribute(node, attrib);
2662 - break;
2649 + case "Id":
2650 + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
2651 + this.Core.CreateSimpleReference(sourceLineNumbers, "Component", id);
2652 + break;
2653 + case "Primary":
2654 + primary = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
2655 + break;
2656 + default:
2657 + this.Core.UnexpectedAttribute(node, attrib);
2658 + break;
2659 }
2660 }
2661 else
@@ -2685,46 +2681,46 @@ namespace WixToolset.Core
2681 /// <returns>Signature for search element.</returns>
2682 private string ParseComponentSearchElement(XElement node)
2683 {
2688 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
2684 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
2685 Identifier id = null;
2686 string componentId = null;
2691 - int type = MsiInterop.MsidbLocatorTypeFileName;
2687 + var type = MsiInterop.MsidbLocatorTypeFileName;
2688 string signature = null;
2689
2694 - foreach (XAttribute attrib in node.Attributes())
2690 + foreach (var attrib in node.Attributes())
2691 {
2692 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
2693 {
2694 switch (attrib.Name.LocalName)
2695 {
2700 - case "Id":
2701 - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
2702 - break;
2703 - case "Guid":
2704 - componentId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
2705 - break;
2706 - case "Type":
2707 - string typeValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
2708 - if (0 < typeValue.Length)
2696 + case "Id":
2697 + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
2698 + break;
2699 + case "Guid":
2700 + componentId = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
2701 + break;
2702 + case "Type":
2703 + var typeValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
2704 + if (0 < typeValue.Length)
2705 + {
2706 + var typeType = Wix.ComponentSearch.ParseTypeType(typeValue);
2707 + switch (typeType)
2708 {
2710 - Wix.ComponentSearch.TypeType typeType = Wix.ComponentSearch.ParseTypeType(typeValue);
2711 - switch (typeType)
2712 - {
2713 - case Wix.ComponentSearch.TypeType.directory:
2714 - type = MsiInterop.MsidbLocatorTypeDirectory;
2715 - break;
2716 - case Wix.ComponentSearch.TypeType.file:
2717 - type = MsiInterop.MsidbLocatorTypeFileName;
2718 - break;
2719 - default:
2720 - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, typeValue, "directory", "file"));
2721 - break;
2722 - }
2709 + case Wix.ComponentSearch.TypeType.directory:
2710 + type = MsiInterop.MsidbLocatorTypeDirectory;
2711 + break;
2712 + case Wix.ComponentSearch.TypeType.file:
2713 + type = MsiInterop.MsidbLocatorTypeFileName;
2714 + break;
2715 + default:
2716 + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, typeValue, "directory", "file"));
2717 + break;
2718 }
2724 - break;
2725 - default:
2726 - this.Core.UnexpectedAttribute(node, attrib);
2727 - break;
2719 + }
2720 + break;
2721 + default:
2722 + this.Core.UnexpectedAttribute(node, attrib);
2723 + break;
2724 }
2725 }
2726 else
@@ -2739,53 +2735,53 @@ namespace WixToolset.Core
2735 }
2736
2737 signature = id.Id;
2742 - bool oneChild = false;
2743 - foreach (XElement child in node.Elements())
2738 + var oneChild = false;
2739 + foreach (var child in node.Elements())
2740 {
2741 if (CompilerCore.WixNamespace == child.Name.Namespace)
2742 {
2743 switch (child.Name.LocalName)
2744 {
2749 - case "DirectorySearch":
2750 - if (oneChild)
2751 - {
2752 - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
2753 - }
2754 - oneChild = true;
2745 + case "DirectorySearch":
2746 + if (oneChild)
2747 + {
2748 + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
2749 + }
2750 + oneChild = true;
2751
2756 - // directorysearch parentage should work like directory element, not the rest of the signature type because of the DrLocator.Parent column
2757 - signature = this.ParseDirectorySearchElement(child, id.Id);
2758 - break;
2759 - case "DirectorySearchRef":
2760 - if (oneChild)
2761 - {
2762 - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
2763 - }
2764 - oneChild = true;
2765 - signature = this.ParseDirectorySearchRefElement(child, id.Id);
2766 - break;
2767 - case "FileSearch":
2768 - if (oneChild)
2769 - {
2770 - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
2771 - }
2772 - oneChild = true;
2773 - signature = this.ParseFileSearchElement(child, id.Id, false, CompilerConstants.IntegerNotSet);
2774 - id = new Identifier(signature, AccessModifier.Private); // FileSearch signatures override parent signatures
2775 - break;
2776 - case "FileSearchRef":
2777 - if (oneChild)
2778 - {
2779 - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
2780 - }
2781 - oneChild = true;
2782 - string newId = this.ParseSimpleRefElement(child, "Signature"); // FileSearch signatures override parent signatures
2783 - id = new Identifier(newId, AccessModifier.Private);
2784 - signature = null;
2785 - break;
2786 - default:
2787 - this.Core.UnexpectedElement(node, child);
2788 - break;
2752 + // directorysearch parentage should work like directory element, not the rest of the signature type because of the DrLocator.Parent column
2753 + signature = this.ParseDirectorySearchElement(child, id.Id);
2754 + break;
2755 + case "DirectorySearchRef":
2756 + if (oneChild)
2757 + {
2758 + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
2759 + }
2760 + oneChild = true;
2761 + signature = this.ParseDirectorySearchRefElement(child, id.Id);
2762 + break;
2763 + case "FileSearch":
2764 + if (oneChild)
2765 + {
2766 + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
2767 + }
2768 + oneChild = true;
2769 + signature = this.ParseFileSearchElement(child, id.Id, false, CompilerConstants.IntegerNotSet);
2770 + id = new Identifier(signature, AccessModifier.Private); // FileSearch signatures override parent signatures
2771 + break;
2772 + case "FileSearchRef":
2773 + if (oneChild)
2774 + {
2775 + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
2776 + }
2777 + oneChild = true;
2778 + var newId = this.ParseSimpleRefElement(child, "Signature"); // FileSearch signatures override parent signatures
2779 + id = new Identifier(newId, AccessModifier.Private);
2780 + signature = null;
2781 + break;
2782 + default:
2783 + this.Core.UnexpectedElement(node, child);
2784 + break;
2785 }
2786 }
2787 else
@@ -2814,19 +2810,19 @@ namespace WixToolset.Core
2810 /// <returns>Identifier for the directory that will be created</returns>
2811 private string ParseCreateFolderElement(XElement node, string componentId, string directoryId, bool win64Component)
2812 {
2817 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
2818 - foreach (XAttribute attrib in node.Attributes())
2813 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
2814 + foreach (var attrib in node.Attributes())
2815 {
2816 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
2817 {
2818 switch (attrib.Name.LocalName)
2819 {
2824 - case "Directory":
2825 - directoryId = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, directoryId);
2826 - break;
2827 - default:
2828 - this.Core.UnexpectedAttribute(node, attrib);
2829 - break;
2820 + case "Directory":
2821 + directoryId = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, directoryId);
2822 + break;
2823 + default:
2824 + this.Core.UnexpectedAttribute(node, attrib);
2825 + break;
2826 }
2827 }
2828 else
@@ -2835,29 +2831,29 @@ namespace WixToolset.Core
2831 }
2832 }
2833
2838 - foreach (XElement child in node.Elements())
2834 + foreach (var child in node.Elements())
2835 {
2836 if (CompilerCore.WixNamespace == child.Name.Namespace)
2837 {
2838 switch (child.Name.LocalName)
2839 {
2844 - case "Shortcut":
2845 - this.ParseShortcutElement(child, componentId, node.Name.LocalName, directoryId, YesNoType.No);
2846 - break;
2847 - case "Permission":
2848 - this.ParsePermissionElement(child, directoryId, "CreateFolder");
2849 - break;
2850 - case "PermissionEx":
2851 - this.ParsePermissionExElement(child, directoryId, "CreateFolder");
2852 - break;
2853 - default:
2854 - this.Core.UnexpectedElement(node, child);
2855 - break;
2840 + case "Shortcut":
2841 + this.ParseShortcutElement(child, componentId, node.Name.LocalName, directoryId, YesNoType.No);
2842 + break;
2843 + case "Permission":
2844 + this.ParsePermissionElement(child, directoryId, "CreateFolder");
2845 + break;
2846 + case "PermissionEx":
2847 + this.ParsePermissionExElement(child, directoryId, "CreateFolder");
2848 + break;
2849 + default:
2850 + this.Core.UnexpectedElement(node, child);
2851 + break;
2852 }
2853 }
2854 else
2855 {
2860 - Dictionary<string, string> context = new Dictionary<string, string>() { { "DirectoryId", directoryId }, { "ComponentId", componentId }, { "Win64", win64Component.ToString() } };
2856 + var context = new Dictionary<string, string>() { { "DirectoryId", directoryId }, { "ComponentId", componentId }, { "Win64", win64Component.ToString() } };
2857 this.Core.ParseExtensionElement(node, child, context);
2858 }
2859 }
@@ -2880,9 +2876,9 @@ namespace WixToolset.Core
2876 /// <param name="fileId">Identifier of file to copy (null if moving the file).</param>
2877 private void ParseCopyFileElement(XElement node, string componentId, string fileId)
2878 {
2883 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
2879 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
2880 Identifier id = null;
2885 - bool delete = false;
2881 + var delete = false;
2882 string destinationDirectory = null;
2883 string destinationName = null;
2884 string destinationShortName = null;
@@ -2892,50 +2888,50 @@ namespace WixToolset.Core
2888 string sourceName = null;
2889 string sourceProperty = null;
2890
2895 - foreach (XAttribute attrib in node.Attributes())
2891 + foreach (var attrib in node.Attributes())
2892 {
2893 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
2894 {
2895 switch (attrib.Name.LocalName)
2896 {
2901 - case "Id":
2902 - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
2903 - break;
2904 - case "Delete":
2905 - delete = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
2906 - break;
2907 - case "DestinationDirectory":
2908 - destinationDirectory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null);
2909 - break;
2910 - case "DestinationName":
2911 - destinationName = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false);
2912 - break;
2913 - case "DestinationProperty":
2914 - destinationProperty = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
2915 - break;
2916 - case "DestinationShortName":
2917 - destinationShortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false);
2918 - break;
2919 - case "FileId":
2920 - if (null != fileId)
2921 - {
2922 - this.Core.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, node.Parent.Name.LocalName));
2923 - }
2924 - fileId = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
2925 - this.Core.CreateSimpleReference(sourceLineNumbers, "File", fileId);
2926 - break;
2927 - case "SourceDirectory":
2928 - sourceDirectory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null);
2929 - break;
2930 - case "SourceName":
2931 - sourceName = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
2932 - break;
2933 - case "SourceProperty":
2934 - sourceProperty = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
2935 - break;
2936 - default:
2937 - this.Core.UnexpectedAttribute(node, attrib);
2938 - break;
2897 + case "Id":
2898 + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
2899 + break;
2900 + case "Delete":
2901 + delete = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
2902 + break;
2903 + case "DestinationDirectory":
2904 + destinationDirectory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null);
2905 + break;
2906 + case "DestinationName":
2907 + destinationName = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false);
2908 + break;
2909 + case "DestinationProperty":
2910 + destinationProperty = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
2911 + break;
2912 + case "DestinationShortName":
2913 + destinationShortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false);
2914 + break;
2915 + case "FileId":
2916 + if (null != fileId)
2917 + {
2918 + this.Core.Write(ErrorMessages.IllegalAttributeWhenNested(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, node.Parent.Name.LocalName));
2919 + }
2920 + fileId = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
2921 + this.Core.CreateSimpleReference(sourceLineNumbers, "File", fileId);
2922 + break;
2923 + case "SourceDirectory":
2924 + sourceDirectory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null);
2925 + break;
2926 + case "SourceName":
2927 + sourceName = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
2928 + break;
2929 + case "SourceProperty":
2930 + sourceProperty = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
2931 + break;
2932 + default:
2933 + this.Core.UnexpectedAttribute(node, attrib);
2934 + break;
2935 }
2936 }
2937 else
@@ -2990,7 +2986,7 @@ namespace WixToolset.Core
2986 var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.MoveFile, id);
2987 row.Set(1, componentId);
2988 row.Set(2, sourceName);
2993 - row.Set(3, String.IsNullOrEmpty(destinationShortName) && String.IsNullOrEmpty(destinationName) ? null : GetMsiFilenameValue(destinationShortName, destinationName));
2989 + row.Set(3, String.IsNullOrEmpty(destinationShortName) && String.IsNullOrEmpty(destinationName) ? null : this.GetMsiFilenameValue(destinationShortName, destinationName));
2990 if (null != sourceDirectory)
2991 {
2992 row.Set(4, sourceDirectory);
@@ -3052,7 +3048,7 @@ namespace WixToolset.Core
3048 var row = this.Core.CreateRow(sourceLineNumbers, TupleDefinitionType.DuplicateFile, id);
3049 row.Set(1, componentId);
3050 row.Set(2, fileId);
3055 - row.Set(3, String.IsNullOrEmpty(destinationShortName) && String.IsNullOrEmpty(destinationName) ? null : GetMsiFilenameValue(destinationShortName, destinationName));
3051 + row.Set(3, String.IsNullOrEmpty(destinationShortName) && String.IsNullOrEmpty(destinationName) ? null : this.GetMsiFilenameValue(destinationShortName, destinationName));
3052 if (null != destinationDirectory)
3053 {
3054 row.Set(4, destinationDirectory);
@@ -3071,264 +3067,264 @@ namespace WixToolset.Core
3067 /// <param name="node">Element to parse.</param>
3068 private void ParseCustomActionElement(XElement node)
3069 {
3074 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
3070 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
3071 Identifier id = null;
3076 - int bits = 0;
3077 - int extendedBits = 0;
3078 - bool inlineScript = false;
3072 + var bits = 0;
3073 + var extendedBits = 0;
3074 + var inlineScript = false;
3075 string innerText = null;
3076 string source = null;
3081 - int sourceBits = 0;
3082 - YesNoType suppressModularization = YesNoType.NotSet;
3077 + var sourceBits = 0;
3078 + var suppressModularization = YesNoType.NotSet;
3079 string target = null;
3084 - int targetBits = 0;
3085 - bool explicitWin64 = false;
3080 + var targetBits = 0;
3081 + var explicitWin64 = false;
3082
3087 - foreach (XAttribute attrib in node.Attributes())
3083 + foreach (var attrib in node.Attributes())
3084 {
3085 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
3086 {
3087 switch (attrib.Name.LocalName)
3088 {
3093 - case "Id":
3094 - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
3095 - break;
3096 - case "BinaryKey":
3097 - if (null != source)
3098 - {
3099 - this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script"));
3100 - }
3101 - source = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
3102 - sourceBits = MsiInterop.MsidbCustomActionTypeBinaryData;
3103 - this.Core.CreateSimpleReference(sourceLineNumbers, "Binary", source); // add a reference to the appropriate Binary
3104 - break;
3105 - case "Directory":
3106 - if (null != source)
3107 - {
3108 - this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script"));
3109 - }
3110 - source = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null);
3111 - sourceBits = MsiInterop.MsidbCustomActionTypeDirectory;
3112 - break;
3113 - case "DllEntry":
3114 - if (null != target)
3115 - {
3116 - this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall"));
3117 - }
3118 - target = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
3119 - targetBits = MsiInterop.MsidbCustomActionTypeDll;
3120 - break;
3121 - case "Error":
3122 - if (null != target)
3123 - {
3124 - this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall"));
3125 - }
3126 - target = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
3127 - targetBits = MsiInterop.MsidbCustomActionTypeTextData | MsiInterop.MsidbCustomActionTypeSourceFile;
3089 + case "Id":
3090 + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
3091 + break;
3092 + case "BinaryKey":
3093 + if (null != source)
3094 + {
3095 + this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script"));
3096 + }
3097 + source = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
3098 + sourceBits = MsiInterop.MsidbCustomActionTypeBinaryData;
3099 + this.Core.CreateSimpleReference(sourceLineNumbers, "Binary", source); // add a reference to the appropriate Binary
3100 + break;
3101 + case "Directory":
3102 + if (null != source)
3103 + {
3104 + this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script"));
3105 + }
3106 + source = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null);
3107 + sourceBits = MsiInterop.MsidbCustomActionTypeDirectory;
3108 + break;
3109 + case "DllEntry":
3110 + if (null != target)
3111 + {
3112 + this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall"));
3113 + }
3114 + target = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
3115 + targetBits = MsiInterop.MsidbCustomActionTypeDll;
3116 + break;
3117 + case "Error":
3118 + if (null != target)
3119 + {
3120 + this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall"));
3121 + }
3122 + target = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
3123 + targetBits = MsiInterop.MsidbCustomActionTypeTextData | MsiInterop.MsidbCustomActionTypeSourceFile;
3124
3129 - bool errorReference = true;
3125 + var errorReference = true;
3126
3131 - try
3132 - {
3133 - // The target can be either a formatted error string or a literal
3134 - // error number. Try to convert to error number to determine whether
3135 - // to add a reference. No need to look at the value.
3136 - Convert.ToInt32(target, CultureInfo.InvariantCulture.NumberFormat);
3137 - }
3138 - catch (FormatException)
3139 - {
3140 - errorReference = false;
3141 - }
3142 - catch (OverflowException)
3143 - {
3144 - errorReference = false;
3145 - }
3127 + try
3128 + {
3129 + // The target can be either a formatted error string or a literal
3130 + // error number. Try to convert to error number to determine whether
3131 + // to add a reference. No need to look at the value.
3132 + Convert.ToInt32(target, CultureInfo.InvariantCulture.NumberFormat);
3133 + }
3134 + catch (FormatException)
3135 + {
3136 + errorReference = false;
3137 + }
3138 + catch (OverflowException)
3139 + {
3140 + errorReference = false;
3141 + }
3142
3147 - if (errorReference)
3148 - {
3149 - this.Core.CreateSimpleReference(sourceLineNumbers, "Error", target);
3150 - }
3151 - break;
3152 - case "ExeCommand":
3153 - if (null != target)
3154 - {
3155 - this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall"));
3156 - }
3157 - target = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); // one of the few cases where an empty string value is valid
3158 - targetBits = MsiInterop.MsidbCustomActionTypeExe;
3159 - break;
3160 - case "Execute":
3161 - string execute = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
3162 - if (0 < execute.Length)
3143 + if (errorReference)
3144 + {
3145 + this.Core.CreateSimpleReference(sourceLineNumbers, "Error", target);
3146 + }
3147 + break;
3148 + case "ExeCommand":
3149 + if (null != target)
3150 + {
3151 + this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall"));
3152 + }
3153 + target = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); // one of the few cases where an empty string value is valid
3154 + targetBits = MsiInterop.MsidbCustomActionTypeExe;
3155 + break;
3156 + case "Execute":
3157 + var execute = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
3158 + if (0 < execute.Length)
3159 + {
3160 + var executeType = Wix.CustomAction.ParseExecuteType(execute);
3161 + switch (executeType)
3162 {
3164 - Wix.CustomAction.ExecuteType executeType = Wix.CustomAction.ParseExecuteType(execute);
3165 - switch (executeType)
3166 - {
3167 - case Wix.CustomAction.ExecuteType.commit:
3168 - bits |= MsiInterop.MsidbCustomActionTypeInScript | MsiInterop.MsidbCustomActionTypeCommit;
3169 - break;
3170 - case Wix.CustomAction.ExecuteType.deferred:
3171 - bits |= MsiInterop.MsidbCustomActionTypeInScript;
3172 - break;
3173 - case Wix.CustomAction.ExecuteType.firstSequence:
3174 - bits |= MsiInterop.MsidbCustomActionTypeFirstSequence;
3175 - break;
3176 - case Wix.CustomAction.ExecuteType.immediate:
3177 - break;
3178 - case Wix.CustomAction.ExecuteType.oncePerProcess:
3179 - bits |= MsiInterop.MsidbCustomActionTypeOncePerProcess;
3180 - break;
3181 - case Wix.CustomAction.ExecuteType.rollback:
3182 - bits |= MsiInterop.MsidbCustomActionTypeInScript | MsiInterop.MsidbCustomActionTypeRollback;
3183 - break;
3184 - case Wix.CustomAction.ExecuteType.secondSequence:
3185 - bits |= MsiInterop.MsidbCustomActionTypeClientRepeat;
3186 - break;
3187 - default:
3188 - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, execute, "commit", "deferred", "firstSequence", "immediate", "oncePerProcess", "rollback", "secondSequence"));
3189 - break;
3190 - }
3191 - }
3192 - break;
3193 - case "FileKey":
3194 - if (null != source)
3195 - {
3196 - this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script"));
3197 - }
3198 - source = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
3199 - sourceBits = MsiInterop.MsidbCustomActionTypeSourceFile;
3200 - this.Core.CreateSimpleReference(sourceLineNumbers, "File", source); // add a reference to the appropriate File
3201 - break;
3202 - case "HideTarget":
3203 - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
3204 - {
3205 - bits |= MsiInterop.MsidbCustomActionTypeHideTarget;
3206 - }
3207 - break;
3208 - case "Impersonate":
3209 - if (YesNoType.No == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
3210 - {
3211 - bits |= MsiInterop.MsidbCustomActionTypeNoImpersonate;
3212 - }
3213 - break;
3214 - case "JScriptCall":
3215 - if (null != target)
3216 - {
3217 - this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall"));
3218 - }
3219 - target = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); // one of the few cases where an empty string value is valid
3220 - targetBits = MsiInterop.MsidbCustomActionTypeJScript;
3221 - break;
3222 - case "PatchUninstall":
3223 - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
3224 - {
3225 - extendedBits |= MsiInterop.MsidbCustomActionTypePatchUninstall;
3226 - }
3227 - break;
3228 - case "Property":
3229 - if (null != source)
3230 - {
3231 - this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script"));
3232 - }
3233 - source = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
3234 - sourceBits = MsiInterop.MsidbCustomActionTypeProperty;
3235 - break;
3236 - case "Return":
3237 - string returnValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
3238 - if (0 < returnValue.Length)
3239 - {
3240 - Wix.CustomAction.ReturnType returnType = Wix.CustomAction.ParseReturnType(returnValue);
3241 - switch (returnType)
3242 - {
3243 - case Wix.CustomAction.ReturnType.asyncNoWait:
3244 - bits |= MsiInterop.MsidbCustomActionTypeAsync | MsiInterop.MsidbCustomActionTypeContinue;
3245 - break;
3246 - case Wix.CustomAction.ReturnType.asyncWait:
3247 - bits |= MsiInterop.MsidbCustomActionTypeAsync;
3248 - break;
3249 - case Wix.CustomAction.ReturnType.check:
3250 - break;
3251 - case Wix.CustomAction.ReturnType.ignore:
3252 - bits |= MsiInterop.MsidbCustomActionTypeContinue;
3253 - break;
3254 - default:
3255 - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, returnValue, "asyncNoWait", "asyncWait", "check", "ignore"));
3256 - break;
3257 - }
3163 + case Wix.CustomAction.ExecuteType.commit:
3164 + bits |= MsiInterop.MsidbCustomActionTypeInScript | MsiInterop.MsidbCustomActionTypeCommit;
3165 + break;
3166 + case Wix.CustomAction.ExecuteType.deferred:
3167 + bits |= MsiInterop.MsidbCustomActionTypeInScript;
3168 + break;
3169 + case Wix.CustomAction.ExecuteType.firstSequence:
3170 + bits |= MsiInterop.MsidbCustomActionTypeFirstSequence;
3171 + break;
3172 + case Wix.CustomAction.ExecuteType.immediate:
3173 + break;
3174 + case Wix.CustomAction.ExecuteType.oncePerProcess:
3175 + bits |= MsiInterop.MsidbCustomActionTypeOncePerProcess;
3176 + break;
3177 + case Wix.CustomAction.ExecuteType.rollback:
3178 + bits |= MsiInterop.MsidbCustomActionTypeInScript | MsiInterop.MsidbCustomActionTypeRollback;
3179 + break;
3180 + case Wix.CustomAction.ExecuteType.secondSequence:
3181 + bits |= MsiInterop.MsidbCustomActionTypeClientRepeat;
3182 + break;
3183 + default:
3184 + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, execute, "commit", "deferred", "firstSequence", "immediate", "oncePerProcess", "rollback", "secondSequence"));
3185 + break;
3186 }
3259 - break;
3260 - case "Script":
3261 - if (null != source)
3187 + }
3188 + break;
3189 + case "FileKey":
3190 + if (null != source)
3191 + {
3192 + this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script"));
3193 + }
3194 + source = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
3195 + sourceBits = MsiInterop.MsidbCustomActionTypeSourceFile;
3196 + this.Core.CreateSimpleReference(sourceLineNumbers, "File", source); // add a reference to the appropriate File
3197 + break;
3198 + case "HideTarget":
3199 + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
3200 + {
3201 + bits |= MsiInterop.MsidbCustomActionTypeHideTarget;
3202 + }
3203 + break;
3204 + case "Impersonate":
3205 + if (YesNoType.No == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
3206 + {
3207 + bits |= MsiInterop.MsidbCustomActionTypeNoImpersonate;
3208 + }
3209 + break;
3210 + case "JScriptCall":
3211 + if (null != target)
3212 + {
3213 + this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall"));
3214 + }
3215 + target = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); // one of the few cases where an empty string value is valid
3216 + targetBits = MsiInterop.MsidbCustomActionTypeJScript;
3217 + break;
3218 + case "PatchUninstall":
3219 + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
3220 + {
3221 + extendedBits |= MsiInterop.MsidbCustomActionTypePatchUninstall;
3222 + }
3223 + break;
3224 + case "Property":
3225 + if (null != source)
3226 + {
3227 + this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script"));
3228 + }
3229 + source = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
3230 + sourceBits = MsiInterop.MsidbCustomActionTypeProperty;
3231 + break;
3232 + case "Return":
3233 + var returnValue = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
3234 + if (0 < returnValue.Length)
3235 + {
3236 + var returnType = Wix.CustomAction.ParseReturnType(returnValue);
3237 + switch (returnType)
3238 {
3263 - this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script"));
3239 + case Wix.CustomAction.ReturnType.asyncNoWait:
3240 + bits |= MsiInterop.MsidbCustomActionTypeAsync | MsiInterop.MsidbCustomActionTypeContinue;
3241 + break;
3242 + case Wix.CustomAction.ReturnType.asyncWait:
3243 + bits |= MsiInterop.MsidbCustomActionTypeAsync;
3244 + break;
3245 + case Wix.CustomAction.ReturnType.check:
3246 + break;
3247 + case Wix.CustomAction.ReturnType.ignore:
3248 + bits |= MsiInterop.MsidbCustomActionTypeContinue;
3249 + break;
3250 + default:
3251 + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, returnValue, "asyncNoWait", "asyncWait", "check", "ignore"));
3252 + break;
3253 }
3254 + }
3255 + break;
3256 + case "Script":
3257 + if (null != source)
3258 + {
3259 + this.Core.Write(ErrorMessages.CustomActionMultipleSources(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "BinaryKey", "Directory", "FileKey", "Property", "Script"));
3260 + }
3261
3266 - if (null != target)
3267 - {
3268 - this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall"));
3269 - }
3262 + if (null != target)
3263 + {
3264 + this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall"));
3265 + }
3266
3271 - // set the source and target to empty string for error messages when the user sets multiple sources or targets
3272 - source = string.Empty;
3273 - target = string.Empty;
3267 + // set the source and target to empty string for error messages when the user sets multiple sources or targets
3268 + source = String.Empty;
3269 + target = String.Empty;
3270
3275 - inlineScript = true;
3271 + inlineScript = true;
3272
3277 - string script = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
3278 - if (0 < script.Length)
3279 - {
3280 - Wix.CustomAction.ScriptType scriptType = Wix.CustomAction.ParseScriptType(script);
3281 - switch (scriptType)
3282 - {
3283 - case Wix.CustomAction.ScriptType.jscript:
3284 - sourceBits = MsiInterop.MsidbCustomActionTypeDirectory;
3285 - targetBits = MsiInterop.MsidbCustomActionTypeJScript;
3286 - break;
3287 - case Wix.CustomAction.ScriptType.vbscript:
3288 - sourceBits = MsiInterop.MsidbCustomActionTypeDirectory;
3289 - targetBits = MsiInterop.MsidbCustomActionTypeVBScript;
3290 - break;
3291 - default:
3292 - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, script, "jscript", "vbscript"));
3293 - break;
3294 - }
3295 - }
3296 - break;
3297 - case "SuppressModularization":
3298 - suppressModularization = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
3299 - break;
3300 - case "TerminalServerAware":
3301 - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
3302 - {
3303 - bits |= MsiInterop.MsidbCustomActionTypeTSAware;
3304 - }
3305 - break;
3306 - case "Value":
3307 - if (null != target)
3308 - {
3309 - this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall"));
3310 - }
3311 - target = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); // one of the few cases where an empty string value is valid
3312 - targetBits = MsiInterop.MsidbCustomActionTypeTextData;
3313 - break;
3314 - case "VBScriptCall":
3315 - if (null != target)
3316 - {
3317 - this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall"));
3318 - }
3319 - target = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); // one of the few cases where an empty string value is valid
3320 - targetBits = MsiInterop.MsidbCustomActionTypeVBScript;
3321 - break;
3322 - case "Win64":
3323 - explicitWin64 = true;
3324 - if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
3273 + var script = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
3274 + if (0 < script.Length)
3275 + {
3276 + var scriptType = Wix.CustomAction.ParseScriptType(script);
3277 + switch (scriptType)
3278 {
3326 - bits |= MsiInterop.MsidbCustomActionType64BitScript;
3279 + case Wix.CustomAction.ScriptType.jscript:
3280 + sourceBits = MsiInterop.MsidbCustomActionTypeDirectory;
3281 + targetBits = MsiInterop.MsidbCustomActionTypeJScript;
3282 + break;
3283 + case Wix.CustomAction.ScriptType.vbscript:
3284 + sourceBits = MsiInterop.MsidbCustomActionTypeDirectory;
3285 + targetBits = MsiInterop.MsidbCustomActionTypeVBScript;
3286 + break;
3287 + default:
3288 + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, script, "jscript", "vbscript"));
3289 + break;
3290 }
3328 - break;
3329 - default:
3330 - this.Core.UnexpectedAttribute(node, attrib);
3331 - break;
3291 + }
3292 + break;
3293 + case "SuppressModularization":
3294 + suppressModularization = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
3295 + break;
3296 + case "TerminalServerAware":
3297 + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
3298 + {
3299 + bits |= MsiInterop.MsidbCustomActionTypeTSAware;
3300 + }
3301 + break;
3302 + case "Value":
3303 + if (null != target)
3304 + {
3305 + this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall"));
3306 + }
3307 + target = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); // one of the few cases where an empty string value is valid
3308 + targetBits = MsiInterop.MsidbCustomActionTypeTextData;
3309 + break;
3310 + case "VBScriptCall":
3311 + if (null != target)
3312 + {
3313 + this.Core.Write(ErrorMessages.CustomActionMultipleTargets(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, "DllEntry", "Error", "ExeCommand", "JScriptCall", "Script", "Value", "VBScriptCall"));
3314 + }
3315 + target = this.Core.GetAttributeValue(sourceLineNumbers, attrib, EmptyRule.CanBeEmpty); // one of the few cases where an empty string value is valid
3316 + targetBits = MsiInterop.MsidbCustomActionTypeVBScript;
3317 + break;
3318 + case "Win64":
3319 + explicitWin64 = true;
3320 + if (YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib))
3321 + {
3322 + bits |= MsiInterop.MsidbCustomActionType64BitScript;
3323 + }
3324 + break;
3325 + default:
3326 + this.Core.UnexpectedAttribute(node, attrib);
3327 + break;
3328 }
3329 }
3330 else
@@ -3461,22 +3457,22 @@ namespace WixToolset.Core
3457 /// <returns>Id of the referenced element.</returns>
3458 private string ParseSimpleRefElement(XElement node, string table)
3459 {
3464 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
3460 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
3461 string id = null;
3462
3467 - foreach (XAttribute attrib in node.Attributes())
3463 + foreach (var attrib in node.Attributes())
3464 {
3465 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
3466 {
3467 switch (attrib.Name.LocalName)
3468 {
3473 - case "Id":
3474 - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
3475 - this.Core.CreateSimpleReference(sourceLineNumbers, table, id);
3476 - break;
3477 - default:
3478 - this.Core.UnexpectedAttribute(node, attrib);
3479 - break;
3469 + case "Id":
3470 + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
3471 + this.Core.CreateSimpleReference(sourceLineNumbers, table, id);
3472 + break;
3473 + default:
3474 + this.Core.UnexpectedAttribute(node, attrib);
3475 + break;
3476 }
3477 }
3478 else
@@ -3504,24 +3500,24 @@ namespace WixToolset.Core
3500 /// <returns>Id of the referenced element.</returns>
3501 private void ParsePatchFamilyRefElement(XElement node, ComplexReferenceParentType parentType, string parentId)
3502 {
3507 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
3508 - string[] primaryKeys = new string[2];
3503 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
3504 + var primaryKeys = new string[2];
3505
3510 - foreach (XAttribute attrib in node.Attributes())
3506 + foreach (var attrib in node.Attributes())
3507 {
3508 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
3509 {
3510 switch (attrib.Name.LocalName)
3511 {
3516 - case "Id":
3517 - primaryKeys[0] = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
3518 - break;
3519 - case "ProductCode":
3520 - primaryKeys[1] = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
3521 - break;
3522 - default:
3523 - this.Core.UnexpectedAttribute(node, attrib);
3524 - break;
3512 + case "Id":
3513 + primaryKeys[0] = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
3514 + break;
3515 + case "ProductCode":
3516 + primaryKeys[1] = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
3517 + break;
3518 + default:
3519 + this.Core.UnexpectedAttribute(node, attrib);
3520 + break;
3521 }
3522 }
3523 else
@@ -3552,21 +3548,21 @@ namespace WixToolset.Core
3548 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
3549 private void ParsePatchFamilyGroupElement(XElement node, ComplexReferenceParentType parentType, string parentId)
3550 {
3555 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
3551 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
3552 Identifier id = null;
3553
3558 - foreach (XAttribute attrib in node.Attributes())
3554 + foreach (var attrib in node.Attributes())
3555 {
3556 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
3557 {
3558 switch (attrib.Name.LocalName)
3559 {
3564 - case "Id":
3565 - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
3566 - break;
3567 - default:
3568 - this.Core.UnexpectedAttribute(node, attrib);
3569 - break;
3560 + case "Id":
3561 + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
3562 + break;
3563 + default:
3564 + this.Core.UnexpectedAttribute(node, attrib);
3565 + break;
3566 }
3567 }
3568 else
@@ -3581,24 +3577,24 @@ namespace WixToolset.Core
3577 id = Identifier.Invalid;
3578 }
3579
3584 - foreach (XElement child in node.Elements())
3580 + foreach (var child in node.Elements())
3581 {
3582 if (CompilerCore.WixNamespace == child.Name.Namespace)
3583 {
3584 switch (child.Name.LocalName)
3585 {
3590 - case "PatchFamily":
3591 - this.ParsePatchFamilyElement(child, ComplexReferenceParentType.PatchFamilyGroup, id.Id);
3592 - break;
3593 - case "PatchFamilyRef":
3594 - this.ParsePatchFamilyRefElement(child, ComplexReferenceParentType.PatchFamilyGroup, id.Id);
3595 - break;
3596 - case "PatchFamilyGroupRef":
3597 - this.ParsePatchFamilyGroupRefElement(child, ComplexReferenceParentType.PatchFamilyGroup, id.Id);
3598 - break;
3599 - default:
3600 - this.Core.UnexpectedElement(node, child);
3601 - break;
3586 + case "PatchFamily":
3587 + this.ParsePatchFamilyElement(child, ComplexReferenceParentType.PatchFamilyGroup, id.Id);
3588 + break;
3589 + case "PatchFamilyRef":
3590 + this.ParsePatchFamilyRefElement(child, ComplexReferenceParentType.PatchFamilyGroup, id.Id);
3591 + break;
3592 + case "PatchFamilyGroupRef":
3593 + this.ParsePatchFamilyGroupRefElement(child, ComplexReferenceParentType.PatchFamilyGroup, id.Id);
3594 + break;
3595 + default:
3596 + this.Core.UnexpectedElement(node, child);
3597 + break;
3598 }
3599 }
3600 else
@@ -3626,22 +3622,22 @@ namespace WixToolset.Core
3622 {
3623 Debug.Assert(ComplexReferenceParentType.PatchFamilyGroup == parentType || ComplexReferenceParentType.Patch == parentType);
3624
3629 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
3625 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
3626 string id = null;
3627
3632 - foreach (XAttribute attrib in node.Attributes())
3628 + foreach (var attrib in node.Attributes())
3629 {
3630 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
3631 {
3632 switch (attrib.Name.LocalName)
3633 {
3638 - case "Id":
3639 - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
3640 - this.Core.CreateSimpleReference(sourceLineNumbers, "WixPatchFamilyGroup", id);
3641 - break;
3642 - default:
3643 - this.Core.UnexpectedAttribute(node, attrib);
3644 - break;
3634 + case "Id":
3635 + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
3636 + this.Core.CreateSimpleReference(sourceLineNumbers, "WixPatchFamilyGroup", id);
3637 + break;
3638 + default:
3639 + this.Core.UnexpectedAttribute(node, attrib);
3640 + break;
3641 }
3642 }
3643 else
@@ -3669,21 +3665,21 @@ namespace WixToolset.Core
3665 /// <param name="node">Element to parse.</param>
3666 private void ParseEnsureTableElement(XElement node)
3667 {
3672 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
3668 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
3669 string id = null;
3670
3675 - foreach (XAttribute attrib in node.Attributes())
3671 + foreach (var attrib in node.Attributes())
3672 {
3673 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
3674 {
3675 switch (attrib.Name.LocalName)
3676 {
3681 - case "Id":
3682 - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
3683 - break;
3684 - default:
3685 - this.Core.UnexpectedAttribute(node, attrib);
3686 - break;
3677 + case "Id":
3678 + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
3679 + break;
3680 + default:
3681 + this.Core.UnexpectedAttribute(node, attrib);
3682 + break;
3683 }
3684 }
3685 else
@@ -3713,11 +3709,11 @@ namespace WixToolset.Core
3709 /// <remarks>not cleaned</remarks>
3710 private void ParseCustomTableElement(XElement node)
3711 {
3716 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
3712 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
3713 string tableId = null;
3714
3715 string categories = null;
3720 - int columnCount = 0;
3716 + var columnCount = 0;
3717 string columnNames = null;
3718 string columnTypes = null;
3719 string descriptions = null;
@@ -3728,23 +3724,23 @@ namespace WixToolset.Core
3724 string modularizations = null;
3725 string primaryKeys = null;
3726 string sets = null;
3731 - bool bootstrapperApplicationData = false;
3727 + var bootstrapperApplicationData = false;
3728
3733 - foreach (XAttribute attrib in node.Attributes())
3729 + foreach (var attrib in node.Attributes())
3730 {
3731 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
3732 {
3733 switch (attrib.Name.LocalName)
3734 {
3739 - case "Id":
3740 - tableId = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
3741 - break;
3742 - case "BootstrapperApplicationData":
3743 - bootstrapperApplicationData = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
3744 - break;
3745 - default:
3746 - this.Core.UnexpectedAttribute(node, attrib);
3747 - break;
3735 + case "Id":
3736 + tableId = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
3737 + break;
3738 + case "BootstrapperApplicationData":
3739 + bootstrapperApplicationData = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
3740 + break;
3741 + default:
3742 + this.Core.UnexpectedAttribute(node, attrib);
3743 + break;
3744 }
3745 }
3746 else
@@ -3762,203 +3758,203 @@ namespace WixToolset.Core
3758 this.Core.Write(ErrorMessages.CustomTableNameTooLong(sourceLineNumbers, node.Name.LocalName, "Id", tableId));
3759 }
3760
3765 - foreach (XElement child in node.Elements())
3761 + foreach (var child in node.Elements())
3762 {
3763 if (CompilerCore.WixNamespace == child.Name.Namespace)
3764 {
3769 - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child);
3765 + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child);
3766 switch (child.Name.LocalName)
3767 {
3772 - case "Column":
3773 - ++columnCount;
3774 -
3775 - string category = String.Empty;
3776 - string columnName = null;
3777 - string columnType = null;
3778 - string description = String.Empty;
3779 - int keyColumn = CompilerConstants.IntegerNotSet;
3780 - string keyTable = String.Empty;
3781 - bool localizable = false;
3782 - long maxValue = CompilerConstants.LongNotSet;
3783 - long minValue = CompilerConstants.LongNotSet;
3784 - string modularization = "None";
3785 - bool nullable = false;
3786 - bool primaryKey = false;
3787 - string setValues = String.Empty;
3788 - string typeName = null;
3789 - int width = 0;
3790 -
3791 - foreach (XAttribute childAttrib in child.Attributes())
3768 + case "Column":
3769 + ++columnCount;
3770 +
3771 + var category = String.Empty;
3772 + string columnName = null;
3773 + string columnType = null;
3774 + var description = String.Empty;
3775 + var keyColumn = CompilerConstants.IntegerNotSet;
3776 + var keyTable = String.Empty;
3777 + var localizable = false;
3778 + var maxValue = CompilerConstants.LongNotSet;
3779 + var minValue = CompilerConstants.LongNotSet;
3780 + var modularization = "None";
3781 + var nullable = false;
3782 + var primaryKey = false;
3783 + var setValues = String.Empty;
3784 + string typeName = null;
3785 + var width = 0;
3786 +
3787 + foreach (var childAttrib in child.Attributes())
3788 + {
3789 + switch (childAttrib.Name.LocalName)
3790 {
3793 - switch (childAttrib.Name.LocalName)
3791 + case "Id":
3792 + columnName = this.Core.GetAttributeIdentifierValue(childSourceLineNumbers, childAttrib);
3793 + break;
3794 + case "Category":
3795 + category = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib);
3796 + break;
3797 + case "Description":
3798 + description = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib);
3799 + break;
3800 + case "KeyColumn":
3801 + keyColumn = this.Core.GetAttributeIntegerValue(childSourceLineNumbers, childAttrib, 1, 32);
3802 + break;
3803 + case "KeyTable":
3804 + keyTable = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib);
3805 + break;
3806 + case "Localizable":
3807 + localizable = YesNoType.Yes == this.Core.GetAttributeYesNoValue(childSourceLineNumbers, childAttrib);
3808 + break;
3809 + case "MaxValue":
3810 + maxValue = this.Core.GetAttributeLongValue(childSourceLineNumbers, childAttrib, Int32.MinValue + 1, Int32.MaxValue);
3811 + break;
3812 + case "MinValue":
3813 + minValue = this.Core.GetAttributeLongValue(childSourceLineNumbers, childAttrib, Int32.MinValue + 1, Int32.MaxValue);
3814 + break;
3815 + case "Modularize":
3816 + modularization = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib);
3817 + break;
3818 + case "Nullable":
3819 + nullable = YesNoType.Yes == this.Core.GetAttributeYesNoValue(childSourceLineNumbers, childAttrib);
3820 + break;
3821 + case "PrimaryKey":
3822 + primaryKey = YesNoType.Yes == this.Core.GetAttributeYesNoValue(childSourceLineNumbers, childAttrib);
3823 + break;
3824 + case "Set":
3825 + setValues = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib);
3826 + break;
3827 + case "Type":
3828 + var typeValue = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib);
3829 + if (0 < typeValue.Length)
3830 {
3795 - case "Id":
3796 - columnName = this.Core.GetAttributeIdentifierValue(childSourceLineNumbers, childAttrib);
3797 - break;
3798 - case "Category":
3799 - category = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib);
3800 - break;
3801 - case "Description":
3802 - description = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib);
3803 - break;
3804 - case "KeyColumn":
3805 - keyColumn = this.Core.GetAttributeIntegerValue(childSourceLineNumbers, childAttrib, 1, 32);
3806 - break;
3807 - case "KeyTable":
3808 - keyTable = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib);
3809 - break;
3810 - case "Localizable":
3811 - localizable = YesNoType.Yes == this.Core.GetAttributeYesNoValue(childSourceLineNumbers, childAttrib);
3812 - break;
3813 - case "MaxValue":
3814 - maxValue = this.Core.GetAttributeLongValue(childSourceLineNumbers, childAttrib, int.MinValue + 1, int.MaxValue);
3815 - break;
3816 - case "MinValue":
3817 - minValue = this.Core.GetAttributeLongValue(childSourceLineNumbers, childAttrib, int.MinValue + 1, int.MaxValue);
3818 - break;
3819 - case "Modularize":
3820 - modularization = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib);
3821 - break;
3822 - case "Nullable":
3823 - nullable = YesNoType.Yes == this.Core.GetAttributeYesNoValue(childSourceLineNumbers, childAttrib);
3824 - break;
3825 - case "PrimaryKey":
3826 - primaryKey = YesNoType.Yes == this.Core.GetAttributeYesNoValue(childSourceLineNumbers, childAttrib);
3827 - break;
3828 - case "Set":
3829 - setValues = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib);
3831 + var typeType = Wix.Column.ParseTypeType(typeValue);
3832 + switch (typeType)
3833 + {
3834 + case Wix.Column.TypeType.binary:
3835 + typeName = "OBJECT";
3836 break;
3831 - case "Type":
3832 - string typeValue = this.Core.GetAttributeValue(childSourceLineNumbers, childAttrib);
3833 - if (0 < typeValue.Length)
3834 - {
3835 - Wix.Column.TypeType typeType = Wix.Column.ParseTypeType(typeValue);
3836 - switch (typeType)
3837 - {
3838 - case Wix.Column.TypeType.binary:
3839 - typeName = "OBJECT";
3840 - break;
3841 - case Wix.Column.TypeType.@int:
3842 - typeName = "SHORT";
3843 - break;
3844 - case Wix.Column.TypeType.@string:
3845 - typeName = "CHAR";
3846 - break;
3847 - default:
3848 - this.Core.Write(ErrorMessages.IllegalAttributeValue(childSourceLineNumbers, child.Name.LocalName, "Type", typeValue, "binary", "int", "string"));
3849 - break;
3850 - }
3851 - }
3837 + case Wix.Column.TypeType.@int:
3838 + typeName = "SHORT";
3839 break;
3853 - case "Width":
3854 - width = this.Core.GetAttributeIntegerValue(childSourceLineNumbers, childAttrib, 0, int.MaxValue);
3840 + case Wix.Column.TypeType.@string:
3841 + typeName = "CHAR";
3842 break;
3843 default:
3857 - this.Core.UnexpectedAttribute(child, childAttrib);
3844 + this.Core.Write(ErrorMessages.IllegalAttributeValue(childSourceLineNumbers, child.Name.LocalName, "Type", typeValue, "binary", "int", "string"));
3845 break;
3846 + }
3847 }
3848 + break;
3849 + case "Width":
3850 + width = this.Core.GetAttributeIntegerValue(childSourceLineNumbers, childAttrib, 0, Int32.MaxValue);
3851 + break;
3852 + default:
3853 + this.Core.UnexpectedAttribute(child, childAttrib);
3854 + break;
3855 }
3856 + }
3857
3862 - if (null == columnName)
3863 - {
3864 - this.Core.Write(ErrorMessages.ExpectedAttribute(childSourceLineNumbers, child.Name.LocalName, "Id"));
3865 - }
3858 + if (null == columnName)
3859 + {
3860 + this.Core.Write(ErrorMessages.ExpectedAttribute(childSourceLineNumbers, child.Name.LocalName, "Id"));
3861 + }
3862
3867 - if (null == typeName)
3868 - {
3869 - this.Core.Write(ErrorMessages.ExpectedAttribute(childSourceLineNumbers, child.Name.LocalName, "Type"));
3870 - }
3871 - else if ("SHORT" == typeName)
3872 - {
3873 - if (2 != width && 4 != width)
3874 - {
3875 - this.Core.Write(ErrorMessages.CustomTableIllegalColumnWidth(childSourceLineNumbers, child.Name.LocalName, "Width", width));
3876 - }
3877 - columnType = String.Concat(nullable ? "I" : "i", width);
3878 - }
3879 - else if ("CHAR" == typeName)
3863 + if (null == typeName)
3864 + {
3865 + this.Core.Write(ErrorMessages.ExpectedAttribute(childSourceLineNumbers, child.Name.LocalName, "Type"));
3866 + }
3867 + else if ("SHORT" == typeName)
3868 + {
3869 + if (2 != width && 4 != width)
3870 {
3881 - string typeChar = localizable ? "l" : "s";
3882 - columnType = String.Concat(nullable ? typeChar.ToUpper(CultureInfo.InvariantCulture) : typeChar.ToLower(CultureInfo.InvariantCulture), width);
3871 + this.Core.Write(ErrorMessages.CustomTableIllegalColumnWidth(childSourceLineNumbers, child.Name.LocalName, "Width", width));
3872 }
3884 - else if ("OBJECT" == typeName)
3873 + columnType = String.Concat(nullable ? "I" : "i", width);
3874 + }
3875 + else if ("CHAR" == typeName)
3876 + {
3877 + var typeChar = localizable ? "l" : "s";
3878 + columnType = String.Concat(nullable ? typeChar.ToUpper(CultureInfo.InvariantCulture) : typeChar.ToLower(CultureInfo.InvariantCulture), width);
3879 + }
3880 + else if ("OBJECT" == typeName)
3881 + {
3882 + if ("Binary" != category)
3883 {
3886 - if ("Binary" != category)
3887 - {
3888 - this.Core.Write(ErrorMessages.ExpectedBinaryCategory(childSourceLineNumbers));
3889 - }
3890 - columnType = String.Concat(nullable ? "V" : "v", width);
3884 + this.Core.Write(ErrorMessages.ExpectedBinaryCategory(childSourceLineNumbers));
3885 }
3886 + columnType = String.Concat(nullable ? "V" : "v", width);
3887 + }
3888
3893 - this.Core.ParseForExtensionElements(child);
3894 -
3895 - columnNames = String.Concat(columnNames, null == columnNames ? String.Empty : "\t", columnName);
3896 - columnTypes = String.Concat(columnTypes, null == columnTypes ? String.Empty : "\t", columnType);
3897 - if (primaryKey)
3898 - {
3899 - primaryKeys = String.Concat(primaryKeys, null == primaryKeys ? String.Empty : "\t", columnName);
3900 - }
3889 + this.Core.ParseForExtensionElements(child);
3890
3902 - minValues = String.Concat(minValues, null == minValues ? String.Empty : "\t", CompilerConstants.LongNotSet != minValue ? minValue.ToString(CultureInfo.InvariantCulture) : String.Empty);
3903 - maxValues = String.Concat(maxValues, null == maxValues ? String.Empty : "\t", CompilerConstants.LongNotSet != maxValue ? maxValue.ToString(CultureInfo.InvariantCulture) : String.Empty);
3904 - keyTables = String.Concat(keyTables, null == keyTables ? String.Empty : "\t", keyTable);
3905 - keyColumns = String.Concat(keyColumns, null == keyColumns ? String.Empty : "\t", CompilerConstants.IntegerNotSet != keyColumn ? keyColumn.ToString(CultureInfo.InvariantCulture) : String.Empty);
3906 - categories = String.Concat(categories, null == categories ? String.Empty : "\t", category);
3907 - sets = String.Concat(sets, null == sets ? String.Empty : "\t", setValues);
3908 - descriptions = String.Concat(descriptions, null == descriptions ? String.Empty : "\t", description);
3909 - modularizations = String.Concat(modularizations, null == modularizations ? String.Empty : "\t", modularization);
3891 + columnNames = String.Concat(columnNames, null == columnNames ? String.Empty : "\t", columnName);
3892 + columnTypes = String.Concat(columnTypes, null == columnTypes ? String.Empty : "\t", columnType);
3893 + if (primaryKey)
3894 + {
3895 + primaryKeys = String.Concat(primaryKeys, null == primaryKeys ? String.Empty : "\t", columnName);
3896 + }
3897
3911 - break;
3912 - case "Row":
3913 - string dataValue = null;
3898 + minValues = String.Concat(minValues, null == minValues ? String.Empty : "\t", CompilerConstants.LongNotSet != minValue ? minValue.ToString(CultureInfo.InvariantCulture) : String.Empty);
3899 + maxValues = String.Concat(maxValues, null == maxValues ? String.Empty : "\t", CompilerConstants.LongNotSet != maxValue ? maxValue.ToString(CultureInfo.InvariantCulture) : String.Empty);
3900 + keyTables = String.Concat(keyTables, null == keyTables ? String.Empty : "\t", keyTable);
3901 + keyColumns = String.Concat(keyColumns, null == keyColumns ? String.Empty : "\t", CompilerConstants.IntegerNotSet != keyColumn ? keyColumn.ToString(CultureInfo.InvariantCulture) : String.Empty);
3902 + categories = String.Concat(categories, null == categories ? String.Empty : "\t", category);
3903 + sets = String.Concat(sets, null == sets ? String.Empty : "\t", setValues);
3904 + descriptions = String.Concat(descriptions, null == descriptions ? String.Empty : "\t", description);
3905 + modularizations = String.Concat(modularizations, null == modularizations ? String.Empty : "\t", modularization);
3906
3915 - foreach (XAttribute childAttrib in child.Attributes())
3916 - {
3917 - this.Core.ParseExtensionAttribute(child, childAttrib);
3918 - }
3907 + break;
3908 + case "Row":
3909 + string dataValue = null;
3910
3920 - foreach (XElement data in child.Elements())
3911 + foreach (var childAttrib in child.Attributes())
3912 + {
3913 + this.Core.ParseExtensionAttribute(child, childAttrib);
3914 + }
3915 +
3916 + foreach (var data in child.Elements())
3917 + {
3918 + var dataSourceLineNumbers = Preprocessor.GetSourceLineNumbers(data);
3919 + switch (data.Name.LocalName)
3920 {
3922 - SourceLineNumber dataSourceLineNumbers = Preprocessor.GetSourceLineNumbers(data);
3923 - switch (data.Name.LocalName)
3921 + case "Data":
3922 + columnName = null;
3923 + foreach (var dataAttrib in data.Attributes())
3924 {
3925 - case "Data":
3926 - columnName = null;
3927 - foreach (XAttribute dataAttrib in data.Attributes())
3928 - {
3929 - switch (dataAttrib.Name.LocalName)
3930 - {
3931 - case "Column":
3932 - columnName = this.Core.GetAttributeValue(dataSourceLineNumbers, dataAttrib);
3933 - break;
3934 - default:
3935 - this.Core.UnexpectedAttribute(data, dataAttrib);
3936 - break;
3937 - }
3938 - }
3939 -
3940 - if (null == columnName)
3941 - {
3942 - this.Core.Write(ErrorMessages.ExpectedAttribute(dataSourceLineNumbers, data.Name.LocalName, "Column"));
3943 - }
3944 -
3945 - dataValue = String.Concat(dataValue, null == dataValue ? String.Empty : Common.CustomRowFieldSeparator.ToString(), columnName, ":", Common.GetInnerText(data));
3925 + switch (dataAttrib.Name.LocalName)
3926 + {
3927 + case "Column":
3928 + columnName = this.Core.GetAttributeValue(dataSourceLineNumbers, dataAttrib);
3929 + break;
3930 + default:
3931 + this.Core.UnexpectedAttribute(data, dataAttrib);
3932 break;
3933 + }
3934 }
3948 - }
3935
3950 - this.Core.CreateSimpleReference(sourceLineNumbers, "WixCustomTable", tableId);
3936 + if (null == columnName)
3937 + {
3938 + this.Core.Write(ErrorMessages.ExpectedAttribute(dataSourceLineNumbers, data.Name.LocalName, "Column"));
3939 + }
3940
3952 - if (!this.Core.EncounteredError)
3953 - {
3954 - var rowRow = this.Core.CreateRow(childSourceLineNumbers, TupleDefinitionType.WixCustomRow);
3955 - rowRow.Set(0, tableId);
3956 - rowRow.Set(1, dataValue);
3941 + dataValue = String.Concat(dataValue, null == dataValue ? String.Empty : Common.CustomRowFieldSeparator.ToString(), columnName, ":", Common.GetInnerText(data));
3942 + break;
3943 }
3958 - break;
3959 - default:
3960 - this.Core.UnexpectedElement(node, child);
3961 - break;
3944 + }
3945 +
3946 + this.Core.CreateSimpleReference(sourceLineNumbers, "WixCustomTable", tableId);
3947 +
3948 + if (!this.Core.EncounteredError)
3949 + {
3950 + var rowRow = this.Core.CreateRow(childSourceLineNumbers, TupleDefinitionType.WixCustomRow);
3951 + rowRow.Set(0, tableId);
3952 + rowRow.Set(1, dataValue);
3953 + }
3954 + break;
3955 + default:
3956 + this.Core.UnexpectedElement(node, child);
3957 + break;
3958 }
3959 }
3960 else
@@ -4005,12 +4001,12 @@ namespace WixToolset.Core
4001 [SuppressMessage("Microsoft.Performance", "CA1820:TestForEmptyStringsUsingStringLength")]
4002 private void ParseDirectoryElement(XElement node, string parentId, int diskId, string fileSource)
4003 {
4008 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
4004 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
4005 Identifier id = null;
4006 string componentGuidGenerationSeed = null;
4011 - bool fileSourceAttribSet = false;
4012 - bool nameHasValue = false;
4013 - string name = "."; // default to parent directory.
4007 + var fileSourceAttribSet = false;
4008 + var nameHasValue = false;
4009 + var name = "."; // default to parent directory.
4010 string[] inlineSyntax = null;
4011 string shortName = null;
4012 string sourceName = null;
@@ -4018,55 +4014,55 @@ namespace WixToolset.Core
4014 string defaultDir = null;
4015 string symbols = null;
4016
4021 - foreach (XAttribute attrib in node.Attributes())
4017 + foreach (var attrib in node.Attributes())
4018 {
4019 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
4020 {
4021 switch (attrib.Name.LocalName)
4022 {
4027 - case "Id":
4028 - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
4029 - break;
4030 - case "ComponentGuidGenerationSeed":
4031 - componentGuidGenerationSeed = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
4032 - break;
4033 - case "DiskId":
4034 - diskId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue);
4035 - break;
4036 - case "FileSource":
4037 - fileSource = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4038 - fileSourceAttribSet = true;
4039 - break;
4040 - case "Name":
4041 - nameHasValue = true;
4042 - if (attrib.Value.Equals("."))
4043 - {
4044 - name = attrib.Value;
4045 - }
4046 - else
4047 - {
4048 - inlineSyntax = this.Core.GetAttributeInlineDirectorySyntax(sourceLineNumbers, attrib);
4049 - }
4050 - break;
4051 - case "ShortName":
4052 - shortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false);
4053 - break;
4054 - case "ShortSourceName":
4055 - shortSourceName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false);
4056 - break;
4057 - case "SourceName":
4058 - if ("." == attrib.Value)
4059 - {
4060 - sourceName = attrib.Value;
4061 - }
4062 - else
4063 - {
4064 - sourceName = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false);
4065 - }
4066 - break;
4067 - default:
4068 - this.Core.UnexpectedAttribute(node, attrib);
4069 - break;
4023 + case "Id":
4024 + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
4025 + break;
4026 + case "ComponentGuidGenerationSeed":
4027 + componentGuidGenerationSeed = this.Core.GetAttributeGuidValue(sourceLineNumbers, attrib, false);
4028 + break;
4029 + case "DiskId":
4030 + diskId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, Int16.MaxValue);
4031 + break;
4032 + case "FileSource":
4033 + fileSource = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4034 + fileSourceAttribSet = true;
4035 + break;
4036 + case "Name":
4037 + nameHasValue = true;
4038 + if (attrib.Value.Equals("."))
4039 + {
4040 + name = attrib.Value;
4041 + }
4042 + else
4043 + {
4044 + inlineSyntax = this.Core.GetAttributeInlineDirectorySyntax(sourceLineNumbers, attrib);
4045 + }
4046 + break;
4047 + case "ShortName":
4048 + shortName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false);
4049 + break;
4050 + case "ShortSourceName":
4051 + shortSourceName = this.Core.GetAttributeShortFilename(sourceLineNumbers, attrib, false);
4052 + break;
4053 + case "SourceName":
4054 + if ("." == attrib.Value)
4055 + {
4056 + sourceName = attrib.Value;
4057 + }
4058 + else
4059 + {
4060 + sourceName = this.Core.GetAttributeLongFilename(sourceLineNumbers, attrib, false);
4061 + }
4062 + break;
4063 + default:
4064 + this.Core.UnexpectedAttribute(node, attrib);
4065 + break;
4066 }
4067 }
4068 else
@@ -4086,7 +4082,7 @@ namespace WixToolset.Core
4082 }
4083 else
4084 {
4089 - int pathStartsAt = 0;
4085 + var pathStartsAt = 0;
4086 if (inlineSyntax[0].EndsWith(":"))
4087 {
4088 parentId = inlineSyntax[0].TrimEnd(':');
@@ -4095,9 +4091,9 @@ namespace WixToolset.Core
4091 pathStartsAt = 1;
4092 }
4093
4098 - for (int i = pathStartsAt; i < inlineSyntax.Length - 1; ++i)
4094 + for (var i = pathStartsAt; i < inlineSyntax.Length - 1; ++i)
4095 {
4100 - Identifier inlineId = this.Core.CreateDirectoryRow(sourceLineNumbers, null, parentId, inlineSyntax[i]);
4096 + var inlineId = this.Core.CreateDirectoryRow(sourceLineNumbers, null, parentId, inlineSyntax[i]);
4097 parentId = inlineId.Id;
4098 }
4099
@@ -4206,34 +4202,34 @@ namespace WixToolset.Core
4202 this.Core.Write(ErrorMessages.IllegalTargetDirDefaultDir(sourceLineNumbers, defaultDir));
4203 }
4204
4209 - foreach (XElement child in node.Elements())
4205 + foreach (var child in node.Elements())
4206 {
4207 if (CompilerCore.WixNamespace == child.Name.Namespace)
4208 {
4209 switch (child.Name.LocalName)
4210 {
4215 - case "Component":
4216 - this.ParseComponentElement(child, ComplexReferenceParentType.Unknown, null, null, diskId, id.Id, fileSource);
4217 - break;
4218 - case "Directory":
4219 - this.ParseDirectoryElement(child, id.Id, diskId, fileSource);
4220 - break;
4221 - case "Merge":
4222 - this.ParseMergeElement(child, id.Id, diskId);
4223 - break;
4224 - case "SymbolPath":
4225 - if (null != symbols)
4226 - {
4227 - symbols += ";" + this.ParseSymbolPathElement(child);
4228 - }
4229 - else
4230 - {
4231 - symbols = this.ParseSymbolPathElement(child);
4232 - }
4233 - break;
4234 - default:
4235 - this.Core.UnexpectedElement(node, child);
4236 - break;
4211 + case "Component":
4212 + this.ParseComponentElement(child, ComplexReferenceParentType.Unknown, null, null, diskId, id.Id, fileSource);
4213 + break;
4214 + case "Directory":
4215 + this.ParseDirectoryElement(child, id.Id, diskId, fileSource);
4216 + break;
4217 + case "Merge":
4218 + this.ParseMergeElement(child, id.Id, diskId);
4219 + break;
4220 + case "SymbolPath":
4221 + if (null != symbols)
4222 + {
4223 + symbols += ";" + this.ParseSymbolPathElement(child);
4224 + }
4225 + else
4226 + {
4227 + symbols = this.ParseSymbolPathElement(child);
4228 + }
4229 + break;
4230 + default:
4231 + this.Core.UnexpectedElement(node, child);
4232 + break;
4233 }
4234 }
4235 else
@@ -4271,30 +4267,30 @@ namespace WixToolset.Core
4267 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
4268 private void ParseDirectoryRefElement(XElement node)
4269 {
4274 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
4270 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
4271 string id = null;
4276 - int diskId = CompilerConstants.IntegerNotSet;
4277 - string fileSource = String.Empty;
4272 + var diskId = CompilerConstants.IntegerNotSet;
4273 + var fileSource = String.Empty;
4274
4279 - foreach (XAttribute attrib in node.Attributes())
4275 + foreach (var attrib in node.Attributes())
4276 {
4277 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
4278 {
4279 switch (attrib.Name.LocalName)
4280 {
4285 - case "Id":
4286 - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
4287 - this.Core.CreateSimpleReference(sourceLineNumbers, "Directory", id);
4288 - break;
4289 - case "DiskId":
4290 - diskId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, short.MaxValue);
4291 - break;
4292 - case "FileSource":
4293 - fileSource = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4294 - break;
4295 - default:
4296 - this.Core.UnexpectedAttribute(node, attrib);
4297 - break;
4281 + case "Id":
4282 + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
4283 + this.Core.CreateSimpleReference(sourceLineNumbers, "Directory", id);
4284 + break;
4285 + case "DiskId":
4286 + diskId = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 1, Int16.MaxValue);
4287 + break;
4288 + case "FileSource":
4289 + fileSource = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4290 + break;
4291 + default:
4292 + this.Core.UnexpectedAttribute(node, attrib);
4293 + break;
4294 }
4295 }
4296 else
@@ -4313,24 +4309,24 @@ namespace WixToolset.Core
4309 fileSource = String.Concat(fileSource, Path.DirectorySeparatorChar);
4310 }
4311
4316 - foreach (XElement child in node.Elements())
4312 + foreach (var child in node.Elements())
4313 {
4314 if (CompilerCore.WixNamespace == child.Name.Namespace)
4315 {
4316 switch (child.Name.LocalName)
4317 {
4322 - case "Component":
4323 - this.ParseComponentElement(child, ComplexReferenceParentType.Unknown, null, null, diskId, id, fileSource);
4324 - break;
4325 - case "Directory":
4326 - this.ParseDirectoryElement(child, id, diskId, fileSource);
4327 - break;
4328 - case "Merge":
4329 - this.ParseMergeElement(child, id, diskId);
4330 - break;
4331 - default:
4332 - this.Core.UnexpectedElement(node, child);
4333 - break;
4318 + case "Component":
4319 + this.ParseComponentElement(child, ComplexReferenceParentType.Unknown, null, null, diskId, id, fileSource);
4320 + break;
4321 + case "Directory":
4322 + this.ParseDirectoryElement(child, id, diskId, fileSource);
4323 + break;
4324 + case "Merge":
4325 + this.ParseMergeElement(child, id, diskId);
4326 + break;
4327 + default:
4328 + this.Core.UnexpectedElement(node, child);
4329 + break;
4330 }
4331 }
4332 else
@@ -4348,34 +4344,34 @@ namespace WixToolset.Core
4344 /// <returns>Signature of search element.</returns>
4345 private string ParseDirectorySearchElement(XElement node, string parentSignature)
4346 {
4351 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
4347 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
4348 Identifier id = null;
4353 - int depth = CompilerConstants.IntegerNotSet;
4349 + var depth = CompilerConstants.IntegerNotSet;
4350 string path = null;
4355 - bool assignToProperty = false;
4351 + var assignToProperty = false;
4352 string signature = null;
4353
4358 - foreach (XAttribute attrib in node.Attributes())
4354 + foreach (var attrib in node.Attributes())
4355 {
4356 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
4357 {
4358 switch (attrib.Name.LocalName)
4359 {
4364 - case "Id":
4365 - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
4366 - break;
4367 - case "Depth":
4368 - depth = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue);
4369 - break;
4370 - case "Path":
4371 - path = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4372 - break;
4373 - case "AssignToProperty":
4374 - assignToProperty = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
4375 - break;
4376 - default:
4377 - this.Core.UnexpectedAttribute(node, attrib);
4378 - break;
4360 + case "Id":
4361 + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
4362 + break;
4363 + case "Depth":
4364 + depth = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue);
4365 + break;
4366 + case "Path":
4367 + path = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4368 + break;
4369 + case "AssignToProperty":
4370 + assignToProperty = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
4371 + break;
4372 + default:
4373 + this.Core.UnexpectedAttribute(node, attrib);
4374 + break;
4375 }
4376 }
4377 else
@@ -4391,51 +4387,51 @@ namespace WixToolset.Core
4387
4388 signature = id.Id;
4389
4394 - bool oneChild = false;
4395 - bool hasFileSearch = false;
4396 - foreach (XElement child in node.Elements())
4390 + var oneChild = false;
4391 + var hasFileSearch = false;
4392 + foreach (var child in node.Elements())
4393 {
4394 if (CompilerCore.WixNamespace == child.Name.Namespace)
4395 {
4400 - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child);
4396 + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child);
4397 switch (child.Name.LocalName)
4398 {
4403 - case "DirectorySearch":
4404 - if (oneChild)
4405 - {
4406 - this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName));
4407 - }
4408 - oneChild = true;
4409 - signature = this.ParseDirectorySearchElement(child, id.Id);
4410 - break;
4411 - case "DirectorySearchRef":
4412 - if (oneChild)
4413 - {
4414 - this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName));
4415 - }
4416 - oneChild = true;
4417 - signature = this.ParseDirectorySearchRefElement(child, id.Id);
4418 - break;
4419 - case "FileSearch":
4420 - if (oneChild)
4421 - {
4422 - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
4423 - }
4424 - oneChild = true;
4425 - hasFileSearch = true;
4426 - signature = this.ParseFileSearchElement(child, id.Id, assignToProperty, depth);
4427 - break;
4428 - case "FileSearchRef":
4429 - if (oneChild)
4430 - {
4431 - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
4432 - }
4433 - oneChild = true;
4434 - signature = this.ParseSimpleRefElement(child, "Signature");
4435 - break;
4436 - default:
4437 - this.Core.UnexpectedElement(node, child);
4438 - break;
4399 + case "DirectorySearch":
4400 + if (oneChild)
4401 + {
4402 + this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName));
4403 + }
4404 + oneChild = true;
4405 + signature = this.ParseDirectorySearchElement(child, id.Id);
4406 + break;
4407 + case "DirectorySearchRef":
4408 + if (oneChild)
4409 + {
4410 + this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName));
4411 + }
4412 + oneChild = true;
4413 + signature = this.ParseDirectorySearchRefElement(child, id.Id);
4414 + break;
4415 + case "FileSearch":
4416 + if (oneChild)
4417 + {
4418 + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
4419 + }
4420 + oneChild = true;
4421 + hasFileSearch = true;
4422 + signature = this.ParseFileSearchElement(child, id.Id, assignToProperty, depth);
4423 + break;
4424 + case "FileSearchRef":
4425 + if (oneChild)
4426 + {
4427 + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
4428 + }
4429 + oneChild = true;
4430 + signature = this.ParseSimpleRefElement(child, "Signature");
4431 + break;
4432 + default:
4433 + this.Core.UnexpectedElement(node, child);
4434 + break;
4435 }
4436
4437 // If AssignToProperty is set, only a FileSearch
@@ -4497,30 +4493,30 @@ namespace WixToolset.Core
4493 /// <returns>Signature of search element.</returns>
4494 private string ParseDirectorySearchRefElement(XElement node, string parentSignature)
4495 {
4500 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
4496 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
4497 Identifier id = null;
4498 Identifier parent = null;
4499 string path = null;
4500 string signature = null;
4501
4506 - foreach (XAttribute attrib in node.Attributes())
4502 + foreach (var attrib in node.Attributes())
4503 {
4504 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
4505 {
4506 switch (attrib.Name.LocalName)
4507 {
4512 - case "Id":
4513 - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
4514 - break;
4515 - case "Parent":
4516 - parent = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
4517 - break;
4518 - case "Path":
4519 - path = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4520 - break;
4521 - default:
4522 - this.Core.UnexpectedAttribute(node, attrib);
4523 - break;
4508 + case "Id":
4509 + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
4510 + break;
4511 + case "Parent":
4512 + parent = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
4513 + break;
4514 + case "Path":
4515 + path = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4516 + break;
4517 + default:
4518 + this.Core.UnexpectedAttribute(node, attrib);
4519 + break;
4520 }
4521 }
4522 else
@@ -4548,49 +4544,49 @@ namespace WixToolset.Core
4544
4545 signature = id.Id;
4546
4551 - bool oneChild = false;
4552 - foreach (XElement child in node.Elements())
4547 + var oneChild = false;
4548 + foreach (var child in node.Elements())
4549 {
4550 if (CompilerCore.WixNamespace == child.Name.Namespace)
4551 {
4556 - SourceLineNumber childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child);
4552 + var childSourceLineNumbers = Preprocessor.GetSourceLineNumbers(child);
4553 switch (child.Name.LocalName)
4554 {
4559 - case "DirectorySearch":
4560 - if (oneChild)
4561 - {
4562 - this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName));
4563 - }
4564 - oneChild = true;
4565 - signature = this.ParseDirectorySearchElement(child, id.Id);
4566 - break;
4567 - case "DirectorySearchRef":
4568 - if (oneChild)
4569 - {
4570 - this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName));
4571 - }
4572 - oneChild = true;
4573 - signature = this.ParseDirectorySearchRefElement(child, id.Id);
4574 - break;
4575 - case "FileSearch":
4576 - if (oneChild)
4577 - {
4578 - this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName));
4579 - }
4580 - oneChild = true;
4581 - signature = this.ParseFileSearchElement(child, id.Id, false, CompilerConstants.IntegerNotSet);
4582 - break;
4583 - case "FileSearchRef":
4584 - if (oneChild)
4585 - {
4586 - this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
4587 - }
4588 - oneChild = true;
4589 - signature = this.ParseSimpleRefElement(child, "Signature");
4590 - break;
4591 - default:
4592 - this.Core.UnexpectedElement(node, child);
4593 - break;
4555 + case "DirectorySearch":
4556 + if (oneChild)
4557 + {
4558 + this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName));
4559 + }
4560 + oneChild = true;
4561 + signature = this.ParseDirectorySearchElement(child, id.Id);
4562 + break;
4563 + case "DirectorySearchRef":
4564 + if (oneChild)
4565 + {
4566 + this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName));
4567 + }
4568 + oneChild = true;
4569 + signature = this.ParseDirectorySearchRefElement(child, id.Id);
4570 + break;
4571 + case "FileSearch":
4572 + if (oneChild)
4573 + {
4574 + this.Core.Write(ErrorMessages.TooManySearchElements(childSourceLineNumbers, node.Name.LocalName));
4575 + }
4576 + oneChild = true;
4577 + signature = this.ParseFileSearchElement(child, id.Id, false, CompilerConstants.IntegerNotSet);
4578 + break;
4579 + case "FileSearchRef":
4580 + if (oneChild)
4581 + {
4582 + this.Core.Write(ErrorMessages.TooManySearchElements(sourceLineNumbers, node.Name.LocalName));
4583 + }
4584 + oneChild = true;
4585 + signature = this.ParseSimpleRefElement(child, "Signature");
4586 + break;
4587 + default:
4588 + this.Core.UnexpectedElement(node, child);
4589 + break;
4590 }
4591 }
4592 else
@@ -4616,132 +4612,132 @@ namespace WixToolset.Core
4612 [SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
4613 private void ParseFeatureElement(XElement node, ComplexReferenceParentType parentType, string parentId, ref int lastDisplay)
4614 {
4619 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
4615 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
4616 Identifier id = null;
4617 string allowAdvertise = null;
4622 - int bits = 0;
4618 + var bits = 0;
4619 string configurableDirectory = null;
4620 string description = null;
4625 - string display = "collapse";
4626 - YesNoType followParent = YesNoType.NotSet;
4621 + var display = "collapse";
4622 + var followParent = YesNoType.NotSet;
4623 string installDefault = null;
4628 - int level = 1;
4624 + var level = 1;
4625 string title = null;
4626 string typicalDefault = null;
4627
4632 - foreach (XAttribute attrib in node.Attributes())
4628 + foreach (var attrib in node.Attributes())
4629 {
4630 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
4631 {
4632 switch (attrib.Name.LocalName)
4633 {
4638 - case "Id":
4639 - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
4640 - break;
4641 - case "Absent":
4642 - string absent = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4643 - if (0 < absent.Length)
4634 + case "Id":
4635 + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
4636 + break;
4637 + case "Absent":
4638 + var absent = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4639 + if (0 < absent.Length)
4640 + {
4641 + var absentType = Wix.Feature.ParseAbsentType(absent);
4642 + switch (absentType)
4643 {
4645 - Wix.Feature.AbsentType absentType = Wix.Feature.ParseAbsentType(absent);
4646 - switch (absentType)
4647 - {
4648 - case Wix.Feature.AbsentType.allow: // this is the default
4649 - break;
4650 - case Wix.Feature.AbsentType.disallow:
4651 - bits = bits | MsiInterop.MsidbFeatureAttributesUIDisallowAbsent;
4652 - break;
4653 - default:
4654 - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, absent, "allow", "disallow"));
4655 - break;
4656 - }
4644 + case Wix.Feature.AbsentType.allow: // this is the default
4645 + break;
4646 + case Wix.Feature.AbsentType.disallow:
4647 + bits = bits | MsiInterop.MsidbFeatureAttributesUIDisallowAbsent;
4648 + break;
4649 + default:
4650 + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, absent, "allow", "disallow"));
4651 + break;
4652 }
4658 - break;
4659 - case "AllowAdvertise":
4660 - allowAdvertise = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4661 - if (0 < allowAdvertise.Length)
4653 + }
4654 + break;
4655 + case "AllowAdvertise":
4656 + allowAdvertise = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4657 + if (0 < allowAdvertise.Length)
4658 + {
4659 + var allowAdvertiseType = Wix.Feature.ParseAllowAdvertiseType(allowAdvertise);
4660 + switch (allowAdvertiseType)
4661 {
4663 - Wix.Feature.AllowAdvertiseType allowAdvertiseType = Wix.Feature.ParseAllowAdvertiseType(allowAdvertise);
4664 - switch (allowAdvertiseType)
4665 - {
4666 - case Wix.Feature.AllowAdvertiseType.no:
4667 - bits |= MsiInterop.MsidbFeatureAttributesDisallowAdvertise;
4668 - break;
4669 - case Wix.Feature.AllowAdvertiseType.system:
4670 - bits |= MsiInterop.MsidbFeatureAttributesNoUnsupportedAdvertise;
4671 - break;
4672 - case Wix.Feature.AllowAdvertiseType.yes: // this is the default
4673 - break;
4674 - default:
4675 - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, allowAdvertise, "no", "system", "yes"));
4676 - break;
4677 - }
4662 + case Wix.Feature.AllowAdvertiseType.no:
4663 + bits |= MsiInterop.MsidbFeatureAttributesDisallowAdvertise;
4664 + break;
4665 + case Wix.Feature.AllowAdvertiseType.system:
4666 + bits |= MsiInterop.MsidbFeatureAttributesNoUnsupportedAdvertise;
4667 + break;
4668 + case Wix.Feature.AllowAdvertiseType.yes: // this is the default
4669 + break;
4670 + default:
4671 + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, allowAdvertise, "no", "system", "yes"));
4672 + break;
4673 }
4679 - break;
4680 - case "ConfigurableDirectory":
4681 - configurableDirectory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null);
4682 - break;
4683 - case "Description":
4684 - description = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4685 - break;
4686 - case "Display":
4687 - display = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4688 - break;
4689 - case "InstallDefault":
4690 - installDefault = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4691 - if (0 < installDefault.Length)
4674 + }
4675 + break;
4676 + case "ConfigurableDirectory":
4677 + configurableDirectory = this.Core.CreateDirectoryReferenceFromInlineSyntax(sourceLineNumbers, attrib, null);
4678 + break;
4679 + case "Description":
4680 + description = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4681 + break;
4682 + case "Display":
4683 + display = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4684 + break;
4685 + case "InstallDefault":
4686 + installDefault = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4687 + if (0 < installDefault.Length)
4688 + {
4689 + var installDefaultType = Wix.Feature.ParseInstallDefaultType(installDefault);
4690 + switch (installDefaultType)
4691 {
4693 - Wix.Feature.InstallDefaultType installDefaultType = Wix.Feature.ParseInstallDefaultType(installDefault);
4694 - switch (installDefaultType)
4692 + case Wix.Feature.InstallDefaultType.followParent:
4693 + if (ComplexReferenceParentType.Product == parentType)
4694 {
4696 - case Wix.Feature.InstallDefaultType.followParent:
4697 - if (ComplexReferenceParentType.Product == parentType)
4698 - {
4699 - this.Core.Write(ErrorMessages.RootFeatureCannotFollowParent(sourceLineNumbers));
4700 - }
4701 - bits = bits | MsiInterop.MsidbFeatureAttributesFollowParent;
4702 - break;
4703 - case Wix.Feature.InstallDefaultType.local: // this is the default
4704 - break;
4705 - case Wix.Feature.InstallDefaultType.source:
4706 - bits = bits | MsiInterop.MsidbFeatureAttributesFavorSource;
4707 - break;
4708 - default:
4709 - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, installDefault, "followParent", "local", "source"));
4710 - break;
4695 + this.Core.Write(ErrorMessages.RootFeatureCannotFollowParent(sourceLineNumbers));
4696 }
4697 + bits = bits | MsiInterop.MsidbFeatureAttributesFollowParent;
4698 + break;
4699 + case Wix.Feature.InstallDefaultType.local: // this is the default
4700 + break;
4701 + case Wix.Feature.InstallDefaultType.source:
4702 + bits = bits | MsiInterop.MsidbFeatureAttributesFavorSource;
4703 + break;
4704 + default:
4705 + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, installDefault, "followParent", "local", "source"));
4706 + break;
4707 }
4713 - break;
4714 - case "Level":
4715 - level = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue);
4716 - break;
4717 - case "Title":
4718 - title = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4719 - if ("PUT-FEATURE-TITLE-HERE" == title)
4720 - {
4721 - this.Core.Write(WarningMessages.PlaceholderValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, title));
4722 - }
4723 - break;
4724 - case "TypicalDefault":
4725 - typicalDefault = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4726 - if (0 < typicalDefault.Length)
4708 + }
4709 + break;
4710 + case "Level":
4711 + level = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue);
4712 + break;
4713 + case "Title":
4714 + title = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4715 + if ("PUT-FEATURE-TITLE-HERE" == title)
4716 + {
4717 + this.Core.Write(WarningMessages.PlaceholderValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, title));
4718 + }
4719 + break;
4720 + case "TypicalDefault":
4721 + typicalDefault = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
4722 + if (0 < typicalDefault.Length)
4723 + {
4724 + var typicalDefaultType = Wix.Feature.ParseTypicalDefaultType(typicalDefault);
4725 + switch (typicalDefaultType)
4726 {
4728 - Wix.Feature.TypicalDefaultType typicalDefaultType = Wix.Feature.ParseTypicalDefaultType(typicalDefault);
4729 - switch (typicalDefaultType)
4730 - {
4731 - case Wix.Feature.TypicalDefaultType.advertise:
4732 - bits = bits | MsiInterop.MsidbFeatureAttributesFavorAdvertise;
4733 - break;
4734 - case Wix.Feature.TypicalDefaultType.install: // this is the default
4735 - break;
4736 - default:
4737 - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, typicalDefault, "advertise", "install"));
4738 - break;
4739 - }
4727 + case Wix.Feature.TypicalDefaultType.advertise:
4728 + bits = bits | MsiInterop.MsidbFeatureAttributesFavorAdvertise;
4729 + break;
4730 + case Wix.Feature.TypicalDefaultType.install: // this is the default
4731 + break;
4732 + default:
4733 + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, typicalDefault, "advertise", "install"));
4734 + break;
4735 }
4741 - break;
4742 - default:
4743 - this.Core.UnexpectedAttribute(node, attrib);
4744 - break;
4736 + }
4737 + break;
4738 + default:
4739 + this.Core.UnexpectedAttribute(node, attrib);
4740 + break;
4741 }
4742 }
4743 else
@@ -4775,40 +4771,40 @@ namespace WixToolset.Core
4771 this.Core.Write(ErrorMessages.FeatureCannotFollowParentAndFavorLocalOrSource(sourceLineNumbers, node.Name.LocalName, "InstallDefault", "FollowParent", "yes"));
4772 }
4773
4778 - int childDisplay = 0;
4779 - foreach (XElement child in node.Elements())
4774 + var childDisplay = 0;
4775 + foreach (var child in node.Elements())
4776 {
4777 if (CompilerCore.WixNamespace == child.Name.Namespace)
4778 {
4779 switch (child.Name.LocalName)
4780 {
4785 - case "ComponentGroupRef":
4786 - this.ParseComponentGroupRefElement(child, ComplexReferenceParentType.Feature, id.Id, null);
4787 - break;
4788 - case "ComponentRef":
4789 - this.ParseComponentRefElement(child, ComplexReferenceParentType.Feature, id.Id, null);
4790 - break;
4791 - case "Component":
4792 - this.ParseComponentElement(child, ComplexReferenceParentType.Feature, id.Id, null, CompilerConstants.IntegerNotSet, null, null);
4793 - break;
4794 - case "Condition":
4795 - this.ParseConditionElement(child, node.Name.LocalName, id.Id, null);
4796 - break;
4797 - case "Feature":
4798 - this.ParseFeatureElement(child, ComplexReferenceParentType.Feature, id.Id, ref childDisplay);
4799 - break;
4800 - case "FeatureGroupRef":
4801 - this.ParseFeatureGroupRefElement(child, ComplexReferenceParentType.Feature, id.Id);
4802 - break;
4803 - case "FeatureRef":
4804 - this.ParseFeatureRefElement(child, ComplexReferenceParentType.Feature, id.Id);
4805 - break;
4806 - case "MergeRef":
4807 - this.ParseMergeRefElement(child, ComplexReferenceParentType.Feature, id.Id);
4808 - break;
4809 - default:
4810 - this.Core.UnexpectedElement(node, child);
4811 - break;
4781 + case "ComponentGroupRef":
4782 + this.ParseComponentGroupRefElement(child, ComplexReferenceParentType.Feature, id.Id, null);
4783 + break;
4784 + case "ComponentRef":
4785 + this.ParseComponentRefElement(child, ComplexReferenceParentType.Feature, id.Id, null);
4786 + break;
4787 + case "Component":
4788 + this.ParseComponentElement(child, ComplexReferenceParentType.Feature, id.Id, null, CompilerConstants.IntegerNotSet, null, null);
4789 + break;
4790 + case "Condition":
4791 + this.ParseConditionElement(child, node.Name.LocalName, id.Id, null);
4792 + break;
4793 + case "Feature":
4794 + this.ParseFeatureElement(child, ComplexReferenceParentType.Feature, id.Id, ref childDisplay);
4795 + break;
4796 + case "FeatureGroupRef":
4797 + this.ParseFeatureGroupRefElement(child, ComplexReferenceParentType.Feature, id.Id);
4798 + break;
4799 + case "FeatureRef":
4800 + this.ParseFeatureRefElement(child, ComplexReferenceParentType.Feature, id.Id);
4801 + break;
4802 + case "MergeRef":
4803 + this.ParseMergeRefElement(child, ComplexReferenceParentType.Feature, id.Id);
4804 + break;
4805 + default:
4806 + this.Core.UnexpectedElement(node, child);
4807 + break;
4808 }
4809 }
4810 else
@@ -4827,33 +4823,33 @@ namespace WixToolset.Core
4823 {
4824 switch (display)
4825 {
4830 - case "collapse":
4831 - lastDisplay = (lastDisplay | 1) + 1;
4832 - row.Set(4, lastDisplay);
4833 - break;
4834 - case "expand":
4835 - lastDisplay = (lastDisplay + 1) | 1;
4836 - row.Set(4, lastDisplay);
4837 - break;
4838 - case "hidden":
4839 - row.Set(4, 0);
4840 - break;
4841 - default:
4842 - int value;
4843 - if (!Int32.TryParse(display, NumberStyles.Integer, CultureInfo.InvariantCulture, out value))
4844 - {
4845 - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Display", display, "collapse", "expand", "hidden"));
4846 - }
4847 - else
4826 + case "collapse":
4827 + lastDisplay = (lastDisplay | 1) + 1;
4828 + row.Set(4, lastDisplay);
4829 + break;
4830 + case "expand":
4831 + lastDisplay = (lastDisplay + 1) | 1;
4832 + row.Set(4, lastDisplay);
4833 + break;
4834 + case "hidden":
4835 + row.Set(4, 0);
4836 + break;
4837 + default:
4838 + int value;
4839 + if (!Int32.TryParse(display, NumberStyles.Integer, CultureInfo.InvariantCulture, out value))
4840 + {
4841 + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Display", display, "collapse", "expand", "hidden"));
4842 + }
4843 + else
4844 + {
4845 + row.Set(4, value);
4846 + // save the display value of this row (if its not hidden) for subsequent rows
4847 + if (0 != (int)row[4])
4848 {
4849 - row.Set(4, value);
4850 - // save the display value of this row (if its not hidden) for subsequent rows
4851 - if (0 != (int)row[4])
4852 - {
4853 - lastDisplay = (int)row[4];
4854 - }
4849 + lastDisplay = (int)row[4];
4850 }
4856 - break;
4851 + }
4852 + break;
4853 }
4854 }
4855 row.Set(5, level);
@@ -4876,26 +4872,26 @@ namespace WixToolset.Core
4872 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
4873 private void ParseFeatureRefElement(XElement node, ComplexReferenceParentType parentType, string parentId)
4874 {
4879 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
4875 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
4876 string id = null;
4881 - YesNoType ignoreParent = YesNoType.NotSet;
4877 + var ignoreParent = YesNoType.NotSet;
4878
4883 - foreach (XAttribute attrib in node.Attributes())
4879 + foreach (var attrib in node.Attributes())
4880 {
4881 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
4882 {
4883 switch (attrib.Name.LocalName)
4884 {
4889 - case "Id":
4890 - id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
4891 - this.Core.CreateSimpleReference(sourceLineNumbers, "Feature", id);
4892 - break;
4893 - case "IgnoreParent":
4894 - ignoreParent = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
4895 - break;
4896 - default:
4897 - this.Core.UnexpectedAttribute(node, attrib);
4898 - break;
4885 + case "Id":
4886 + id = this.Core.GetAttributeIdentifierValue(sourceLineNumbers, attrib);
4887 + this.Core.CreateSimpleReference(sourceLineNumbers, "Feature", id);
4888 + break;
4889 + case "IgnoreParent":
4890 + ignoreParent = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
4891 + break;
4892 + default:
4893 + this.Core.UnexpectedAttribute(node, attrib);
4894 + break;
4895 }
4896 }
4897 else
@@ -4910,40 +4906,40 @@ namespace WixToolset.Core
4906 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id"));
4907 }
4908
4913 - int lastDisplay = 0;
4914 - foreach (XElement child in node.Elements())
4909 + var lastDisplay = 0;
4910 + foreach (var child in node.Elements())
4911 {
4912 if (CompilerCore.WixNamespace == child.Name.Namespace)
4913 {
4914 switch (child.Name.LocalName)
4915 {
4920 - case "ComponentGroupRef":
4921 - this.ParseComponentGroupRefElement(child, ComplexReferenceParentType.Feature, id, null);
4922 - break;
4923 - case "ComponentRef":
4924 - this.ParseComponentRefElement(child, ComplexReferenceParentType.Feature, id, null);
4925 - break;
4926 - case "Component":
4927 - this.ParseComponentElement(child, ComplexReferenceParentType.Feature, id, null, CompilerConstants.IntegerNotSet, null, null);
4928 - break;
4929 - case "Feature":
4930 - this.ParseFeatureElement(child, ComplexReferenceParentType.Feature, id, ref lastDisplay);
4931 - break;
4932 - case "FeatureGroup":
4933 - this.ParseFeatureGroupElement(child, ComplexReferenceParentType.Feature, id);
4934 - break;
4935 - case "FeatureGroupRef":
4936 - this.ParseFeatureGroupRefElement(child, ComplexReferenceParentType.Feature, id);
4937 - break;
4938 - case "FeatureRef":
4939 - this.ParseFeatureRefElement(child, ComplexReferenceParentType.Feature, id);
4940 - break;
4941 - case "MergeRef":
4942 - this.ParseMergeRefElement(child, ComplexReferenceParentType.Feature, id);
4943 - break;
4944 - default:
4945 - this.Core.UnexpectedElement(node, child);
4946 - break;
4916 + case "ComponentGroupRef":
4917 + this.ParseComponentGroupRefElement(child, ComplexReferenceParentType.Feature, id, null);
4918 + break;
4919 + case "ComponentRef":
4920 + this.ParseComponentRefElement(child, ComplexReferenceParentType.Feature, id, null);
4921 + break;
4922 + case "Component":
4923 + this.ParseComponentElement(child, ComplexReferenceParentType.Feature, id, null, CompilerConstants.IntegerNotSet, null, null);
4924 + break;
4925 + case "Feature":
4926 + this.ParseFeatureElement(child, ComplexReferenceParentType.Feature, id, ref lastDisplay);
4927 + break;
4928 + case "FeatureGroup":
4929 + this.ParseFeatureGroupElement(child, ComplexReferenceParentType.Feature, id);
4930 + break;
4931 + case "FeatureGroupRef":
4932 + this.ParseFeatureGroupRefElement(child, ComplexReferenceParentType.Feature, id);
4933 + break;
4934 + case "FeatureRef":
4935 + this.ParseFeatureRefElement(child, ComplexReferenceParentType.Feature, id);
4936 + break;
4937 + case "MergeRef":
4938 + this.ParseMergeRefElement(child, ComplexReferenceParentType.Feature, id);
4939 + break;
4940 + default:
4941 + this.Core.UnexpectedElement(node, child);
4942 + break;
4943 }
4944 }
4945 else
@@ -4968,21 +4964,21 @@ namespace WixToolset.Core
4964 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
4965 private void ParseFeatureGroupElement(XElement node, ComplexReferenceParentType parentType, string parentId)
4966 {
4971 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
4967 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
4968 Identifier id = null;
4969
4974 - foreach (XAttribute attrib in node.Attributes())
4970 + foreach (var attrib in node.Attributes())
4971 {
4972 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
4973 {
4974 switch (attrib.Name.LocalName)
4975 {
4980 - case "Id":
4981 - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
4982 - break;
4983 - default:
4984 - this.Core.UnexpectedAttribute(node, attrib);
4985 - break;
4976 + case "Id":
4977 + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
4978 + break;
4979 + default:
4980 + this.Core.UnexpectedAttribute(node, attrib);
4981 + break;
4982 }
4983 }
4984 else
@@ -4997,37 +4993,37 @@ namespace WixToolset.Core
4993 id = Identifier.Invalid;
4994 }
4995
5000 - int lastDisplay = 0;
5001 - foreach (XElement child in node.Elements())
4996 + var lastDisplay = 0;
4997 + foreach (var child in node.Elements())
4998 {
4999 if (CompilerCore.WixNamespace == child.Name.Namespace)
5000 {
5001 switch (child.Name.LocalName)
5002 {
5007 - case "ComponentGroupRef":
5008 - this.ParseComponentGroupRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id, null);
5009 - break;
5010 - case "ComponentRef":
5011 - this.ParseComponentRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id, null);
5012 - break;
5013 - case "Component":
5014 - this.ParseComponentElement(child, ComplexReferenceParentType.FeatureGroup, id.Id, null, CompilerConstants.IntegerNotSet, null, null);
5015 - break;
5016 - case "Feature":
5017 - this.ParseFeatureElement(child, ComplexReferenceParentType.FeatureGroup, id.Id, ref lastDisplay);
5018 - break;
5019 - case "FeatureGroupRef":
5020 - this.ParseFeatureGroupRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id);
5021 - break;
5022 - case "FeatureRef":
5023 - this.ParseFeatureRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id);
5024 - break;
5025 - case "MergeRef":
5026 - this.ParseMergeRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id);
5027 - break;
5028 - default:
5029 - this.Core.UnexpectedElement(node, child);
5030 - break;
5003 + case "ComponentGroupRef":
5004 + this.ParseComponentGroupRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id, null);
5005 + break;
5006 + case "ComponentRef":
5007 + this.ParseComponentRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id, null);
5008 + break;
5009 + case "Component":
5010 + this.ParseComponentElement(child, ComplexReferenceParentType.FeatureGroup, id.Id, null, CompilerConstants.IntegerNotSet, null, null);
5011 + break;
5012 + case "Feature":
5013 + this.ParseFeatureElement(child, ComplexReferenceParentType.FeatureGroup, id.Id, ref lastDisplay);
5014 + break;
5015 + case "FeatureGroupRef":
5016 + this.ParseFeatureGroupRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id);
5017 + break;
5018 + case "FeatureRef":
5019 + this.ParseFeatureRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id);
5020 + break;
5021 + case "MergeRef":
5022 + this.ParseMergeRefElement(child, ComplexReferenceParentType.FeatureGroup, id.Id);
5023 + break;
5024 + default:
5025 + this.Core.UnexpectedElement(node, child);
5026 + break;
5027 }
5028 }
5029 else
@@ -5055,30 +5051,30 @@ namespace WixToolset.Core
5051 {
5052 Debug.Assert(ComplexReferenceParentType.Feature == parentType || ComplexReferenceParentType.FeatureGroup == parentType || ComplexReferenceParentType.ComponentGroup == parentType || ComplexReferenceParentType.Product == parentType);
5053
5058 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
5054 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
5055 string id = null;
5060 - YesNoType ignoreParent = YesNoType.NotSet;
5061 - YesNoType primary = YesNoType.NotSet;
5056 + var ignoreParent = YesNoType.NotSet;
5057 + var primary = YesNoType.NotSet;
5058
5063 - foreach (XAttribute attrib in node.Attributes())
5059 + foreach (var attrib in node.Attributes())
5060 {
5061 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
5062 {
5063 switch (attrib.Name.LocalName)
5064 {
5069 - case "Id":
5070 - id = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
5071 - this.Core.CreateSimpleReference(sourceLineNumbers, "WixFeatureGroup", id);
5072 - break;
5073 - case "IgnoreParent":
5074 - ignoreParent = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
5075 - break;
5076 - case "Primary":
5077 - primary = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
5078 - break;
5079 - default:
5080 - this.Core.UnexpectedAttribute(node, attrib);
5081 - break;
5065 + case "Id":
5066 + id = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
5067 + this.Core.CreateSimpleReference(sourceLineNumbers, "WixFeatureGroup", id);
5068 + break;
5069 + case "IgnoreParent":
5070 + ignoreParent = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
5071 + break;
5072 + case "Primary":
5073 + primary = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
5074 + break;
5075 + default:
5076 + this.Core.UnexpectedAttribute(node, attrib);
5077 + break;
5078 }
5079 }
5080 else
@@ -5110,74 +5106,74 @@ namespace WixToolset.Core
5106 /// <param name="componentId">Identifier of parent component.</param>
5107 private void ParseEnvironmentElement(XElement node, string componentId)
5108 {
5113 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
5109 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
5110 Identifier id = null;
5111 string action = null;
5112 string name = null;
5117 - Wix.Environment.PartType partType = Wix.Environment.PartType.NotSet;
5113 + var partType = Wix.Environment.PartType.NotSet;
5114 string part = null;
5119 - bool permanent = false;
5120 - string separator = ";"; // default to ';'
5121 - bool system = false;
5115 + var permanent = false;
5116 + var separator = ";"; // default to ';'
5117 + var system = false;
5118 string text = null;
5123 - string uninstall = "-"; // default to remove at uninstall
5119 + var uninstall = "-"; // default to remove at uninstall
5120
5125 - foreach (XAttribute attrib in node.Attributes())
5121 + foreach (var attrib in node.Attributes())
5122 {
5123 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
5124 {
5125 switch (attrib.Name.LocalName)
5126 {
5131 - case "Id":
5132 - id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
5133 - break;
5134 - case "Action":
5135 - string value = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
5136 - if (0 < value.Length)
5137 - {
5138 - Wix.Environment.ActionType actionType = Wix.Environment.ParseActionType(value);
5139 - switch (actionType)
5140 - {
5141 - case Wix.Environment.ActionType.create:
5142 - action = "+";
5143 - break;
5144 - case Wix.Environment.ActionType.set:
5145 - action = "=";
5146 - break;
5147 - case Wix.Environment.ActionType.remove:
5148 - action = "!";
5149 - break;
5150 - default:
5151 - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, value, "create", "set", "remove"));
5152 - break;
5153 - }
5154 - }
5155 - break;
5156 - case "Name":
5157 - name = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
5158 - break;
5159 - case "Part":
5160 - part = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
5161 - if (!Wix.Environment.TryParsePartType(part, out partType))
5127 + case "Id":
5128 + id = this.Core.GetAttributeIdentifier(sourceLineNumbers, attrib);
5129 + break;
5130 + case "Action":
5131 + var value = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
5132 + if (0 < value.Length)
5133 + {
5134 + var actionType = Wix.Environment.ParseActionType(value);
5135 + switch (actionType)
5136 {
5163 - this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Part", part, "all", "first", "last"));
5137 + case Wix.Environment.ActionType.create:
5138 + action = "+";
5139 + break;
5140 + case Wix.Environment.ActionType.set:
5141 + action = "=";
5142 + break;
5143 + case Wix.Environment.ActionType.remove:
5144 + action = "!";
5145 + break;
5146 + default:
5147 + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, attrib.Name.LocalName, value, "create", "set", "remove"));
5148 + break;
5149 }
5165 - break;
5166 - case "Permanent":
5167 - permanent = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
5168 - break;
5169 - case "Separator":
5170 - separator = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
5171 - break;
5172 - case "System":
5173 - system = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
5174 - break;
5175 - case "Value":
5176 - text = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
5177 - break;
5178 - default:
5179 - this.Core.UnexpectedAttribute(node, attrib);
5180 - break;
5150 + }
5151 + break;
5152 + case "Name":
5153 + name = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
5154 + break;
5155 + case "Part":
5156 + part = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
5157 + if (!Wix.Environment.TryParsePartType(part, out partType))
5158 + {
5159 + this.Core.Write(ErrorMessages.IllegalAttributeValue(sourceLineNumbers, node.Name.LocalName, "Part", part, "all", "first", "last"));
5160 + }
5161 + break;
5162 + case "Permanent":
5163 + permanent = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
5164 + break;
5165 + case "Separator":
5166 + separator = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
5167 + break;
5168 + case "System":
5169 + system = YesNoType.Yes == this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
5170 + break;
5171 + case "Value":
5172 + text = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
5173 + break;
5174 + default:
5175 + this.Core.UnexpectedAttribute(node, attrib);
5176 + break;
5177 }
5178 }
5179 else
@@ -5205,14 +5201,14 @@ namespace WixToolset.Core
5201
5202 switch (partType)
5203 {
5208 - case Wix.Environment.PartType.all:
5209 - break;
5210 - case Wix.Environment.PartType.first:
5211 - text = String.Concat(text, separator, "[~]");
5212 - break;
5213 - case Wix.Environment.PartType.last:
5214 - text = String.Concat("[~]", separator, text);
5215 - break;
5204 + case Wix.Environment.PartType.all:
5205 + break;
5206 + case Wix.Environment.PartType.first:
5207 + text = String.Concat(text, separator, "[~]");
5208 + break;
5209 + case Wix.Environment.PartType.last:
5210 + text = String.Concat("[~]", separator, text);
5211 + break;
5212 }
5213 }
5214
@@ -5238,21 +5234,21 @@ namespace WixToolset.Core
5234 /// <param name="node">Element to parse.</param>
5235 private void ParseErrorElement(XElement node)
5236 {
5241 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
5242 - int id = CompilerConstants.IntegerNotSet;
5237 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
5238 + var id = CompilerConstants.IntegerNotSet;
5239
5244 - foreach (XAttribute attrib in node.Attributes())
5240 + foreach (var attrib in node.Attributes())
5241 {
5242 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
5243 {
5244 switch (attrib.Name.LocalName)
5245 {
5250 - case "Id":
5251 - id = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, short.MaxValue);
5252 - break;
5253 - default:
5254 - this.Core.UnexpectedAttribute(node, attrib);
5255 - break;
5246 + case "Id":
5247 + id = this.Core.GetAttributeIntegerValue(sourceLineNumbers, attrib, 0, Int16.MaxValue);
5248 + break;
5249 + default:
5250 + this.Core.UnexpectedAttribute(node, attrib);
5251 + break;
5252 }
5253 }
5254 else
@@ -5286,38 +5282,38 @@ namespace WixToolset.Core
5282 /// <param name="progId">ProgId for extension.</param>
5283 private void ParseExtensionElement(XElement node, string componentId, YesNoType advertise, string progId)
5284 {
5289 - SourceLineNumber sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
5285 + var sourceLineNumbers = Preprocessor.GetSourceLineNumbers(node);
5286 string extension = null;
5287 string mime = null;
5288
5293 - foreach (XAttribute attrib in node.Attributes())
5289 + foreach (var attrib in node.Attributes())
5290 {
5291 if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || CompilerCore.WixNamespace == attrib.Name.Namespace)
5292 {
5293 switch (attrib.Name.LocalName)
5294 {
5299 - case "Id":
5300 - extension = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
5301 - break;
5302 - case "Advertise":
5303 - YesNoType extensionAdvertise = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
5304 - if ((YesNoType.No == advertise && YesNoType.Yes == extensionAdvertise) || (YesNoType.Yes == advertise && YesNoType.No == extensionAdvertise))
5305 - {
5306 - this.Core.Write(ErrorMessages.AdvertiseStateMustMatch(sourceLineNumbers, extensionAdvertise.ToString(), advertise.ToString()));
5307 - }
5308 - advertise = extensionAdvertise;
5309 - break;
5310 - case "ContentType":
5311 - mime = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
5312 - break;
5313 - default:
5314 - this.Core.UnexpectedAttribute(node, attrib);
5315 - break;
5295 + case "Id":
5296 + extension = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
5297 + break;
5298 + case "Advertise":
5299 + var extensionAdvertise = this.Core.GetAttributeYesNoValue(sourceLineNumbers, attrib);
5300 + if ((YesNoType.No == advertise && YesNoType.Yes == extensionAdvertise) || (YesNoType.Yes == advertise && YesNoType.No == extensionAdvertise))
5301 + {
5302 + this.Core.Write(ErrorMessages.AdvertiseStateMustMatch(sourceLineNumbers, extensionAdvertise.ToString(), advertise.ToString()));
5303 + }
5304 + advertise = extensionAdvertise;
5305 + break;
5306 + case "ContentType":
5307 + mime = this.Core.GetAttributeValue(sourceLineNumbers, attrib);
5308 + break;
5309 + default:
5310 + this.Core.UnexpectedAttribute(node, attrib);
5311 + break;
5312 }
5313 }
5314 else
5315 {
5320 - Dictionary<string, string> context = new Dictionary<string, string>() { { "ProgId", progId }, { "ComponentId", componentId } };
5316 + var context = new Dictionary<string, string>() { { "ProgId", progId }, { "ComponentId", componentId } };
5317 this.Core.ParseExtensionAttribute(node, attrib, context);
5318 }
5319 }
@@ -5327,25 +5323,25 @@ namespace WixToolset.Core
5323 advertise = YesNoType.No;
5324 }
5325
5330 - foreach (XElement child in node.Elements())
5326 + foreach (var child in node.Elements())
5327 {
5328 if (CompilerCore.WixNamespace == child.Name.Namespace)
5329 {
5330 switch (child.Name.LocalName)
5331 {
5336 - case "Verb":
5337 - this.ParseVerbElement(child, extension, progId, componentId, advertise);
5338 - break;
5339 - case "MIME":
5340 - string newMime = this.ParseMIMEElement(child, extension, componentId, advertise);
5341 - if (null != newMime && null == mime)
5342 - {
5343 - mime = newMime;
5344 - }
5345 - break;
5346 - default:

This file is too large to show in full.

src/WixToolset.Core/Localizer.cs
+1 -1
@@ -26,7 +26,7 @@ namespace WixToolset.Core
26 public Localization ParseLocalizationFile(string path)
27 {
28 var document = XDocument.Load(path);
29 - return ParseLocalizationFile(document);
29 + return this.ParseLocalizationFile(document);
30 }
31
32 public Localization ParseLocalizationFile(XDocument document)
src/WixToolset.Core/Preprocessor.cs
+1 -1
@@ -133,7 +133,7 @@ namespace WixToolset.Core
133
134 this.Context = context;
135 this.Context.CurrentSourceLineNumber = new SourceLineNumber(context.SourcePath);
136 - this.Context.Variables = this.Context.Variables == null ? new Dictionary<string, string>() : new Dictionary<string, string>(this.Context.Variables);
136 + this.Context.Variables = (this.Context.Variables == null) ? new Dictionary<string, string>() : new Dictionary<string, string>(this.Context.Variables);
137
138 this.PreProcess();
139