feat(vtag): passthrough fast-path skips Roslyn for mirror scripts (A)

This commit is contained in:
Joseph Doherty
2026-06-07 15:26:20 -04:00
parent 3834400f05
commit 08d7477860
5 changed files with 256 additions and 3 deletions
@@ -50,6 +50,18 @@ public sealed class RoslynVirtualTagEvaluator : IVirtualTagEvaluator, IDisposabl
if (_disposed) return VirtualTagEvalResult.Failure("evaluator disposed");
if (string.IsNullOrWhiteSpace(expression)) return VirtualTagEvalResult.Failure("empty expression");
// A — passthrough fast-path: the mirror shape `return ctx.GetTag("X").Value;` needs no
// Roslyn. Narrow exact pattern; near-misses fall through to the compiled path below.
// Semantics are byte-identical to the compiled mirror: a present dependency returns its
// value (Ok), and an absent one makes GetTag yield a Bad snapshot whose .Value is null,
// so the script returns null — Ok(null) here too.
if (PassthroughScript.TryMatch(expression, out var passthroughRef))
{
return dependencies.TryGetValue(passthroughRef, out var ptValue)
? VirtualTagEvalResult.Ok(ptValue)
: VirtualTagEvalResult.Ok(null);
}
ScriptEvaluator<VirtualTagContext, object?> evaluator;
try
{