aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2024-12-26 13:24:51 -0800
committerRob Mensching <rob@firegiant.com>2024-12-26 15:19:23 -0800
commitb1e207c28833978a902d7411daa2f4bde41bf962 (patch)
tree63b704e3281badcd0ab35471f023173973355b9c
parent95701ccca7e32aba135e497bc5887431607a4292 (diff)
downloadwix-b1e207c28833978a902d7411daa2f4bde41bf962.tar.gz
wix-b1e207c28833978a902d7411daa2f4bde41bf962.tar.bz2
wix-b1e207c28833978a902d7411daa2f4bde41bf962.zip
Fix loc and wix variables to allow dots in their identifier name again
Fixes 8713
-rw-r--r--src/wix/WixToolset.Core/Common.cs3
-rw-r--r--src/wix/test/WixToolsetTest.Core/VariableResolverFixture.cs17
2 files changed, 14 insertions, 6 deletions
diff --git a/src/wix/WixToolset.Core/Common.cs b/src/wix/WixToolset.Core/Common.cs
index bcaa25af..b1821195 100644
--- a/src/wix/WixToolset.Core/Common.cs
+++ b/src/wix/WixToolset.Core/Common.cs
@@ -765,7 +765,8 @@ namespace WixToolset.Core
765 765
766 var equalsDefaultValue = value.IndexOf('=', firstDot + 1, closeParen - firstDot); 766 var equalsDefaultValue = value.IndexOf('=', firstDot + 1, closeParen - firstDot);
767 var end = equalsDefaultValue == -1 ? closeParen : equalsDefaultValue; 767 var end = equalsDefaultValue == -1 ? closeParen : equalsDefaultValue;
768 var secondDot = value.IndexOf('.', firstDot + 1, end - firstDot); 768 // bind variables may have a second dot to define their scope, other variables do not have scope and ignore additional dots.
769 var secondDot = ns == "bind" ? value.IndexOf('.', firstDot + 1, end - firstDot) : -1;
769 770
770 if (secondDot == -1) 771 if (secondDot == -1)
771 { 772 {
diff --git a/src/wix/test/WixToolsetTest.Core/VariableResolverFixture.cs b/src/wix/test/WixToolsetTest.Core/VariableResolverFixture.cs
index 89951c2a..aeebe5cd 100644
--- a/src/wix/test/WixToolsetTest.Core/VariableResolverFixture.cs
+++ b/src/wix/test/WixToolsetTest.Core/VariableResolverFixture.cs
@@ -3,6 +3,7 @@
3namespace WixToolsetTest.Core 3namespace WixToolsetTest.Core
4{ 4{
5 using System.Collections.Generic; 5 using System.Collections.Generic;
6 using System.Linq;
6 using WixInternal.TestSupport; 7 using WixInternal.TestSupport;
7 using WixToolset.Core; 8 using WixToolset.Core;
8 using WixToolset.Data; 9 using WixToolset.Data;
@@ -18,12 +19,14 @@ namespace WixToolsetTest.Core
18 var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider(); 19 var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider();
19 var variableResolver = serviceProvider.GetService<IVariableResolver>(); 20 var variableResolver = serviceProvider.GetService<IVariableResolver>();
20 21
21 var variables = new Dictionary<string, BindVariable>() 22 var variables = new BindVariable[]
22 { 23 {
23 { "ProductName", new BindVariable() { Id = "ProductName", Value = "Localized Product Name" } }, 24 new() { Id = "ProductName", Value = "Localized Product Name" },
24 { "ProductNameEdition", new BindVariable() { Id = "ProductNameEdition", Value = "!(loc.ProductName) Enterprise Edition" } }, 25 new() { Id = "ProductNameEdition", Value = "!(loc.ProductName) Enterprise Edition" },
25 { "ProductNameEditionVersion", new BindVariable() { Id = "ProductNameEditionVersion", Value = "!(loc.ProductNameEdition) v1.2.3" } }, 26 new() { Id = "ProductNameEditionVersion", Value = "!(loc.ProductNameEdition) v1.2.3" },
26 }; 27 new() { Id = "Dotted.Loc.Variable", Value = "Dotted.Loc.Variable = !(loc.ProductNameEditionVersion)" },
28 new() { Id = "NestedDotted.Loc.Variable", Value = "!(loc.Dotted.Loc.Variable) worked" },
29 }.ToDictionary(b => b.Id);
27 30
28 var localization = new Localization(0, null, "x-none", variables, new Dictionary<string, LocalizedControl>()); 31 var localization = new Localization(0, null, "x-none", variables, new Dictionary<string, LocalizedControl>());
29 32
@@ -45,6 +48,10 @@ namespace WixToolsetTest.Core
45 WixAssert.StringEqual("Welcome to Localized Product Name Enterprise Edition v1.2.3", result.Value); 48 WixAssert.StringEqual("Welcome to Localized Product Name Enterprise Edition v1.2.3", result.Value);
46 Assert.True(result.UpdatedValue); 49 Assert.True(result.UpdatedValue);
47 50
51 result = variableResolver.ResolveVariables(null, "start !(loc.NestedDotted.Loc.Variable) end");
52 WixAssert.StringEqual("start Dotted.Loc.Variable = Localized Product Name Enterprise Edition v1.2.3 worked end", result.Value);
53 Assert.True(result.UpdatedValue);
54
48 result = variableResolver.ResolveVariables(null, "Welcome to !(bind.property.ProductVersion)"); 55 result = variableResolver.ResolveVariables(null, "Welcome to !(bind.property.ProductVersion)");
49 WixAssert.StringEqual("Welcome to !(bind.property.ProductVersion)", result.Value); 56 WixAssert.StringEqual("Welcome to !(bind.property.ProductVersion)", result.Value);
50 Assert.False(result.UpdatedValue); 57 Assert.False(result.UpdatedValue);