fix(scripting): #1109 byte[][] stays refused with a ByteString-specific reason
A script result has no ByteString-array form (its only byte shape is one flat Byte array) and the worker wire has no ByteString or nested-array tag, so byte[][] is left refused with every other jagged array (no new wire tag). Its reason now says it is not an array of ByteStrings and offers both forms that publish: a flat byte[] (SelectMany) or a string[] of Base64 blobs. Pinned by ScriptResultMaterializerTests.
This commit is contained in:
@@ -128,6 +128,18 @@ public static class ScriptResultMaterializer
|
||||
private static void EnsurePublishable(Type type)
|
||||
{
|
||||
if (IsPublishable(type)) return;
|
||||
// lmxopcua#1109: byte[][] reads like "an array of ByteStrings", which OPC UA does have (the OpcUaClient driver even
|
||||
// surfaces a ByteString[] as byte[][]). But a script result has no ByteString-array form: the result rule's only
|
||||
// byte shape is a one-dimensional Byte array, and the out-of-process wire (VariantCodec) has no ByteString or
|
||||
// nested-array tag — adding one is deliberately out of scope. So byte[][] stays refused with every other jagged
|
||||
// array; the reason just says so explicitly and offers the string[] form, which does publish.
|
||||
if (type == typeof(byte[][]))
|
||||
throw new ScriptResultException(
|
||||
"The script returned a value of type 'Byte[][]', which an OPC UA node cannot carry: an array of arrays has " +
|
||||
"no representation on a node whose DataType is a scalar type, and a script result cannot be an array of " +
|
||||
"ByteStrings either (its only byte shape is one flat Byte array); return one flat byte[] " +
|
||||
"(e.g. a.SelectMany(x => x).ToArray()) or a string[] of encoded blobs " +
|
||||
"(e.g. a.Select(Convert.ToBase64String).ToArray()).");
|
||||
if (type.IsArray && type.GetElementType()!.IsArray)
|
||||
throw new ScriptResultException(
|
||||
$"The script returned a value of type '{Describe(type)}', which an OPC UA node cannot carry: an array of " +
|
||||
|
||||
Reference in New Issue
Block a user