{"record":{"id":"df964d4c90806893","repo":"dotnet/runtime","slug":"notimplementedexception-span","errorCode":null,"errorMessage":"NotImplementedException: Span","messagePattern":"NotImplementedException: Span","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mono/browser/runtime/marshal-to-cs.ts","lineNumber":421,"sourceCode":"            } else if (value instanceof Float32Array) {\n                marshal_array_to_cs_impl(arg, value, MarshalerType.Single);\n            } else if (value instanceof Float64Array) {\n                marshal_array_to_cs_impl(arg, value, MarshalerType.Double);\n            } else if (value instanceof Int32Array) {\n                marshal_array_to_cs_impl(arg, value, MarshalerType.Int32);\n            } else if (Array.isArray(value)) {\n                marshal_array_to_cs_impl(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                marshal_task_to_cs(arg, value);\n            } else if (value instanceof Span) {\n                throw new Error(\"NotImplementedException: Span\");\n            } else if (js_type == \"object\") {\n                const js_handle = mono_wasm_get_js_handle(value);\n                set_arg_type(arg, MarshalerType.JSObject);\n                if (BuildConfiguration === \"Debug\" && Object.isExtensible(value)) {\n                    value[proxy_debug_symbol] = `JS Object with JSHandle ${js_handle}`;\n                }\n                set_js_handle(arg, js_handle);\n            } else {\n                throw new Error(`JSObject proxy is not supported for ${js_type} ${value}`);\n            }\n        } else {\n            assert_not_disposed(value);\n            if (value instanceof ArraySegment) {\n                throw new Error(\"NotImplementedException: ArraySegment. \" + jsinteropDoc);\n            } else if (value instanceof ManagedError) {\n                set_arg_type(arg, MarshalerType.Exception);\n                set_gc_handle(arg, gc_handle);\n            } else if (value instanceof ManagedObject) {","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/mono/browser/runtime/marshal-to-cs.ts#L403-L439","documentation":"marshal_cs_object_to_cs throws when value instanceof Span but the C# parameter is the generic object marshaler. Span uses its own marshaler (_marshal_span_to_cs) which is selected only when the C# parameter is strongly typed as Span<T>; through the object path it is unsupported.","triggerScenarios":"Passing a JS Span object (one returned from a prior C# Span<T> call) to a C# [JSExport] parameter typed as object/JSObject rather than Span<T>.","commonSituations":"Round-tripping a Span through a generic API; passing a memory view to a loosely-typed method.","solutions":["Declare the C# parameter as the concrete Span<T> (byte, int, double, or float element).","Copy the Span into a supported array (Uint8Array/Int32Array/Float32Array/Float64Array) and pass that to an object/array-typed parameter."],"exampleFix":"// C# before\n[JSExport] public static void Take(object v) { }\n// JS: dotnet.jsExports.Take(spanFromCs); // throws\n// C# after\n[JSExport] public static void Take(Span<byte> v) { }","handlingStrategy":"type-guard","validationCode":"if (value && value instanceof Span) throw new TypeError('Pass a Span only to a C# Span<T> parameter, not object/JSObject.');","typeGuard":"function isSpan(v: unknown): boolean { return v != null && typeof v === 'object' && v instanceof Span; }","tryCatchPattern":null,"preventionTips":["Declare C# parameters that receive memory views as the concrete Span<T>.","Do not pass Span through generic object-typed APIs; copy into a supported array first.","Keep element types to byte/int/double/float."],"tags":["marshaling","interop","span"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}