{"record":{"id":"9a9442d921f5fbd3","repo":"dotnet/wpf","slug":"sr-timing-invalidargfinitepositive","errorCode":null,"errorMessage":"SR.Timing_InvalidArgFinitePositive","messagePattern":"SR\\.Timing_InvalidArgFinitePositive","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Timeline.cs","lineNumber":601,"sourceCode":"        public double SpeedRatio\n        {\n            get\n            {\n                return (double)GetValue(SpeedRatioProperty);\n            }\n            set\n            {\n                SetValue(SpeedRatioProperty, value);\n            }\n        }\n\n        private static bool ValidateSpeedRatio(object value)\n        {\n            double newValue = (double)value;\n\n            if (newValue <= 0 || newValue > double.MaxValue || double.IsNaN(newValue))\n            {\n                throw new ArgumentException(SR.Timing_InvalidArgFinitePositive, nameof(value));\n            }\n\n            return true;\n        }\n\n        #endregion // SpeedRatio Property\n\n        #endregion // Properties\n\n        #region Methods\n\n        /// <summary>\n        /// Called by the <see ref=\"Clock.FromTimeline\" /> method to\n        /// create a type-specific clock for this Timeline.\n        /// </summary>\n        /// <returns>\n        /// A clock for this Timeline.\n        /// </returns>","sourceCodeStart":583,"sourceCodeEnd":619,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Timeline.cs#L583-L619","documentation":"Timeline.SpeedRatio is validated by ValidateSpeedRatio, which requires a finite positive double: > 0, <= double.MaxValue, and not NaN. Zero, negative, NaN, or +Infinity values throw ArgumentException with Timing_InvalidArgFinitePositive.","triggerScenarios":"timeline.SpeedRatio = 0, = -2, = double.NaN, or = double.PositiveInfinity (Infinity exceeds double.MaxValue per this check). Also via data binding to a value that can be 0.","commonSituations":"Computing speed from a divisor that yields 0 or Infinity (speed = distance/time with time 0); NaN from double.TryParse of empty input; UI numeric fields allowing 0 or negatives.","solutions":["Validate/guard before assignment: double.IsFinite(v) && v > 0 (note Infinity must be excluded).","Clamp small/invalid values to a minimum like 0.001 or fall back to 1.","For dynamic speed control, coerce the bound value in a value converter or property setter."],"exampleFix":"// before\ntimeline.SpeedRatio = newSpeed; // may be 0 or NaN\n// after\ntimeline.SpeedRatio = double.IsFinite(newSpeed) && newSpeed > 0 ? newSpeed : 1.0;","handlingStrategy":"validation","validationCode":"double v = double.IsFinite(speed) && speed > 0 ? speed : 1.0;\ntimeline.SpeedRatio = v;","typeGuard":"static bool IsValidSpeedRatio(double v) => double.IsFinite(v) && v > 0;\nstatic double SafeSpeedRatio(double v) => double.IsFinite(v) && v > 0 ? v : 1.0;","tryCatchPattern":"try { timeline.SpeedRatio = speed; }\ncatch (ArgumentException) { timeline.SpeedRatio = 1.0; }","preventionTips":["Exclude 0, negatives, NaN, and Infinity before assignment.","Guard divisions that compute speed (time divisor can be 0).","Coerce numeric UI input to a safe minimum like 0.01."],"tags":["wpf","animation","timeline","argument"],"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-21T21:30:21.729Z"}