aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.WindowsInstaller
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2020-04-11 21:49:09 +1000
committerSean Hall <r.sean.hall@gmail.com>2020-04-12 12:46:21 +1000
commit6d8b6f79b44b6a41a630aa3aad5a3c7f16701798 (patch)
treeb82ede9934cb7777a19e74a912c68481e76c21cd /src/WixToolset.Core.WindowsInstaller
parentdf69d4172d3117d8b66ba51fa5ae7f4be538700d (diff)
downloadwix-6d8b6f79b44b6a41a630aa3aad5a3c7f16701798.tar.gz
wix-6d8b6f79b44b6a41a630aa3aad5a3c7f16701798.tar.bz2
wix-6d8b6f79b44b6a41a630aa3aad5a3c7f16701798.zip
General cleanup.
Try not to send strings to specify the tuple or table. Try to avoid using the Set method on tuples. Always create new tuples and add them to the section in the same line.
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller')
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/AddCreateFoldersCommand.cs6
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs31
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs2
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs38
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/CreateSpecialPropertiesCommand.cs24
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs2
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs20
7 files changed, 59 insertions, 64 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/AddCreateFoldersCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/AddCreateFoldersCommand.cs
index 6cc4153f..ba844da4 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/AddCreateFoldersCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/AddCreateFoldersCommand.cs
@@ -26,13 +26,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind
26 { 26 {
27 if (!createFolderTuplesByComponentRef.Contains(componentTuple.Id.Id)) 27 if (!createFolderTuplesByComponentRef.Contains(componentTuple.Id.Id))
28 { 28 {
29 var createFolderTuple = new CreateFolderTuple(componentTuple.SourceLineNumbers) 29 this.Section.AddTuple(new CreateFolderTuple(componentTuple.SourceLineNumbers)
30 { 30 {
31 DirectoryRef = componentTuple.DirectoryRef, 31 DirectoryRef = componentTuple.DirectoryRef,
32 ComponentRef = componentTuple.Id.Id, 32 ComponentRef = componentTuple.Id.Id,
33 }; 33 });
34
35 this.Section.Tuples.Add(createFolderTuple);
36 } 34 }
37 } 35 }
38 } 36 }
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs
index 2bfd587f..ae7e5788 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/AssignMediaCommand.cs
@@ -71,12 +71,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind
71 // When building merge module, all the files go to "#MergeModule.CABinet". 71 // When building merge module, all the files go to "#MergeModule.CABinet".
72 if (SectionType.Module == this.Section.Type) 72 if (SectionType.Module == this.Section.Type)
73 { 73 {
74 var mergeModuleMediaRow = new MediaTuple(); 74 var mergeModuleMediaTuple = this.Section.AddTuple(new MediaTuple
75 mergeModuleMediaRow.Cabinet = "#MergeModule.CABinet"; 75 {
76 76 Cabinet = "#MergeModule.CABinet",
77 this.Section.Tuples.Add(mergeModuleMediaRow); 77 });
78 78
79 filesByCabinetMedia.Add(mergeModuleMediaRow, new List<FileFacade>(this.FileFacades)); 79 filesByCabinetMedia.Add(mergeModuleMediaTuple, new List<FileFacade>(this.FileFacades));
80 } 80 }
81 else if (mediaTemplateTable.Count == 0) 81 else if (mediaTemplateTable.Count == 0)
82 { 82 {
@@ -212,13 +212,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind
212 // If there are uncompressed files and no MediaRow, create a default one. 212 // If there are uncompressed files and no MediaRow, create a default one.
213 if (uncompressedFiles.Count > 0 && !this.Section.Tuples.OfType<MediaTuple>().Any()) 213 if (uncompressedFiles.Count > 0 && !this.Section.Tuples.OfType<MediaTuple>().Any())
214 { 214 {
215 var defaultMediaRow = new MediaTuple(null, new Identifier(AccessModifier.Private, 1)) 215 var defaultMediaRow = this.Section.AddTuple(new MediaTuple(null, new Identifier(AccessModifier.Private, 1))
216 { 216 {
217 DiskId = 1 217 DiskId = 1,
218 }; 218 });
219 219
220 mediaRows.Add(1, defaultMediaRow); 220 mediaRows.Add(1, defaultMediaRow);
221 this.Section.Tuples.Add(defaultMediaRow);
222 } 221 }
223 } 222 }
224 223
@@ -298,14 +297,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind
298 /// <returns></returns> 297 /// <returns></returns>
299 private MediaTuple AddMediaRow(WixMediaTemplateTuple mediaTemplateTuple, int cabIndex) 298 private MediaTuple AddMediaRow(WixMediaTemplateTuple mediaTemplateTuple, int cabIndex)
300 { 299 {
301 var currentMediaTuple = new MediaTuple(mediaTemplateTuple.SourceLineNumbers, new Identifier(AccessModifier.Private, cabIndex)); 300 return this.Section.AddTuple(new MediaTuple(mediaTemplateTuple.SourceLineNumbers, new Identifier(AccessModifier.Private, cabIndex))
302 currentMediaTuple.DiskId = cabIndex; 301 {
303 currentMediaTuple.Cabinet = String.Format(CultureInfo.InvariantCulture, this.CabinetNameTemplate, cabIndex); 302 DiskId = cabIndex,
304 currentMediaTuple.CompressionLevel = mediaTemplateTuple.CompressionLevel; 303 Cabinet = String.Format(CultureInfo.InvariantCulture, this.CabinetNameTemplate, cabIndex),
305 304 CompressionLevel = mediaTemplateTuple.CompressionLevel,
306 this.Section.Tuples.Add(currentMediaTuple); 305 });
307
308 return currentMediaTuple;
309 } 306 }
310 } 307 }
311} 308}
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs
index f4fa510f..ca6bfd2f 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/AttachPatchTransformsCommand.cs
@@ -225,7 +225,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
225 // Put the summary information that was extracted back in now that it is updated. 225 // Put the summary information that was extracted back in now that it is updated.
226 foreach (var readSummaryInfo in summaryInfo.Values.OrderBy(s => s.PropertyId)) 226 foreach (var readSummaryInfo in summaryInfo.Values.OrderBy(s => s.PropertyId))
227 { 227 {
228 section.Tuples.Add(readSummaryInfo); 228 section.AddTuple(readSummaryInfo);
229 } 229 }
230 230
231 this.SubStorages = subStorages; 231 this.SubStorages = subStorages;
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs
index 8aa6047f..7a9dbc69 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindSummaryInfoCommand.cs
@@ -44,10 +44,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind
44 this.InstallerVersion = 0; 44 this.InstallerVersion = 0;
45 this.ModularizationGuid = null; 45 this.ModularizationGuid = null;
46 46
47 bool foundCreateDataTime = false; 47 var foundCreateDataTime = false;
48 bool foundLastSaveDataTime = false; 48 var foundLastSaveDataTime = false;
49 bool foundCreatingApplication = false; 49 var foundCreatingApplication = false;
50 string now = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture); 50 var now = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture);
51 51
52 foreach (var summaryInformationTuple in this.Section.Tuples.OfType<SummaryInformationTuple>()) 52 foreach (var summaryInformationTuple in this.Section.Tuples.OfType<SummaryInformationTuple>())
53 { 53 {
@@ -110,31 +110,31 @@ namespace WixToolset.Core.WindowsInstaller.Bind
110 // add a summary information row for the create time/date property if its not already set 110 // add a summary information row for the create time/date property if its not already set
111 if (!foundCreateDataTime) 111 if (!foundCreateDataTime)
112 { 112 {
113 var createTimeDateRow = new SummaryInformationTuple(null); 113 this.Section.AddTuple(new SummaryInformationTuple(null)
114 createTimeDateRow.PropertyId = SumaryInformationType.Created; 114 {
115 createTimeDateRow.Value = now; 115 PropertyId = SumaryInformationType.Created,
116 116 Value = now,
117 this.Section.Tuples.Add(createTimeDateRow); 117 });
118 } 118 }
119 119
120 // add a summary information row for the last save time/date property if its not already set 120 // add a summary information row for the last save time/date property if its not already set
121 if (!foundLastSaveDataTime) 121 if (!foundLastSaveDataTime)
122 { 122 {
123 var lastSaveTimeDateRow = new SummaryInformationTuple(null); 123 this.Section.AddTuple(new SummaryInformationTuple(null)
124 lastSaveTimeDateRow.PropertyId = SumaryInformationType.LastSaved; 124 {
125 lastSaveTimeDateRow.Value = now; 125 PropertyId = SumaryInformationType.LastSaved,
126 126 Value = now,
127 this.Section.Tuples.Add(lastSaveTimeDateRow); 127 });
128 } 128 }
129 129
130 // add a summary information row for the creating application property if its not already set 130 // add a summary information row for the creating application property if its not already set
131 if (!foundCreatingApplication) 131 if (!foundCreatingApplication)
132 { 132 {
133 var creatingApplicationRow = new SummaryInformationTuple(null); 133 this.Section.AddTuple(new SummaryInformationTuple(null)
134 creatingApplicationRow.PropertyId = SumaryInformationType.CreatingApplication; 134 {
135 creatingApplicationRow.Value = String.Format(CultureInfo.InvariantCulture, AppCommon.GetCreatingApplicationString()); 135 PropertyId = SumaryInformationType.CreatingApplication,
136 136 Value = String.Format(CultureInfo.InvariantCulture, AppCommon.GetCreatingApplicationString()),
137 this.Section.Tuples.Add(creatingApplicationRow); 137 });
138 } 138 }
139 } 139 }
140 } 140 }
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateSpecialPropertiesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateSpecialPropertiesCommand.cs
index 0d165f80..5b4fe9e5 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateSpecialPropertiesCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateSpecialPropertiesCommand.cs
@@ -57,26 +57,26 @@ namespace WixToolset.Core.WindowsInstaller.Bind
57 57
58 if (0 < adminProperties.Count) 58 if (0 < adminProperties.Count)
59 { 59 {
60 var tuple = new PropertyTuple(null, new Identifier(AccessModifier.Private, "AdminProperties")); 60 this.Section.AddTuple(new PropertyTuple(null, new Identifier(AccessModifier.Private, "AdminProperties"))
61 tuple.Value = String.Join(";", adminProperties); 61 {
62 62 Value = String.Join(";", adminProperties),
63 this.Section.Tuples.Add(tuple); 63 });
64 } 64 }
65 65
66 if (0 < secureProperties.Count) 66 if (0 < secureProperties.Count)
67 { 67 {
68 var tuple = new PropertyTuple(null, new Identifier(AccessModifier.Private, "SecureCustomProperties")); 68 this.Section.AddTuple(new PropertyTuple(null, new Identifier(AccessModifier.Private, "SecureCustomProperties"))
69 tuple.Value = String.Join(";", secureProperties); 69 {
70 70 Value = String.Join(";", secureProperties),
71 this.Section.Tuples.Add(tuple); 71 });
72 } 72 }
73 73
74 if (0 < hiddenProperties.Count) 74 if (0 < hiddenProperties.Count)
75 { 75 {
76 var tuple = new PropertyTuple(null, new Identifier(AccessModifier.Private, "MsiHiddenProperties")); 76 this.Section.AddTuple(new PropertyTuple(null, new Identifier(AccessModifier.Private, "MsiHiddenProperties"))
77 tuple.Value = String.Join(";", hiddenProperties); 77 {
78 78 Value = String.Join(";", hiddenProperties)
79 this.Section.Tuples.Add(tuple); 79 });
80 } 80 }
81 } 81 }
82 } 82 }
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs
index fe014b0b..a5055209 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/SequenceActionsCommand.cs
@@ -186,7 +186,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
186 186
187 foreach (var action in scheduledActionTuples) 187 foreach (var action in scheduledActionTuples)
188 { 188 {
189 this.Section.Tuples.Add(action); 189 this.Section.AddTuple(action);
190 } 190 }
191 } 191 }
192 192
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs
index 81d46b41..7ecd58d7 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/UpdateFileFacadesCommand.cs
@@ -158,8 +158,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
158 158
159 if (null == facade.Hash) 159 if (null == facade.Hash)
160 { 160 {
161 facade.Hash = new MsiFileHashTuple(facade.SourceLineNumber, facade.Identifier); 161 facade.Hash = this.Section.AddTuple(new MsiFileHashTuple(facade.SourceLineNumber, facade.Identifier));
162 this.Section.Tuples.Add(facade.Hash);
163 } 162 }
164 163
165 facade.Hash.Options = 0; 164 facade.Hash.Options = 0;
@@ -337,23 +336,24 @@ namespace WixToolset.Core.WindowsInstaller.Bind
337 336
338 // override directly authored value 337 // override directly authored value
339 var lookup = String.Concat(facade.ComponentRef, "/", name); 338 var lookup = String.Concat(facade.ComponentRef, "/", name);
340 if (!assemblyNameTuples.TryGetValue(lookup, out var assemblyNameRow)) 339 if (!assemblyNameTuples.TryGetValue(lookup, out var assemblyNameTuple))
341 { 340 {
342 assemblyNameRow = new MsiAssemblyNameTuple(facade.SourceLineNumber); 341 assemblyNameTuple = this.Section.AddTuple(new MsiAssemblyNameTuple(facade.SourceLineNumber)
343 assemblyNameRow.ComponentRef = facade.ComponentRef; 342 {
344 assemblyNameRow.Name = name; 343 ComponentRef = facade.ComponentRef,
345 assemblyNameRow.Value = value; 344 Name = name,
345 Value = value,
346 });
346 347
347 if (null == facade.AssemblyNames) 348 if (null == facade.AssemblyNames)
348 { 349 {
349 facade.AssemblyNames = new List<MsiAssemblyNameTuple>(); 350 facade.AssemblyNames = new List<MsiAssemblyNameTuple>();
350 } 351 }
351 352
352 facade.AssemblyNames.Add(assemblyNameRow); 353 facade.AssemblyNames.Add(assemblyNameTuple);
353 this.Section.Tuples.Add(assemblyNameRow);
354 } 354 }
355 355
356 assemblyNameRow.Value = value; 356 assemblyNameTuple.Value = value;
357 357
358 if (this.VariableCache != null) 358 if (this.VariableCache != null)
359 { 359 {