fix(centralui): diagnose cache keyed on editor context; surface blocking-wait advisory as Monaco warning (review 2026-10-21 07/C-1, lane F)
This commit is contained in:
+47
@@ -201,6 +201,53 @@ public class ScriptAnalysisServiceTests
|
||||
Assert.DoesNotContain(resp.Markers, m => m.Code == "SCADA003");
|
||||
}
|
||||
|
||||
/// <summary>Review 2026-10-21 07/C-1: identical code with a changed declared-parameter set must not be served the stale cached marker.</summary>
|
||||
[Fact]
|
||||
public void Diagnose_CacheKey_IncludesDeclaredParameters()
|
||||
{
|
||||
const string code = "var x = Parameters[\"x\"];";
|
||||
var before = _svc.Diagnose(new DiagnoseRequest(code, DeclaredParameters: new[] { "name" }));
|
||||
var after = _svc.Diagnose(new DiagnoseRequest(code, DeclaredParameters: new[] { "name", "x" }));
|
||||
|
||||
Assert.Contains(before.Markers, m => m.Code == "SCADA003");
|
||||
Assert.DoesNotContain(after.Markers, m => m.Code == "SCADA003");
|
||||
}
|
||||
|
||||
/// <summary>Review 2026-10-21 07/C-1: byte-identical scripts on templates with different attribute sets do not share an answer.</summary>
|
||||
[Fact]
|
||||
public void Diagnose_CacheKey_IncludesSelfAttributes()
|
||||
{
|
||||
const string code = "var v = Attributes[\"Speed\"];";
|
||||
var without = _svc.Diagnose(new DiagnoseRequest(code, SelfAttributes: new[] { new AttributeShape("Other", "String") }));
|
||||
var with = _svc.Diagnose(new DiagnoseRequest(code, SelfAttributes: new[] { new AttributeShape("Speed", "Double") }));
|
||||
|
||||
Assert.NotEqual(
|
||||
without.Markers.Select(m => m.Message).ToList(),
|
||||
with.Markers.Select(m => m.Message).ToList());
|
||||
}
|
||||
|
||||
/// <summary>Lane F follow-up: a blocking Task wait surfaces as a Monaco warning marker on its line.</summary>
|
||||
[Fact]
|
||||
public void BlockingWait_ReportsWarningMarkerOnItsLine()
|
||||
{
|
||||
var resp = _svc.Diagnose(new DiagnoseRequest(
|
||||
"var t = System.Threading.Tasks.Task.FromResult(1);\nvar r = t.Result;\nreturn r;"));
|
||||
|
||||
var marker = Assert.Single(resp.Markers, m => m.Code == "SCADA_BLOCKING_WAIT");
|
||||
Assert.Equal(4, marker.Severity);
|
||||
Assert.Equal(2, marker.StartLineNumber);
|
||||
Assert.Contains(".Result", marker.Message);
|
||||
}
|
||||
|
||||
/// <summary>A script that only awaits gets no blocking-wait marker.</summary>
|
||||
[Fact]
|
||||
public void AwaitedTask_NoBlockingWaitMarker()
|
||||
{
|
||||
var resp = _svc.Diagnose(new DiagnoseRequest(
|
||||
"var t = System.Threading.Tasks.Task.FromResult(1);\nreturn await t;"));
|
||||
Assert.DoesNotContain(resp.Markers, m => m.Code == "SCADA_BLOCKING_WAIT");
|
||||
}
|
||||
|
||||
// ── Completions ───────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Verifies that completion inside a Parameters string literal returns the declared parameter names.</summary>
|
||||
|
||||
Reference in New Issue
Block a user