{"record":{"id":"a838467a78bbe70d","repo":"AvaloniaUI/Avalonia","slug":"invalid-cue-string-value","errorCode":null,"errorMessage":"Invalid Cue string \"{value}\"","messagePattern":"Invalid Cue string \"(.+?)\"","errorType":"validation","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Animation/Cue.cs","lineNumber":48,"sourceCode":"        /// <summary>\n        /// Parses a string to a <see cref=\"Cue\"/> object.\n        /// </summary>\n        public static Cue Parse(string value, CultureInfo? culture)\n        {\n            string v = value;\n\n            if (value.EndsWith('%'))\n            {\n                v = v.TrimEnd('%');\n            }\n\n            if (double.TryParse(v, NumberStyles.Float, culture, out double res))\n            {\n                return new Cue(res / 100d);\n            }\n            else\n            {\n                throw new FormatException($\"Invalid Cue string \\\"{value}\\\"\");\n            }\n        }\n\n        /// <summary>\n        /// Checks for equality between a <see cref=\"Cue\"/>\n        /// and a <see cref=\"double\"/> value.\n        /// </summary>\n        /// <param name=\"other\"></param>\n        /// <returns></returns>\n        public bool Equals(double other)\n        {\n            return CueValue == other;\n        }\n    }\n\n    public class CueTypeConverter : TypeConverter\n    {\n        public override bool CanConvertFrom(ITypeDescriptorContext? context, Type sourceType)","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Animation/Cue.cs#L30-L66","documentation":"Thrown by Cue.Parse when the input string cannot be parsed to a number. After stripping an optional trailing '%', the remainder must parse as a double via the supplied culture; otherwise a FormatException is raised.","triggerScenarios":"Calling Cue.Parse(s, culture) where s (minus a trailing '%') is not a valid floating-point number in that culture.","commonSituations":"Localized culture mismatch (decimal separator '.' vs ','); stray characters/whitespace inside the number; empty string; non-numeric tokens.","solutions":["Pass CultureInfo.InvariantCulture when the value is machine-generated.","Sanitize the input: trim whitespace, remove unsupported characters.","Validate with double.TryParse before constructing the Cue."],"exampleFix":"// before\nvar cue = Cue.Parse(\"0,5\", CultureInfo.InvariantCulture); // comma vs dot\n\n// after\nvar cue = Cue.Parse(\"0.5\", CultureInfo.InvariantCulture);","handlingStrategy":"validation","validationCode":"var s = input.Trim().TrimEnd('%');\nif (!double.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out _))\n    throw new FormatException($\"Invalid Cue string: {input}\");","typeGuard":"static bool IsValidCueString(string s) {\n    var v = s.Trim().TrimEnd('%');\n    return double.TryParse(v, NumberStyles.Float, CultureInfo.InvariantCulture, out _);\n}","tryCatchPattern":"try { var cue = Cue.Parse(input, CultureInfo.InvariantCulture); }\ncatch (FormatException) { /* fall back to a default cue */ }","preventionTips":["Use CultureInfo.InvariantCulture for machine-generated values.","Sanitize input (trim whitespace, remove stray characters) before parsing.","Validate with double.TryParse before constructing the Cue."],"tags":["animation","parsing","culture","cue","avalonia"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}