diff options
author | Rob Mensching <rob@firegiant.com> | 2021-04-19 16:08:25 -0700 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2021-04-19 16:30:02 -0700 |
commit | 9728166b827e8010494fbcb18ab734bb6d523c9b (patch) | |
tree | 1dfb42bdcf8d3eb4c00e94f3990458bd5b2948c7 /src | |
parent | c9c92ff83b24d6ed055032f62e833090ea4f8d9c (diff) | |
download | wix-9728166b827e8010494fbcb18ab734bb6d523c9b.tar.gz wix-9728166b827e8010494fbcb18ab734bb6d523c9b.tar.bz2 wix-9728166b827e8010494fbcb18ab734bb6d523c9b.zip |
Prefer IReadOnlyCollection<> or IReadOnlyList<> over IEnumerable<>
Part of wixtoolset/issues#6422
Diffstat (limited to 'src')
-rw-r--r-- | src/WixToolset.Data/Intermediate.cs | 34 | ||||
-rw-r--r-- | src/WixToolset.Data/WindowsInstaller/WindowsInstallerStandard.cs | 4 |
2 files changed, 30 insertions, 8 deletions
diff --git a/src/WixToolset.Data/Intermediate.cs b/src/WixToolset.Data/Intermediate.cs index 05ffdbf6..37fe7549 100644 --- a/src/WixToolset.Data/Intermediate.cs +++ b/src/WixToolset.Data/Intermediate.cs | |||
@@ -18,6 +18,7 @@ namespace WixToolset.Data | |||
18 | private const string WixOutputStreamName = "wix-ir.json"; | 18 | private const string WixOutputStreamName = "wix-ir.json"; |
19 | 19 | ||
20 | private readonly Dictionary<string, Localization> localizationsByCulture; | 20 | private readonly Dictionary<string, Localization> localizationsByCulture; |
21 | private readonly List<IntermediateSection> sections; | ||
21 | 22 | ||
22 | /// <summary> | 23 | /// <summary> |
23 | /// Instantiate a new Intermediate. | 24 | /// Instantiate a new Intermediate. |
@@ -26,7 +27,7 @@ namespace WixToolset.Data | |||
26 | { | 27 | { |
27 | this.Id = Convert.ToBase64String(Guid.NewGuid().ToByteArray()).TrimEnd('=').Replace('+', '.').Replace('/', '_'); | 28 | this.Id = Convert.ToBase64String(Guid.NewGuid().ToByteArray()).TrimEnd('=').Replace('+', '.').Replace('/', '_'); |
28 | this.localizationsByCulture = new Dictionary<string, Localization>(StringComparer.OrdinalIgnoreCase); | 29 | this.localizationsByCulture = new Dictionary<string, Localization>(StringComparer.OrdinalIgnoreCase); |
29 | this.Sections = new List<IntermediateSection>(); | 30 | this.sections = new List<IntermediateSection>(); |
30 | } | 31 | } |
31 | 32 | ||
32 | public Intermediate(string id, IEnumerable<IntermediateSection> sections, IDictionary<string, Localization> localizationsByCulture) : this(id, level: null, sections, localizationsByCulture) | 33 | public Intermediate(string id, IEnumerable<IntermediateSection> sections, IDictionary<string, Localization> localizationsByCulture) : this(id, level: null, sections, localizationsByCulture) |
@@ -38,7 +39,7 @@ namespace WixToolset.Data | |||
38 | this.Id = id; | 39 | this.Id = id; |
39 | this.Level = level; | 40 | this.Level = level; |
40 | this.localizationsByCulture = (localizationsByCulture != null) ? new Dictionary<string, Localization>(localizationsByCulture, StringComparer.OrdinalIgnoreCase) : new Dictionary<string, Localization>(StringComparer.OrdinalIgnoreCase); | 41 | this.localizationsByCulture = (localizationsByCulture != null) ? new Dictionary<string, Localization>(localizationsByCulture, StringComparer.OrdinalIgnoreCase) : new Dictionary<string, Localization>(StringComparer.OrdinalIgnoreCase); |
41 | this.Sections = (sections != null) ? new List<IntermediateSection>(sections) : new List<IntermediateSection>(); | 42 | this.sections = (sections != null) ? new List<IntermediateSection>(sections) : new List<IntermediateSection>(); |
42 | } | 43 | } |
43 | 44 | ||
44 | /// <summary> | 45 | /// <summary> |
@@ -54,12 +55,12 @@ namespace WixToolset.Data | |||
54 | /// <summary> | 55 | /// <summary> |
55 | /// Get the localizations contained in this intermediate. | 56 | /// Get the localizations contained in this intermediate. |
56 | /// </summary> | 57 | /// </summary> |
57 | public IEnumerable<Localization> Localizations => this.localizationsByCulture.Values; | 58 | public IReadOnlyCollection<Localization> Localizations => this.localizationsByCulture.Values; |
58 | 59 | ||
59 | /// <summary> | 60 | /// <summary> |
60 | /// Get the sections contained in this intermediate. | 61 | /// Get the sections contained in this intermediate. |
61 | /// </summary> | 62 | /// </summary> |
62 | public IList<IntermediateSection> Sections { get; } | 63 | public IReadOnlyCollection<IntermediateSection> Sections => this.sections; |
63 | 64 | ||
64 | /// <summary> | 65 | /// <summary> |
65 | /// Loads an intermediate from a path on disk. | 66 | /// Loads an intermediate from a path on disk. |
@@ -146,7 +147,7 @@ namespace WixToolset.Data | |||
146 | /// </summary> | 147 | /// </summary> |
147 | /// <param name="intermediateFiles">Paths to intermediate files saved on disk.</param> | 148 | /// <param name="intermediateFiles">Paths to intermediate files saved on disk.</param> |
148 | /// <returns>Returns the loaded intermediates</returns> | 149 | /// <returns>Returns the loaded intermediates</returns> |
149 | public static IEnumerable<Intermediate> Load(IEnumerable<string> intermediateFiles) | 150 | public static IReadOnlyList<Intermediate> Load(IEnumerable<string> intermediateFiles) |
150 | { | 151 | { |
151 | var creator = new SimpleSymbolDefinitionCreator(); | 152 | var creator = new SimpleSymbolDefinitionCreator(); |
152 | return Intermediate.Load(intermediateFiles, creator); | 153 | return Intermediate.Load(intermediateFiles, creator); |
@@ -159,7 +160,7 @@ namespace WixToolset.Data | |||
159 | /// <param name="creator">ISymbolDefinitionCreator to use when reconstituting the intermediates.</param> | 160 | /// <param name="creator">ISymbolDefinitionCreator to use when reconstituting the intermediates.</param> |
160 | /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatches.</param> | 161 | /// <param name="suppressVersionCheck">Suppress checking for wix.dll version mismatches.</param> |
161 | /// <returns>Returns the loaded intermediates</returns> | 162 | /// <returns>Returns the loaded intermediates</returns> |
162 | public static IEnumerable<Intermediate> Load(IEnumerable<string> intermediateFiles, ISymbolDefinitionCreator creator, bool suppressVersionCheck = false) | 163 | public static IReadOnlyList<Intermediate> Load(IEnumerable<string> intermediateFiles, ISymbolDefinitionCreator creator, bool suppressVersionCheck = false) |
163 | { | 164 | { |
164 | var jsons = new Queue<JsonWithPath>(); | 165 | var jsons = new Queue<JsonWithPath>(); |
165 | var intermediates = new List<Intermediate>(); | 166 | var intermediates = new List<Intermediate>(); |
@@ -190,6 +191,27 @@ namespace WixToolset.Data | |||
190 | } | 191 | } |
191 | 192 | ||
192 | /// <summary> | 193 | /// <summary> |
194 | /// Adds a section to the intermedaite. | ||
195 | /// </summary> | ||
196 | /// <param name="section">Section to add to the intermediate.</param> | ||
197 | /// <returns>Section added to the intermediate.</returns> | ||
198 | public IntermediateSection AddSection(IntermediateSection section) | ||
199 | { | ||
200 | this.sections.Add(section); | ||
201 | return section; | ||
202 | } | ||
203 | |||
204 | /// <summary> | ||
205 | /// Removes a section from the intermediate. | ||
206 | /// </summary> | ||
207 | /// <param name="section">Section to remove.</param> | ||
208 | /// <returns>True if the section was removed; otherwise false.</returns> | ||
209 | public bool Removesection(IntermediateSection section) | ||
210 | { | ||
211 | return this.sections.Remove(section); | ||
212 | } | ||
213 | |||
214 | /// <summary> | ||
193 | /// Updates the intermediate level to the specified level. | 215 | /// Updates the intermediate level to the specified level. |
194 | /// </summary> | 216 | /// </summary> |
195 | /// <param name="level">Intermediate level.</param> | 217 | /// <param name="level">Intermediate level.</param> |
diff --git a/src/WixToolset.Data/WindowsInstaller/WindowsInstallerStandard.cs b/src/WixToolset.Data/WindowsInstaller/WindowsInstallerStandard.cs index 0e6092b3..b6930b79 100644 --- a/src/WixToolset.Data/WindowsInstaller/WindowsInstallerStandard.cs +++ b/src/WixToolset.Data/WindowsInstaller/WindowsInstallerStandard.cs | |||
@@ -414,12 +414,12 @@ namespace WixToolset.Data.WindowsInstaller | |||
414 | /// <summary> | 414 | /// <summary> |
415 | /// Standard actions. | 415 | /// Standard actions. |
416 | /// </summary> | 416 | /// </summary> |
417 | public static IEnumerable<WixActionSymbol> StandardActions() => standardActionsById.Values; | 417 | public static IReadOnlyCollection<WixActionSymbol> StandardActions() => standardActionsById.Values; |
418 | 418 | ||
419 | /// <summary> | 419 | /// <summary> |
420 | /// Standard directories. | 420 | /// Standard directories. |
421 | /// </summary> | 421 | /// </summary> |
422 | public static IEnumerable<DirectorySymbol> StandardDirectories() => standardDirectoriesById.Values; | 422 | public static IReadOnlyCollection<DirectorySymbol> StandardDirectories() => standardDirectoriesById.Values; |
423 | 423 | ||
424 | /// <summary> | 424 | /// <summary> |
425 | /// Gets the platform specific directory id for a directory. Most directories are not platform | 425 | /// Gets the platform specific directory id for a directory. Most directories are not platform |