aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/Link
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core/Link')
-rw-r--r--src/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs14
-rw-r--r--src/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs10
-rw-r--r--src/WixToolset.Core/Link/ResolveReferencesCommand.cs18
-rw-r--r--src/WixToolset.Core/Link/WixGroupingOrdering.cs56
4 files changed, 44 insertions, 54 deletions
diff --git a/src/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs b/src/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs
index 00613ca1..daf3e878 100644
--- a/src/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs
+++ b/src/WixToolset.Core/Link/FindEntrySectionAndLoadSymbolsCommand.cs
@@ -6,14 +6,18 @@ namespace WixToolset.Core.Link
6 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.Linq; 7 using System.Linq;
8 using WixToolset.Data; 8 using WixToolset.Data;
9 using WixToolset.Extensibility.Services;
9 10
10 internal class FindEntrySectionAndLoadSymbolsCommand : ICommand 11 internal class FindEntrySectionAndLoadSymbolsCommand
11 { 12 {
12 public FindEntrySectionAndLoadSymbolsCommand(IEnumerable<IntermediateSection> sections) 13 public FindEntrySectionAndLoadSymbolsCommand(IMessaging messaging, IEnumerable<IntermediateSection> sections)
13 { 14 {
15 this.Messaging = messaging;
14 this.Sections = sections; 16 this.Sections = sections;
15 } 17 }
16 18
19 private IMessaging Messaging { get; }
20
17 private IEnumerable<IntermediateSection> Sections { get; } 21 private IEnumerable<IntermediateSection> Sections { get; }
18 22
19 /// <summary> 23 /// <summary>
@@ -55,7 +59,7 @@ namespace WixToolset.Core.Link
55 //if (SectionType.Unknown != expectedEntrySectionType && section.Type != expectedEntrySectionType) 59 //if (SectionType.Unknown != expectedEntrySectionType && section.Type != expectedEntrySectionType)
56 //{ 60 //{
57 // string outputExtension = Output.GetExtension(this.ExpectedOutputType); 61 // string outputExtension = Output.GetExtension(this.ExpectedOutputType);
58 // Messaging.Instance.OnMessage(WixWarnings.UnexpectedEntrySection(section.SourceLineNumbers, section.Type.ToString(), expectedEntrySectionType.ToString(), outputExtension)); 62 // this.Messaging.Write(WixWarnings.UnexpectedEntrySection(section.SourceLineNumbers, section.Type.ToString(), expectedEntrySectionType.ToString(), outputExtension));
59 //} 63 //}
60 64
61 if (null == this.EntrySection) 65 if (null == this.EntrySection)
@@ -64,8 +68,8 @@ namespace WixToolset.Core.Link
64 } 68 }
65 else 69 else
66 { 70 {
67 Messaging.Instance.OnMessage(WixErrors.MultipleEntrySections(this.EntrySection.Tuples.FirstOrDefault()?.SourceLineNumbers, this.EntrySection.Id, section.Id)); 71 this.Messaging.Write(ErrorMessages.MultipleEntrySections(this.EntrySection.Tuples.FirstOrDefault()?.SourceLineNumbers, this.EntrySection.Id, section.Id));
68 Messaging.Instance.OnMessage(WixErrors.MultipleEntrySections2(section.Tuples.FirstOrDefault()?.SourceLineNumbers)); 72 this.Messaging.Write(ErrorMessages.MultipleEntrySections2(section.Tuples.FirstOrDefault()?.SourceLineNumbers));
69 } 73 }
70 } 74 }
71 75
diff --git a/src/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs b/src/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs
index ac0dd7ec..23fac864 100644
--- a/src/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs
+++ b/src/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs
@@ -5,15 +5,19 @@ namespace WixToolset.Link
5 using System.Collections.Generic; 5 using System.Collections.Generic;
6 using System.Linq; 6 using System.Linq;
7 using WixToolset.Data; 7 using WixToolset.Data;
8 using WixToolset.Extensibility.Services;
8 9
9 public class ReportConflictingSymbolsCommand 10 public class ReportConflictingSymbolsCommand
10 { 11 {
11 public ReportConflictingSymbolsCommand(IEnumerable<Symbol> possibleConflicts, IEnumerable<IntermediateSection> resolvedSections) 12 public ReportConflictingSymbolsCommand(IMessaging messaging, IEnumerable<Symbol> possibleConflicts, IEnumerable<IntermediateSection> resolvedSections)
12 { 13 {
14 this.Messaging = messaging;
13 this.PossibleConflicts = possibleConflicts; 15 this.PossibleConflicts = possibleConflicts;
14 this.ResolvedSections = resolvedSections; 16 this.ResolvedSections = resolvedSections;
15 } 17 }
16 18
19 private IMessaging Messaging { get; }
20
17 private IEnumerable<Symbol> PossibleConflicts { get; } 21 private IEnumerable<Symbol> PossibleConflicts { get; }
18 22
19 private IEnumerable<IntermediateSection> ResolvedSections { get; } 23 private IEnumerable<IntermediateSection> ResolvedSections { get; }
@@ -37,11 +41,11 @@ namespace WixToolset.Link
37 41
38 if (actuallyReferencedDuplicateSymbols.Any()) 42 if (actuallyReferencedDuplicateSymbols.Any())
39 { 43 {
40 Messaging.Instance.OnMessage(WixErrors.DuplicateSymbol(referencedDuplicateSymbol.Row.SourceLineNumbers, referencedDuplicateSymbol.Name)); 44 this.Messaging.Write(ErrorMessages.DuplicateSymbol(referencedDuplicateSymbol.Row.SourceLineNumbers, referencedDuplicateSymbol.Name));
41 45
42 foreach (Symbol duplicate in actuallyReferencedDuplicateSymbols) 46 foreach (Symbol duplicate in actuallyReferencedDuplicateSymbols)
43 { 47 {
44 Messaging.Instance.OnMessage(WixErrors.DuplicateSymbol2(duplicate.Row.SourceLineNumbers)); 48 this.Messaging.Write(ErrorMessages.DuplicateSymbol2(duplicate.Row.SourceLineNumbers));
45 } 49 }
46 } 50 }
47 } 51 }
diff --git a/src/WixToolset.Core/Link/ResolveReferencesCommand.cs b/src/WixToolset.Core/Link/ResolveReferencesCommand.cs
index 266871bd..c05464e9 100644
--- a/src/WixToolset.Core/Link/ResolveReferencesCommand.cs
+++ b/src/WixToolset.Core/Link/ResolveReferencesCommand.cs
@@ -7,19 +7,21 @@ namespace WixToolset.Link
7 using System.Linq; 7 using System.Linq;
8 using WixToolset.Data; 8 using WixToolset.Data;
9 using WixToolset.Data.Tuples; 9 using WixToolset.Data.Tuples;
10 using WixToolset.Extensibility.Services;
10 11
11 /// <summary> 12 /// <summary>
12 /// Resolves all the simple references in a section. 13 /// Resolves all the simple references in a section.
13 /// </summary> 14 /// </summary>
14 internal class ResolveReferencesCommand : ICommand 15 internal class ResolveReferencesCommand
15 { 16 {
16 private IntermediateSection entrySection; 17 private IntermediateSection entrySection;
17 private IDictionary<string, Symbol> symbols; 18 private IDictionary<string, Symbol> symbols;
18 private HashSet<Symbol> referencedSymbols; 19 private HashSet<Symbol> referencedSymbols;
19 private HashSet<IntermediateSection> resolvedSections; 20 private HashSet<IntermediateSection> resolvedSections;
20 21
21 public ResolveReferencesCommand(IntermediateSection entrySection, IDictionary<string, Symbol> symbols) 22 public ResolveReferencesCommand(IMessaging messaging, IntermediateSection entrySection, IDictionary<string, Symbol> symbols)
22 { 23 {
24 this.Messaging = messaging;
23 this.entrySection = entrySection; 25 this.entrySection = entrySection;
24 this.symbols = symbols; 26 this.symbols = symbols;
25 } 27 }
@@ -30,6 +32,8 @@ namespace WixToolset.Link
30 32
31 public IEnumerable<IntermediateSection> ResolvedSections { get { return this.resolvedSections; } } 33 public IEnumerable<IntermediateSection> ResolvedSections { get { return this.resolvedSections; } }
32 34
35 private IMessaging Messaging { get; }
36
33 /// <summary> 37 /// <summary>
34 /// Resolves all the simple references in a section. 38 /// Resolves all the simple references in a section.
35 /// </summary> 39 /// </summary>
@@ -69,14 +73,14 @@ namespace WixToolset.Link
69 73
70 if (!this.symbols.TryGetValue(wixSimpleReferenceRow.SymbolicName, out var symbol)) 74 if (!this.symbols.TryGetValue(wixSimpleReferenceRow.SymbolicName, out var symbol))
71 { 75 {
72 Messaging.Instance.OnMessage(WixErrors.UnresolvedReference(wixSimpleReferenceRow.SourceLineNumbers, wixSimpleReferenceRow.SymbolicName)); 76 this.Messaging.Write(ErrorMessages.UnresolvedReference(wixSimpleReferenceRow.SourceLineNumbers, wixSimpleReferenceRow.SymbolicName));
73 } 77 }
74 else // see if the symbol (and any of its duplicates) are appropriately accessible. 78 else // see if the symbol (and any of its duplicates) are appropriately accessible.
75 { 79 {
76 IList<Symbol> accessible = DetermineAccessibleSymbols(section, symbol); 80 IList<Symbol> accessible = DetermineAccessibleSymbols(section, symbol);
77 if (!accessible.Any()) 81 if (!accessible.Any())
78 { 82 {
79 Messaging.Instance.OnMessage(WixErrors.UnresolvedReference(wixSimpleReferenceRow.SourceLineNumbers, wixSimpleReferenceRow.SymbolicName, symbol.Access)); 83 this.Messaging.Write(ErrorMessages.UnresolvedReference(wixSimpleReferenceRow.SourceLineNumbers, wixSimpleReferenceRow.SymbolicName, symbol.Access));
80 } 84 }
81 else if (1 == accessible.Count) 85 else if (1 == accessible.Count)
82 { 86 {
@@ -95,16 +99,16 @@ namespace WixToolset.Link
95 99
96 if (String.IsNullOrEmpty(referencingSourceLineNumber)) 100 if (String.IsNullOrEmpty(referencingSourceLineNumber))
97 { 101 {
98 Messaging.Instance.OnMessage(WixErrors.DuplicateSymbol(accessibleSymbol.Row.SourceLineNumbers, accessibleSymbol.Name)); 102 this.Messaging.Write(ErrorMessages.DuplicateSymbol(accessibleSymbol.Row.SourceLineNumbers, accessibleSymbol.Name));
99 } 103 }
100 else 104 else
101 { 105 {
102 Messaging.Instance.OnMessage(WixErrors.DuplicateSymbol(accessibleSymbol.Row.SourceLineNumbers, accessibleSymbol.Name, referencingSourceLineNumber)); 106 this.Messaging.Write(ErrorMessages.DuplicateSymbol(accessibleSymbol.Row.SourceLineNumbers, accessibleSymbol.Name, referencingSourceLineNumber));
103 } 107 }
104 108
105 foreach (Symbol accessibleDuplicate in accessible.Skip(1)) 109 foreach (Symbol accessibleDuplicate in accessible.Skip(1))
106 { 110 {
107 Messaging.Instance.OnMessage(WixErrors.DuplicateSymbol2(accessibleDuplicate.Row.SourceLineNumbers)); 111 this.Messaging.Write(ErrorMessages.DuplicateSymbol2(accessibleDuplicate.Row.SourceLineNumbers));
108 } 112 }
109 } 113 }
110 } 114 }
diff --git a/src/WixToolset.Core/Link/WixGroupingOrdering.cs b/src/WixToolset.Core/Link/WixGroupingOrdering.cs
index f15ebc75..50c4d8d2 100644
--- a/src/WixToolset.Core/Link/WixGroupingOrdering.cs
+++ b/src/WixToolset.Core/Link/WixGroupingOrdering.cs
@@ -11,13 +11,14 @@ namespace WixToolset.Core.Link
11 using System.Text; 11 using System.Text;
12 using WixToolset.Data; 12 using WixToolset.Data;
13 using WixToolset.Data.Tuples; 13 using WixToolset.Data.Tuples;
14 using WixToolset.Extensibility.Services;
14 15
15 /// <summary> 16 /// <summary>
16 /// Grouping and Ordering class of the WiX toolset. 17 /// Grouping and Ordering class of the WiX toolset.
17 /// </summary> 18 /// </summary>
18 internal sealed class WixGroupingOrdering : IMessageHandler 19 internal sealed class WixGroupingOrdering
19 { 20 {
20 private IMessageHandler messageHandler; 21 private IMessaging messageHandler;
21 private List<string> groupTypes; 22 private List<string> groupTypes;
22 private List<string> itemTypes; 23 private List<string> itemTypes;
23 private ItemCollection items; 24 private ItemCollection items;
@@ -32,7 +33,7 @@ namespace WixToolset.Core.Link
32 /// <param name="messageHandler">Handler for any error messages.</param> 33 /// <param name="messageHandler">Handler for any error messages.</param>
33 /// <param name="groupTypes">Group types to include.</param> 34 /// <param name="groupTypes">Group types to include.</param>
34 /// <param name="itemTypes">Item types to include.</param> 35 /// <param name="itemTypes">Item types to include.</param>
35 public WixGroupingOrdering(IntermediateSection entrySections, IMessageHandler messageHandler) 36 public WixGroupingOrdering(IntermediateSection entrySections, IMessaging messageHandler)
36 { 37 {
37 this.EntrySection = entrySections; 38 this.EntrySection = entrySections;
38 this.messageHandler = messageHandler; 39 this.messageHandler = messageHandler;
@@ -59,29 +60,6 @@ namespace WixToolset.Core.Link
59 } 60 }
60 61
61 /// <summary> 62 /// <summary>
62 /// Sends a message to the message handler if there is one.
63 /// </summary>
64 /// <param name="mea">Message event arguments.</param>
65 public void OnMessage(MessageEventArgs e)
66 {
67 WixErrorEventArgs errorEventArgs = e as WixErrorEventArgs;
68
69 if (null != errorEventArgs || MessageLevel.Error == e.Level)
70 {
71 this.encounteredError = true;
72 }
73
74 if (null != this.messageHandler)
75 {
76 this.messageHandler.OnMessage(e);
77 }
78 else if (null != errorEventArgs)
79 {
80 throw new WixException(errorEventArgs);
81 }
82 }
83
84 /// <summary>
85 /// Finds all nested items under a parent group and creates new WixGroup data for them. 63 /// Finds all nested items under a parent group and creates new WixGroup data for them.
86 /// </summary> 64 /// </summary>
87 /// <param name="parentType">The group type for the parent group to flatten.</param> 65 /// <param name="parentType">The group type for the parent group to flatten.</param>
@@ -156,7 +134,7 @@ namespace WixToolset.Core.Link
156 Item parentItem; 134 Item parentItem;
157 if (!this.items.TryGetValue(parentType, parentId, out parentItem)) 135 if (!this.items.TryGetValue(parentType, parentId, out parentItem))
158 { 136 {
159 this.OnMessage(WixErrors.IdentifierNotFound(parentType, parentId)); 137 this.messageHandler.Write(ErrorMessages.IdentifierNotFound(parentType, parentId));
160 return; 138 return;
161 } 139 }
162 140
@@ -257,7 +235,7 @@ namespace WixToolset.Core.Link
257 //if (null == wixGroupTable || 0 == wixGroupTable.Rows.Count) 235 //if (null == wixGroupTable || 0 == wixGroupTable.Rows.Count)
258 //{ 236 //{
259 // // TODO: Change message name to make it *not* Bundle specific? 237 // // TODO: Change message name to make it *not* Bundle specific?
260 // this.OnMessage(WixErrors.MissingBundleInformation("WixGroup")); 238 // this.Write(WixErrors.MissingBundleInformation("WixGroup"));
261 //} 239 //}
262 240
263 // Collect all of the groups 241 // Collect all of the groups
@@ -326,7 +304,7 @@ namespace WixToolset.Core.Link
326 if (this.FindCircularGroupReference(item, item, itemsSeen, out circularReference)) 304 if (this.FindCircularGroupReference(item, item, itemsSeen, out circularReference))
327 { 305 {
328 itemsInKnownLoops.Add(itemsSeen); 306 itemsInKnownLoops.Add(itemsSeen);
329 this.OnMessage(WixErrors.ReferenceLoopDetected(item.Row.SourceLineNumbers, circularReference)); 307 this.messageHandler.Write(ErrorMessages.ReferenceLoopDetected(item.Row.SourceLineNumbers, circularReference));
330 } 308 }
331 } 309 }
332 } 310 }
@@ -398,12 +376,12 @@ namespace WixToolset.Core.Link
398 376
399 if (!this.items.TryGetValue(rowItemType, rowItemName, out var item)) 377 if (!this.items.TryGetValue(rowItemType, rowItemName, out var item))
400 { 378 {
401 this.OnMessage(WixErrors.IdentifierNotFound(rowItemType, rowItemName)); 379 this.messageHandler.Write(ErrorMessages.IdentifierNotFound(rowItemType, rowItemName));
402 } 380 }
403 381
404 if (!this.items.TryGetValue(rowDependsOnType, rowDependsOnName, out var dependsOn)) 382 if (!this.items.TryGetValue(rowDependsOnType, rowDependsOnName, out var dependsOn))
405 { 383 {
406 this.OnMessage(WixErrors.IdentifierNotFound(rowDependsOnType, rowDependsOnName)); 384 this.messageHandler.Write(ErrorMessages.IdentifierNotFound(rowDependsOnType, rowDependsOnName));
407 } 385 }
408 386
409 if (null == item || null == dependsOn) 387 if (null == item || null == dependsOn)
@@ -411,7 +389,7 @@ namespace WixToolset.Core.Link
411 continue; 389 continue;
412 } 390 }
413 391
414 item.AddAfter(dependsOn, this); 392 item.AddAfter(dependsOn, this.messageHandler);
415 } 393 }
416 } 394 }
417 395
@@ -426,12 +404,12 @@ namespace WixToolset.Core.Link
426 // ordering. 404 // ordering.
427 foreach (Item item in this.items) 405 foreach (Item item in this.items)
428 { 406 {
429 item.PropagateAfterToChildItems(this); 407 item.PropagateAfterToChildItems(this.messageHandler);
430 } 408 }
431 409
432 foreach (Item item in this.items) 410 foreach (Item item in this.items)
433 { 411 {
434 item.FlattenAfters(this); 412 item.FlattenAfters(this.messageHandler);
435 } 413 }
436 } 414 }
437 415
@@ -595,7 +573,7 @@ namespace WixToolset.Core.Link
595 /// </summary> 573 /// </summary>
596 /// <param name="items">List of items to add.</param> 574 /// <param name="items">List of items to add.</param>
597 /// <param name="messageHandler">Message handler in case a circular ordering reference is found.</param> 575 /// <param name="messageHandler">Message handler in case a circular ordering reference is found.</param>
598 public void AddAfter(ItemCollection items, IMessageHandler messageHandler) 576 public void AddAfter(ItemCollection items, IMessaging messageHandler)
599 { 577 {
600 foreach (Item item in items) 578 foreach (Item item in items)
601 { 579 {
@@ -608,7 +586,7 @@ namespace WixToolset.Core.Link
608 /// </summary> 586 /// </summary>
609 /// <param name="item">Items to add.</param> 587 /// <param name="item">Items to add.</param>
610 /// <param name="messageHandler">Message handler in case a circular ordering reference is found.</param> 588 /// <param name="messageHandler">Message handler in case a circular ordering reference is found.</param>
611 public void AddAfter(Item after, IMessageHandler messageHandler) 589 public void AddAfter(Item after, IMessaging messageHandler)
612 { 590 {
613 if (this.beforeItems.Contains(after)) 591 if (this.beforeItems.Contains(after))
614 { 592 {
@@ -617,7 +595,7 @@ namespace WixToolset.Core.Link
617 // have lost some distinction between authored and propagated ordering. 595 // have lost some distinction between authored and propagated ordering.
618 string circularReference = String.Format(CultureInfo.InvariantCulture, "{0}:{1} -> {2}:{3} -> {0}:{1}", 596 string circularReference = String.Format(CultureInfo.InvariantCulture, "{0}:{1} -> {2}:{3} -> {0}:{1}",
619 this.Type, this.Id, after.Type, after.Id); 597 this.Type, this.Id, after.Type, after.Id);
620 messageHandler.OnMessage(WixErrors.OrderingReferenceLoopDetected(after.Row.SourceLineNumbers, circularReference)); 598 messageHandler.Write(ErrorMessages.OrderingReferenceLoopDetected(after.Row.SourceLineNumbers, circularReference));
621 return; 599 return;
622 } 600 }
623 601
@@ -632,7 +610,7 @@ namespace WixToolset.Core.Link
632 /// <remarks>Because items don't know about their parent groups (and can, in fact, be in more 610 /// <remarks>Because items don't know about their parent groups (and can, in fact, be in more
633 /// than one group at a time), we need to propagate the 'afters' from each parent item to its children 611 /// than one group at a time), we need to propagate the 'afters' from each parent item to its children
634 /// before we attempt to flatten the ordering.</remarks> 612 /// before we attempt to flatten the ordering.</remarks>
635 public void PropagateAfterToChildItems(IMessageHandler messageHandler) 613 public void PropagateAfterToChildItems(IMessaging messageHandler)
636 { 614 {
637 if (this.ShouldItemPropagateChildOrdering()) 615 if (this.ShouldItemPropagateChildOrdering())
638 { 616 {
@@ -647,7 +625,7 @@ namespace WixToolset.Core.Link
647 /// Flattens the ordering dependency for this item. 625 /// Flattens the ordering dependency for this item.
648 /// </summary> 626 /// </summary>
649 /// <param name="messageHandler">Message handler in case a circular ordering reference is found.</param> 627 /// <param name="messageHandler">Message handler in case a circular ordering reference is found.</param>
650 public void FlattenAfters(IMessageHandler messageHandler) 628 public void FlattenAfters(IMessaging messageHandler)
651 { 629 {
652 if (this.flattenedAfterItems) 630 if (this.flattenedAfterItems)
653 { 631 {