From eb2f85d7ee5ad5c91af0943ffe936ee8ccfdab0d Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Sat, 3 Feb 2024 22:52:23 -0500 Subject: [PATCH] Improve error when virtual action symbols collide. --- .../TestData/CloseApplication/Package.wxs | 14 +++++++++----- .../Link/ReportConflictingSymbolsCommand.cs | 11 ++++++++++- src/wix/WixToolset.Core/LinkerErrors.cs | 6 ++++++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/ext/Util/test/WixToolsetTest.Util/TestData/CloseApplication/Package.wxs b/src/ext/Util/test/WixToolsetTest.Util/TestData/CloseApplication/Package.wxs index 8e0542569..8dba33b42 100644 --- a/src/ext/Util/test/WixToolsetTest.Util/TestData/CloseApplication/Package.wxs +++ b/src/ext/Util/test/WixToolsetTest.Util/TestData/CloseApplication/Package.wxs @@ -1,4 +1,4 @@ - + @@ -7,11 +7,15 @@ + + + + - - - - + + + + diff --git a/src/wix/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs b/src/wix/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs index 2851fa60a..b1db46a2d 100644 --- a/src/wix/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs +++ b/src/wix/WixToolset.Core/Link/ReportConflictingSymbolsCommand.cs @@ -5,6 +5,7 @@ namespace WixToolset.Core.Link using System.Collections.Generic; using System.Linq; using WixToolset.Data; + using WixToolset.Data.Symbols; using WixToolset.Extensibility.Services; internal class ReportConflictingSymbolsCommand @@ -62,7 +63,15 @@ public void Execute() reportDuplicates = virtualConflicts; - this.Messaging.Write(LinkerErrors.VirtualSymbolMustBeOverridden(first.Symbol, referencingSourceLineNumber)); + switch (first.Symbol) + { + case WixActionSymbol action: + this.Messaging.Write(LinkerErrors.VirtualSymbolMustBeOverridden(action)); + break; + default: + this.Messaging.Write(LinkerErrors.VirtualSymbolMustBeOverridden(first.Symbol, referencingSourceLineNumber)); + break; + } } else { diff --git a/src/wix/WixToolset.Core/LinkerErrors.cs b/src/wix/WixToolset.Core/LinkerErrors.cs index c234087e3..ab30e8c6a 100644 --- a/src/wix/WixToolset.Core/LinkerErrors.cs +++ b/src/wix/WixToolset.Core/LinkerErrors.cs @@ -3,6 +3,7 @@ namespace WixToolset.Core { using WixToolset.Data; + using WixToolset.Data.Symbols; internal static class LinkerErrors { @@ -101,6 +102,11 @@ public static Message VirtualSymbolMustBeOverridden(IntermediateSymbol symbol) return Message(symbol.SourceLineNumbers, Ids.VirtualSymbolMustBeOverridden, "The {0} symbol '{1}' conflicts with a virtual symbol. Use the 'override' access modifier to override the virtual symbol or use a different Id to avoid the conflict.", symbol.Definition.Name, symbol.Id.Id); } + public static Message VirtualSymbolMustBeOverridden(WixActionSymbol actionSymbol) + { + return Message(actionSymbol.SourceLineNumbers, Ids.VirtualSymbolMustBeOverridden, "The action '{0}' conflicts with a virtual symbol with the same id. To override the virtual symbol (e.g., to reschedule a custom action), use the 'override' access modifier: 'override {0}'. If you didn't intend to override a virtual symbol, use a different id to avoid the conflict.", actionSymbol.Action); + } + public static Message VirtualSymbolMustBeOverridden(IntermediateSymbol symbol, SourceLineNumber referencingSourceLineNumber) { if (referencingSourceLineNumber is null)