{"record":{"id":"e38bb809a9f00782","repo":"AvaloniaUI/Avalonia","slug":"invalid-value","errorCode":null,"errorMessage":"Invalid value","messagePattern":"Invalid value","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Animation/IterationCount.cs","lineNumber":44,"sourceCode":"        /// <summary>\n        /// Initializes a new instance of the <see cref=\"IterationCount\"/> struct.\n        /// </summary>\n        /// <param name=\"value\">The number of iterations of an animation.</param>\n        public IterationCount(ulong value)\n            : this(value, IterationType.Many)\n        {\n        }\n\n        /// <summary>\n        /// Initializes a new instance of the <see cref=\"IterationCount\"/> struct.\n        /// </summary>\n        /// <param name=\"value\">The size of the IterationCount.</param>\n        /// <param name=\"type\">The unit of the IterationCount.</param>\n        public IterationCount(ulong value, IterationType type)\n        {\n            if (type > IterationType.Infinite)\n            {\n                throw new ArgumentException(\"Invalid value\", nameof(type));\n            }\n\n            _type = type;\n            _value = value;\n        }\n\n        /// <summary>\n        /// Gets an instance of <see cref=\"IterationCount\"/> that indicates that an animation\n        /// should repeat forever.\n        /// </summary>\n        public static IterationCount Infinite => new IterationCount(0, IterationType.Infinite);\n\n        /// <summary>\n        /// Gets the unit of the <see cref=\"IterationCount\"/>.\n        /// </summary>\n        public IterationType RepeatType => _type;\n\n        /// <summary>","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Animation/IterationCount.cs#L26-L62","documentation":"Thrown by the IterationCount(ulong, IterationType) constructor when the type argument is an invalid enum value greater than IterationType.Infinite. IterationType is { Many=0, Infinite=1 }, so any other numeric value is rejected.","triggerScenarios":"Constructing new IterationCount(value, (IterationType)99) or otherwise casting an out-of-range integer to IterationType.","commonSituations":"Casting an arbitrary int to IterationType without validation; deserializing a numeric enum value outside the defined range.","solutions":["Use only IterationType.Many or IterationType.Infinite.","Validate the enum with Enum.IsDefined before constructing.","Prefer IterationCount.Infinite or new IterationCount(n) helpers over the two-arg constructor."],"exampleFix":"// before\nvar ic = new IterationCount(3, (IterationType)5);\n\n// after\nvar ic = new IterationCount(3, IterationType.Many);","handlingStrategy":"validation","validationCode":"if (!Enum.IsDefined(typeof(IterationType), type))\n    throw new ArgumentException(\"Invalid IterationType.\", nameof(type));","typeGuard":"static bool IsValidIterationType(IterationType t) => Enum.IsDefined(typeof(IterationType), t);","tryCatchPattern":null,"preventionTips":["Use only IterationType.Many or IterationType.Infinite.","Validate with Enum.IsDefined before constructing from a cast/external value.","Prefer the IterationCount(ulong) or IterationCount.Infinite helpers."],"tags":["animation","validation","enum","iteration-count","avalonia"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}