Integrate Symbol to TupleWithSection rename
Rob Mensching committed
Jun 24, 2020 at 12:24 UTC
8968578d50858721317d410549a9f9b5c62bf1f7
4 files changed
+91
-92
src/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs
+10
-10
@@ -31,17 +31,17 @@ namespace WixToolset.Core.Link
31
/// <summary>
32
/// Gets the collection of loaded symbols.
33
/// </summary>
34
- public IDictionary<string, Symbol> Symbols { get; private set; }
34
+ public IDictionary<string, TupleWithSection> TuplesByName { get; private set; }
35
36
/// <summary>
37
/// Gets the collection of possibly conflicting symbols.
38
/// </summary>
39
- public IEnumerable<Symbol> PossiblyConflictingSymbols { get; private set; }
39
+ public IEnumerable<TupleWithSection> PossibleConflicts { get; private set; }
40
41
public void Execute()
42
{
43
- var symbols = new Dictionary<string, Symbol>();
44
- var possibleConflicts = new HashSet<Symbol>();
43
+ var tuplesByName = new Dictionary<string, TupleWithSection>();
44
+ var possibleConflicts = new HashSet<TupleWithSection>();
45
46
if (!Enum.TryParse(this.ExpectedOutputType.ToString(), out SectionType expectedEntrySectionType))
47
{
@@ -74,11 +74,11 @@ namespace WixToolset.Core.Link
74
// Load all the symbols from the section's tables that create symbols.
75
foreach (var tuple in section.Tuples.Where(t => t.Id != null))
76
{
77
- var symbol = new Symbol(section, tuple);
77
+ var symbol = new TupleWithSection(section, tuple);
78
79
- if (!symbols.TryGetValue(symbol.Name, out var existingSymbol))
79
+ if (!tuplesByName.TryGetValue(symbol.Name, out var existingSymbol))
80
{
81
- symbols.Add(symbol.Name, symbol);
81
+ tuplesByName.Add(symbol.Name, symbol);
82
}
83
else // uh-oh, duplicate symbols.
84
{
@@ -86,7 +86,7 @@ namespace WixToolset.Core.Link
86
// point to identical tuples. Identical directory tuples are redundant and will not cause
87
// conflicts.
88
if (AccessModifier.Private == existingSymbol.Access && AccessModifier.Private == symbol.Access &&
89
- TupleDefinitionType.Directory == existingSymbol.Row.Definition.Type && existingSymbol.Row.IsIdentical(symbol.Row))
89
+ TupleDefinitionType.Directory == existingSymbol.Tuple.Definition.Type && existingSymbol.Tuple.IsIdentical(symbol.Tuple))
90
{
91
// Ensure identical symbol's tuple is marked redundant to ensure (should the tuple be
92
// referenced into the final output) it will not add duplicate primary keys during
@@ -103,8 +103,8 @@ namespace WixToolset.Core.Link
103
}
104
}
105
106
- this.Symbols = symbols;
107
- this.PossiblyConflictingSymbols = possibleConflicts;
106
+ this.TuplesByName = tuplesByName;
107
+ this.PossibleConflicts = possibleConflicts;
108
}
109
}
110
}
src/WixToolset.Core/Link/ReportConflictingTuplesCommand.cs
renamed
+13
-14
@@ -7,9 +7,9 @@ namespace WixToolset.Core.Link
7
using WixToolset.Data;
8
using WixToolset.Extensibility.Services;
9
10
- internal class ReportConflictingSymbolsCommand
10
+ internal class ReportConflictingTuplesCommand
11
{
12
- public ReportConflictingSymbolsCommand(IMessaging messaging, IEnumerable<Symbol> possibleConflicts, IEnumerable<IntermediateSection> resolvedSections)
12
+ public ReportConflictingTuplesCommand(IMessaging messaging, IEnumerable<TupleWithSection> possibleConflicts, IEnumerable<IntermediateSection> resolvedSections)
13
{
14
this.Messaging = messaging;
15
this.PossibleConflicts = possibleConflicts;
@@ -18,34 +18,33 @@ namespace WixToolset.Core.Link
18
19
private IMessaging Messaging { get; }
20
21
- private IEnumerable<Symbol> PossibleConflicts { get; }
21
+ private IEnumerable<TupleWithSection> PossibleConflicts { get; }
22
23
private IEnumerable<IntermediateSection> ResolvedSections { get; }
24
25
public void Execute()
26
{
27
// Do a quick check if there are any possibly conflicting symbols that don't come from tables that allow
28
- // overriding. Hopefully the symbols with possible conflicts list is usually very short list (empty should
28
+ // overriding. Hopefully the tuples with possible conflicts list is usually very short list (empty should
29
// be the most common). If we find any matches, we'll do a more costly check to see if the possible conflicting
30
- // symbols are in sections we actually referenced. From the resulting set, show an error for each duplicate
31
- // (aka: conflicting) symbol. This should catch any rows with colliding primary keys (since symbols are based
32
- // on the primary keys of rows).
33
- var illegalDuplicates = this.PossibleConflicts.Where(s => s.Row.Definition.Type != TupleDefinitionType.WixAction && s.Row.Definition.Type != TupleDefinitionType.WixVariable).ToList();
30
+ // tuples are in sections we actually referenced. From the resulting set, show an error for each duplicate
31
+ // (aka: conflicting) tuple.
32
+ var illegalDuplicates = this.PossibleConflicts.Where(s => s.Tuple.Definition.Type != TupleDefinitionType.WixAction && s.Tuple.Definition.Type != TupleDefinitionType.WixVariable).ToList();
33
if (0 < illegalDuplicates.Count)
34
{
35
var referencedSections = new HashSet<IntermediateSection>(this.ResolvedSections);
36
38
- foreach (Symbol referencedDuplicateSymbol in illegalDuplicates.Where(s => referencedSections.Contains(s.Section)))
37
+ foreach (var referencedDuplicate in illegalDuplicates.Where(s => referencedSections.Contains(s.Section)))
38
{
40
- List<Symbol> actuallyReferencedDuplicateSymbols = referencedDuplicateSymbol.PossiblyConflictingSymbols.Where(s => referencedSections.Contains(s.Section)).ToList();
39
+ var actuallyReferencedDuplicates = referencedDuplicate.PossiblyConflicts.Where(s => referencedSections.Contains(s.Section)).ToList();
40
42
- if (actuallyReferencedDuplicateSymbols.Any())
41
+ if (actuallyReferencedDuplicates.Any())
42
{
44
- this.Messaging.Write(ErrorMessages.DuplicateSymbol(referencedDuplicateSymbol.Row.SourceLineNumbers, referencedDuplicateSymbol.Name));
43
+ this.Messaging.Write(ErrorMessages.DuplicateSymbol(referencedDuplicate.Tuple.SourceLineNumbers, referencedDuplicate.Name));
44
46
- foreach (Symbol duplicate in actuallyReferencedDuplicateSymbols)
45
+ foreach (var duplicate in actuallyReferencedDuplicates)
46
{
48
- this.Messaging.Write(ErrorMessages.DuplicateSymbol2(duplicate.Row.SourceLineNumbers));
47
+ this.Messaging.Write(ErrorMessages.DuplicateSymbol2(duplicate.Tuple.SourceLineNumbers));
48
}
49
}
50
}
src/WixToolset.Core/Link/ResolveReferencesCommand.cs
+50
-50
@@ -15,19 +15,19 @@ namespace WixToolset.Core.Link
15
internal class ResolveReferencesCommand
16
{
17
private readonly IntermediateSection entrySection;
18
- private readonly IDictionary<string, Symbol> symbols;
19
- private HashSet<Symbol> referencedSymbols;
18
+ private readonly IDictionary<string, TupleWithSection> tuplesWithSections;
19
+ private HashSet<TupleWithSection> referencedTuples;
20
private HashSet<IntermediateSection> resolvedSections;
21
22
- public ResolveReferencesCommand(IMessaging messaging, IntermediateSection entrySection, IDictionary<string, Symbol> symbols)
22
+ public ResolveReferencesCommand(IMessaging messaging, IntermediateSection entrySection, IDictionary<string, TupleWithSection> tuplesWithSections)
23
{
24
this.Messaging = messaging;
25
this.entrySection = entrySection;
26
- this.symbols = symbols;
26
+ this.tuplesWithSections = tuplesWithSections;
27
this.BuildingMergeModule = (SectionType.Module == entrySection.Type);
28
}
29
30
- public IEnumerable<Symbol> ReferencedSymbols => this.referencedSymbols;
30
+ public IEnumerable<TupleWithSection> ReferencedTupleWithSections => this.referencedTuples;
31
32
public IEnumerable<IntermediateSection> ResolvedSections => this.resolvedSections;
33
@@ -41,7 +41,7 @@ namespace WixToolset.Core.Link
41
public void Execute()
42
{
43
this.resolvedSections = new HashSet<IntermediateSection>();
44
- this.referencedSymbols = new HashSet<Symbol>();
44
+ this.referencedTuples = new HashSet<TupleWithSection>();
45
46
this.RecursivelyResolveReferences(this.entrySection);
47
}
@@ -60,8 +60,8 @@ namespace WixToolset.Core.Link
60
}
61
62
// Process all of the references contained in this section using the collection of
63
- // symbols provided. Then recursively call this method to process the
64
- // located symbol's section. All in all this is a very simple depth-first
63
+ // tuples provided. Then recursively call this method to process the
64
+ // located tuple's section. All in all this is a very simple depth-first
65
// search of the references per-section.
66
foreach (var wixSimpleReferenceRow in section.Tuples.OfType<WixSimpleReferenceTuple>())
67
{
@@ -72,44 +72,44 @@ namespace WixToolset.Core.Link
72
continue;
73
}
74
75
- if (!this.symbols.TryGetValue(wixSimpleReferenceRow.SymbolicName, out var symbol))
75
+ if (!this.tuplesWithSections.TryGetValue(wixSimpleReferenceRow.SymbolicName, out var tupleWithSection))
76
{
77
this.Messaging.Write(ErrorMessages.UnresolvedReference(wixSimpleReferenceRow.SourceLineNumbers, wixSimpleReferenceRow.SymbolicName));
78
}
79
- else // see if the symbol (and any of its duplicates) are appropriately accessible.
79
+ else // see if the tuple (and any of its duplicates) are appropriately accessible.
80
{
81
- IList<Symbol> accessible = this.DetermineAccessibleSymbols(section, symbol);
81
+ var accessible = this.DetermineAccessibleTuples(section, tupleWithSection);
82
if (!accessible.Any())
83
{
84
- this.Messaging.Write(ErrorMessages.UnresolvedReference(wixSimpleReferenceRow.SourceLineNumbers, wixSimpleReferenceRow.SymbolicName, symbol.Access));
84
+ this.Messaging.Write(ErrorMessages.UnresolvedReference(wixSimpleReferenceRow.SourceLineNumbers, wixSimpleReferenceRow.SymbolicName, tupleWithSection.Access));
85
}
86
else if (1 == accessible.Count)
87
{
88
- var accessibleSymbol = accessible[0];
89
- this.referencedSymbols.Add(accessibleSymbol);
88
+ var accessibleTuple = accessible[0];
89
+ this.referencedTuples.Add(accessibleTuple);
90
91
- if (null != accessibleSymbol.Section)
91
+ if (null != accessibleTuple.Section)
92
{
93
- this.RecursivelyResolveReferences(accessibleSymbol.Section);
93
+ this.RecursivelyResolveReferences(accessibleTuple.Section);
94
}
95
}
96
- else // display errors for the duplicate symbols.
96
+ else // display errors for the duplicate tuples.
97
{
98
- var accessibleSymbol = accessible[0];
98
+ var accessibleTuple = accessible[0];
99
var referencingSourceLineNumber = wixSimpleReferenceRow.SourceLineNumbers?.ToString();
100
101
if (String.IsNullOrEmpty(referencingSourceLineNumber))
102
{
103
- this.Messaging.Write(ErrorMessages.DuplicateSymbol(accessibleSymbol.Row.SourceLineNumbers, accessibleSymbol.Name));
103
+ this.Messaging.Write(ErrorMessages.DuplicateSymbol(accessibleTuple.Tuple.SourceLineNumbers, accessibleTuple.Name));
104
}
105
else
106
{
107
- this.Messaging.Write(ErrorMessages.DuplicateSymbol(accessibleSymbol.Row.SourceLineNumbers, accessibleSymbol.Name, referencingSourceLineNumber));
107
+ this.Messaging.Write(ErrorMessages.DuplicateSymbol(accessibleTuple.Tuple.SourceLineNumbers, accessibleTuple.Name, referencingSourceLineNumber));
108
}
109
110
- foreach (Symbol accessibleDuplicate in accessible.Skip(1))
110
+ foreach (var accessibleDuplicate in accessible.Skip(1))
111
{
112
- this.Messaging.Write(ErrorMessages.DuplicateSymbol2(accessibleDuplicate.Row.SourceLineNumbers));
112
+ this.Messaging.Write(ErrorMessages.DuplicateSymbol2(accessibleDuplicate.Tuple.SourceLineNumbers));
113
}
114
}
115
}
@@ -117,67 +117,67 @@ namespace WixToolset.Core.Link
117
}
118
119
/// <summary>
120
- /// Determine if the symbol and any of its duplicates are accessbile by referencing section.
120
+ /// Determine if the tuple and any of its duplicates are accessbile by referencing section.
121
/// </summary>
122
- /// <param name="referencingSection">Section referencing the symbol.</param>
123
- /// <param name="symbol">Symbol being referenced.</param>
124
- /// <returns>List of symbols accessible by referencing section.</returns>
125
- private IList<Symbol> DetermineAccessibleSymbols(IntermediateSection referencingSection, Symbol symbol)
122
+ /// <param name="referencingSection">Section referencing the tuple.</param>
123
+ /// <param name="tupleWithSection">Tuple being referenced.</param>
124
+ /// <returns>List of tuples accessible by referencing section.</returns>
125
+ private List<TupleWithSection> DetermineAccessibleTuples(IntermediateSection referencingSection, TupleWithSection tupleWithSection)
126
{
127
- List<Symbol> symbols = new List<Symbol>();
127
+ var accessibleTuples = new List<TupleWithSection>();
128
129
- if (this.AccessibleSymbol(referencingSection, symbol))
129
+ if (this.AccessibleTuple(referencingSection, tupleWithSection))
130
{
131
- symbols.Add(symbol);
131
+ accessibleTuples.Add(tupleWithSection);
132
}
133
134
- foreach (Symbol dupe in symbol.PossiblyConflictingSymbols)
134
+ foreach (var dupe in tupleWithSection.PossiblyConflicts)
135
{
136
// don't count overridable WixActionTuples
137
- WixActionTuple symbolAction = symbol.Row as WixActionTuple;
138
- WixActionTuple dupeAction = dupe.Row as WixActionTuple;
139
- if (symbolAction?.Overridable != dupeAction?.Overridable)
137
+ var tupleAction = tupleWithSection.Tuple as WixActionTuple;
138
+ var dupeAction = dupe.Tuple as WixActionTuple;
139
+ if (tupleAction?.Overridable != dupeAction?.Overridable)
140
{
141
continue;
142
}
143
144
- if (this.AccessibleSymbol(referencingSection, dupe))
144
+ if (this.AccessibleTuple(referencingSection, dupe))
145
{
146
- symbols.Add(dupe);
146
+ accessibleTuples.Add(dupe);
147
}
148
}
149
150
- foreach (Symbol dupe in symbol.RedundantSymbols)
150
+ foreach (var dupe in tupleWithSection.Redundants)
151
{
152
- if (this.AccessibleSymbol(referencingSection, dupe))
152
+ if (this.AccessibleTuple(referencingSection, dupe))
153
{
154
- symbols.Add(dupe);
154
+ accessibleTuples.Add(dupe);
155
}
156
}
157
158
- return symbols;
158
+ return accessibleTuples;
159
}
160
161
/// <summary>
162
- /// Determine if a single symbol is accessible by the referencing section.
162
+ /// Determine if a single tuple is accessible by the referencing section.
163
/// </summary>
164
- /// <param name="referencingSection">Section referencing the symbol.</param>
165
- /// <param name="symbol">Symbol being referenced.</param>
166
- /// <returns>True if symbol is accessible.</returns>
167
- private bool AccessibleSymbol(IntermediateSection referencingSection, Symbol symbol)
164
+ /// <param name="referencingSection">Section referencing the tuple.</param>
165
+ /// <param name="tupleWithSection">Tuple being referenced.</param>
166
+ /// <returns>True if tuple is accessible.</returns>
167
+ private bool AccessibleTuple(IntermediateSection referencingSection, TupleWithSection tupleWithSection)
168
{
169
- switch (symbol.Access)
169
+ switch (tupleWithSection.Access)
170
{
171
case AccessModifier.Public:
172
return true;
173
case AccessModifier.Internal:
174
- return symbol.Section.CompilationId.Equals(referencingSection.CompilationId) || (null != symbol.Section.LibraryId && symbol.Section.LibraryId.Equals(referencingSection.LibraryId));
174
+ return tupleWithSection.Section.CompilationId.Equals(referencingSection.CompilationId) || (null != tupleWithSection.Section.LibraryId && tupleWithSection.Section.LibraryId.Equals(referencingSection.LibraryId));
175
case AccessModifier.Protected:
176
- return symbol.Section.CompilationId.Equals(referencingSection.CompilationId);
176
+ return tupleWithSection.Section.CompilationId.Equals(referencingSection.CompilationId);
177
case AccessModifier.Private:
178
- return referencingSection == symbol.Section;
178
+ return referencingSection == tupleWithSection.Section;
179
default:
180
- throw new ArgumentOutOfRangeException(nameof(symbol.Access));
180
+ throw new ArgumentOutOfRangeException(nameof(tupleWithSection.Access));
181
}
182
}
183
}
src/WixToolset.Core/Linker.cs
+18
-18
@@ -149,12 +149,12 @@ namespace WixToolset.Core
149
throw new WixException(ErrorMessages.MissingEntrySection(this.Context.ExpectedOutputType.ToString()));
150
}
151
152
- // Add the missing standard action symbols.
153
- this.LoadStandardActionSymbols(find.EntrySection, find.Symbols);
152
+ // Add the missing standard action tuples.
153
+ this.LoadStandardActions(find.EntrySection, find.TuplesByName);
154
155
- // Resolve the symbol references to find the set of sections we care about for linking.
155
+ // Resolve the tuple references to find the set of sections we care about for linking.
156
// Of course, we start with the entry section (that's how it got its name after all).
157
- var resolve = new ResolveReferencesCommand(this.Messaging, find.EntrySection, find.Symbols);
157
+ var resolve = new ResolveReferencesCommand(this.Messaging, find.EntrySection, find.TuplesByName);
158
159
resolve.Execute();
160
@@ -190,16 +190,16 @@ namespace WixToolset.Core
190
}
191
192
// Display an error message for Components that were not referenced by a Feature.
193
- foreach (var symbol in resolve.ReferencedSymbols.Where(s => s.Row.Definition.Type == TupleDefinitionType.Component))
193
+ foreach (var tupleWithSection in resolve.ReferencedTupleWithSections.Where(s => s.Tuple.Definition.Type == TupleDefinitionType.Component))
194
{
195
- if (!referencedComponents.Contains(symbol.Name))
195
+ if (!referencedComponents.Contains(tupleWithSection.Name))
196
{
197
- this.Messaging.Write(ErrorMessages.OrphanedComponent(symbol.Row.SourceLineNumbers, symbol.Row.Id.Id));
197
+ this.Messaging.Write(ErrorMessages.OrphanedComponent(tupleWithSection.Tuple.SourceLineNumbers, tupleWithSection.Tuple.Id.Id));
198
}
199
}
200
201
// Report duplicates that would ultimately end up being primary key collisions.
202
- var reportDupes = new ReportConflictingSymbolsCommand(this.Messaging, find.PossiblyConflictingSymbols, resolve.ResolvedSections);
202
+ var reportDupes = new ReportConflictingTuplesCommand(this.Messaging, find.PossibleConflicts, resolve.ResolvedSections);
203
reportDupes.Execute();
204
205
if (this.Messaging.EncounteredError)
@@ -208,7 +208,7 @@ namespace WixToolset.Core
208
}
209
210
// resolve the feature to feature connects
211
- this.ResolveFeatureToFeatureConnects(featuresToFeatures, find.Symbols);
211
+ this.ResolveFeatureToFeatureConnects(featuresToFeatures, find.TuplesByName);
212
213
// Create the section to hold the linked content.
214
var resolvedSection = new IntermediateSection(find.EntrySection.Id, find.EntrySection.Type, find.EntrySection.Codepage);
@@ -734,17 +734,17 @@ namespace WixToolset.Core
734
/// <summary>
735
/// Load the standard action symbols.
736
/// </summary>
737
- /// <param name="symbols">Collection of symbols.</param>
738
- private void LoadStandardActionSymbols(IntermediateSection section, IDictionary<string, Symbol> symbols)
737
+ /// <param name="tuplesByName">Collection of symbols.</param>
738
+ private void LoadStandardActions(IntermediateSection section, IDictionary<string, TupleWithSection> tuplesByName)
739
{
740
- foreach (var actionRow in WindowsInstallerStandard.StandardActions())
740
+ foreach (var actionTuple in WindowsInstallerStandard.StandardActions())
741
{
742
- var symbol = new Symbol(section, actionRow);
742
+ var tupleWithSection = new TupleWithSection(section, actionTuple);
743
744
- // If the action's symbol has not already been defined (i.e. overriden by the user), add it now.
745
- if (!symbols.ContainsKey(symbol.Name))
744
+ // If the action's tuple has not already been defined (i.e. overriden by the user), add it now.
745
+ if (!tuplesByName.ContainsKey(tupleWithSection.Name))
746
{
747
- symbols.Add(symbol.Name, symbol);
747
+ tuplesByName.Add(tupleWithSection.Name, tupleWithSection);
748
}
749
}
750
}
@@ -1242,7 +1242,7 @@ namespace WixToolset.Core
1242
/// </summary>
1243
/// <param name="featuresToFeatures">Feature to feature complex references.</param>
1244
/// <param name="allSymbols">All symbols loaded from the sections.</param>
1245
- private void ResolveFeatureToFeatureConnects(ConnectToFeatureCollection featuresToFeatures, IDictionary<string, Symbol> allSymbols)
1245
+ private void ResolveFeatureToFeatureConnects(ConnectToFeatureCollection featuresToFeatures, IDictionary<string, TupleWithSection> allSymbols)
1246
{
1247
foreach (ConnectToFeature connection in featuresToFeatures)
1248
{
@@ -1254,7 +1254,7 @@ namespace WixToolset.Core
1254
1255
if (allSymbols.TryGetValue(wixSimpleReferenceRow.SymbolicName, out var symbol))
1256
{
1257
- var featureTuple = (FeatureTuple)symbol.Row;
1257
+ var featureTuple = (FeatureTuple)symbol.Tuple;
1258
featureTuple.ParentFeatureRef = connection.PrimaryFeature;
1259
}
1260
}