aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core/Resolver.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core/Resolver.cs')
-rw-r--r--src/WixToolset.Core/Resolver.cs81
1 files changed, 44 insertions, 37 deletions
diff --git a/src/WixToolset.Core/Resolver.cs b/src/WixToolset.Core/Resolver.cs
index 1b72e3d0..c2d5cc87 100644
--- a/src/WixToolset.Core/Resolver.cs
+++ b/src/WixToolset.Core/Resolver.cs
@@ -25,48 +25,42 @@ namespace WixToolset.Core
25 25
26 public IEnumerable<BindPath> BindPaths { get; set; } 26 public IEnumerable<BindPath> BindPaths { get; set; }
27 27
28 public Intermediate IntermediateRepresentation { get; set; }
29
30 public string IntermediateFolder { get; set; } 28 public string IntermediateFolder { get; set; }
31 29
32 public IEnumerable<Localization> Localizations { get; set; } 30 public Intermediate IntermediateRepresentation { get; set; }
33 31
34 private IMessaging Messaging { get; set; } 32 public IEnumerable<Localization> Localizations { get; set; }
35 33
36 public ResolveResult Execute() 34 public ResolveResult Execute()
37 { 35 {
38 this.Messaging = this.ServiceProvider.GetService<IMessaging>(); 36 var extensionManager = this.ServiceProvider.GetService<IExtensionManager>();
39
40 var localizer = new Localizer(this.Messaging, this.Localizations);
41
42 var variableResolver = new WixVariableResolver(this.Messaging, localizer);
43 this.PopulateVariableResolver(variableResolver);
44 37
45 var context = this.ServiceProvider.GetService<IResolveContext>(); 38 var context = this.ServiceProvider.GetService<IResolveContext>();
46 context.Messaging = this.Messaging; 39 context.Messaging = this.ServiceProvider.GetService<IMessaging>();
47 context.BindPaths = this.BindPaths; 40 context.BindPaths = this.BindPaths;
48 context.Extensions = this.ServiceProvider.GetService<IExtensionManager>().Create<IResolverExtension>(); 41 context.Extensions = extensionManager.Create<IResolverExtension>();
42 context.ExtensionData = extensionManager.Create<IExtensionData>();
49 context.IntermediateFolder = this.IntermediateFolder; 43 context.IntermediateFolder = this.IntermediateFolder;
50 context.IntermediateRepresentation = this.IntermediateRepresentation; 44 context.IntermediateRepresentation = this.IntermediateRepresentation;
51 context.WixVariableResolver = variableResolver; 45 context.Localizations = this.Localizations;
46 context.VariableResolver = new WixVariableResolver(context.Messaging);
52 47
53 // Preresolve.
54 //
55 foreach (IResolverExtension extension in context.Extensions) 48 foreach (IResolverExtension extension in context.Extensions)
56 { 49 {
57 extension.PreResolve(context); 50 extension.PreResolve(context);
58 } 51 }
59 52
60 // Resolve. 53 ResolveResult resolveResult = null;
61 // 54 try
62 this.LocalizeUI(context); 55 {
56 PopulateVariableResolver(context);
63 57
64 var resolveResult = this.Resolve(localizer.Codepage, context); 58 this.LocalizeUI(context);
65 59
66 if (resolveResult != null) 60 resolveResult = this.Resolve(context);
61 }
62 finally
67 { 63 {
68 // Postresolve.
69 //
70 foreach (IResolverExtension extension in context.Extensions) 64 foreach (IResolverExtension extension in context.Extensions)
71 { 65 {
72 extension.PostResolve(resolveResult); 66 extension.PostResolve(resolveResult);
@@ -76,7 +70,7 @@ namespace WixToolset.Core
76 return resolveResult; 70 return resolveResult;
77 } 71 }
78 72
79 private ResolveResult Resolve(int codepage, IResolveContext context) 73 private ResolveResult Resolve(IResolveContext context)
80 { 74 {
81 var buildingPatch = context.IntermediateRepresentation.Sections.Any(s => s.Type == SectionType.Patch); 75 var buildingPatch = context.IntermediateRepresentation.Sections.Any(s => s.Type == SectionType.Patch);
82 76
@@ -87,7 +81,7 @@ namespace WixToolset.Core
87 var command = new ResolveFieldsCommand(); 81 var command = new ResolveFieldsCommand();
88 command.Messaging = context.Messaging; 82 command.Messaging = context.Messaging;
89 command.BuildingPatch = buildingPatch; 83 command.BuildingPatch = buildingPatch;
90 command.BindVariableResolver = context.WixVariableResolver; 84 command.VariableResolver = context.VariableResolver;
91 command.BindPaths = context.BindPaths; 85 command.BindPaths = context.BindPaths;
92 command.Extensions = context.Extensions; 86 command.Extensions = context.Extensions;
93 command.FilesWithEmbeddedFiles = filesWithEmbeddedFiles; 87 command.FilesWithEmbeddedFiles = filesWithEmbeddedFiles;
@@ -122,7 +116,7 @@ namespace WixToolset.Core
122 116
123 return new ResolveResult 117 return new ResolveResult
124 { 118 {
125 Codepage = codepage, 119 Codepage = context.VariableResolver.Codepage,
126 ExpectedEmbeddedFiles = expectedEmbeddedFiles, 120 ExpectedEmbeddedFiles = expectedEmbeddedFiles,
127 DelayedFields = delayedFields, 121 DelayedFields = delayedFields,
128 IntermediateRepresentation = context.IntermediateRepresentation 122 IntermediateRepresentation = context.IntermediateRepresentation
@@ -140,7 +134,7 @@ namespace WixToolset.Core
140 { 134 {
141 string dialog = row.Dialog; 135 string dialog = row.Dialog;
142 136
143 if (context.WixVariableResolver.TryGetLocalizedControl(dialog, null, out LocalizedControl localizedControl)) 137 if (context.VariableResolver.TryGetLocalizedControl(dialog, null, out LocalizedControl localizedControl))
144 { 138 {
145 if (CompilerConstants.IntegerNotSet != localizedControl.X) 139 if (CompilerConstants.IntegerNotSet != localizedControl.X)
146 { 140 {
@@ -176,7 +170,7 @@ namespace WixToolset.Core
176 string dialog = row.Dialog_; 170 string dialog = row.Dialog_;
177 string control = row.Control; 171 string control = row.Control;
178 172
179 if (context.WixVariableResolver.TryGetLocalizedControl(dialog, control, out LocalizedControl localizedControl)) 173 if (context.VariableResolver.TryGetLocalizedControl(dialog, control, out LocalizedControl localizedControl))
180 { 174 {
181 if (CompilerConstants.IntegerNotSet != localizedControl.X) 175 if (CompilerConstants.IntegerNotSet != localizedControl.X)
182 { 176 {
@@ -209,21 +203,34 @@ namespace WixToolset.Core
209 } 203 }
210 } 204 }
211 205
212 private void PopulateVariableResolver(WixVariableResolver resolver) 206 private static void PopulateVariableResolver(IResolveContext context)
213 { 207 {
214 // Gather all the wix variables. 208 var creator = context.ServiceProvider.GetService<ITupleDefinitionCreator>();
215 var wixVariableTuples = this.IntermediateRepresentation.Sections.SelectMany(s => s.Tuples).OfType<WixVariableTuple>(); 209
216 foreach (var tuple in wixVariableTuples) 210 var localizations = context.Localizations.Concat(context.IntermediateRepresentation.Localizations).ToList();
211
212 // Add localizations from the extensions with data.
213 foreach (var data in context.ExtensionData)
217 { 214 {
218 try 215 var library = data.GetLibrary(creator);
219 { 216
220 resolver.AddVariable(tuple.WixVariable, tuple.Value, tuple.Overridable); 217 if (library?.Localizations != null)
221 }
222 catch (ArgumentException)
223 { 218 {
224 this.Messaging.Write(ErrorMessages.WixVariableCollision(tuple.SourceLineNumbers, tuple.WixVariable)); 219 localizations.AddRange(library.Localizations);
225 } 220 }
226 } 221 }
222
223 foreach (var localization in localizations)
224 {
225 context.VariableResolver.AddLocalization(localization);
226 }
227
228 // Gather all the wix variables.
229 var wixVariableTuples = context.IntermediateRepresentation.Sections.SelectMany(s => s.Tuples).OfType<WixVariableTuple>();
230 foreach (var tuple in wixVariableTuples)
231 {
232 context.VariableResolver.AddVariable(tuple.SourceLineNumbers, tuple.WixVariable, tuple.Value, tuple.Overridable);
233 }
227 } 234 }
228 } 235 }
229} 236}