fix(central-ui): mirror WaitForAttribute on inbound-script analysis RouteTarget
Add WaitForAttribute(attributeName, targetValue, timeout, cancellationToken)
to InboundScriptHost.RouteTarget and SandboxInboundScriptHost.RouteTarget,
mirroring the shipped runtime signature in RouteHelper. Eliminates the false
CS error the editor raised against valid Route.To("X").WaitForAttribute(...)
calls in inbound API method scripts. Test asserts the call diagnoses clean
under ScriptKind.InboundApi.
This commit is contained in:
@@ -98,5 +98,21 @@ public class InboundScriptHost
|
||||
IReadOnlyDictionary<string, string> attributeValues,
|
||||
System.Threading.CancellationToken cancellationToken = default) =>
|
||||
System.Threading.Tasks.Task.CompletedTask;
|
||||
|
||||
/// <summary>
|
||||
/// Waits until a named attribute on the target instance reaches the specified value,
|
||||
/// or until the timeout elapses.
|
||||
/// </summary>
|
||||
/// <param name="attributeName">The name of the attribute to watch.</param>
|
||||
/// <param name="targetValue">The value to wait for.</param>
|
||||
/// <param name="timeout">Maximum time to wait before returning false.</param>
|
||||
/// <param name="cancellationToken">Cancellation token.</param>
|
||||
/// <returns>A task that resolves to true if the attribute reached the target value within the timeout, false otherwise.</returns>
|
||||
public System.Threading.Tasks.Task<bool> WaitForAttribute(
|
||||
string attributeName,
|
||||
object? targetValue,
|
||||
System.TimeSpan timeout,
|
||||
System.Threading.CancellationToken cancellationToken = default) =>
|
||||
System.Threading.Tasks.Task.FromResult(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,21 @@ public class SandboxInboundScriptHost
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw Unavailable("SetAttributes(...)");
|
||||
|
||||
/// <summary>
|
||||
/// Always throws <see cref="ScriptSandboxException"/>; cross-site routing is unavailable in a Test Run.
|
||||
/// </summary>
|
||||
/// <param name="attributeName">Attribute name (included in the exception message).</param>
|
||||
/// <param name="targetValue">Unused target value.</param>
|
||||
/// <param name="timeout">Unused timeout.</param>
|
||||
/// <param name="cancellationToken">Unused token.</param>
|
||||
/// <returns>Never returns; always throws <see cref="ScriptSandboxException"/>.</returns>
|
||||
public Task<bool> WaitForAttribute(
|
||||
string attributeName,
|
||||
object? targetValue,
|
||||
TimeSpan timeout,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw Unavailable($"WaitForAttribute(\"{attributeName}\")");
|
||||
|
||||
private ScriptSandboxException Unavailable(string operation) =>
|
||||
new($"Route.To(\"{_instanceCode}\").{operation} is not available in Test Run — " +
|
||||
"cross-site routing needs a deployed site reachable over the cluster transport.");
|
||||
|
||||
Reference in New Issue
Block a user