{"record":{"id":"736ad4064defa3bb","repo":"dotnet/wpf","slug":"sr-animation-invalid-defaultvalue-origin-0-value-2-736ad4","errorCode":null,"errorMessage":"SR.Animation_Invalid_DefaultValue (origin: {0}, value: {2})","messagePattern":"SR\\.Animation_Invalid_DefaultValue \\(origin: (.+?), value: (.+?)\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/Int16Animation.cs","lineNumber":313,"sourceCode":"                    if (IsAdditive)\n                    {\n                        foundation = defaultOriginValue;\n                        validateOrigin = true;\n                    }\n\n                    break;\n\n                default:\n\n                    Debug.Fail(\"Unknown animation type.\");\n\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","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/Int16Animation.cs#L295-L331","documentation":"Int16Animation.GetCurrentValueCore throws this InvalidOperationException when the origin (from) value is not a valid animation value for Int16 per AnimatedTypeHelpers.IsValidAnimationValueInt16. For integer types this effectively guards against invalid default values being used as the interpolation source. The message names parameter 'origin' and the invalid value.","triggerScenarios":"GetCurrentValueCore invoked with defaultOriginValue failing IsValidAnimationValueInt16 while validateOrigin is true — an invalid default origin value supplied to an Int16Animation.","commonSituations":"Binding an animation From value to data that yields an out-of-range/invalid short; custom animation code passing unchecked defaults; round-tripping values that overflow Int16.","solutions":["Clamp/validate the origin value to the Int16 range before starting the animation","Check the bound source property for validity (e.g. short.MinValue..short.MaxValue) prior to animation","Wrap animation setup in try/catch for InvalidOperationException and substitute a safe default"],"exampleFix":"// before\nshort from = unchecked((short)someInt); // may be invalid/overflowed\nvar anim = new Int16Animation(from, to, duration);\n// after\nif (someInt >= short.MinValue && someInt <= short.MaxValue)\n    var anim = new Int16Animation((short)someInt, to, duration);","handlingStrategy":"validation","validationCode":"if (from < short.MinValue || from > short.MaxValue) throw new ArgumentOutOfRangeException(nameof(from));","typeGuard":"static bool IsValidShortValue(int v) => v >= short.MinValue && v <= short.MaxValue;","tryCatchPattern":"try { animation.Begin(); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"origin\")) { /* fall back to a valid default origin */ }","preventionTips":["Clamp values to the Int16 range before feeding animations","Validate data-bound source values on the view model before triggering animations","Avoid unchecked casts into short; use checked/Math.Clamp"],"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"}