{"record":{"id":"a873865c21f42820","repo":"stride3d/stride","slug":"typeof-unmanagedarray-t-type-is-not-supported-a87386","errorCode":null,"errorMessage":"{ typeof(UnmanagedArray<T>) } type is not supported.","messagePattern":"(.+?) type is not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Physics/FloatHeightStickArraySource.cs","lineNumber":44,"sourceCode":"        /// <summary>\n        /// The value to fill the height stick array.\n        /// </summary>\n        [DataMember(30)]\n        public float InitialHeight { get; set; } = 0;\n\n        public bool IsValid() => HeightmapUtils.CheckHeightParameters(HeightStickSize, HeightType, HeightRange, HeightScale, false) &&\n            MathUtil.IsInRange(InitialHeight, HeightRange.X, HeightRange.Y);\n\n        public void CopyTo<T>(UnmanagedArray<T> heightStickArray, int index) where T : struct\n        {\n            if (heightStickArray == null) throw new ArgumentNullException(nameof(heightStickArray));\n            if (heightStickArray is UnmanagedArray<float> unmanagedArray)\n            {\n                unmanagedArray.Fill(InitialHeight, index, HeightStickSize.X * HeightStickSize.Y);\n            }\n            else\n            {\n                throw new NotSupportedException($\"{ typeof(UnmanagedArray<T>) } type is not supported.\");\n            }\n        }\n\n        public bool Match(object obj)\n        {\n            var other = obj as FloatHeightStickArraySource;\n\n            if (other == null)\n            {\n                return false;\n            }\n\n            return other.HeightStickSize == HeightStickSize &&\n                other.HeightRange == HeightRange &&\n                Math.Abs(other.InitialHeight - InitialHeight) < float.Epsilon;\n        }\n    }\n}","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Physics/FloatHeightStickArraySource.cs#L26-L62","documentation":"FloatHeightStickArraySource.CopyTo only supports filling UnmanagedArray<float> buffers; it fills with the InitialHeight float. Passing any other element type T throws NotSupportedException naming the unsupported UnmanagedArray<T> type.","triggerScenarios":"Calling FloatHeightStickArraySource.CopyTo with an UnmanagedArray<short>, UnmanagedArray<byte>, or any non-float element type.","commonSituations":"Mixing up heightstick sources: short/byte heightstick arrays are meant to be populated from ShortsHeightStickArraySource/BytesHeightStickArraySource, not the float variant; refactoring changed the array element type.","solutions":["Pass an UnmanagedArray<float> to FloatHeightStickArraySource.CopyTo.","Use the correct heightstick source type (short/byte variants) if your heightfield uses quantized heights.","Convert the destination buffer to UnmanagedArray<float> before copying."],"exampleFix":"// before\nUnmanagedArray<short> heights = ...;\nfloatSource.CopyTo(heights, 0); // throws\n// after\nUnmanagedArray<float> heights = new UnmanagedArray<float>(width * height);\nfloatSource.CopyTo(heights, 0);","handlingStrategy":"type-guard","validationCode":"if (heightStickArray is UnmanagedArray<float>)\n    source.CopyTo(heightStickArray, 0);","typeGuard":"static bool IsFloatHeightArray<T>(UnmanagedArray<T> a) where T : struct => a is UnmanagedArray<float>;","tryCatchPattern":"try { source.CopyTo(heightStickArray, 0); }\ncatch (NotSupportedException) { /* use the short/byte heightstick source instead */ }","preventionTips":["Use FloatHeightStickArraySource only with UnmanagedArray<float>","Match source type to the heightfield's HeightType","Centralize heightstick buffer creation in one typed helper"],"tags":["physics","heightfield","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}