From 155a6e96346e0cb3d9ab6f5372fa29b46ebaee89 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 19 Dec 2017 12:25:40 -0800 Subject: Integrate simplified message handling --- src/WixToolset.Core/Link/ResolveReferencesCommand.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/WixToolset.Core/Link/ResolveReferencesCommand.cs') 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 using System.Linq; using WixToolset.Data; using WixToolset.Data.Tuples; + using WixToolset.Extensibility.Services; /// /// Resolves all the simple references in a section. /// - internal class ResolveReferencesCommand : ICommand + internal class ResolveReferencesCommand { private IntermediateSection entrySection; private IDictionary symbols; private HashSet referencedSymbols; private HashSet resolvedSections; - public ResolveReferencesCommand(IntermediateSection entrySection, IDictionary symbols) + public ResolveReferencesCommand(IMessaging messaging, IntermediateSection entrySection, IDictionary symbols) { + this.Messaging = messaging; this.entrySection = entrySection; this.symbols = symbols; } @@ -30,6 +32,8 @@ namespace WixToolset.Link public IEnumerable ResolvedSections { get { return this.resolvedSections; } } + private IMessaging Messaging { get; } + /// /// Resolves all the simple references in a section. /// @@ -69,14 +73,14 @@ namespace WixToolset.Link if (!this.symbols.TryGetValue(wixSimpleReferenceRow.SymbolicName, out var symbol)) { - Messaging.Instance.OnMessage(WixErrors.UnresolvedReference(wixSimpleReferenceRow.SourceLineNumbers, wixSimpleReferenceRow.SymbolicName)); + this.Messaging.Write(ErrorMessages.UnresolvedReference(wixSimpleReferenceRow.SourceLineNumbers, wixSimpleReferenceRow.SymbolicName)); } else // see if the symbol (and any of its duplicates) are appropriately accessible. { IList accessible = DetermineAccessibleSymbols(section, symbol); if (!accessible.Any()) { - Messaging.Instance.OnMessage(WixErrors.UnresolvedReference(wixSimpleReferenceRow.SourceLineNumbers, wixSimpleReferenceRow.SymbolicName, symbol.Access)); + this.Messaging.Write(ErrorMessages.UnresolvedReference(wixSimpleReferenceRow.SourceLineNumbers, wixSimpleReferenceRow.SymbolicName, symbol.Access)); } else if (1 == accessible.Count) { @@ -95,16 +99,16 @@ namespace WixToolset.Link if (String.IsNullOrEmpty(referencingSourceLineNumber)) { - Messaging.Instance.OnMessage(WixErrors.DuplicateSymbol(accessibleSymbol.Row.SourceLineNumbers, accessibleSymbol.Name)); + this.Messaging.Write(ErrorMessages.DuplicateSymbol(accessibleSymbol.Row.SourceLineNumbers, accessibleSymbol.Name)); } else { - Messaging.Instance.OnMessage(WixErrors.DuplicateSymbol(accessibleSymbol.Row.SourceLineNumbers, accessibleSymbol.Name, referencingSourceLineNumber)); + this.Messaging.Write(ErrorMessages.DuplicateSymbol(accessibleSymbol.Row.SourceLineNumbers, accessibleSymbol.Name, referencingSourceLineNumber)); } foreach (Symbol accessibleDuplicate in accessible.Skip(1)) { - Messaging.Instance.OnMessage(WixErrors.DuplicateSymbol2(accessibleDuplicate.Row.SourceLineNumbers)); + this.Messaging.Write(ErrorMessages.DuplicateSymbol2(accessibleDuplicate.Row.SourceLineNumbers)); } } } -- cgit v1.2.3-55-g6feb