diff options
| author | Bob Arnson <bob@firegiant.com> | 2020-01-29 15:04:53 -0500 |
|---|---|---|
| committer | Bob Arnson <bob@firegiant.com> | 2020-01-29 15:08:59 -0500 |
| commit | c9c3ab2776252d3131fea561bd3f3fac8c045f5e (patch) | |
| tree | dc57f6f3685ebbacd0ae9ec46b410cfccc546273 /src | |
| parent | 2d6d903defea5625da52831c2a2a7a958b1ab325 (diff) | |
| download | wix-c9c3ab2776252d3131fea561bd3f3fac8c045f5e.tar.gz wix-c9c3ab2776252d3131fea561bd3f3fac8c045f5e.tar.bz2 wix-c9c3ab2776252d3131fea561bd3f3fac8c045f5e.zip | |
Clean up variable resolution during Resolve.
Diffstat (limited to 'src')
| -rw-r--r-- | src/WixToolset.Core/CommandLine/BuildCommand.cs | 1 | ||||
| -rw-r--r-- | src/WixToolset.Core/Resolver.cs | 30 | ||||
| -rw-r--r-- | src/WixToolset.Core/VariableResolver.cs | 8 |
3 files changed, 17 insertions, 22 deletions
diff --git a/src/WixToolset.Core/CommandLine/BuildCommand.cs b/src/WixToolset.Core/CommandLine/BuildCommand.cs index 023a3c1e..0868a3b6 100644 --- a/src/WixToolset.Core/CommandLine/BuildCommand.cs +++ b/src/WixToolset.Core/CommandLine/BuildCommand.cs | |||
| @@ -284,7 +284,6 @@ namespace WixToolset.Core.CommandLine | |||
| 284 | context.IntermediateFolder = intermediateFolder; | 284 | context.IntermediateFolder = intermediateFolder; |
| 285 | context.IntermediateRepresentation = output; | 285 | context.IntermediateRepresentation = output; |
| 286 | context.Localizations = localizations; | 286 | context.Localizations = localizations; |
| 287 | context.VariableResolver = this.ServiceProvider.GetService<IVariableResolver>(); | ||
| 288 | 287 | ||
| 289 | var resolver = this.ServiceProvider.GetService<IResolver>(); | 288 | var resolver = this.ServiceProvider.GetService<IResolver>(); |
| 290 | resolveResult = resolver.Resolve(context); | 289 | resolveResult = resolver.Resolve(context); |
diff --git a/src/WixToolset.Core/Resolver.cs b/src/WixToolset.Core/Resolver.cs index d2a81477..cbae3742 100644 --- a/src/WixToolset.Core/Resolver.cs +++ b/src/WixToolset.Core/Resolver.cs | |||
| @@ -22,12 +22,16 @@ namespace WixToolset.Core | |||
| 22 | this.ServiceProvider = serviceProvider; | 22 | this.ServiceProvider = serviceProvider; |
| 23 | 23 | ||
| 24 | this.Messaging = serviceProvider.GetService<IMessaging>(); | 24 | this.Messaging = serviceProvider.GetService<IMessaging>(); |
| 25 | |||
| 26 | this.VariableResolver = serviceProvider.GetService<IVariableResolver>(); | ||
| 25 | } | 27 | } |
| 26 | 28 | ||
| 27 | private IServiceProvider ServiceProvider { get; } | 29 | private IServiceProvider ServiceProvider { get; } |
| 28 | 30 | ||
| 29 | private IMessaging Messaging { get; } | 31 | private IMessaging Messaging { get; } |
| 30 | 32 | ||
| 33 | private IVariableResolver VariableResolver { get; set; } | ||
| 34 | |||
| 31 | public IEnumerable<IBindPath> BindPaths { get; set; } | 35 | public IEnumerable<IBindPath> BindPaths { get; set; } |
| 32 | 36 | ||
| 33 | public string IntermediateFolder { get; set; } | 37 | public string IntermediateFolder { get; set; } |
| @@ -40,7 +44,6 @@ namespace WixToolset.Core | |||
| 40 | 44 | ||
| 41 | public IResolveResult Resolve(IResolveContext context) | 45 | public IResolveResult Resolve(IResolveContext context) |
| 42 | { | 46 | { |
| 43 | |||
| 44 | foreach (var extension in context.Extensions) | 47 | foreach (var extension in context.Extensions) |
| 45 | { | 48 | { |
| 46 | extension.PreResolve(context); | 49 | extension.PreResolve(context); |
| @@ -49,11 +52,11 @@ namespace WixToolset.Core | |||
| 49 | ResolveResult resolveResult = null; | 52 | ResolveResult resolveResult = null; |
| 50 | try | 53 | try |
| 51 | { | 54 | { |
| 52 | PopulateVariableResolver(context); | 55 | var codepage = this.PopulateVariableResolver(context); |
| 53 | 56 | ||
| 54 | this.LocalizeUI(context); | 57 | this.LocalizeUI(context); |
| 55 | 58 | ||
| 56 | resolveResult = this.DoResolve(context); | 59 | resolveResult = this.DoResolve(context, codepage); |
| 57 | } | 60 | } |
| 58 | finally | 61 | finally |
| 59 | { | 62 | { |
| @@ -66,7 +69,7 @@ namespace WixToolset.Core | |||
| 66 | return resolveResult; | 69 | return resolveResult; |
| 67 | } | 70 | } |
| 68 | 71 | ||
| 69 | private ResolveResult DoResolve(IResolveContext context) | 72 | private ResolveResult DoResolve(IResolveContext context, int? codepage) |
| 70 | { | 73 | { |
| 71 | var buildingPatch = context.IntermediateRepresentation.Sections.Any(s => s.Type == SectionType.Patch); | 74 | var buildingPatch = context.IntermediateRepresentation.Sections.Any(s => s.Type == SectionType.Patch); |
| 72 | 75 | ||
| @@ -77,7 +80,7 @@ namespace WixToolset.Core | |||
| 77 | var command = new ResolveFieldsCommand(); | 80 | var command = new ResolveFieldsCommand(); |
| 78 | command.Messaging = this.Messaging; | 81 | command.Messaging = this.Messaging; |
| 79 | command.BuildingPatch = buildingPatch; | 82 | command.BuildingPatch = buildingPatch; |
| 80 | command.VariableResolver = context.VariableResolver; | 83 | command.VariableResolver = this.VariableResolver; |
| 81 | command.BindPaths = context.BindPaths; | 84 | command.BindPaths = context.BindPaths; |
| 82 | command.Extensions = context.Extensions; | 85 | command.Extensions = context.Extensions; |
| 83 | command.FilesWithEmbeddedFiles = filesWithEmbeddedFiles; | 86 | command.FilesWithEmbeddedFiles = filesWithEmbeddedFiles; |
| @@ -112,7 +115,7 @@ namespace WixToolset.Core | |||
| 112 | 115 | ||
| 113 | return new ResolveResult | 116 | return new ResolveResult |
| 114 | { | 117 | { |
| 115 | Codepage = context.VariableResolver.Codepage, | 118 | Codepage = codepage.HasValue ? codepage.Value : -1, |
| 116 | ExpectedEmbeddedFiles = expectedEmbeddedFiles, | 119 | ExpectedEmbeddedFiles = expectedEmbeddedFiles, |
| 117 | DelayedFields = delayedFields, | 120 | DelayedFields = delayedFields, |
| 118 | IntermediateRepresentation = context.IntermediateRepresentation | 121 | IntermediateRepresentation = context.IntermediateRepresentation |
| @@ -128,7 +131,7 @@ namespace WixToolset.Core | |||
| 128 | { | 131 | { |
| 129 | foreach (var tuple in section.Tuples.OfType<DialogTuple>()) | 132 | foreach (var tuple in section.Tuples.OfType<DialogTuple>()) |
| 130 | { | 133 | { |
| 131 | if (context.VariableResolver.TryGetLocalizedControl(tuple.Id.Id, null, out var localizedControl)) | 134 | if (this.VariableResolver.TryGetLocalizedControl(tuple.Id.Id, null, out var localizedControl)) |
| 132 | { | 135 | { |
| 133 | if (CompilerConstants.IntegerNotSet != localizedControl.X) | 136 | if (CompilerConstants.IntegerNotSet != localizedControl.X) |
| 134 | { | 137 | { |
| @@ -163,7 +166,7 @@ namespace WixToolset.Core | |||
| 163 | 166 | ||
| 164 | foreach (var tuple in section.Tuples.OfType<ControlTuple>()) | 167 | foreach (var tuple in section.Tuples.OfType<ControlTuple>()) |
| 165 | { | 168 | { |
| 166 | if (context.VariableResolver.TryGetLocalizedControl(tuple.DialogRef, tuple.Control, out var localizedControl)) | 169 | if (this.VariableResolver.TryGetLocalizedControl(tuple.DialogRef, tuple.Control, out var localizedControl)) |
| 167 | { | 170 | { |
| 168 | if (CompilerConstants.IntegerNotSet != localizedControl.X) | 171 | if (CompilerConstants.IntegerNotSet != localizedControl.X) |
| 169 | { | 172 | { |
| @@ -198,23 +201,24 @@ namespace WixToolset.Core | |||
| 198 | } | 201 | } |
| 199 | } | 202 | } |
| 200 | 203 | ||
| 201 | private static void PopulateVariableResolver(IResolveContext context) | 204 | private int? PopulateVariableResolver(IResolveContext context) |
| 202 | { | 205 | { |
| 203 | var creator = context.ServiceProvider.GetService<ITupleDefinitionCreator>(); | ||
| 204 | |||
| 205 | var localizations = FilterLocalizations(context); | 206 | var localizations = FilterLocalizations(context); |
| 207 | var codepage = localizations.FirstOrDefault()?.Codepage; | ||
| 206 | 208 | ||
| 207 | foreach (var localization in localizations) | 209 | foreach (var localization in localizations) |
| 208 | { | 210 | { |
| 209 | context.VariableResolver.AddLocalization(localization); | 211 | this.VariableResolver.AddLocalization(localization); |
| 210 | } | 212 | } |
| 211 | 213 | ||
| 212 | // Gather all the wix variables. | 214 | // Gather all the wix variables. |
| 213 | var wixVariableTuples = context.IntermediateRepresentation.Sections.SelectMany(s => s.Tuples).OfType<WixVariableTuple>(); | 215 | var wixVariableTuples = context.IntermediateRepresentation.Sections.SelectMany(s => s.Tuples).OfType<WixVariableTuple>(); |
| 214 | foreach (var tuple in wixVariableTuples) | 216 | foreach (var tuple in wixVariableTuples) |
| 215 | { | 217 | { |
| 216 | context.VariableResolver.AddVariable(tuple.SourceLineNumbers, tuple.Id.Id, tuple.Value, tuple.Overridable); | 218 | this.VariableResolver.AddVariable(tuple.SourceLineNumbers, tuple.Id.Id, tuple.Value, tuple.Overridable); |
| 217 | } | 219 | } |
| 220 | |||
| 221 | return codepage; | ||
| 218 | } | 222 | } |
| 219 | 223 | ||
| 220 | private static IEnumerable<Localization> FilterLocalizations(IResolveContext context) | 224 | private static IEnumerable<Localization> FilterLocalizations(IResolveContext context) |
diff --git a/src/WixToolset.Core/VariableResolver.cs b/src/WixToolset.Core/VariableResolver.cs index c2a54a12..189fb883 100644 --- a/src/WixToolset.Core/VariableResolver.cs +++ b/src/WixToolset.Core/VariableResolver.cs | |||
| @@ -29,24 +29,16 @@ namespace WixToolset.Core | |||
| 29 | this.locVariables = new Dictionary<string, BindVariable>(); | 29 | this.locVariables = new Dictionary<string, BindVariable>(); |
| 30 | this.wixVariables = new Dictionary<string, BindVariable>(); | 30 | this.wixVariables = new Dictionary<string, BindVariable>(); |
| 31 | this.localizedControls = new Dictionary<string, LocalizedControl>(); | 31 | this.localizedControls = new Dictionary<string, LocalizedControl>(); |
| 32 | this.Codepage = -1; | ||
| 33 | } | 32 | } |
| 34 | 33 | ||
| 35 | private IServiceProvider ServiceProvider { get; } | 34 | private IServiceProvider ServiceProvider { get; } |
| 36 | 35 | ||
| 37 | private IMessaging Messaging { get; } | 36 | private IMessaging Messaging { get; } |
| 38 | 37 | ||
| 39 | public int Codepage { get; private set; } | ||
| 40 | |||
| 41 | public int VariableCount => this.wixVariables.Count; | 38 | public int VariableCount => this.wixVariables.Count; |
| 42 | 39 | ||
| 43 | public void AddLocalization(Localization localization) | 40 | public void AddLocalization(Localization localization) |
| 44 | { | 41 | { |
| 45 | if (-1 == this.Codepage) | ||
| 46 | { | ||
| 47 | this.Codepage = localization.Codepage; | ||
| 48 | } | ||
| 49 | |||
| 50 | foreach (var variable in localization.Variables) | 42 | foreach (var variable in localization.Variables) |
| 51 | { | 43 | { |
| 52 | if (!TryAddWixVariable(this.locVariables, variable)) | 44 | if (!TryAddWixVariable(this.locVariables, variable)) |
