Correctly join command line arguments and other small clean up and optimizations
Rob Mensching committed
Dec 27, 2017 at 22:58 UTC
58b8be53fd966e3d475362912477a422f5b5aa11
6 files changed
+45
-58
src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
+38
-45
@@ -39,7 +39,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
39
this.PdbFile = context.OutputPdbPath;
40
this.IntermediateFolder = context.IntermediateFolder;
41
this.Validator = validator;
42
-
42
+
43
this.BackendExtensions = backendExtension;
44
}
45
@@ -90,6 +90,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
90
91
var fileTransfers = new List<FileTransfer>();
92
93
+ var containsMergeModules = false;
94
var suppressedTableNames = new HashSet<string>();
95
96
// If there are any fields to resolve later, create the cache to populate during bind.
@@ -209,7 +210,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
210
command.Execute();
211
}
212
212
- // Gather information about files that did not come from merge modules (i.e. rows with a reference to the File table).
213
+ // Gather information about files that do not come from merge modules.
214
{
215
var command = new UpdateFileFacadesCommand(this.Messaging, section);
216
command.FileFacades = fileFacades;
@@ -233,13 +234,15 @@ namespace WixToolset.Core.WindowsInstaller.Bind
234
command.Execute();
235
}
236
237
+ // Retrieve file information from merge modules.
238
if (SectionType.Product == section.Type)
239
{
238
- // Retrieve files and their information from merge modules.
240
var wixMergeTuples = section.Tuples.OfType<WixMergeTuple>().ToList();
241
242
if (wixMergeTuples.Any())
243
{
244
+ containsMergeModules = true;
245
+
246
var command = new ExtractMergeModuleFilesCommand(this.Messaging, section, wixMergeTuples);
247
command.FileFacades = fileFacades;
248
command.OutputInstallerVersion = installerVersion;
@@ -266,11 +269,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind
269
return;
270
}
271
269
-#if TODO_FIX_INSTANCE_TRANSFORM
270
- // With the Component Guids set now we can create instance transforms.
271
- this.CreateInstanceTransforms(this.Output);
272
-#endif
273
-
272
// Assign files to media.
273
Dictionary<int, MediaTuple> assignedMediaRows;
274
Dictionary<MediaTuple, IEnumerable<FileFacade>> filesByCabinetMedia;
@@ -292,7 +290,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
290
return;
291
}
292
295
- // Try to put as much above here as possible, updating the IR is better.
293
+ // Time to create the output object. Try to put as much above here as possible, updating the IR is better.
294
Output output;
295
{
296
var command = new CreateOutputFromIRCommand(section, this.TableDefinitions, this.BackendExtensions);
@@ -307,12 +305,18 @@ namespace WixToolset.Core.WindowsInstaller.Bind
305
command.Execute();
306
}
307
310
- // Modularize identifiers and add tables with real streams to the import tables.
308
+ // Modularize identifiers.
309
if (OutputType.Module == output.Type)
310
{
313
- var command = new ModularaizeCommand(output, modularizationGuid, section.Tuples.OfType<WixSuppressModularizationTuple>());
311
+ var command = new ModularizeCommand(output, modularizationGuid, section.Tuples.OfType<WixSuppressModularizationTuple>());
312
command.Execute();
313
}
314
+ else // we can create instance transforms since Component Guids are set.
315
+ {
316
+#if TODO_FIX_INSTANCE_TRANSFORM
317
+ this.CreateInstanceTransforms(this.Output);
318
+#endif
319
+ }
320
321
#if TODO_FINISH_UPDATE
322
// Extended binder extensions can be called now that fields are resolved.
@@ -367,7 +371,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
371
}
372
373
// create cabinet files and process uncompressed files
370
- string layoutDirectory = Path.GetDirectoryName(this.OutputPath);
374
+ var layoutDirectory = Path.GetDirectoryName(this.OutputPath);
375
if (!this.SuppressLayout || OutputType.Module == output.Type)
376
{
377
this.Messaging.Write(VerboseMessages.CreatingCabinetFiles());
@@ -399,36 +403,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind
403
}
404
#endif
405
402
- // Add back suppressed tables which must be present prior to merging in modules.
403
- if (OutputType.Product == output.Type)
404
- {
405
- Table wixMergeTable = output.Tables["WixMerge"];
406
-
407
- if (null != wixMergeTable && 0 < wixMergeTable.Rows.Count)
408
- {
409
- foreach (SequenceTable sequence in Enum.GetValues(typeof(SequenceTable)))
410
- {
411
- string sequenceTableName = sequence.ToString();
412
- Table sequenceTable = output.Tables[sequenceTableName];
413
-
414
- if (null == sequenceTable)
415
- {
416
- sequenceTable = output.EnsureTable(this.TableDefinitions[sequenceTableName]);
417
- }
418
-
419
- if (0 == sequenceTable.Rows.Count)
420
- {
421
- suppressedTableNames.Add(sequenceTableName);
422
- }
423
- }
424
- }
425
- }
426
-
427
- //foreach (BinderExtension extension in this.Extensions)
428
- //{
429
- // extension.PostBind(this.Context);
430
- //}
431
-
406
this.ValidateComponentGuids(output);
407
408
// stop processing if an error previously occurred
@@ -455,18 +429,37 @@ namespace WixToolset.Core.WindowsInstaller.Bind
429
}
430
431
// Output the output to a file.
458
- Pdb pdb = new Pdb();
459
- pdb.Output = output;
432
if (!String.IsNullOrEmpty(this.PdbFile))
433
{
434
+ Pdb pdb = new Pdb();
435
+ pdb.Output = output;
436
pdb.Save(this.PdbFile);
437
}
438
439
// Merge modules.
466
- if (OutputType.Product == output.Type)
440
+ if (containsMergeModules)
441
{
442
this.Messaging.Write(VerboseMessages.MergingModules());
443
444
+ // Add back possibly suppressed sequence tables since all sequence tables must be present
445
+ // for the merge process to work. We'll drop the suppressed sequence tables again as
446
+ // necessary.
447
+ foreach (SequenceTable sequence in Enum.GetValues(typeof(SequenceTable)))
448
+ {
449
+ var sequenceTableName = sequence.ToString();
450
+ var sequenceTable = output.Tables[sequenceTableName];
451
+
452
+ if (null == sequenceTable)
453
+ {
454
+ sequenceTable = output.EnsureTable(this.TableDefinitions[sequenceTableName]);
455
+ }
456
+
457
+ if (0 == sequenceTable.Rows.Count)
458
+ {
459
+ suppressedTableNames.Add(sequenceTableName);
460
+ }
461
+ }
462
+
463
var command = new MergeModulesCommand();
464
command.FileFacades = fileFacades;
465
command.Output = output;
src/WixToolset.Core.WindowsInstaller/Bind/ModularizeCommand.cs
renamed
+4
-9
@@ -13,9 +13,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind
13
using WixToolset.Data.Tuples;
14
using WixToolset.Data.WindowsInstaller;
15
16
- internal class ModularaizeCommand
16
+ internal class ModularizeCommand
17
{
18
- public ModularaizeCommand(Output output, string modularizationGuid, IEnumerable<WixSuppressModularizationTuple> suppressTuples)
18
+ public ModularizeCommand(Output output, string modularizationGuid, IEnumerable<WixSuppressModularizationTuple> suppressTuples)
19
{
20
this.Output = output;
21
this.ModularizationGuid = modularizationGuid;
@@ -38,12 +38,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
38
}
39
}
40
41
- /// <summary>
42
- /// Modularize the table.
43
- /// </summary>
44
- /// <param name="modularizationGuid">String containing the GUID of the Merge Module, if appropriate.</param>
45
- /// <param name="suppressModularizationIdentifiers">Optional collection of identifiers that should not be modularized.</param>
46
- public void ModularizeTable(Table table)
41
+ private void ModularizeTable(Table table)
42
{
43
var modularizedColumns = new List<int>();
44
@@ -79,7 +74,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
74
75
if (!(WindowsInstallerStandard.IsStandardAction(fieldData) || WindowsInstallerStandard.IsStandardProperty(fieldData)))
76
{
82
- ColumnModularizeType modularizeType = field.Column.ModularizeType;
77
+ var modularizeType = field.Column.ModularizeType;
78
79
// special logic for the ControlEvent table's Argument column
80
// this column requires different modularization methods depending upon the value of the Event column
src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs
+1
-1
@@ -41,7 +41,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
41
42
public void Execute()
43
{
44
- List<FileTransfer> fileTransfers = new List<FileTransfer>();
44
+ var fileTransfers = new List<FileTransfer>();
45
46
var directories = new Dictionary<string, ResolvedDirectory>();
47
src/WixToolset.Core/CommandLine/CommandLineParser.cs
+1
-1
@@ -54,7 +54,7 @@ namespace WixToolset.Core.CommandLine
54
55
if (!String.IsNullOrEmpty(context.Arguments))
56
{
57
- args = CommandLineParser.ParseArgumentsToArray(context.Arguments).Union(args).ToArray();
57
+ args = CommandLineParser.ParseArgumentsToArray(context.Arguments).Concat(args).ToArray();
58
}
59
60
return this.ParseStandardCommandLine(context, args);
src/WixToolset.Core/Librarian.cs
+1
-1
@@ -143,7 +143,7 @@ namespace WixToolset.Core
143
144
foreach (var tuple in sections.SelectMany(s => s.Tuples))
145
{
146
- foreach (var field in tuple.Fields.Where(f => f.Type == IntermediateFieldType.Path))
146
+ foreach (var field in tuple.Fields.Where(f => f?.Type == IntermediateFieldType.Path))
147
{
148
var pathField = field.AsPath();
149
src/test/TestData/Example.Extension/ExampleTableDefinitions.cs
-1
@@ -2,7 +2,6 @@
2
3
namespace Example.Extension
4
{
5
- using System.Collections.Generic;
5
using WixToolset.Data.WindowsInstaller;
6
7
public static class ExampleTableDefinitions