Minor code cleanup
Rob Mensching committed
Jun 4, 2020 at 11:22 UTC
2c3793752060e50fe2049d860a8ccb4a2475414c
4 files changed
+36
-37
src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs
+16
-18
@@ -238,6 +238,14 @@ namespace WixToolset.Core.WindowsInstaller.Bind
238
239
// This must occur after all variables and source paths have been resolved.
240
List<FileFacade> fileFacades;
241
+ if (SectionType.Patch == section.Type)
242
+ {
243
+ var command = new GetFileFacadesFromTransforms(this.Messaging, this.FileSystemManager, this.SubStorages);
244
+ command.Execute();
245
+
246
+ fileFacades = command.FileFacades;
247
+ }
248
+ else
249
{
250
var command = new GetFileFacadesCommand(section);
251
command.Execute();
@@ -254,24 +262,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind
262
{
263
containsMergeModules = true;
264
257
- var command = new ExtractMergeModuleFilesCommand(this.Messaging, section, wixMergeTuples);
258
- command.FileFacades = fileFacades;
259
- command.OutputInstallerVersion = installerVersion;
260
- command.SuppressLayout = this.SuppressLayout;
261
- command.IntermediateFolder = this.IntermediateFolder;
265
+ var command = new ExtractMergeModuleFilesCommand(this.Messaging, wixMergeTuples, fileFacades, installerVersion, this.IntermediateFolder, this.SuppressLayout);
266
command.Execute();
267
268
fileFacades.AddRange(command.MergeModulesFileFacades);
269
}
270
}
267
- else if (SectionType.Patch == section.Type)
268
- {
269
- var command = new GetFileFacadesFromTransforms(this.Messaging, this.FileSystemManager, this.SubStorages);
270
- command.Execute();
271
- var filesFromTransforms = command.FileFacades;
272
-
273
- fileFacades.AddRange(filesFromTransforms);
274
- }
271
272
// stop processing if an error previously occurred
273
if (this.Messaging.EncounteredError)
@@ -368,11 +364,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind
364
output.SubStorages.Add(storage);
365
}
366
}
371
- else // we can create instance transforms since Component Guids are set.
372
- {
373
- var command = new CreateInstanceTransformsCommand(section, output, tableDefinitions, this.BackendHelper);
374
- command.Execute();
375
- }
367
368
#if TODO_FINISH_UPDATE
369
// Extended binder extensions can be called now that fields are resolved.
@@ -412,6 +403,13 @@ namespace WixToolset.Core.WindowsInstaller.Bind
403
404
this.ValidateComponentGuids(output);
405
406
+ // We can create instance transforms since Component Guids and Outputs are created.
407
+ if (output.Type == OutputType.Product)
408
+ {
409
+ var command = new CreateInstanceTransformsCommand(section, output, tableDefinitions, this.BackendHelper);
410
+ command.Execute();
411
+ }
412
+
413
// Stop processing if an error previously occurred.
414
if (this.Messaging.EncounteredError)
415
{
src/WixToolset.Core.WindowsInstaller/Bind/ExtractMergeModuleFilesCommand.cs
+10
-9
@@ -21,26 +21,27 @@ namespace WixToolset.Core.WindowsInstaller.Bind
21
/// </summary>
22
internal class ExtractMergeModuleFilesCommand
23
{
24
- public ExtractMergeModuleFilesCommand(IMessaging messaging, IntermediateSection section, List<WixMergeTuple> wixMergeTuples)
24
+ public ExtractMergeModuleFilesCommand(IMessaging messaging, IEnumerable<WixMergeTuple> wixMergeTuples, IEnumerable<FileFacade> fileFacades, int installerVersion, string intermediateFolder, bool suppressLayout)
25
{
26
this.Messaging = messaging;
27
- this.Section = section;
27
this.WixMergeTuples = wixMergeTuples;
28
+ this.FileFacades = fileFacades;
29
+ this.OutputInstallerVersion = installerVersion;
30
+ this.IntermediateFolder = intermediateFolder;
31
+ this.SuppressLayout = suppressLayout;
32
}
33
34
private IMessaging Messaging { get; }
35
33
- private IntermediateSection Section { get; }
36
+ private IEnumerable<WixMergeTuple> WixMergeTuples { get; }
37
35
- private List<WixMergeTuple> WixMergeTuples { get; }
38
+ private IEnumerable<FileFacade> FileFacades { get; }
39
37
- public IEnumerable<FileFacade> FileFacades { private get; set; }
40
+ private int OutputInstallerVersion { get; }
41
39
- public int OutputInstallerVersion { private get; set; }
42
+ private string IntermediateFolder { get; }
43
41
- public bool SuppressLayout { private get; set; }
42
-
43
- public string IntermediateFolder { private get; set; }
44
+ private bool SuppressLayout { get; }
45
46
public IEnumerable<FileFacade> MergeModulesFileFacades { get; private set; }
47
src/WixToolset.Core.WindowsInstaller/Bind/GetFileFacadesFromTransforms.cs
+1
-1
@@ -27,7 +27,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
27
28
private IEnumerable<SubStorage> SubStorages { get; }
29
30
- public IEnumerable<FileFacade> FileFacades { get; private set; }
30
+ public List<FileFacade> FileFacades { get; private set; }
31
32
public void Execute()
33
{
src/WixToolset.Core/Linker.cs
+9
-9
@@ -168,7 +168,7 @@ namespace WixToolset.Core
168
// references that particpate in groups.
169
sections = resolve.ResolvedSections.ToList();
170
171
- // TODO: consider filtering "localizations" down to only those localizations from
171
+ // TODO: consider filtering "localizations" down to only those localizations from
172
// intermediates in the sections.
173
174
this.FlattenSectionsComplexReferences(sections);
@@ -261,8 +261,8 @@ namespace WixToolset.Core
261
if (WindowsInstallerStandard.IsStandardDirectory(directory))
262
{
263
// if the directory table contains references to standard windows folders
264
- // mergemod.dll will add customactions to set the MSM directory to
265
- // the same directory as the standard windows folder and will add references to
264
+ // mergemod.dll will add customactions to set the MSM directory to
265
+ // the same directory as the standard windows folder and will add references to
266
// custom action to all the standard sequence tables. A problem will occur
267
// if the MSI does not have these tables as mergemod.dll does not add these
268
// tables to the MSI if absent. This code adds the tables in case mergemod.dll
@@ -982,7 +982,7 @@ namespace WixToolset.Core
982
}
983
984
// If the child of the complex reference is another group, then in Step 2
985
- // we're going to have to process this complex reference again to copy
985
+ // we're going to have to process this complex reference again to copy
986
// the child group's references into the parent group.
987
if ((ComplexReferenceChildType.ComponentGroup == wixComplexReferenceRow.ChildType) ||
988
(ComplexReferenceChildType.FeatureGroup == wixComplexReferenceRow.ChildType) ||
@@ -1081,14 +1081,14 @@ namespace WixToolset.Core
1081
var childTypeAndId = this.CombineTypeAndId(wixComplexReferenceRow.ChildType, wixComplexReferenceRow.Child);
1082
if (loopDetector.Contains(childTypeAndId))
1083
{
1084
- // Create a comma delimited list of the references that participate in the
1084
+ // Create a comma delimited list of the references that participate in the
1085
// loop for the error message. Start at the bottom of the stack and work the
1086
// way up to present the loop as a directed graph.
1087
var loop = String.Join(" -> ", loopDetector);
1088
1089
this.Messaging.Write(ErrorMessages.ReferenceLoopDetected(wixComplexReferenceRow?.SourceLineNumbers, loop));
1090
1091
- // Cleanup the parentGroupsNeedingProcessing and the loopDetector just like the
1091
+ // Cleanup the parentGroupsNeedingProcessing and the loopDetector just like the
1092
// exit of this method does at the end because we are exiting early.
1093
loopDetector.Pop();
1094
parentGroupsNeedingProcessing.Remove(parentTypeAndId);
@@ -1097,7 +1097,7 @@ namespace WixToolset.Core
1097
}
1098
1099
// Check to see if the child group still needs to be processed. If so,
1100
- // go do that so that we'll get all of that children's (and children's
1100
+ // go do that so that we'll get all of that children's (and children's
1101
// children) complex references correctly merged into our parent group.
1102
if (parentGroupsNeedingProcessing.ContainsKey(childTypeAndId))
1103
{
@@ -1107,7 +1107,7 @@ namespace WixToolset.Core
1107
// If the child is a parent to anything (i.e. the parent has grandchildren)
1108
// clone each of the children's complex references, repoint them to the parent
1109
// complex reference (because we're moving references up the tree), and finally
1110
- // add the cloned child's complex reference to the list of complex references
1110
+ // add the cloned child's complex reference to the list of complex references
1111
// that we'll eventually add to the parent group.
1112
if (parentGroups.TryGetValue(childTypeAndId, out var referencesToChild))
1113
{
@@ -1148,7 +1148,7 @@ namespace WixToolset.Core
1148
}
1149
else if (i > 0)
1150
{
1151
- // Since the list is already sorted, we can find duplicates by simply
1151
+ // Since the list is already sorted, we can find duplicates by simply
1152
// looking at the next sibling in the list and tossing out one if they
1153
// match.
1154
var crefCompare = referencesToParent[i - 1];