{"record":{"id":"b175c6380a4a3542","repo":"dotnet/runtime","slug":"not-implemented","errorCode":null,"errorMessage":"not implemented","messagePattern":"not implemented","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/marshal-to-cs.ts","lineNumber":476,"sourceCode":"            const targetView = dotnetApi.localHeapViewU8().subarray(bufferOffset, bufferOffset + length);\n            targetView.set(value);\n        } else if (elementType == MarshalerType.Int32) {\n            dotnetAssert.check(Array.isArray(value) || value instanceof Int32Array, \"Value is not an Array or Int32Array\");\n            const bufferOffset = fixupPointer(bufferPtr, 2);\n            const targetView = dotnetApi.localHeapViewI32().subarray(bufferOffset, bufferOffset + length);\n            targetView.set(value);\n        } else if (elementType == MarshalerType.Double) {\n            dotnetAssert.check(Array.isArray(value) || value instanceof Float64Array, \"Value is not an Array or Float64Array\");\n            const bufferOffset = fixupPointer(bufferPtr, 3);\n            const targetView = dotnetApi.localHeapViewF64().subarray(bufferOffset, bufferOffset + length);\n            targetView.set(value);\n        } else if (elementType == MarshalerType.Single) {\n            dotnetAssert.check(Array.isArray(value) || value instanceof Float32Array, \"Value is not an Array or Float32Array\");\n            const bufferOffset = fixupPointer(bufferPtr, 2);\n            const targetView = dotnetApi.localHeapViewF32().subarray(bufferOffset, bufferOffset + length);\n            targetView.set(value);\n        } else {\n            throw new Error(\"not implemented\");\n        }\n        setArgIntptr(arg, bufferPtr);\n        setArgType(arg, MarshalerType.Array);\n        setArgElementType(arg, elementType);\n        setArgLength(arg, value.length);\n    }\n}\n\nfunction _marshalSpanToCs(arg: JSMarshalerArgument, value: Span, elementType?: MarshalerType): void {\n    dotnetAssert.check(!!elementType, \"Expected valid elementType parameter\");\n    dotnetAssert.check(!value.isDisposed, \"ObjectDisposedException\");\n    checkViewType(elementType, value._viewType);\n\n    setArgType(arg, MarshalerType.Span);\n    setArgIntptr(arg, value._pointer);\n    setArgLength(arg, value.length);\n}\n","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/marshal-to-cs.ts#L458-L494","documentation":"The terminal else branch of marshalArrayToCsImpl: the requested array elementType is none of String/Object/JSObject/Byte/Int32/Double/Single. The marshaler was asked to materialize an array of an element type for which no buffer-copy path exists.","triggerScenarios":"A C# signature declares an array of an unsupported element type (e.g. char[], bool[], DateTime[], an enum array, or a struct[]) routed through the generic array marshaler; or a wrong MarshalerType enum is passed due to a metadata bug.","commonSituations":"Declaring interop APIs with element types not in the supported set (Byte, Int32, Double, Single, String, Object, JSObject); version skew where a new MarshalerType value exists on one side only.","solutions":["Use a supported element type for the array (byte[], int[], double[], float[], string[], object[], JSObject[]).","For booleans/chars/enums, marshal as int or byte and convert in C#.","Rebuild both sides to ensure MarshalerType enum values agree."],"exampleFix":"// before\n[return: JSMarshalAsAttribute<JSType.Array>()] // of bool\nstatic partial bool[] GetFlags();\n\n// after\n[return: JSMarshalAsAttribute<JSType.Array<JSType.Byte>>()]\nstatic partial byte[] GetFlags();","handlingStrategy":"validation","validationCode":"const SUPPORTED_ARRAY_ELEMENT = new Set([\"Byte\",\"Int32\",\"Double\",\"Single\",\"String\",\"Object\",\"JSObject\"]);\nfunction checkArrayElement(jsType: string) {\n    if (!SUPPORTED_ARRAY_ELEMENT.has(jsType)) {\n        throw new Error(`Unsupported array element type: ${jsType}`);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restrict interop array element types to the supported set.","Box enums/bools/chars into int or byte before crossing the boundary."],"tags":["marshaling","array","interop","element-type"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}