{"record":{"id":"554ce0f4feca2ce6","repo":"AvaloniaUI/Avalonia","slug":"unrecognized-cursor-type-s","errorCode":null,"errorMessage":"Unrecognized cursor type '{s}'.","messagePattern":"Unrecognized cursor type '(.+?)'\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Input/Cursor.cs","lineNumber":71,"sourceCode":"        public Cursor(StandardCursorType cursorType)\n            : this(GetCursorFactory().GetCursor(cursorType), cursorType.ToString())\n        {\n        }\n\n        public Cursor(Bitmap cursor, PixelPoint hotSpot)\n            : this(GetCursorFactory().CreateCursor(cursor, hotSpot), \"BitmapCursor\")\n        {\n        }\n\n        internal ICursorImpl PlatformImpl { get; }\n\n        public void Dispose() => PlatformImpl.Dispose();\n\n        public static Cursor Parse(string s)\n        {\n            return Enum.TryParse<StandardCursorType>(s, true, out var t) ?\n                new Cursor(t) :\n                throw new ArgumentException($\"Unrecognized cursor type '{s}'.\");\n        }\n\n        private static ICursorFactory GetCursorFactory()\n        {\n            return AvaloniaLocator.Current.GetRequiredService<ICursorFactory>();\n        }\n\n        public override string ToString()\n        {\n            return _name;\n        }\n    }\n}\n","sourceCodeStart":53,"sourceCodeEnd":85,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Input/Cursor.cs#L53-L85","documentation":"Cursor.Parse converts a cursor name string into a Cursor by matching it against the StandardCursorType enum (case-insensitive). If the string is not a known standard cursor name, there is no valid cursor to build, so it throws ArgumentException.","triggerScenarios":"Calling `Cursor.Parse(\"hand\" /*typo*/)` or `Cursor.Parse(\"grab\")` with a string that is not one of the StandardCursorType enum values (e.g. Arrow, Ibeam, Wait, Cross, Hand, AppStarting, Help, No, SizeAll, SizeNESW, SizeNS, SizeNWSE, SizeWE, UpArrow, None, ContextMenu, DragCopy, DragMove, DragLink, BottomSide, TopSide, LeftSide, RightSide, TopLeftCorner, TopRightCorner, BottomLeftCorner, BottomRightCorner).","commonSituations":"Parsing cursor names from config/XAML/JSON with a typo or using a CSS cursor name not present in StandardCursorType. Reading theme strings that contain unexpected values.","solutions":["Use a value from the StandardCursorType enum (case-insensitive).","Validate the string first with `Enum.TryParse<StandardCursorType>(s, true, out _)`.","Fall back to a default cursor when the name is unrecognized instead of letting Parse throw."],"exampleFix":"// before:\nvar c = Cursor.Parse(userInput); // throws on unknown\n\n// after:\nCursor c = Enum.TryParse<StandardCursorType>(userInput, true, out var t)\n    ? new Cursor(t)\n    : Cursor.Default;","handlingStrategy":"validation","validationCode":"Cursor c = Enum.TryParse<StandardCursorType>(s, true, out var t)\n    ? new Cursor(t)\n    : Cursor.Default;","typeGuard":"static bool IsKnownCursor(string s) => Enum.TryParse<StandardCursorType>(s, true, out _);","tryCatchPattern":"try { return Cursor.Parse(s); }\ncatch (ArgumentException) { return Cursor.Default; }","preventionTips":["Validate cursor strings with Enum.TryParse before Parse.","Keep a whitelist of supported StandardCursorType names.","Sanitize config-driven cursor names."],"tags":["cursor","parse","input","argument"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}