{"record":{"id":"4bbcfea10656568f","repo":"stride3d/stride","slug":"heightstickarray","errorCode":null,"errorMessage":"heightStickArray","messagePattern":"heightStickArray","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Physics/ByteHeightStickArraySource.cs","lineNumber":47,"sourceCode":"        /// </summary>\n        [DataMember(30)]\n        [NotNull]\n        [Display(\"HeightScale\", Expand = ExpandRule.Always)]\n        public IHeightScaleCalculator HeightScaleCalculator { get; set; } = new HeightScaleCalculator();\n\n        /// <summary>\n        /// The value to fill the height stick array.\n        /// </summary>\n        [DataMember(40)]\n        [DataMemberRange(0, 255, 1, 10, 0)]\n        public byte InitialByte { get; set; } = 0;\n\n        public bool IsValid() => HeightmapUtils.CheckHeightParameters(HeightStickSize, HeightType, HeightRange, HeightScale, false) &&\n            MathUtil.IsInRange(InitialByte, byte.MinValue, byte.MaxValue);\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<byte> unmanagedArray)\n            {\n                unmanagedArray.Fill(InitialByte, 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 ByteHeightStickArraySource;\n\n            if (other == null)\n            {\n                return false;\n            }","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Physics/ByteHeightStickArraySource.cs#L29-L65","documentation":"ByteHeightStickArraySource.CopyTo throws ArgumentNullException when the destination UnmanagedArray 'heightStickArray' is null. This source represents a heightfield fully filled with a constant byte value and needs a valid destination buffer to fill.","triggerScenarios":"Calling CopyTo with a null destination when setting up a heightfield collider from a ByteHeightStickArraySource (e.g. heightfield buffer not yet allocated).","commonSituations":"Heightfield collider construction where the UnmanagedArray was created lazily and copy is invoked first.","solutions":["Allocate the destination UnmanagedArray before calling CopyTo","Check for null before invoking CopyTo"],"exampleFix":"// before\nsource.CopyTo(heightStickArray, 0);\n// after\nheightStickArray ??= new UnmanagedArray<byte>(size.X * size.Y);\nsource.CopyTo(heightStickArray, 0);","handlingStrategy":"validation","validationCode":"if (heightStickArray != null)\n    byteSource.CopyTo(heightStickArray, index);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Allocate the unmanaged heightfield buffer before copying","Initialize heightfield collider data in a fixed order","Null-check lazily created buffers"],"tags":["physics","heightfield","null-argument"],"backgroundTag":"null-argument","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"}