{"record":{"id":"b5f2f9a5eed8f800","repo":"stride3d/stride","slug":"nameof-heightrange-nameof-heightrange-y-should-be-greater","errorCode":null,"errorMessage":"{ nameof(heightRange) }.{ nameof(heightRange.Y) } should be greater than { nameof(heightRange.X) }.","messagePattern":"(.+?)\\.(.+?) should be greater than (.+?)\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Physics/Engine/HeightmapUtils.cs","lineNumber":38,"sourceCode":"                }\n\n                // HeightScale\n\n                if (MathUtil.IsZero(heightScale))\n                {\n                    throw new ArgumentException($\"{ nameof(heightScale) } is 0.\");\n                }\n\n                if ((heightType == HeightfieldTypes.Float) && !MathUtil.IsOne(heightScale))\n                {\n                    throw new ArgumentException($\"{ nameof(heightScale) } should be 1 in { heightType } type.\");\n                }\n\n                // HeightRange\n\n                if (heightRange.Y < heightRange.X)\n                {\n                    throw new ArgumentException($\"{ nameof(heightRange) }.{ nameof(heightRange.Y) } should be greater than { nameof(heightRange.X) }.\");\n                }\n\n                if (Math.Abs((heightRange.Y / heightScale) - (heightRange.X / heightScale)) < 1)\n                {\n                    throw new ArgumentException($\"{ nameof(heightRange) } is too short.\");\n                }\n\n                if ((heightType == HeightfieldTypes.Byte) &&\n                    (Math.Sign(heightRange.X) + Math.Sign(heightRange.Y)) == 0)\n                {\n                    throw new ArgumentException($\"Can't handle { nameof(heightRange) } included both of positive and negative in { heightType } type.\");\n                }\n            }\n            catch (ArgumentException)\n            {\n                if (throwExceptionWhenInvalid) throw;\n\n                return false;","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Physics/Engine/HeightmapUtils.cs#L20-L56","documentation":"CheckHeightParameters requires heightRange.Y (max) to be strictly greater than heightRange.X (min); an inverted or empty range cannot map heights and throws ArgumentException. It is thrown before the too-short check, so this is the first range error hit.","triggerScenarios":"Passing a HeightRange where Max < Min, e.g. new HeightRange(10, -10), or a range whose X and Y are swapped after editing.","commonSituations":"Manual range entry in the editor with swapped min/max; computing range from data with Mathf.Min/Max results assigned to the wrong fields; copying ranges between heightmaps of opposite orientation.","solutions":["Order the range so HeightRange.X is the minimum and Y the maximum.","Compute the range from data: X = min(heights), Y = max(heights).","Validate with heightmap.IsValid() before collider creation.","Add an editor/runtime assertion that range.Y > range.X when the heightmap is configured."],"exampleFix":"// before\nheightmap.HeightRange = new FloatRange(10f, -10f);\n// after\nheightmap.HeightRange = new FloatRange(-10f, 10f); // X = min, Y = max","handlingStrategy":"validation","validationCode":"if (range.Y <= range.X) range = new FloatRange(range.Y, range.X); // or reject","typeGuard":"bool ValidRange(FloatRange r) => r.Y > r.X;","tryCatchPattern":"try { CheckHeightParameters(size, type, range, scale, true); } catch (ArgumentException) { /* recompute min/max from data */ }","preventionTips":["Always store min in X and max in Y","Compute ranges via Math.Min/Math.Max from height data","Add editor validation for min/max fields"],"tags":["csharp","argument-validation","physics","height-range"],"backgroundTag":"value-out-of-range","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"}