aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/Linker.cs
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2017-12-19 12:25:40 -0800
committerRob Mensching <rob@firegiant.com>2017-12-19 12:25:40 -0800
commit155a6e96346e0cb3d9ab6f5372fa29b46ebaee89 (patch)
tree59d1f151bfde8068b6014b05b5c8cfea3402c974 /src/WixToolset.Core/Linker.cs
parent6f1665ed759b31bd095f186f9239232c653597cd (diff)
downloadwix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.tar.gz
wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.tar.bz2
wix-155a6e96346e0cb3d9ab6f5372fa29b46ebaee89.zip
Integrate simplified message handling
Diffstat (limited to 'src/WixToolset.Core/Linker.cs')
-rw-r--r--src/WixToolset.Core/Linker.cs54
1 files changed, 27 insertions, 27 deletions
diff --git a/src/WixToolset.Core/Linker.cs b/src/WixToolset.Core/Linker.cs
index ccf6f329..d980d79f 100644
--- a/src/WixToolset.Core/Linker.cs
+++ b/src/WixToolset.Core/Linker.cs
@@ -17,7 +17,7 @@ namespace WixToolset.Core
17 /// <summary> 17 /// <summary>
18 /// Linker core of the WiX toolset. 18 /// Linker core of the WiX toolset.
19 /// </summary> 19 /// </summary>
20 public sealed class Linker : IMessageHandler 20 public sealed class Linker
21 { 21 {
22 private static readonly char[] colonCharacter = ":".ToCharArray(); 22 private static readonly char[] colonCharacter = ":".ToCharArray();
23 private static readonly string emptyGuid = Guid.Empty.ToString("B"); 23 private static readonly string emptyGuid = Guid.Empty.ToString("B");
@@ -129,14 +129,14 @@ namespace WixToolset.Core
129 129
130 // First find the entry section and while processing all sections load all the symbols from all of the sections. 130 // First find the entry section and while processing all sections load all the symbols from all of the sections.
131 // sections.FindEntrySectionAndLoadSymbols(false, this, expectedOutputType, out entrySection, out allSymbols); 131 // sections.FindEntrySectionAndLoadSymbols(false, this, expectedOutputType, out entrySection, out allSymbols);
132 var find = new FindEntrySectionAndLoadSymbolsCommand(sections); 132 var find = new FindEntrySectionAndLoadSymbolsCommand(this.Context.Messaging, sections);
133 find.ExpectedOutputType = this.Context.ExpectedOutputType; 133 find.ExpectedOutputType = this.Context.ExpectedOutputType;
134 find.Execute(); 134 find.Execute();
135 135
136 // Must have found the entry section by now. 136 // Must have found the entry section by now.
137 if (null == find.EntrySection) 137 if (null == find.EntrySection)
138 { 138 {
139 throw new WixException(WixErrors.MissingEntrySection(this.Context.ExpectedOutputType.ToString())); 139 throw new WixException(ErrorMessages.MissingEntrySection(this.Context.ExpectedOutputType.ToString()));
140 } 140 }
141 141
142 // Add the missing standard action symbols. 142 // Add the missing standard action symbols.
@@ -144,12 +144,12 @@ namespace WixToolset.Core
144 144
145 // Resolve the symbol references to find the set of sections we care about for linking. 145 // Resolve the symbol references to find the set of sections we care about for linking.
146 // Of course, we start with the entry section (that's how it got its name after all). 146 // Of course, we start with the entry section (that's how it got its name after all).
147 var resolve = new ResolveReferencesCommand(find.EntrySection, find.Symbols); 147 var resolve = new ResolveReferencesCommand(this.Context.Messaging, find.EntrySection, find.Symbols);
148 resolve.BuildingMergeModule = (SectionType.Module == find.EntrySection.Type); 148 resolve.BuildingMergeModule = (SectionType.Module == find.EntrySection.Type);
149 149
150 resolve.Execute(); 150 resolve.Execute();
151 151
152 if (Messaging.Instance.EncounteredError) 152 if (this.Context.Messaging.EncounteredError)
153 { 153 {
154 return null; 154 return null;
155 } 155 }
@@ -160,7 +160,7 @@ namespace WixToolset.Core
160 160
161 this.FlattenSectionsComplexReferences(sections); 161 this.FlattenSectionsComplexReferences(sections);
162 162
163 if (Messaging.Instance.EncounteredError) 163 if (this.Context.Messaging.EncounteredError)
164 { 164 {
165 return null; 165 return null;
166 } 166 }
@@ -172,7 +172,7 @@ namespace WixToolset.Core
172 var modulesToFeatures = new ConnectToFeatureCollection(); 172 var modulesToFeatures = new ConnectToFeatureCollection();
173 this.ProcessComplexReferences(find.EntrySection, sections, referencedComponents, componentsToFeatures, featuresToFeatures, modulesToFeatures); 173 this.ProcessComplexReferences(find.EntrySection, sections, referencedComponents, componentsToFeatures, featuresToFeatures, modulesToFeatures);
174 174
175 if (Messaging.Instance.EncounteredError) 175 if (this.Context.Messaging.EncounteredError)
176 { 176 {
177 return null; 177 return null;
178 } 178 }
@@ -182,15 +182,15 @@ namespace WixToolset.Core
182 { 182 {
183 if (!referencedComponents.Contains(symbol.Name)) 183 if (!referencedComponents.Contains(symbol.Name))
184 { 184 {
185 this.OnMessage(WixErrors.OrphanedComponent(symbol.Row.SourceLineNumbers, symbol.Row.Id.Id)); 185 this.OnMessage(ErrorMessages.OrphanedComponent(symbol.Row.SourceLineNumbers, symbol.Row.Id.Id));
186 } 186 }
187 } 187 }
188 188
189 // Report duplicates that would ultimately end up being primary key collisions. 189 // Report duplicates that would ultimately end up being primary key collisions.
190 var reportDupes = new ReportConflictingSymbolsCommand(find.PossiblyConflictingSymbols, resolve.ResolvedSections); 190 var reportDupes = new ReportConflictingSymbolsCommand(this.Context.Messaging, find.PossiblyConflictingSymbols, resolve.ResolvedSections);
191 reportDupes.Execute(); 191 reportDupes.Execute();
192 192
193 if (Messaging.Instance.EncounteredError) 193 if (this.Context.Messaging.EncounteredError)
194 { 194 {
195 return null; 195 return null;
196 } 196 }
@@ -422,7 +422,7 @@ namespace WixToolset.Core
422 } 422 }
423 else if (!row.Overridable || (collidingRow.Overridable && row.Overridable)) 423 else if (!row.Overridable || (collidingRow.Overridable && row.Overridable))
424 { 424 {
425 this.OnMessage(WixErrors.WixVariableCollision(row.SourceLineNumbers, row.WixVariable)); 425 this.OnMessage(ErrorMessages.WixVariableCollision(row.SourceLineNumbers, row.WixVariable));
426 } 426 }
427 } 427 }
428 else 428 else
@@ -691,7 +691,7 @@ namespace WixToolset.Core
691 // Bundles have groups of data that must be flattened in a way different from other types. 691 // Bundles have groups of data that must be flattened in a way different from other types.
692 this.FlattenBundleTables(resolvedSection); 692 this.FlattenBundleTables(resolvedSection);
693 693
694 if (Messaging.Instance.EncounteredError) 694 if (this.Context.Messaging.EncounteredError)
695 { 695 {
696 return null; 696 return null;
697 } 697 }
@@ -702,7 +702,7 @@ namespace WixToolset.Core
702 this.CheckOutputConsistency(output); 702 this.CheckOutputConsistency(output);
703#endif 703#endif
704 704
705 return Messaging.Instance.EncounteredError ? null : output; 705 return this.Context.Messaging.EncounteredError ? null : output;
706 } 706 }
707 707
708#if SOLVE_CUSTOM_TABLE 708#if SOLVE_CUSTOM_TABLE
@@ -1079,10 +1079,10 @@ namespace WixToolset.Core
1079 /// <summary> 1079 /// <summary>
1080 /// Sends a message to the message delegate if there is one. 1080 /// Sends a message to the message delegate if there is one.
1081 /// </summary> 1081 /// </summary>
1082 /// <param name="mea">Message event arguments.</param> 1082 /// <param name="message">Message event arguments.</param>
1083 public void OnMessage(MessageEventArgs e) 1083 public void OnMessage(Message message)
1084 { 1084 {
1085 this.Context.Messaging.OnMessage(e); 1085 this.Context.Messaging.Write(message);
1086 } 1086 }
1087 1087
1088 /// <summary> 1088 /// <summary>
@@ -1138,7 +1138,7 @@ namespace WixToolset.Core
1138 { 1138 {
1139 if (connection.IsExplicitPrimaryFeature) 1139 if (connection.IsExplicitPrimaryFeature)
1140 { 1140 {
1141 this.OnMessage(WixErrors.MultiplePrimaryReferences(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.Child, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.Parent, (null != connection.PrimaryFeature ? "Feature" : "Product"), connection.PrimaryFeature ?? resolvedSection.Id)); 1141 this.OnMessage(ErrorMessages.MultiplePrimaryReferences(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.Child, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.Parent, (null != connection.PrimaryFeature ? "Feature" : "Product"), connection.PrimaryFeature ?? resolvedSection.Id));
1142 continue; 1142 continue;
1143 } 1143 }
1144 else 1144 else
@@ -1170,7 +1170,7 @@ namespace WixToolset.Core
1170 connection = featuresToFeatures[wixComplexReferenceRow.Child]; 1170 connection = featuresToFeatures[wixComplexReferenceRow.Child];
1171 if (null != connection) 1171 if (null != connection)
1172 { 1172 {
1173 this.OnMessage(WixErrors.MultiplePrimaryReferences(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.Child, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.Parent, (null != connection.PrimaryFeature ? "Feature" : "Product"), (null != connection.PrimaryFeature ? connection.PrimaryFeature : resolvedSection.Id))); 1173 this.OnMessage(ErrorMessages.MultiplePrimaryReferences(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.Child, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.Parent, (null != connection.PrimaryFeature ? "Feature" : "Product"), (null != connection.PrimaryFeature ? connection.PrimaryFeature : resolvedSection.Id)));
1174 continue; 1174 continue;
1175 } 1175 }
1176 1176
@@ -1187,7 +1187,7 @@ namespace WixToolset.Core
1187 { 1187 {
1188 if (connection.IsExplicitPrimaryFeature) 1188 if (connection.IsExplicitPrimaryFeature)
1189 { 1189 {
1190 this.OnMessage(WixErrors.MultiplePrimaryReferences(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.Child, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.Parent, (null != connection.PrimaryFeature ? "Feature" : "Product"), (null != connection.PrimaryFeature ? connection.PrimaryFeature : resolvedSection.Id))); 1190 this.OnMessage(ErrorMessages.MultiplePrimaryReferences(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.Child, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.Parent, (null != connection.PrimaryFeature ? "Feature" : "Product"), (null != connection.PrimaryFeature ? connection.PrimaryFeature : resolvedSection.Id)));
1191 continue; 1191 continue;
1192 } 1192 }
1193 else 1193 else
@@ -1214,7 +1214,7 @@ namespace WixToolset.Core
1214 case ComplexReferenceChildType.Component: 1214 case ComplexReferenceChildType.Component:
1215 if (componentsToModules.ContainsKey(wixComplexReferenceRow.Child)) 1215 if (componentsToModules.ContainsKey(wixComplexReferenceRow.Child))
1216 { 1216 {
1217 this.OnMessage(WixErrors.ComponentReferencedTwice(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.Child)); 1217 this.OnMessage(ErrorMessages.ComponentReferencedTwice(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.Child));
1218 continue; 1218 continue;
1219 } 1219 }
1220 else 1220 else
@@ -1258,7 +1258,7 @@ namespace WixToolset.Core
1258 connection = featuresToFeatures[wixComplexReferenceRow.Child]; 1258 connection = featuresToFeatures[wixComplexReferenceRow.Child];
1259 if (null != connection) 1259 if (null != connection)
1260 { 1260 {
1261 this.OnMessage(WixErrors.MultiplePrimaryReferences(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.Child, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.Parent, (null != connection.PrimaryFeature ? "Feature" : "Product"), (null != connection.PrimaryFeature ? connection.PrimaryFeature : resolvedSection.Id))); 1261 this.OnMessage(ErrorMessages.MultiplePrimaryReferences(wixComplexReferenceRow.SourceLineNumbers, wixComplexReferenceRow.ChildType.ToString(), wixComplexReferenceRow.Child, wixComplexReferenceRow.ParentType.ToString(), wixComplexReferenceRow.Parent, (null != connection.PrimaryFeature ? "Feature" : "Product"), (null != connection.PrimaryFeature ? connection.PrimaryFeature : resolvedSection.Id)));
1262 continue; 1262 continue;
1263 } 1263 }
1264 1264
@@ -1443,7 +1443,7 @@ namespace WixToolset.Core
1443 // way up to present the loop as a directed graph. 1443 // way up to present the loop as a directed graph.
1444 var loop = String.Join(" -> ", loopDetector); 1444 var loop = String.Join(" -> ", loopDetector);
1445 1445
1446 this.OnMessage(WixErrors.ReferenceLoopDetected(wixComplexReferenceRow?.SourceLineNumbers, loop)); 1446 this.OnMessage(ErrorMessages.ReferenceLoopDetected(wixComplexReferenceRow?.SourceLineNumbers, loop));
1447 1447
1448 // Cleanup the parentGroupsNeedingProcessing and the loopDetector just like the 1448 // Cleanup the parentGroupsNeedingProcessing and the loopDetector just like the
1449 // exit of this method does at the end because we are exiting early. 1449 // exit of this method does at the end because we are exiting early.
@@ -1580,7 +1580,7 @@ namespace WixToolset.Core
1580 // will hold Payloads under UX, ChainPackages (references?) under Chain, 1580 // will hold Payloads under UX, ChainPackages (references?) under Chain,
1581 // and ChainPackages/Payloads under the attached and any detatched 1581 // and ChainPackages/Payloads under the attached and any detatched
1582 // Containers. 1582 // Containers.
1583 var groups = new WixGroupingOrdering(entrySection, this); 1583 var groups = new WixGroupingOrdering(entrySection, this.Context.Messaging);
1584 1584
1585 // Create UX payloads and Package payloads 1585 // Create UX payloads and Package payloads
1586 groups.UseTypes(new string[] { "Container", "Layout", "PackageGroup", "PayloadGroup", "Package" }, new string[] { "PackageGroup", "Package", "PayloadGroup", "Payload" }); 1586 groups.UseTypes(new string[] { "Container", "Layout", "PackageGroup", "PayloadGroup", "Package" }, new string[] { "PackageGroup", "Package", "PayloadGroup", "Payload" });
@@ -1685,11 +1685,11 @@ namespace WixToolset.Core
1685 // display an error for the component or merge module as approrpriate 1685 // display an error for the component or merge module as approrpriate
1686 if (null != multipleFeatureComponents) 1686 if (null != multipleFeatureComponents)
1687 { 1687 {
1688 this.OnMessage(WixErrors.ComponentExpectedFeature(row.SourceLineNumbers, connectionId, row.Definition.Name, row.Id.Id)); 1688 this.OnMessage(ErrorMessages.ComponentExpectedFeature(row.SourceLineNumbers, connectionId, row.Definition.Name, row.Id.Id));
1689 } 1689 }
1690 else 1690 else
1691 { 1691 {
1692 this.OnMessage(WixErrors.MergeModuleExpectedFeature(row.SourceLineNumbers, connectionId)); 1692 this.OnMessage(ErrorMessages.MergeModuleExpectedFeature(row.SourceLineNumbers, connectionId));
1693 } 1693 }
1694 } 1694 }
1695 else 1695 else
@@ -1704,7 +1704,7 @@ namespace WixToolset.Core
1704 { 1704 {
1705 if (!multipleFeatureComponents.Contains(connectionId)) 1705 if (!multipleFeatureComponents.Contains(connectionId))
1706 { 1706 {
1707 this.OnMessage(WixWarnings.ImplicitComponentPrimaryFeature(connectionId)); 1707 this.OnMessage(WarningMessages.ImplicitComponentPrimaryFeature(connectionId));
1708 1708
1709 // remember this component so only one warning is generated for it 1709 // remember this component so only one warning is generated for it
1710 multipleFeatureComponents[connectionId] = null; 1710 multipleFeatureComponents[connectionId] = null;
@@ -1712,7 +1712,7 @@ namespace WixToolset.Core
1712 } 1712 }
1713 else 1713 else
1714 { 1714 {
1715 this.OnMessage(WixWarnings.ImplicitMergeModulePrimaryFeature(connectionId)); 1715 this.OnMessage(WarningMessages.ImplicitMergeModulePrimaryFeature(connectionId));
1716 } 1716 }
1717 } 1717 }
1718 1718