diff options
| author | Rob Mensching <rob@firegiant.com> | 2017-11-01 10:59:45 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2017-11-01 10:59:45 -0700 |
| commit | 2bb37beda887d120a0ddabf874ad25357101faa1 (patch) | |
| tree | c35e97b03274b86cfc9ff7fd2caeee211165a140 /src/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs | |
| parent | df7413aeed3aea3425dff20ae0c8b1be3a3ab525 (diff) | |
| download | wix-2bb37beda887d120a0ddabf874ad25357101faa1.tar.gz wix-2bb37beda887d120a0ddabf874ad25357101faa1.tar.bz2 wix-2bb37beda887d120a0ddabf874ad25357101faa1.zip | |
Update to WiX Intermediate Representation
Diffstat (limited to 'src/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs')
| -rw-r--r-- | src/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs | 81 |
1 files changed, 40 insertions, 41 deletions
diff --git a/src/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs b/src/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs index effb06e4..00613ca1 100644 --- a/src/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs +++ b/src/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs | |||
| @@ -1,6 +1,6 @@ | |||
| 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. | 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 | 2 | ||
| 3 | namespace WixToolset.Link | 3 | namespace WixToolset.Core.Link |
| 4 | { | 4 | { |
| 5 | using System; | 5 | using System; |
| 6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
| @@ -9,13 +9,13 @@ namespace WixToolset.Link | |||
| 9 | 9 | ||
| 10 | internal class FindEntrySectionAndLoadSymbolsCommand : ICommand | 10 | internal class FindEntrySectionAndLoadSymbolsCommand : ICommand |
| 11 | { | 11 | { |
| 12 | private IEnumerable<Section> sections; | 12 | public FindEntrySectionAndLoadSymbolsCommand(IEnumerable<IntermediateSection> sections) |
| 13 | |||
| 14 | public FindEntrySectionAndLoadSymbolsCommand(IEnumerable<Section> sections) | ||
| 15 | { | 13 | { |
| 16 | this.sections = sections; | 14 | this.Sections = sections; |
| 17 | } | 15 | } |
| 18 | 16 | ||
| 17 | private IEnumerable<IntermediateSection> Sections { get; } | ||
| 18 | |||
| 19 | /// <summary> | 19 | /// <summary> |
| 20 | /// Sets the expected entry output type, based on output file extension provided to the linker. | 20 | /// Sets the expected entry output type, based on output file extension provided to the linker. |
| 21 | /// </summary> | 21 | /// </summary> |
| @@ -24,13 +24,16 @@ namespace WixToolset.Link | |||
| 24 | /// <summary> | 24 | /// <summary> |
| 25 | /// Gets the located entry section after the command is executed. | 25 | /// Gets the located entry section after the command is executed. |
| 26 | /// </summary> | 26 | /// </summary> |
| 27 | public Section EntrySection { get; private set; } | 27 | public IntermediateSection EntrySection { get; private set; } |
| 28 | 28 | ||
| 29 | /// <summary> | 29 | /// <summary> |
| 30 | /// Gets the collection of loaded symbols. | 30 | /// Gets the collection of loaded symbols. |
| 31 | /// </summary> | 31 | /// </summary> |
| 32 | public IDictionary<string, Symbol> Symbols { get; private set; } | 32 | public IDictionary<string, Symbol> Symbols { get; private set; } |
| 33 | 33 | ||
| 34 | /// <summary> | ||
| 35 | /// Gets the collection of possibly conflicting symbols. | ||
| 36 | /// </summary> | ||
| 34 | public IEnumerable<Symbol> PossiblyConflictingSymbols { get; private set; } | 37 | public IEnumerable<Symbol> PossiblyConflictingSymbols { get; private set; } |
| 35 | 38 | ||
| 36 | public void Execute() | 39 | public void Execute() |
| @@ -38,22 +41,22 @@ namespace WixToolset.Link | |||
| 38 | Dictionary<string, Symbol> symbols = new Dictionary<string, Symbol>(); | 41 | Dictionary<string, Symbol> symbols = new Dictionary<string, Symbol>(); |
| 39 | HashSet<Symbol> possibleConflicts = new HashSet<Symbol>(); | 42 | HashSet<Symbol> possibleConflicts = new HashSet<Symbol>(); |
| 40 | 43 | ||
| 41 | SectionType expectedEntrySectionType; | 44 | if (!Enum.TryParse(this.ExpectedOutputType.ToString(), out SectionType expectedEntrySectionType)) |
| 42 | if (!Enum.TryParse<SectionType>(this.ExpectedOutputType.ToString(), out expectedEntrySectionType)) | ||
| 43 | { | 45 | { |
| 44 | expectedEntrySectionType = SectionType.Unknown; | 46 | expectedEntrySectionType = SectionType.Unknown; |
| 45 | } | 47 | } |
| 46 | 48 | ||
| 47 | foreach (Section section in this.sections) | 49 | foreach (var section in this.Sections) |
| 48 | { | 50 | { |
| 49 | // Try to find the one and only entry section. | 51 | // Try to find the one and only entry section. |
| 50 | if (SectionType.Product == section.Type || SectionType.Module == section.Type || SectionType.PatchCreation == section.Type || SectionType.Patch == section.Type || SectionType.Bundle == section.Type) | 52 | if (SectionType.Product == section.Type || SectionType.Module == section.Type || SectionType.PatchCreation == section.Type || SectionType.Patch == section.Type || SectionType.Bundle == section.Type) |
| 51 | { | 53 | { |
| 52 | if (SectionType.Unknown != expectedEntrySectionType && section.Type != expectedEntrySectionType) | 54 | // TODO: remove this? |
| 53 | { | 55 | //if (SectionType.Unknown != expectedEntrySectionType && section.Type != expectedEntrySectionType) |
| 54 | string outputExtension = Output.GetExtension(this.ExpectedOutputType); | 56 | //{ |
| 55 | Messaging.Instance.OnMessage(WixWarnings.UnexpectedEntrySection(section.SourceLineNumbers, section.Type.ToString(), expectedEntrySectionType.ToString(), outputExtension)); | 57 | // string outputExtension = Output.GetExtension(this.ExpectedOutputType); |
| 56 | } | 58 | // Messaging.Instance.OnMessage(WixWarnings.UnexpectedEntrySection(section.SourceLineNumbers, section.Type.ToString(), expectedEntrySectionType.ToString(), outputExtension)); |
| 59 | //} | ||
| 57 | 60 | ||
| 58 | if (null == this.EntrySection) | 61 | if (null == this.EntrySection) |
| 59 | { | 62 | { |
| @@ -61,42 +64,38 @@ namespace WixToolset.Link | |||
| 61 | } | 64 | } |
| 62 | else | 65 | else |
| 63 | { | 66 | { |
| 64 | Messaging.Instance.OnMessage(WixErrors.MultipleEntrySections(this.EntrySection.SourceLineNumbers, this.EntrySection.Id, section.Id)); | 67 | Messaging.Instance.OnMessage(WixErrors.MultipleEntrySections(this.EntrySection.Tuples.FirstOrDefault()?.SourceLineNumbers, this.EntrySection.Id, section.Id)); |
| 65 | Messaging.Instance.OnMessage(WixErrors.MultipleEntrySections2(section.SourceLineNumbers)); | 68 | Messaging.Instance.OnMessage(WixErrors.MultipleEntrySections2(section.Tuples.FirstOrDefault()?.SourceLineNumbers)); |
| 66 | } | 69 | } |
| 67 | } | 70 | } |
| 68 | 71 | ||
| 69 | // Load all the symbols from the section's tables that create symbols. | 72 | // Load all the symbols from the section's tables that create symbols. |
| 70 | foreach (Table table in section.Tables.Where(t => t.Definition.CreateSymbols)) | 73 | foreach (var row in section.Tuples.Where(t => t.Id != null)) |
| 71 | { | 74 | { |
| 72 | foreach (Row row in table.Rows) | 75 | var symbol = new Symbol(section, row); |
| 73 | { | ||
| 74 | Symbol symbol = new Symbol(row); | ||
| 75 | 76 | ||
| 76 | Symbol existingSymbol; | 77 | if (!symbols.TryGetValue(symbol.Name, out var existingSymbol)) |
| 77 | if (!symbols.TryGetValue(symbol.Name, out existingSymbol)) | 78 | { |
| 79 | symbols.Add(symbol.Name, symbol); | ||
| 80 | } | ||
| 81 | else // uh-oh, duplicate symbols. | ||
| 82 | { | ||
| 83 | // If the duplicate symbols are both private directories, there is a chance that they | ||
| 84 | // point to identical tuples. Identical directory tuples are redundant and will not cause | ||
| 85 | // conflicts. | ||
| 86 | if (AccessModifier.Private == existingSymbol.Access && AccessModifier.Private == symbol.Access && | ||
| 87 | TupleDefinitionType.Directory == existingSymbol.Row.Definition.Type && existingSymbol.Row.IsIdentical(symbol.Row)) | ||
| 78 | { | 88 | { |
| 79 | symbols.Add(symbol.Name, symbol); | 89 | // Ensure identical symbol's tuple is marked redundant to ensure (should the tuple be |
| 90 | // referenced into the final output) it will not add duplicate primary keys during | ||
| 91 | // the .IDT importing. | ||
| 92 | //symbol.Row.Redundant = true; - TODO: remove this | ||
| 93 | existingSymbol.AddRedundant(symbol); | ||
| 80 | } | 94 | } |
| 81 | else // uh-oh, duplicate symbols. | 95 | else |
| 82 | { | 96 | { |
| 83 | // If the duplicate symbols are both private directories, there is a chance that they | 97 | existingSymbol.AddPossibleConflict(symbol); |
| 84 | // point to identical rows. Identical directory rows are redundant and will not cause | 98 | possibleConflicts.Add(existingSymbol); |
| 85 | // conflicts. | ||
| 86 | if (AccessModifier.Private == existingSymbol.Access && AccessModifier.Private == symbol.Access && | ||
| 87 | "Directory" == existingSymbol.Row.Table.Name && existingSymbol.Row.IsIdentical(symbol.Row)) | ||
| 88 | { | ||
| 89 | // Ensure identical symbol's row is marked redundant to ensure (should the row be | ||
| 90 | // referenced into the final output) it will not add duplicate primary keys during | ||
| 91 | // the .IDT importing. | ||
| 92 | symbol.Row.Redundant = true; | ||
| 93 | existingSymbol.AddRedundant(symbol); | ||
| 94 | } | ||
| 95 | else | ||
| 96 | { | ||
| 97 | existingSymbol.AddPossibleConflict(symbol); | ||
| 98 | possibleConflicts.Add(existingSymbol); | ||
| 99 | } | ||
| 100 | } | 99 | } |
| 101 | } | 100 | } |
| 102 | } | 101 | } |
