stride3d/stride · error · ArgumentOutOfRangeException

value

Error message

value

What it means

GestureConfig.RequiredNumberOfFingers validates the assigned value: it must be at least 1, and if the config was created with a restricted number of fingers, it must equal that restriction. Violating either throws ArgumentOutOfRangeException with parameter name 'value'.

Solutions

  1. Set RequiredNumberOfFingers to 1 or more
  2. Match the restricted finger count for gesture configs that require an exact count (e.g. 2 for pinch)
  3. Validate deserialized config values before assigning them

Example fix

// before
gestureConfig.RequiredNumberOfFingers = fingersFromConfig; // may be 0
// after
gestureConfig.RequiredNumberOfFingers = Math.Max(1, fingersFromConfig);
Defensive patterns

Strategy: validation

Validate before calling

if (fingerCount >= 1)
    config.RequiredNumberOfFingers = fingerCount;

Try / catch

try { config.RequiredNumberOfFingers = v; }
catch (ArgumentOutOfRangeException) { config.RequiredNumberOfFingers = 1; }

Prevention

When it happens

Trigger: Assigning RequiredNumberOfFingers = 0 or a negative number; or assigning a count that differs from restrictedNumberOfFinger when the config was built for a fixed finger count (e.g. a two-finger pinch config given 3).

Common situations: Initializing gesture settings from serialized config where the default int value 0 leaks into the property; configuring a specific gesture (pinch/rotate) with a finger count other than its required one.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/faa63e85e5d18359. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Input/Gestures/GestureConfig.cs:52

            restrictedNumberOfFinger = numberOfFinger;
        }

        /// <summary>
        /// This value represents the required number of simultaneous finger to tap to trigger the gesture. For example: 1 for single finger, and so on...
        /// </summary>
        /// <remarks>This value is strictly positive.</remarks>
        /// <exception cref="ArgumentOutOfRangeException">The given value is not in the allowed range.</exception>
        /// <exception cref="InvalidOperationException">Tried to modify the configuration after it has been frozen by the system.</exception>
        public int RequiredNumberOfFingers
        {
            get { return requiredNumberOfFingers; }
            set
            {
                CheckNotFrozen();

                if (value < 1)
                    throw new ArgumentOutOfRangeException("value");

                if (restrictedNumberOfFinger != 0 && value != restrictedNumberOfFinger)
                    throw new ArgumentOutOfRangeException("value");

                requiredNumberOfFingers = value;
            }
        }
        private int requiredNumberOfFingers;

        /// <summary>
        /// Indicate that the configuration is frozen and cannot be modified anymore by the user.
        /// </summary>
        private bool frozen;

        /// <summary>
        /// Freeze the configuration so that the user cannot modify it anymore.
        /// </summary>
        private void Freeze()

View on GitHub (pinned to 96fad776d2)