stride3d/stride · error · ArgumentOutOfRangeException
value
Error message
value
What it means
GestureConfigDrag.MinimumDragDistance throws ArgumentOutOfRangeException with paramName "value" when the assigned minimum drag distance is negative. The threshold distance is a magnitude; 0 is permitted, negative values are not.
Solutions
- Assign a non-negative distance, e.g. MinimumDragDistance = 20f
- Wrap computed values with Math.Abs() before assignment
- Validate/sanitize loaded config values before applying them
Example fix
// before dragConfig.MinimumDragDistance = -1f; // after dragConfig.MinimumDragDistance = 20f;
Defensive patterns
Strategy: validation
Validate before calling
if (float.IsNaN(d) || d < 0f) throw new ArgumentException("MinimumDragDistance must be >= 0");
dragConfig.MinimumDragDistance = d; Type guard
bool IsValidDistance(float v) => !float.IsNaN(v) && v >= 0f;
Try / catch
try { dragConfig.MinimumDragDistance = d; }
catch (ArgumentOutOfRangeException ex) when (ex.ParamName == "value")
{
dragConfig.MinimumDragDistance = 20f;
} Prevention
- Sanitize user-editable settings to reject negative thresholds
- Use Math.Abs() on computed deltas
- Avoid -1 'unset' sentinels for distance fields
When it happens
Trigger: Assigning a negative float to MinimumDragDistance on an unfrozen GestureConfigDrag, usually from an unvalidated config value or an unsigned/signed conversion mistake.
Common situations: Reading thresholds from user-editable settings where a minus sign slipped in; computing distance from a vector without Abs(); sentinel -1 'unset' values in config files.
Related errors
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/32e1d07f59a851f3.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Input/Gestures/GestureConfigDrag.cs:30
/// <remarks>A drag gesture can be composed of 1 or more fingers.</remarks>
public sealed class GestureConfigDrag : GestureConfig
{
/// <summary>
/// Specify the minimum translation distance required before that the gesture can be recognized as a Drag.
/// </summary>
/// <exception cref="InvalidOperationException">Tried to modify the configuration after it has been frozen by the system.</exception>
/// <exception cref="ArgumentOutOfRangeException">The provided value was negative.</exception>
/// <remarks>The user can reduce this value if he needs the drag gesture to be triggered even for very small drags.
/// On the contrary, he can increase this value if he wants to avoid to deals with too small drags.</remarks>
public float MinimumDragDistance
{
get { return minimumDragDistance; }
set
{
CheckNotFrozen();
if (value < 0)
throw new ArgumentOutOfRangeException("value");
minimumDragDistance = value;
}
}
private float minimumDragDistance;
/// <summary>
/// The (x,y) error margins allowed during directional dragging.
/// </summary>
/// <exception cref="InvalidOperationException">Tried to modify the configuration after it has been frozen by the system.</exception>
/// <exception cref="ArgumentOutOfRangeException">The provided x or y value was not positive.</exception>
/// <remarks>Those values are used only for directional (vertical or horizontal) dragging.
/// Decrease those values to trigger the gesture only when the dragging is perfectly in the desired direction.
/// Increase those values to allow directional gestures to be more approximative.</remarks>
public Vector2 AllowedErrorMargins
{
get { return allowedErrorMargins; }View on GitHub (pinned to 96fad776d2)