{"record":{"id":"47b605775e0ff8f7","repo":"dotnet/wpf","slug":"timing-invalidargfinitepositive","errorCode":"Timing_InvalidArgFinitePositive","errorMessage":"SR.Timing_InvalidArgFinitePositive (Timing_InvalidArgFinitePositive)","messagePattern":"SR\\.Timing_InvalidArgFinitePositive \\(Timing_InvalidArgFinitePositive\\)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/ClockController.cs","lineNumber":279,"sourceCode":"            {\n                return _owner;\n            }\n        }\n\n        /// <summary>\n        /// Returns or sets the interactive speed for the Clock.\n        /// </summary>\n        public double SpeedRatio\n        {\n            get\n            {\n                return _owner.InternalGetSpeedRatio();\n            }\n            set\n            {\n                if (value < 0 || value > double.MaxValue || double.IsNaN(value))\n                {\n                    throw new ArgumentException(SR.Timing_InvalidArgFinitePositive, nameof(value));\n                }\n\n                _owner.InternalSetSpeedRatio(value);\n            }\n        }\n\n        #endregion // Properties\n    }\n}\n","sourceCodeStart":261,"sourceCodeEnd":289,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/ClockController.cs#L261-L289","documentation":"ClockController.SpeedRatio must be a finite positive double. The setter throws ArgumentException (Timing_InvalidArgFinitePositive) when the value is negative, NaN, or greater than double.MaxValue (i.e. not a valid finite positive number).","triggerScenarios":"Setting controller.SpeedRatio = -1, double.NaN, double.PositiveInfinity, or double.MaxValue-boundary values; computing a speed ratio via division that yields NaN/Infinity (e.g. elapsed/0).","commonSituations":"Dynamic playback-speed controls fed by division expressions; data-bound SpeedRatio where the bound source contains NaN/Infinity; reverting speed after a pause with an uninitialized variable.","solutions":["Validate before assigning: value > 0 && !double.IsNaN(value) && value < double.MaxValue","Clamp computed ratios to a sane range (e.g. 0.1–10)","Use double.IsFinite(value) checks on division-derived speeds","Guard against division by zero when computing ratio from measured durations"],"exampleFix":"// before\ndouble ratio = elapsed / measured; // can be NaN/Infinity\ncontroller.SpeedRatio = ratio; // throws\n// after\ndouble ratio = measured > 0 ? elapsed / measured : 1.0;\nif (ratio > 0 && !double.IsNaN(ratio) && ratio < double.MaxValue)\n    controller.SpeedRatio = ratio;","handlingStrategy":"validation","validationCode":"bool isValidSpeed(double v) => v > 0 && !double.IsNaN(v) && v < double.MaxValue;\nif (isValidSpeed(candidate)) controller.SpeedRatio = candidate;","typeGuard":"static bool IsFinitePositive(double v) => !double.IsNaN(v) && !double.IsInfinity(v) && v > 0 && v < double.MaxValue;","tryCatchPattern":"try { controller.SpeedRatio = value; }\ncatch (ArgumentException) { controller.SpeedRatio = 1.0; }","preventionTips":["Guard division when computing speed ratios (denominator > 0)","Clamp UI-driven speed values to a bounded range","Never assign raw bound/data values to SpeedRatio without a finite-positive check"],"tags":["wpf","animation","speedratio","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}