harden(vtag): exclude backslash from passthrough capture + parity tests (A review)
This commit is contained in:
@@ -76,4 +76,26 @@ public sealed class PassthroughScriptTests
|
||||
PassthroughScript.TryMatch(source, out var tag).ShouldBeFalse();
|
||||
tag.ShouldBe(string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A tag literal containing a backslash escape (C# source <c>"a\\b"</c> → runtime name
|
||||
/// <c>a\b</c>) does NOT match the passthrough pattern — it falls through to Roslyn, which
|
||||
/// interprets the escape and resolves the correct dependency key. Capturing the raw source
|
||||
/// text <c>a\\b</c> would produce a wrong-result silent miss against the key <c>a\b</c>.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void Rejects_tag_literal_containing_backslash_escape()
|
||||
{
|
||||
// C# literal "return ctx.GetTag(\"a\\\\b\").Value;" → script source contains: a\\b (two chars: backslash + b)
|
||||
PassthroughScript.TryMatch("return ctx.GetTag(\"a\\\\b\").Value;", out var tag).ShouldBeFalse();
|
||||
tag.ShouldBe(string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>A plain dotted tag name (no backslash) still matches — the fix is additive only.</summary>
|
||||
[Fact]
|
||||
public void Matches_plain_dotted_tag_after_backslash_fix()
|
||||
{
|
||||
PassthroughScript.TryMatch("return ctx.GetTag(\"Site1.Area.Tag\").Value;", out var tag).ShouldBeTrue();
|
||||
tag.ShouldBe("Site1.Area.Tag");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user