{"record":{"id":"c34f52c1122bd503","repo":"dotnet/runtime","slug":"notimplementedexception-typedarray-c34f52","errorCode":null,"errorMessage":"NotImplementedException: TypedArray","messagePattern":"NotImplementedException: TypedArray","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/marshal-to-cs.ts","lineNumber":388,"sourceCode":"            } else if (value instanceof Error) {\n                marshalExceptionToCs(arg, value);\n            } else if (value instanceof Uint8Array) {\n                marshalArrayToCsImpl(arg, value, MarshalerType.Byte);\n            } 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);","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/marshal-to-cs.ts#L370-L406","documentation":"Thrown by marshalCsObjectToCs for typed arrays that the generic object marshaler explicitly does not support: Int8Array, Int16Array, Uint8ClampedArray, Uint16Array, and Uint32Array. Only Uint8Array, Float32Array, Float32Array, Float64Array, and Int32Array are accepted there; the unsupported views intentionally throw rather than silently coerce.","triggerScenarios":"Passing an Int16Array/Uint16Array/Uint32Array/Int8Array/Uint8ClampedArray as an `object` argument to a C# interop method, or returning one from a JS function imported with object marshaling.","commonSituations":"Working with Web Audio or canvas pixel data (Uint16Array/Uint32Array) and forwarding buffers straight to C#; porting code that used these arrays on the JS side without remapping to the supported set.","solutions":["Remap the buffer to a supported view: new Uint8Array(otherArray.buffer) for byte data, new Int32Array(...) for 32-bit, etc.","Change the C# signature to use Span<byte>/byte[] or the matching supported element type.","For 16-bit data, expand to Int32Array or pack into Uint8Array and reinterpret in C#."],"exampleFix":"// before\nconst data = new Uint16Array(...);\ninterop.ProcessObject(data); // C# object param\n\n// after\nconst data = new Uint8Array(raw.buffer);\ninterop.ProcessBytes(data); // C# byte[] / Span<byte>","handlingStrategy":"validation","validationCode":"const SUPPORTED_VIEWS = [Uint8Array, Int32Array, Float32Array, Float64Array];\nfunction asCsObject(value: unknown): unknown {\n    if (ArrayBuffer.isView(value) && !SUPPORTED_VIEWS.some(t => value instanceof t)) {\n        const v = value as TypedArray;\n        return new Uint8Array(v.buffer, v.byteOffset, v.byteLength); // remap to byte view\n    }\n    return value;\n}","typeGuard":"const isSupportedTypedArray = (v: unknown): boolean =>\n    v instanceof Uint8Array || v instanceof Int32Array ||\n    v instanceof Float32Array || v instanceof Float64Array;","tryCatchPattern":null,"preventionTips":["Standardize on Uint8Array/Int32Array/Float32Array/Float64Array at the JS↔C# boundary.","Add a lint rule or wrapper that rejects Int8Array/Int16Array/Uint16Array/Uint32Array/Uint8ClampedArray for interop."],"tags":["marshaling","typedarray","interop","type-mismatch"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}