@joebigelow / wix / commits / a4be3486

Expose WixVariableResolver via WixToolsetServiceProvider

Rob Mensching committed Feb 28, 2019 at 16:56 UTC a4be3486b60d232b546f438bc4bd7a4a80cf330c
6 files changed +10 -10
src/WixToolset.Core/CommandLine/BuildCommand.cs
+1 -1
@@ -275,7 +275,7 @@ namespace WixToolset.Core.CommandLine
275 context.IntermediateFolder = intermediateFolder;
276 context.IntermediateRepresentation = output;
277 context.Localizations = localizations;
278 - context.VariableResolver = new WixVariableResolver(this.Messaging);
278 + context.VariableResolver = this.ServiceProvider.GetService<IVariableResolver>();
279
280 var resolver = this.ServiceProvider.GetService<IResolver>();
281 resolveResult = resolver.Resolve(context);
src/WixToolset.Core/Compiler.cs
+2 -1
@@ -45,6 +45,7 @@ namespace WixToolset.Core
45 private string activeName;
46 private string activeLanguage;
47
48 + // TODO: Implement this differently to not require the VariableResolver.
49 private WixVariableResolver componentIdPlaceholdersResolver;
50
51 /// <summary>
@@ -131,7 +132,7 @@ namespace WixToolset.Core
132
133 this.Core = new CompilerCore(target, this.Messaging, parseHelper, extensionsByNamespace);
134 this.Core.ShowPedanticMessages = this.ShowPedanticMessages;
134 - this.componentIdPlaceholdersResolver = new WixVariableResolver(this.Messaging);
135 + this.componentIdPlaceholdersResolver = new WixVariableResolver(this.ServiceProvider);
136
137 // parse the document
138 var source = this.Context.Source;
src/WixToolset.Core/ILocalizer.cs
+2 -2
@@ -1,4 +1,4 @@
1 -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
1 +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3 namespace WixToolset.Core
4 {
@@ -6,7 +6,7 @@ namespace WixToolset.Core
6 using WixToolset.Data;
7
8 /// <summary>
9 - /// Parses localization files and localizes database values.
9 + /// Parses localization source files.
10 /// </summary>
11 public interface ILocalizer
12 {
src/WixToolset.Core/Librarian.cs
+1 -1
@@ -106,7 +106,7 @@ namespace WixToolset.Core
106 // Resolve paths to files that are to be embedded in the library.
107 if (context.BindFiles)
108 {
109 - var variableResolver = new WixVariableResolver(this.Messaging);
109 + var variableResolver = this.ServiceProvider.GetService<IVariableResolver>();
110
111 var fileResolver = new FileResolver(context.BindPaths, context.Extensions);
112
src/WixToolset.Core/WixToolsetServiceProvider.cs
+1 -1
@@ -49,8 +49,8 @@ namespace WixToolset.Core
49 this.AddService<ILinker>((provider, singletons) => new Linker(provider));
50 this.AddService<IResolver>((provider, singletons) => new Resolver(provider));
51
52 - // Internal implementations.
52 this.AddService<ILocalizer>((provider, singletons) => new Localizer(provider));
53 + this.AddService<IVariableResolver>((provider, singletons) => new WixVariableResolver(provider));
54 }
55
56 private Dictionary<Type, Func<IServiceProvider, Dictionary<Type, object>, object>> CreationFunctions { get; }
src/WixToolset.Core/WixVariableResolver.cs
+3 -4
@@ -21,13 +21,14 @@ namespace WixToolset.Core
21 /// <summary>
22 /// Instantiate a new WixVariableResolver.
23 /// </summary>
24 - public WixVariableResolver(IMessaging messaging)
24 + internal WixVariableResolver(IServiceProvider serviceProvider)
25 {
26 + this.Messaging = serviceProvider.GetService<IMessaging>();
27 +
28 this.locVariables = new Dictionary<string, BindVariable>();
29 this.wixVariables = new Dictionary<string, BindVariable>();
30 this.localizedControls = new Dictionary<string, LocalizedControl>();
31 this.Codepage = -1;
30 - this.Messaging = messaging;
32 }
33
34 private IMessaging Messaging { get; }
@@ -88,8 +89,6 @@ namespace WixToolset.Core
89 /// <param name="value">The value to resolve.</param>
90 /// <param name="localizationOnly">true to only resolve localization variables; false otherwise.</param>
91 /// <param name="errorOnUnknown">true if unknown variables should throw errors.</param>
91 - /// <param name="isDefault">true if the resolved value was the default.</param>
92 - /// <param name="delayedResolve">true if the value has variables that cannot yet be resolved.</param>
92 /// <returns>The resolved value.</returns>
93 internal VariableResolution ResolveVariables(SourceLineNumber sourceLineNumbers, string value, bool localizationOnly, bool errorOnUnknown)
94 {