aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Arnson <bob@firegiant.com>2020-03-11 20:54:04 -0400
committerBob Arnson <bob@firegiant.com>2020-03-11 22:13:02 -0400
commit61d0e33943811cc31aeeae0c8c1c5c5768986bbe (patch)
tree7dc8d2ea9bf729e593865e3b4ba88a1de61cc860
parent72b6f0109008103dfe974fa4d2d3ce42e7b6b53e (diff)
downloadwix-61d0e33943811cc31aeeae0c8c1c5c5768986bbe.tar.gz
wix-61d0e33943811cc31aeeae0c8c1c5c5768986bbe.tar.bz2
wix-61d0e33943811cc31aeeae0c8c1c5c5768986bbe.zip
Fix https://github.com/wixtoolset/issues/issues/5860 recursive loc strings.
-rw-r--r--src/WixToolset.Core/VariableResolver.cs6
-rw-r--r--src/test/WixToolsetTest.CoreIntegration/VariableResolverFixture.cs37
2 files changed, 41 insertions, 2 deletions
diff --git a/src/WixToolset.Core/VariableResolver.cs b/src/WixToolset.Core/VariableResolver.cs
index 3e0b65b3..0a7916a3 100644
--- a/src/WixToolset.Core/VariableResolver.cs
+++ b/src/WixToolset.Core/VariableResolver.cs
@@ -35,7 +35,7 @@ namespace WixToolset.Core
35 35
36 private IMessaging Messaging { get; } 36 private IMessaging Messaging { get; }
37 37
38 public int VariableCount => this.wixVariables.Count; 38 public int VariableCount => this.wixVariables.Count;
39 39
40 public void AddLocalization(Localization localization) 40 public void AddLocalization(Localization localization)
41 { 41 {
@@ -94,7 +94,7 @@ namespace WixToolset.Core
94 result.IsDefault = true; 94 result.IsDefault = true;
95 result.Value = value; 95 result.Value = value;
96 96
97 if (0 < matches.Count) 97 while (!result.DelayedResolve && matches.Count > 0)
98 { 98 {
99 var sb = new StringBuilder(value); 99 var sb = new StringBuilder(value);
100 100
@@ -203,6 +203,8 @@ namespace WixToolset.Core
203 } 203 }
204 204
205 result.Value = sb.ToString(); 205 result.Value = sb.ToString();
206 value = result.Value;
207 matches = Common.WixVariableRegex.Matches(value);
206 } 208 }
207 209
208 return result; 210 return result;
diff --git a/src/test/WixToolsetTest.CoreIntegration/VariableResolverFixture.cs b/src/test/WixToolsetTest.CoreIntegration/VariableResolverFixture.cs
new file mode 100644
index 00000000..b53842f7
--- /dev/null
+++ b/src/test/WixToolsetTest.CoreIntegration/VariableResolverFixture.cs
@@ -0,0 +1,37 @@
1
2// 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.
3
4namespace WixToolsetTest.CoreIntegration
5{
6 using System.Collections.Generic;
7 using WixToolset.Core;
8 using WixToolset.Data;
9 using WixToolset.Data.Bind;
10 using WixToolset.Extensibility.Services;
11 using Xunit;
12
13 public class VariableResolverFixture
14 {
15 [Fact]
16 public void CanRecursivelyResolveVariables()
17 {
18 var serviceProvider = new WixToolsetServiceProvider();
19 var variableResolver = serviceProvider.GetService<IVariableResolver>();
20
21 var variables = new Dictionary<string, BindVariable>()
22 {
23 { "ProductName", new BindVariable() { Id = "ProductName", Value = "Localized Product Name" } },
24 { "ProductNameEdition", new BindVariable() { Id = "ProductNameEdition", Value = "!(loc.ProductName) Enterprise Edition" } },
25 { "ProductNameEditionVersion", new BindVariable() { Id = "ProductNameEditionVersion", Value = "!(loc.ProductNameEdition) v1.2.3" } },
26 };
27
28 var localization = new Localization(0, "x-none", variables, new Dictionary<string,LocalizedControl>());
29
30 variableResolver.AddLocalization(localization);
31
32 Assert.Equal("Welcome to Localized Product Name", variableResolver.ResolveVariables(null, "Welcome to !(loc.ProductName)", false).Value);
33 Assert.Equal("Welcome to Localized Product Name Enterprise Edition", variableResolver.ResolveVariables(null, "Welcome to !(loc.ProductNameEdition)", false).Value);
34 Assert.Equal("Welcome to Localized Product Name Enterprise Edition v1.2.3", variableResolver.ResolveVariables(null, "Welcome to !(loc.ProductNameEditionVersion)", false).Value);
35 }
36 }
37}