diff --git a/src/ThisAssembly.Constants/ConstantsGenerator.cs b/src/ThisAssembly.Constants/ConstantsGenerator.cs index c09da1c6..107f812b 100644 --- a/src/ThisAssembly.Constants/ConstantsGenerator.cs +++ b/src/ThisAssembly.Constants/ConstantsGenerator.cs @@ -25,6 +25,11 @@ public void Initialize(IncrementalGeneratorInitializationContext context) x.Right.GetOptions(x.Left).TryGetValue("build_metadata.Constant.Value", out var value); x.Right.GetOptions(x.Left).TryGetValue("build_metadata.Constant.Comment", out var comment); x.Right.GetOptions(x.Left).TryGetValue("build_metadata.Constant.Root", out var root); + + // Revert auto-escaping due to https://github.com/dotnet/roslyn/issues/51692 + if (value != null && value.StartsWith("|") && value.EndsWith("|")) + value = value[1..^1].Replace('|', ';'); + return ( name: Path.GetFileName(x.Left.Path), value: value!, diff --git a/src/ThisAssembly.Constants/ThisAssembly.Constants.targets b/src/ThisAssembly.Constants/ThisAssembly.Constants.targets index 91958a41..329a601e 100644 --- a/src/ThisAssembly.Constants/ThisAssembly.Constants.targets +++ b/src/ThisAssembly.Constants/ThisAssembly.Constants.targets @@ -44,7 +44,12 @@ BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun" DependsOnTargets="PrepareResourceNames;PrepareConstants"> - + + + |$([MSBuild]::ValueOrdefault('%(Constant.Value)', '').Replace(';', '|'))| + + + diff --git a/src/ThisAssembly.Tests/Tests.cs b/src/ThisAssembly.Tests/Tests.cs index 91c31dc9..f2376293 100644 --- a/src/ThisAssembly.Tests/Tests.cs +++ b/src/ThisAssembly.Tests/Tests.cs @@ -102,4 +102,8 @@ public void CanUseGitBranchConstants() Assert.NotEmpty(ThisAssembly.Git.Branch); Output.WriteLine(ThisAssembly.Git.Branch); } + + [Fact] + public void CanUseSemicolonsInConstant() + => Assert.Equal("A;B;C", ThisAssembly.Constants.WithSemiColon); } diff --git a/src/ThisAssembly.Tests/ThisAssembly.Tests.csproj b/src/ThisAssembly.Tests/ThisAssembly.Tests.csproj index b51b9cab..ef198a21 100644 --- a/src/ThisAssembly.Tests/ThisAssembly.Tests.csproj +++ b/src/ThisAssembly.Tests/ThisAssembly.Tests.csproj @@ -66,6 +66,7 @@ + Included/%(Filename)%(Extension)