@joebigelow / wix / commits / 58791d3d

Add SequenceTable.WindowsInstallerTableName() and other minor clean up

Rob Mensching committed Jun 4, 2020 at 10:18 UTC 58791d3dbffce2a96280e08fc2d36ab69571d02c
2 files changed +38 -21
src/WixToolset.Data/WindowsInstaller/SequenceTableExtensions.cs new
+17
@@ -0,0 +1,17 @@
1 +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2 +
3 +namespace WixToolset.Data.WindowsInstaller
4 +{
5 + using WixToolset.Data.Tuples;
6 +
7 + /// <summary>
8 + /// Enhancements to the SequenceTable enum.
9 + /// </summary>
10 + public static class SequenceTableExtensions
11 + {
12 + /// <summary>
13 + /// Gets the SequenceTable enum as the Windows Installer table name.
14 + /// </summary>
15 + public static string WindowsInstallerTableName(this SequenceTable sequence) => (sequence == SequenceTable.AdvertiseExecuteSequence) ? "AdvtExecuteSequence" : sequence.ToString();
16 + }
17 +}
src/WixToolset.Data/WindowsInstaller/Table.cs
+21 -21
@@ -59,6 +59,27 @@ namespace WixToolset.Data.WindowsInstaller
59 return row;
60 }
61
62 + /// <summary>
63 + /// Validates the rows of this OutputTable and throws if it collides on
64 + /// primary keys.
65 + /// </summary>
66 + public void ValidateRows()
67 + {
68 + var primaryKeys = new Dictionary<string, SourceLineNumber>();
69 +
70 + foreach (var row in this.Rows)
71 + {
72 + var primaryKey = row.GetPrimaryKey();
73 +
74 + if (primaryKeys.TryGetValue(primaryKey, out var collisionSourceLineNumber))
75 + {
76 + throw new WixException(ErrorMessages.DuplicatePrimaryKey(collisionSourceLineNumber, primaryKey, this.Definition.Name));
77 + }
78 +
79 + primaryKeys.Add(primaryKey, row.SourceLineNumbers);
80 + }
81 + }
82 +
83 /// <summary>
84 /// Parse a table from the xml.
85 /// </summary>
@@ -165,26 +186,5 @@ namespace WixToolset.Data.WindowsInstaller
186
187 writer.WriteEndElement();
188 }
168 -
169 - /// <summary>
170 - /// Validates the rows of this OutputTable and throws if it collides on
171 - /// primary keys.
172 - /// </summary>
173 - public void ValidateRows()
174 - {
175 - var primaryKeys = new Dictionary<string, SourceLineNumber>();
176 -
177 - foreach (var row in this.Rows)
178 - {
179 - var primaryKey = row.GetPrimaryKey();
180 -
181 - if (primaryKeys.TryGetValue(primaryKey, out var collisionSourceLineNumber))
182 - {
183 - throw new WixException(ErrorMessages.DuplicatePrimaryKey(collisionSourceLineNumber, primaryKey, this.Definition.Name));
184 - }
185 -
186 - primaryKeys.Add(primaryKey, row.SourceLineNumbers);
187 - }
188 - }
189 }
190 }