{"record":{"id":"2730c3e70026a511","repo":"dotnet/runtime","slug":"notimplementedexception-span-2730c3","errorCode":null,"errorMessage":"NotImplementedException: Span","messagePattern":"NotImplementedException: Span","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/marshal-to-cs.ts","lineNumber":392,"sourceCode":"            } else if (value instanceof Float64Array) {\n                marshalArrayToCsImpl(arg, value, MarshalerType.Double);\n            } else if (value instanceof Float32Array) {\n                marshalArrayToCsImpl(arg, value, MarshalerType.Single);\n            } else if (value instanceof Int32Array) {\n                marshalArrayToCsImpl(arg, value, MarshalerType.Int32);\n            } else if (Array.isArray(value)) {\n                marshalArrayToCsImpl(arg, value, MarshalerType.Object);\n            } else if (value instanceof Int16Array\n                || value instanceof Int8Array\n                || value instanceof Uint8ClampedArray\n                || value instanceof Uint16Array\n                || value instanceof Uint32Array\n            ) {\n                throw new Error(\"NotImplementedException: TypedArray\");\n            } else if (isThenable(value)) {\n                marshalTaskToCs(arg, value);\n            } else if (value instanceof Span) {\n                throw new Error(\"NotImplementedException: Span\");\n            } else if (jsType == \"object\") {\n                const jsHandle = getJsHandleFromJSObject(value);\n                setArgType(arg, MarshalerType.JSObject);\n                if (BuildConfiguration === \"Debug\" && Object.isExtensible(value)) {\n                    value[proxyDebugSymbol] = `JS Object with JSHandle ${jsHandle}`;\n                }\n                setJsHandle(arg, jsHandle);\n            } else {\n                throw new Error(`JSObject proxy is not supported for ${jsType} ${value}`);\n            }\n        } else {\n            assertNotDisposed(value);\n            if (value instanceof ArraySegment) {\n                throw new Error(\"NotImplementedException: ArraySegment. \" + jsinteropDoc);\n            } else if (value instanceof ManagedError) {\n                setArgType(arg, MarshalerType.Exception);\n                setGcHandle(arg, gcHandle);\n            } else if (value instanceof ManagedObject) {","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/marshal-to-cs.ts#L374-L410","documentation":"Thrown by marshalCsObjectToCs when the value is an instance of the runtime's internal Span type while being marshaled through the generic object marshaler. Span instances are designed for round-trip only (created by C# and returned to JS), not for ad-hoc construction and passing back as object.","triggerScenarios":"A JS function imported into C# with an `object` return/parameter type returns or receives a Span<T> object that the runtime created earlier, but the parameter is declared as plain object instead of Span<T>.","commonSituations":"Holding a Span<T> returned from one C# call and passing it into another C# method whose signature uses `object` instead of `Span<T>`/`Span<byte>`.","solutions":["Declare the C# parameter/return as Span<T> (e.g. Span<byte>) so the dedicated span marshaler is selected.","Copy the span contents into a supported array (span.slice() / copyTo) and pass the array through the object marshaler."],"exampleFix":"// before\nstatic partial void Process(object value); // passing a Span<byte>\n\n// after\nstatic partial void Process(Span<byte> value);","handlingStrategy":"validation","validationCode":"// Don't push a Span through the object marshaler\nfunction prepare(value: unknown): unknown {\n    if (value && typeof value === \"object\" && \"slice\" in value && \"_pointer\" in value) {\n        // it's a runtime Span<T>; copy out instead\n        return (value as any).slice();\n    }\n    return value;\n}","typeGuard":"const isSpanLike = (v: unknown): boolean =>\n    !!v && typeof v === \"object\" &&\n    \"_pointer\" in (v as any) && typeof (v as any).slice === \"function\";","tryCatchPattern":null,"preventionTips":["Declare C# parameters as Span<T> rather than object when spans are expected.","Document which interop APIs return Span/ArraySegment so callers pass them correctly."],"tags":["marshaling","span","interop","type-mismatch"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}