aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.Burn/RowIndexedList.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core.Burn/RowIndexedList.cs')
-rw-r--r--src/WixToolset.Core.Burn/RowIndexedList.cs21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/WixToolset.Core.Burn/RowIndexedList.cs b/src/WixToolset.Core.Burn/RowIndexedList.cs
index 73172dc2..fd762a24 100644
--- a/src/WixToolset.Core.Burn/RowIndexedList.cs
+++ b/src/WixToolset.Core.Burn/RowIndexedList.cs
@@ -13,9 +13,9 @@ namespace WixToolset.Core.Burn
13 /// </summary> 13 /// </summary>
14 internal sealed class RowIndexedList<T> : IList<T> where T : Row 14 internal sealed class RowIndexedList<T> : IList<T> where T : Row
15 { 15 {
16 private Dictionary<string, T> index; 16 private readonly Dictionary<string, T> index;
17 private List<T> rows; 17 private readonly List<T> rows;
18 private List<T> duplicates; 18 private readonly List<T> duplicates;
19 19
20 /// <summary> 20 /// <summary>
21 /// Creates an empty <see cref="RowIndexedList{T}"/>. 21 /// Creates an empty <see cref="RowIndexedList{T}"/>.
@@ -34,7 +34,7 @@ namespace WixToolset.Core.Burn
34 public RowIndexedList(IEnumerable<T> rows) 34 public RowIndexedList(IEnumerable<T> rows)
35 : this() 35 : this()
36 { 36 {
37 foreach (T row in rows) 37 foreach (var row in rows)
38 { 38 {
39 this.Add(row); 39 this.Add(row);
40 } 40 }
@@ -81,8 +81,7 @@ namespace WixToolset.Core.Burn
81 /// <returns>Row or null if key is not found.</returns> 81 /// <returns>Row or null if key is not found.</returns>
82 public T Get(string key) 82 public T Get(string key)
83 { 83 {
84 T result; 84 return this.TryGet(key, out var result) ? result : null;
85 return this.TryGet(key, out result) ? result : null;
86 } 85 }
87 86
88 /// <summary> 87 /// <summary>
@@ -169,12 +168,11 @@ namespace WixToolset.Core.Burn
169 /// <param name="index">Index to remove the row at.</param> 168 /// <param name="index">Index to remove the row at.</param>
170 public void RemoveAt(int index) 169 public void RemoveAt(int index)
171 { 170 {
172 T row = this.rows[index]; 171 var row = this.rows[index];
173 172
174 this.rows.RemoveAt(index); 173 this.rows.RemoveAt(index);
175 174
176 T indexRow; 175 if (this.index.TryGetValue(row.GetKey(), out var indexRow) && indexRow == row)
177 if (this.index.TryGetValue(row.GetKey(), out indexRow) && indexRow == row)
178 { 176 {
179 this.index.Remove(row.GetKey()); 177 this.index.Remove(row.GetKey());
180 } 178 }
@@ -264,11 +262,10 @@ namespace WixToolset.Core.Burn
264 /// <returns></returns> 262 /// <returns></returns>
265 public bool Remove(T row) 263 public bool Remove(T row)
266 { 264 {
267 bool removed = this.rows.Remove(row); 265 var removed = this.rows.Remove(row);
268 if (removed) 266 if (removed)
269 { 267 {
270 T indexRow; 268 if (this.index.TryGetValue(row.GetKey(), out var indexRow) && indexRow == row)
271 if (this.index.TryGetValue(row.GetKey(), out indexRow) && indexRow == row)
272 { 269 {
273 this.index.Remove(row.GetKey()); 270 this.index.Remove(row.GetKey());
274 } 271 }