From b1e207c28833978a902d7411daa2f4bde41bf962 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 26 Dec 2024 13:24:51 -0800 Subject: Fix loc and wix variables to allow dots in their identifier name again Fixes 8713 --- src/wix/WixToolset.Core/Common.cs | 3 ++- .../test/WixToolsetTest.Core/VariableResolverFixture.cs | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src') 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 var equalsDefaultValue = value.IndexOf('=', firstDot + 1, closeParen - firstDot); var end = equalsDefaultValue == -1 ? closeParen : equalsDefaultValue; - var secondDot = value.IndexOf('.', firstDot + 1, end - firstDot); + // bind variables may have a second dot to define their scope, other variables do not have scope and ignore additional dots. + var secondDot = ns == "bind" ? value.IndexOf('.', firstDot + 1, end - firstDot) : -1; if (secondDot == -1) { 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 @@ namespace WixToolsetTest.Core { using System.Collections.Generic; + using System.Linq; using WixInternal.TestSupport; using WixToolset.Core; using WixToolset.Data; @@ -18,12 +19,14 @@ namespace WixToolsetTest.Core var serviceProvider = WixToolsetServiceProviderFactory.CreateServiceProvider(); var variableResolver = serviceProvider.GetService(); - var variables = new Dictionary() + var variables = new BindVariable[] { - { "ProductName", new BindVariable() { Id = "ProductName", Value = "Localized Product Name" } }, - { "ProductNameEdition", new BindVariable() { Id = "ProductNameEdition", Value = "!(loc.ProductName) Enterprise Edition" } }, - { "ProductNameEditionVersion", new BindVariable() { Id = "ProductNameEditionVersion", Value = "!(loc.ProductNameEdition) v1.2.3" } }, - }; + new() { Id = "ProductName", Value = "Localized Product Name" }, + new() { Id = "ProductNameEdition", Value = "!(loc.ProductName) Enterprise Edition" }, + new() { Id = "ProductNameEditionVersion", Value = "!(loc.ProductNameEdition) v1.2.3" }, + new() { Id = "Dotted.Loc.Variable", Value = "Dotted.Loc.Variable = !(loc.ProductNameEditionVersion)" }, + new() { Id = "NestedDotted.Loc.Variable", Value = "!(loc.Dotted.Loc.Variable) worked" }, + }.ToDictionary(b => b.Id); var localization = new Localization(0, null, "x-none", variables, new Dictionary()); @@ -45,6 +48,10 @@ namespace WixToolsetTest.Core WixAssert.StringEqual("Welcome to Localized Product Name Enterprise Edition v1.2.3", result.Value); Assert.True(result.UpdatedValue); + result = variableResolver.ResolveVariables(null, "start !(loc.NestedDotted.Loc.Variable) end"); + WixAssert.StringEqual("start Dotted.Loc.Variable = Localized Product Name Enterprise Edition v1.2.3 worked end", result.Value); + Assert.True(result.UpdatedValue); + result = variableResolver.ResolveVariables(null, "Welcome to !(bind.property.ProductVersion)"); WixAssert.StringEqual("Welcome to !(bind.property.ProductVersion)", result.Value); Assert.False(result.UpdatedValue); -- cgit v1.2.3-55-g6feb