{"record":{"id":"8c1d04007acc7073","repo":"dotnet/wpf","slug":"sr-animation-invalid-defaultvalue-destination-0-value-2-8c1d04","errorCode":null,"errorMessage":"SR.Animation_Invalid_DefaultValue (destination: {0}, value: {2})","messagePattern":"SR\\.Animation_Invalid_DefaultValue \\(destination: (.+?), value: (.+?)\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/Int16Animation.cs","lineNumber":324,"sourceCode":"\n                    break;\n            }\n\n            if (validateOrigin \n                && !AnimatedTypeHelpers.IsValidAnimationValueInt16(defaultOriginValue))\n            {\n                throw new InvalidOperationException(\n                    SR.Format(\n                        SR.Animation_Invalid_DefaultValue,\n                        this.GetType(),\n                        \"origin\",\n                        defaultOriginValue.ToString(CultureInfo.InvariantCulture)));\n            }\n\n            if (validateDestination \n                && !AnimatedTypeHelpers.IsValidAnimationValueInt16(defaultDestinationValue))\n            {\n                throw new InvalidOperationException(\n                    SR.Format(\n                        SR.Animation_Invalid_DefaultValue,\n                        this.GetType(),\n                        \"destination\",\n                        defaultDestinationValue.ToString(CultureInfo.InvariantCulture)));\n            }\n\n\n            if (IsCumulative)\n            {\n                double currentRepeat = (double)(animationClock.CurrentIteration - 1);\n\n                if (currentRepeat > 0.0)\n                {\n                    Int16 accumulator = AnimatedTypeHelpers.SubtractInt16(to, from);\n\n                    accumulated = AnimatedTypeHelpers.ScaleInt16(accumulator, currentRepeat);\n                }","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/Int16Animation.cs#L306-L342","documentation":"Int16Animation.GetCurrentValueCore throws this InvalidOperationException when the destination (to) value is not a valid animation value for Int16 (AnimatedTypeHelpers.IsValidAnimationValueInt16 fails). Animations need a valid numeric destination to interpolate toward. The message names parameter 'destination' and the invalid value.","triggerScenarios":"GetCurrentValueCore invoked with defaultDestinationValue failing IsValidAnimationValueInt16 while validateDestination is true — invalid default destination value supplied to Int16Animation.","commonSituations":"Data-bound To values producing out-of-range values; animation targets whose property value overflows Int16; malformed default values from generated/custom animation plumbing.","solutions":["Validate the destination value fits Int16 before animating","Clamp the bound value to short.MinValue/short.MaxValue","Fall back to a known-good destination value on failure"],"exampleFix":"// before\nvar anim = new Int16Animation(from, (short)userValue, duration); // userValue may exceed range\n// after\nshort to = (short)Math.Clamp(userValue, short.MinValue, short.MaxValue);\nvar anim = new Int16Animation(from, to, duration);","handlingStrategy":"validation","validationCode":"if (to < short.MinValue || to > short.MaxValue) throw new ArgumentOutOfRangeException(nameof(to));","typeGuard":"static bool IsValidShortValue(int v) => v >= short.MinValue && v <= short.MaxValue;","tryCatchPattern":"try { animation.Begin(); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"destination\")) { /* clamp and retry with valid destination */ }","preventionTips":["Clamp animation destinations with Math.Clamp to short.MinValue/short.MaxValue","Validate user/data inputs that feed To/By values before animating","Keep animation endpoint types aligned with the animated property's type"],"tags":["wpf","animation","int16","invalid-value"],"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"}