From 38afa9e7bc7eacc021f8805f607368a05751e3c3 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 25 Jun 2020 14:43:50 -0700 Subject: The Great Tuple to Symbol Rename (tm) --- .../Link/FindEntrySectionAndLoadSymbolsCommand.cs | 34 +++---- .../Link/IntermediateTupleExtensions.cs | 8 +- .../Link/ReportConflictingTuplesCommand.cs | 18 ++-- .../Link/ResolveReferencesCommand.cs | 104 ++++++++++----------- .../Link/WixComplexReferenceTupleExtensions.cs | 32 +++---- src/WixToolset.Core/Link/WixGroupingOrdering.cs | 16 ++-- 6 files changed, 106 insertions(+), 106 deletions(-) (limited to 'src/WixToolset.Core/Link') diff --git a/src/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs b/src/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs index 31cbf0b8..1c2ca8eb 100644 --- a/src/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs +++ b/src/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs @@ -31,17 +31,17 @@ namespace WixToolset.Core.Link /// /// Gets the collection of loaded symbols. /// - public IDictionary TuplesByName { get; private set; } + public IDictionary SymbolsByName { get; private set; } /// /// Gets the collection of possibly conflicting symbols. /// - public IEnumerable PossibleConflicts { get; private set; } + public IEnumerable PossibleConflicts { get; private set; } public void Execute() { - var tuplesByName = new Dictionary(); - var possibleConflicts = new HashSet(); + var symbolsByName = new Dictionary(); + var possibleConflicts = new HashSet(); if (!Enum.TryParse(this.ExpectedOutputType.ToString(), out SectionType expectedEntrySectionType)) { @@ -66,44 +66,44 @@ namespace WixToolset.Core.Link } else { - this.Messaging.Write(ErrorMessages.MultipleEntrySections(this.EntrySection.Tuples.FirstOrDefault()?.SourceLineNumbers, this.EntrySection.Id, section.Id)); - this.Messaging.Write(ErrorMessages.MultipleEntrySections2(section.Tuples.FirstOrDefault()?.SourceLineNumbers)); + this.Messaging.Write(ErrorMessages.MultipleEntrySections(this.EntrySection.Symbols.FirstOrDefault()?.SourceLineNumbers, this.EntrySection.Id, section.Id)); + this.Messaging.Write(ErrorMessages.MultipleEntrySections2(section.Symbols.FirstOrDefault()?.SourceLineNumbers)); } } // Load all the symbols from the section's tables that create symbols. - foreach (var tuple in section.Tuples.Where(t => t.Id != null)) + foreach (var symbol in section.Symbols.Where(t => t.Id != null)) { - var symbol = new TupleWithSection(section, tuple); + var symbolWithSection = new SymbolWithSection(section, symbol); - if (!tuplesByName.TryGetValue(symbol.Name, out var existingSymbol)) + if (!symbolsByName.TryGetValue(symbolWithSection.Name, out var existingSymbol)) { - tuplesByName.Add(symbol.Name, symbol); + symbolsByName.Add(symbolWithSection.Name, symbolWithSection); } else // uh-oh, duplicate symbols. { // If the duplicate symbols are both private directories, there is a chance that they - // point to identical tuples. Identical directory tuples are redundant and will not cause + // point to identical symbols. Identical directory symbols are redundant and will not cause // conflicts. - if (AccessModifier.Private == existingSymbol.Access && AccessModifier.Private == symbol.Access && - TupleDefinitionType.Directory == existingSymbol.Tuple.Definition.Type && existingSymbol.Tuple.IsIdentical(symbol.Tuple)) + if (AccessModifier.Private == existingSymbol.Access && AccessModifier.Private == symbolWithSection.Access && + SymbolDefinitionType.Directory == existingSymbol.Symbol.Definition.Type && existingSymbol.Symbol.IsIdentical(symbolWithSection.Symbol)) { - // Ensure identical symbol's tuple is marked redundant to ensure (should the tuple be + // Ensure identical symbol's symbol is marked redundant to ensure (should the symbol be // referenced into the final output) it will not add duplicate primary keys during // the .IDT importing. //symbol.Row.Redundant = true; - TODO: remove this - existingSymbol.AddRedundant(symbol); + existingSymbol.AddRedundant(symbolWithSection); } else { - existingSymbol.AddPossibleConflict(symbol); + existingSymbol.AddPossibleConflict(symbolWithSection); possibleConflicts.Add(existingSymbol); } } } } - this.TuplesByName = tuplesByName; + this.SymbolsByName = symbolsByName; this.PossibleConflicts = possibleConflicts; } } diff --git a/src/WixToolset.Core/Link/IntermediateTupleExtensions.cs b/src/WixToolset.Core/Link/IntermediateTupleExtensions.cs index c4c12e81..db53f1ce 100644 --- a/src/WixToolset.Core/Link/IntermediateTupleExtensions.cs +++ b/src/WixToolset.Core/Link/IntermediateTupleExtensions.cs @@ -4,12 +4,12 @@ namespace WixToolset.Core.Link { using WixToolset.Data; - internal static class IntermediateTupleExtensions + internal static class IntermediateSymbolExtensions { - public static bool IsIdentical(this IntermediateTuple first, IntermediateTuple second) + public static bool IsIdentical(this IntermediateSymbol first, IntermediateSymbol second) { - var identical = (first.Definition.Type == second.Definition.Type && - first.Definition.Name == second.Definition.Name && + var identical = (first.Definition.Type == second.Definition.Type && + first.Definition.Name == second.Definition.Name && first.Definition.FieldDefinitions.Length == second.Definition.FieldDefinitions.Length); for (int i = 0; identical && i < first.Definition.FieldDefinitions.Length; ++i) diff --git a/src/WixToolset.Core/Link/ReportConflictingTuplesCommand.cs b/src/WixToolset.Core/Link/ReportConflictingTuplesCommand.cs index ff01f573..ace2e19d 100644 --- a/src/WixToolset.Core/Link/ReportConflictingTuplesCommand.cs +++ b/src/WixToolset.Core/Link/ReportConflictingTuplesCommand.cs @@ -7,9 +7,9 @@ namespace WixToolset.Core.Link using WixToolset.Data; using WixToolset.Extensibility.Services; - internal class ReportConflictingTuplesCommand + internal class ReportConflictingSymbolsCommand { - public ReportConflictingTuplesCommand(IMessaging messaging, IEnumerable possibleConflicts, IEnumerable resolvedSections) + public ReportConflictingSymbolsCommand(IMessaging messaging, IEnumerable possibleConflicts, IEnumerable resolvedSections) { this.Messaging = messaging; this.PossibleConflicts = possibleConflicts; @@ -18,18 +18,18 @@ namespace WixToolset.Core.Link private IMessaging Messaging { get; } - private IEnumerable PossibleConflicts { get; } + private IEnumerable PossibleConflicts { get; } private IEnumerable ResolvedSections { get; } public void Execute() { // Do a quick check if there are any possibly conflicting symbols that don't come from tables that allow - // overriding. Hopefully the tuples with possible conflicts list is usually very short list (empty should + // overriding. Hopefully the symbols with possible conflicts list is usually very short list (empty should // be the most common). If we find any matches, we'll do a more costly check to see if the possible conflicting - // tuples are in sections we actually referenced. From the resulting set, show an error for each duplicate - // (aka: conflicting) tuple. - var illegalDuplicates = this.PossibleConflicts.Where(s => s.Tuple.Definition.Type != TupleDefinitionType.WixAction && s.Tuple.Definition.Type != TupleDefinitionType.WixVariable).ToList(); + // symbols are in sections we actually referenced. From the resulting set, show an error for each duplicate + // (aka: conflicting) symbol. + var illegalDuplicates = this.PossibleConflicts.Where(s => s.Symbol.Definition.Type != SymbolDefinitionType.WixAction && s.Symbol.Definition.Type != SymbolDefinitionType.WixVariable).ToList(); if (0 < illegalDuplicates.Count) { var referencedSections = new HashSet(this.ResolvedSections); @@ -40,11 +40,11 @@ namespace WixToolset.Core.Link if (actuallyReferencedDuplicates.Any()) { - this.Messaging.Write(ErrorMessages.DuplicateSymbol(referencedDuplicate.Tuple.SourceLineNumbers, referencedDuplicate.Name)); + this.Messaging.Write(ErrorMessages.DuplicateSymbol(referencedDuplicate.Symbol.SourceLineNumbers, referencedDuplicate.Name)); foreach (var duplicate in actuallyReferencedDuplicates) { - this.Messaging.Write(ErrorMessages.DuplicateSymbol2(duplicate.Tuple.SourceLineNumbers)); + this.Messaging.Write(ErrorMessages.DuplicateSymbol2(duplicate.Symbol.SourceLineNumbers)); } } } diff --git a/src/WixToolset.Core/Link/ResolveReferencesCommand.cs b/src/WixToolset.Core/Link/ResolveReferencesCommand.cs index 4ffb5443..d2be0699 100644 --- a/src/WixToolset.Core/Link/ResolveReferencesCommand.cs +++ b/src/WixToolset.Core/Link/ResolveReferencesCommand.cs @@ -6,7 +6,7 @@ namespace WixToolset.Core.Link using System.Collections.Generic; using System.Linq; using WixToolset.Data; - using WixToolset.Data.Tuples; + using WixToolset.Data.Symbols; using WixToolset.Extensibility.Services; /// @@ -15,19 +15,19 @@ namespace WixToolset.Core.Link internal class ResolveReferencesCommand { private readonly IntermediateSection entrySection; - private readonly IDictionary tuplesWithSections; - private HashSet referencedTuples; + private readonly IDictionary symbolsWithSections; + private HashSet referencedSymbols; private HashSet resolvedSections; - public ResolveReferencesCommand(IMessaging messaging, IntermediateSection entrySection, IDictionary tuplesWithSections) + public ResolveReferencesCommand(IMessaging messaging, IntermediateSection entrySection, IDictionary symbolsWithSections) { this.Messaging = messaging; this.entrySection = entrySection; - this.tuplesWithSections = tuplesWithSections; + this.symbolsWithSections = symbolsWithSections; this.BuildingMergeModule = (SectionType.Module == entrySection.Type); } - public IEnumerable ReferencedTupleWithSections => this.referencedTuples; + public IEnumerable ReferencedSymbolWithSections => this.referencedSymbols; public IEnumerable ResolvedSections => this.resolvedSections; @@ -41,7 +41,7 @@ namespace WixToolset.Core.Link public void Execute() { this.resolvedSections = new HashSet(); - this.referencedTuples = new HashSet(); + this.referencedSymbols = new HashSet(); this.RecursivelyResolveReferences(this.entrySection); } @@ -60,10 +60,10 @@ namespace WixToolset.Core.Link } // Process all of the references contained in this section using the collection of - // tuples provided. Then recursively call this method to process the - // located tuple's section. All in all this is a very simple depth-first + // symbols provided. Then recursively call this method to process the + // located symbol's section. All in all this is a very simple depth-first // search of the references per-section. - foreach (var wixSimpleReferenceRow in section.Tuples.OfType()) + foreach (var wixSimpleReferenceRow in section.Symbols.OfType()) { // If we're building a Merge Module, ignore all references to the Media table // because Merge Modules don't have Media tables. @@ -72,44 +72,44 @@ namespace WixToolset.Core.Link continue; } - if (!this.tuplesWithSections.TryGetValue(wixSimpleReferenceRow.SymbolicName, out var tupleWithSection)) + if (!this.symbolsWithSections.TryGetValue(wixSimpleReferenceRow.SymbolicName, out var symbolWithSection)) { this.Messaging.Write(ErrorMessages.UnresolvedReference(wixSimpleReferenceRow.SourceLineNumbers, wixSimpleReferenceRow.SymbolicName)); } - else // see if the tuple (and any of its duplicates) are appropriately accessible. + else // see if the symbol (and any of its duplicates) are appropriately accessible. { - var accessible = this.DetermineAccessibleTuples(section, tupleWithSection); + var accessible = this.DetermineAccessibleSymbols(section, symbolWithSection); if (!accessible.Any()) { - this.Messaging.Write(ErrorMessages.UnresolvedReference(wixSimpleReferenceRow.SourceLineNumbers, wixSimpleReferenceRow.SymbolicName, tupleWithSection.Access)); + this.Messaging.Write(ErrorMessages.UnresolvedReference(wixSimpleReferenceRow.SourceLineNumbers, wixSimpleReferenceRow.SymbolicName, symbolWithSection.Access)); } else if (1 == accessible.Count) { - var accessibleTuple = accessible[0]; - this.referencedTuples.Add(accessibleTuple); + var accessibleSymbol = accessible[0]; + this.referencedSymbols.Add(accessibleSymbol); - if (null != accessibleTuple.Section) + if (null != accessibleSymbol.Section) { - this.RecursivelyResolveReferences(accessibleTuple.Section); + this.RecursivelyResolveReferences(accessibleSymbol.Section); } } - else // display errors for the duplicate tuples. + else // display errors for the duplicate symbols. { - var accessibleTuple = accessible[0]; + var accessibleSymbol = accessible[0]; var referencingSourceLineNumber = wixSimpleReferenceRow.SourceLineNumbers?.ToString(); if (String.IsNullOrEmpty(referencingSourceLineNumber)) { - this.Messaging.Write(ErrorMessages.DuplicateSymbol(accessibleTuple.Tuple.SourceLineNumbers, accessibleTuple.Name)); + this.Messaging.Write(ErrorMessages.DuplicateSymbol(accessibleSymbol.Symbol.SourceLineNumbers, accessibleSymbol.Name)); } else { - this.Messaging.Write(ErrorMessages.DuplicateSymbol(accessibleTuple.Tuple.SourceLineNumbers, accessibleTuple.Name, referencingSourceLineNumber)); + this.Messaging.Write(ErrorMessages.DuplicateSymbol(accessibleSymbol.Symbol.SourceLineNumbers, accessibleSymbol.Name, referencingSourceLineNumber)); } foreach (var accessibleDuplicate in accessible.Skip(1)) { - this.Messaging.Write(ErrorMessages.DuplicateSymbol2(accessibleDuplicate.Tuple.SourceLineNumbers)); + this.Messaging.Write(ErrorMessages.DuplicateSymbol2(accessibleDuplicate.Symbol.SourceLineNumbers)); } } } @@ -117,67 +117,67 @@ namespace WixToolset.Core.Link } /// - /// Determine if the tuple and any of its duplicates are accessbile by referencing section. + /// Determine if the symbol and any of its duplicates are accessbile by referencing section. /// - /// Section referencing the tuple. - /// Tuple being referenced. - /// List of tuples accessible by referencing section. - private List DetermineAccessibleTuples(IntermediateSection referencingSection, TupleWithSection tupleWithSection) + /// Section referencing the symbol. + /// Symbol being referenced. + /// List of symbols accessible by referencing section. + private List DetermineAccessibleSymbols(IntermediateSection referencingSection, SymbolWithSection symbolWithSection) { - var accessibleTuples = new List(); + var accessibleSymbols = new List(); - if (this.AccessibleTuple(referencingSection, tupleWithSection)) + if (this.AccessibleSymbol(referencingSection, symbolWithSection)) { - accessibleTuples.Add(tupleWithSection); + accessibleSymbols.Add(symbolWithSection); } - foreach (var dupe in tupleWithSection.PossiblyConflicts) + foreach (var dupe in symbolWithSection.PossiblyConflicts) { - // don't count overridable WixActionTuples - var tupleAction = tupleWithSection.Tuple as WixActionTuple; - var dupeAction = dupe.Tuple as WixActionTuple; - if (tupleAction?.Overridable != dupeAction?.Overridable) + // don't count overridable WixActionSymbols + var symbolAction = symbolWithSection.Symbol as WixActionSymbol; + var dupeAction = dupe.Symbol as WixActionSymbol; + if (symbolAction?.Overridable != dupeAction?.Overridable) { continue; } - if (this.AccessibleTuple(referencingSection, dupe)) + if (this.AccessibleSymbol(referencingSection, dupe)) { - accessibleTuples.Add(dupe); + accessibleSymbols.Add(dupe); } } - foreach (var dupe in tupleWithSection.Redundants) + foreach (var dupe in symbolWithSection.Redundants) { - if (this.AccessibleTuple(referencingSection, dupe)) + if (this.AccessibleSymbol(referencingSection, dupe)) { - accessibleTuples.Add(dupe); + accessibleSymbols.Add(dupe); } } - return accessibleTuples; + return accessibleSymbols; } /// - /// Determine if a single tuple is accessible by the referencing section. + /// Determine if a single symbol is accessible by the referencing section. /// - /// Section referencing the tuple. - /// Tuple being referenced. - /// True if tuple is accessible. - private bool AccessibleTuple(IntermediateSection referencingSection, TupleWithSection tupleWithSection) + /// Section referencing the symbol. + /// Symbol being referenced. + /// True if symbol is accessible. + private bool AccessibleSymbol(IntermediateSection referencingSection, SymbolWithSection symbolWithSection) { - switch (tupleWithSection.Access) + switch (symbolWithSection.Access) { case AccessModifier.Public: return true; case AccessModifier.Internal: - return tupleWithSection.Section.CompilationId.Equals(referencingSection.CompilationId) || (null != tupleWithSection.Section.LibraryId && tupleWithSection.Section.LibraryId.Equals(referencingSection.LibraryId)); + return symbolWithSection.Section.CompilationId.Equals(referencingSection.CompilationId) || (null != symbolWithSection.Section.LibraryId && symbolWithSection.Section.LibraryId.Equals(referencingSection.LibraryId)); case AccessModifier.Protected: - return tupleWithSection.Section.CompilationId.Equals(referencingSection.CompilationId); + return symbolWithSection.Section.CompilationId.Equals(referencingSection.CompilationId); case AccessModifier.Private: - return referencingSection == tupleWithSection.Section; + return referencingSection == symbolWithSection.Section; default: - throw new ArgumentOutOfRangeException(nameof(tupleWithSection.Access)); + throw new ArgumentOutOfRangeException(nameof(symbolWithSection.Access)); } } } diff --git a/src/WixToolset.Core/Link/WixComplexReferenceTupleExtensions.cs b/src/WixToolset.Core/Link/WixComplexReferenceTupleExtensions.cs index 80cafa50..1702d3ca 100644 --- a/src/WixToolset.Core/Link/WixComplexReferenceTupleExtensions.cs +++ b/src/WixToolset.Core/Link/WixComplexReferenceTupleExtensions.cs @@ -3,17 +3,17 @@ namespace WixToolset.Core.Link { using System; - using WixToolset.Data.Tuples; + using WixToolset.Data.Symbols; - internal static class WixComplexReferenceTupleExtensions + internal static class WixComplexReferenceSymbolExtensions { /// /// Creates a shallow copy of the ComplexReference. /// /// A shallow copy of the ComplexReference. - public static WixComplexReferenceTuple Clone(this WixComplexReferenceTuple source) + public static WixComplexReferenceSymbol Clone(this WixComplexReferenceSymbol source) { - var clone = new WixComplexReferenceTuple(source.SourceLineNumbers, source.Id); + var clone = new WixComplexReferenceSymbol(source.SourceLineNumbers, source.Id); clone.ParentType = source.ParentType; clone.Parent = source.Parent; clone.ParentLanguage = source.ParentLanguage; @@ -29,23 +29,23 @@ namespace WixToolset.Core.Link /// /// Complex reference to compare to. /// Zero if the objects are equivalent, negative number if the provided object is less, positive if greater. - public static int CompareToWithoutConsideringPrimary(this WixComplexReferenceTuple tuple, WixComplexReferenceTuple other) + public static int CompareToWithoutConsideringPrimary(this WixComplexReferenceSymbol symbol, WixComplexReferenceSymbol other) { - var comparison = tuple.ChildType - other.ChildType; + var comparison = symbol.ChildType - other.ChildType; if (0 == comparison) { - comparison = String.Compare(tuple.Child, other.Child, StringComparison.Ordinal); + comparison = String.Compare(symbol.Child, other.Child, StringComparison.Ordinal); if (0 == comparison) { - comparison = tuple.ParentType - other.ParentType; + comparison = symbol.ParentType - other.ParentType; if (0 == comparison) { - string thisParentLanguage = null == tuple.ParentLanguage ? String.Empty : tuple.ParentLanguage; + string thisParentLanguage = null == symbol.ParentLanguage ? String.Empty : symbol.ParentLanguage; string otherParentLanguage = null == other.ParentLanguage ? String.Empty : other.ParentLanguage; comparison = String.Compare(thisParentLanguage, otherParentLanguage, StringComparison.Ordinal); if (0 == comparison) { - comparison = String.Compare(tuple.Parent, other.Parent, StringComparison.Ordinal); + comparison = String.Compare(symbol.Parent, other.Parent, StringComparison.Ordinal); } } } @@ -58,15 +58,15 @@ namespace WixToolset.Core.Link /// Changes all of the parent references to point to the passed in parent reference. /// /// New parent complex reference. - public static void Reparent(this WixComplexReferenceTuple tuple, WixComplexReferenceTuple parent) + public static void Reparent(this WixComplexReferenceSymbol symbol, WixComplexReferenceSymbol parent) { - tuple.Parent = parent.Parent; - tuple.ParentLanguage = parent.ParentLanguage; - tuple.ParentType = parent.ParentType; + symbol.Parent = parent.Parent; + symbol.ParentLanguage = parent.ParentLanguage; + symbol.ParentType = parent.ParentType; - if (!tuple.IsPrimary) + if (!symbol.IsPrimary) { - tuple.IsPrimary = parent.IsPrimary; + symbol.IsPrimary = parent.IsPrimary; } } } diff --git a/src/WixToolset.Core/Link/WixGroupingOrdering.cs b/src/WixToolset.Core/Link/WixGroupingOrdering.cs index 7e0030ca..a7013062 100644 --- a/src/WixToolset.Core/Link/WixGroupingOrdering.cs +++ b/src/WixToolset.Core/Link/WixGroupingOrdering.cs @@ -10,7 +10,7 @@ namespace WixToolset.Core.Link using System.Linq; using System.Text; using WixToolset.Data; - using WixToolset.Data.Tuples; + using WixToolset.Data.Symbols; using WixToolset.Extensibility.Services; using WixToolset.Data.Burn; @@ -155,7 +155,7 @@ namespace WixToolset.Core.Link foreach (int rowIndex in sortedIndexes) { //wixGroupTable.Rows.RemoveAt(rowIndex); - this.EntrySection.Tuples.RemoveAt(rowIndex); + this.EntrySection.Symbols.RemoveAt(rowIndex); } } @@ -173,7 +173,7 @@ namespace WixToolset.Core.Link // groups to read from that table instead. foreach (var item in orderedItems) { - this.EntrySection.AddTuple(new WixGroupTuple(item.Row.SourceLineNumbers) + this.EntrySection.AddSymbol(new WixGroupSymbol(item.Row.SourceLineNumbers) { ParentId = parentId, ParentType = (ComplexReferenceParentType)Enum.Parse(typeof(ComplexReferenceParentType), parentType), @@ -238,9 +238,9 @@ namespace WixToolset.Core.Link //} // Collect all of the groups - for (int rowIndex = 0; rowIndex < this.EntrySection.Tuples.Count; ++rowIndex) + for (int rowIndex = 0; rowIndex < this.EntrySection.Symbols.Count; ++rowIndex) { - if (this.EntrySection.Tuples[rowIndex] is WixGroupTuple row) + if (this.EntrySection.Symbols[rowIndex] is WixGroupSymbol row) { var rowParentName = row.ParentId; var rowParentType = row.ParentType.ToString(); @@ -357,7 +357,7 @@ namespace WixToolset.Core.Link // return; //} - foreach (var row in this.EntrySection.Tuples.OfType()) + foreach (var row in this.EntrySection.Symbols.OfType()) { var rowItemType = row.ItemType.ToString(); var rowItemName = row.ItemIdRef; @@ -513,7 +513,7 @@ namespace WixToolset.Core.Link private readonly ItemCollection beforeItems; // for checking for circular references private bool flattenedAfterItems; - public Item(IntermediateTuple row, string type, string id) + public Item(IntermediateSymbol row, string type, string id) { this.Row = row; this.Type = type; @@ -526,7 +526,7 @@ namespace WixToolset.Core.Link this.flattenedAfterItems = false; } - public IntermediateTuple Row { get; private set; } + public IntermediateSymbol Row { get; private set; } public string Type { get; private set; } public string Id { get; private set; } public string Key { get; private set; } -- cgit v1.2.3-55-g6feb