fix(scripting): #1063 one compile-refusal authority for editor and deploy gate (ScriptCompileRules + the runtime's own wrapper text) — CS0161 and wrapper injection are now flagged in the editor; #1065 {{equip}} in a Calculation script is refused by the gate and by a new Calculation editor mode
#1063: the Monaco diagnostics dropped every Roslyn error located in the synthesized wrapper as 'phantom', so CS0161 (not all code paths return a value, pinned on Run) passed the editor and failed the deploy gate. ScriptCompileRules (Core.Scripting) now states which diagnostics refuse (every Error, wherever located; LMX001/002 injection) and which sources skip the compile (blank/passthrough value scripts); ScriptEvaluator and the editor both use it, and the editor wraps with ScriptEvaluator.WrapperPreamble/ WrapperSuffix instead of its own copy. Wrapper-located refusals are drawn on the script's last line. EditorGateParityTests runs one corpus through editor and gate in all three modes. #1065: a Calculation tag is raw/device-level with no equipment and its seam never substitutes {{equip}}, so such a script deployed clean and read Bad forever. Refused rather than substituted: EquipTokenLiteralScanner.FindInCalculation is run by RoslynDeployScriptChecker for every Calculation use (before the passthrough shortcut, outside the shared VT/Calc cache) and by the editor in the new 'calculation' mode (Calculation tag editor; ScriptEdit defaults to it when a Calculation tag uses the script).
This commit is contained in:
+20
@@ -211,6 +211,26 @@ public sealed class AdminOperationsActorScriptCompileGateTests : ControlPlaneAct
|
||||
reply.Message.ShouldContain("Calculation tag 'tag-calc' (plant/calc/cdev/sum)");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// lmxopcua#1065: a Calculation tag has no equipment, and the Calculation seam never substitutes <c>{{equip}}</c>,
|
||||
/// so a Calculation script carrying it used to deploy clean and read <c>{{equip}}/speed</c> literally — Bad forever.
|
||||
/// The gate now refuses it (the passthrough shape too, which never reaches Roslyn), naming the Calculation tag;
|
||||
/// the VirtualTag in the same draft uses the token legitimately (positive control: it is not named).
|
||||
/// </summary>
|
||||
[Theory]
|
||||
[InlineData("return ctx.GetTag(\"{{equip}}/speed\").Value;")]
|
||||
[InlineData("return Convert.ToDouble(ctx.GetTag(\"{{equip}}/speed\").Value ?? 0.0) + 1;")]
|
||||
public void An_equip_token_in_a_calculation_script_is_refused_naming_the_calculation_tag(string calcSource)
|
||||
{
|
||||
var reply = Deploy(SeedDraft(new Seed(CalcSource: calcSource)), new RoslynDeployScriptChecker(), expectDispatch: false);
|
||||
reply.Outcome.ShouldBe(StartDeploymentOutcome.Rejected);
|
||||
reply.Message.ShouldNotBeNull();
|
||||
reply.Message.ShouldContain("script 's-calc' does not compile as a Calculation script");
|
||||
reply.Message.ShouldContain("Calculation tag 'tag-calc' (plant/calc/cdev/sum)");
|
||||
reply.Message.ShouldContain("equip token in a Calculation script");
|
||||
reply.Message.ShouldNotContain("script 's-vt'");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Disabled_users_are_not_checked_they_never_compile_at_runtime()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user