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:
+29
@@ -63,5 +63,34 @@ public sealed class ScriptUsageClassifyTests
|
||||
}));
|
||||
u.UsedAsValue.ShouldBeTrue();
|
||||
u.UsedAsPredicate.ShouldBeFalse();
|
||||
// #1065: a Calculation use opens the editor in Calculation mode ({{equip}} refused, as the deploy gate does).
|
||||
u.UsedAsCalculation.ShouldBeTrue();
|
||||
u.DefaultMode.ShouldBe(ScriptAnalysisModes.Calculation);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task A_script_shared_by_a_virtual_tag_and_a_calculation_tag_opens_in_calculation_mode()
|
||||
{
|
||||
// Calculation mode is the value shape plus the one Calculation-only refusal, so it shows every refusal either
|
||||
// value use can meet; value mode would hide the {{equip}} refusal of the Calculation use.
|
||||
var u = await Classify(db =>
|
||||
{
|
||||
db.VirtualTags.Add(new VirtualTag { VirtualTagId = "vt-1", EquipmentId = "eq", Name = "v", DataType = "Double", ScriptId = "s-1" });
|
||||
db.Tags.Add(new Tag
|
||||
{
|
||||
TagId = "t-1", DeviceId = "d", Name = "calc", DataType = "Double", AccessLevel = ZB.MOM.WW.OtOpcUa.Configuration.Enums.TagAccessLevel.Read, TagConfig = "{\"scriptId\":\"s-1\"}",
|
||||
});
|
||||
});
|
||||
u.UsedAsCalculation.ShouldBeTrue();
|
||||
u.DefaultMode.ShouldBe(ScriptAnalysisModes.Calculation);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task A_virtual_tag_only_script_is_not_a_calculation_script()
|
||||
{
|
||||
var u = await Classify(db =>
|
||||
db.VirtualTags.Add(new VirtualTag { VirtualTagId = "vt-1", EquipmentId = "eq", Name = "v", DataType = "Double", ScriptId = "s-1" }));
|
||||
u.UsedAsCalculation.ShouldBeFalse();
|
||||
u.DefaultMode.ShouldBe(ScriptAnalysisModes.Value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user