diff options
| author | Rob Mensching <rob@firegiant.com> | 2017-09-17 15:35:20 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2017-09-17 16:00:11 -0700 |
| commit | d3d3649a68cb1fa589fdd987a6690dbd5d671f0d (patch) | |
| tree | 44fe37ee352b7e3a355cc1e08b1d7d5988c14cc0 /src/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs | |
| parent | a62610d23d6feb98be3b1e529a4e81b19d77d9d8 (diff) | |
| download | wix-d3d3649a68cb1fa589fdd987a6690dbd5d671f0d.tar.gz wix-d3d3649a68cb1fa589fdd987a6690dbd5d671f0d.tar.bz2 wix-d3d3649a68cb1fa589fdd987a6690dbd5d671f0d.zip | |
Initial code commit
Diffstat (limited to 'src/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs')
| -rw-r--r-- | src/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs b/src/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs new file mode 100644 index 00000000..39c3a5c2 --- /dev/null +++ b/src/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs | |||
| @@ -0,0 +1,49 @@ | |||
| 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.Link | ||
| 4 | { | ||
| 5 | using System.Collections.Generic; | ||
| 6 | using System.Linq; | ||
| 7 | using WixToolset.Data; | ||
| 8 | |||
| 9 | public class ReportConflictingSymbolsCommand : ICommand | ||
| 10 | { | ||
| 11 | private IEnumerable<Symbol> possibleConflicts; | ||
| 12 | private IEnumerable<Section> resolvedSections; | ||
| 13 | |||
| 14 | public ReportConflictingSymbolsCommand(IEnumerable<Symbol> possibleConflicts, IEnumerable<Section> resolvedSections) | ||
| 15 | { | ||
| 16 | this.possibleConflicts = possibleConflicts; | ||
| 17 | this.resolvedSections = resolvedSections; | ||
| 18 | } | ||
| 19 | |||
| 20 | public void Execute() | ||
| 21 | { | ||
| 22 | // Do a quick check if there are any possibly conflicting symbols that don't come from tables that allow | ||
| 23 | // overriding. Hopefully the symbols with possible conflicts list is usually very short list (empty should | ||
| 24 | // be the most common). If we find any matches, we'll do a more costly check to see if the possible conflicting | ||
| 25 | // symbols are in sections we actually referenced. From the resulting set, show an error for each duplicate | ||
| 26 | // (aka: conflicting) symbol. This should catch any rows with colliding primary keys (since symbols are based | ||
| 27 | // on the primary keys of rows). | ||
| 28 | List<Symbol> illegalDuplicates = possibleConflicts.Where(s => "WixAction" != s.Row.Table.Name && "WixVariable" != s.Row.Table.Name).ToList(); | ||
| 29 | if (0 < illegalDuplicates.Count) | ||
| 30 | { | ||
| 31 | HashSet<Section> referencedSections = new HashSet<Section>(resolvedSections); | ||
| 32 | foreach (Symbol referencedDuplicateSymbol in illegalDuplicates.Where(s => referencedSections.Contains(s.Section))) | ||
| 33 | { | ||
| 34 | List<Symbol> actuallyReferencedDuplicateSymbols = referencedDuplicateSymbol.PossiblyConflictingSymbols.Where(s => referencedSections.Contains(s.Section)).ToList(); | ||
| 35 | |||
| 36 | if (actuallyReferencedDuplicateSymbols.Any()) | ||
| 37 | { | ||
| 38 | Messaging.Instance.OnMessage(WixErrors.DuplicateSymbol(referencedDuplicateSymbol.Row.SourceLineNumbers, referencedDuplicateSymbol.Name)); | ||
| 39 | |||
| 40 | foreach (Symbol duplicate in actuallyReferencedDuplicateSymbols) | ||
| 41 | { | ||
| 42 | Messaging.Instance.OnMessage(WixErrors.DuplicateSymbol2(duplicate.Row.SourceLineNumbers)); | ||
| 43 | } | ||
| 44 | } | ||
| 45 | } | ||
| 46 | } | ||
| 47 | } | ||
| 48 | } | ||
| 49 | } | ||
