{"record":{"id":"ede868d5e532c46b","repo":"dotnet/wpf","slug":"sr-invalidlocalizabilityvalue","errorCode":null,"errorMessage":"SR.InvalidLocalizabilityValue","messagePattern":"SR\\.InvalidLocalizabilityValue","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Globalization/LocalizationComments.cs","lineNumber":266,"sourceCode":"            if (ReadabilityIndexTable.TryGet(value, out enumValue))\n            {\n                attributeGroup.Readability = (Readability)enumValue;\n                return;\n            }\n\n            if (ModifiabilityIndexTable.TryGet(value, out enumValue))\n            {\n                attributeGroup.Modifiability = (Modifiability)enumValue;\n                return;\n            }\n\n            if (LocalizationCategoryIndexTable.TryGet(value, out enumValue))\n            {\n                attributeGroup.Category = (LocalizationCategory)enumValue;\n                return;\n            }\n\n            throw new FormatException(SR.Format(SR.InvalidLocalizabilityValue, value));\n        }\n\n\n        private const char CommentStart = '(';\n        private const char CommentEnd = ')';\n        private const char EscapeChar = '\\\\';\n\n        // loc comments file recognized element\n        internal const string LocDocumentRoot = \"LocalizableAssembly\";\n        internal const string LocResourcesElement = \"LocalizableFile\";\n        internal const string LocCommentsElement = \"LocalizationDirectives\";\n        internal const string LocFileNameAttribute = \"Name\";\n        internal const string LocCommentIDAttribute = \"Uid\";\n        internal const string LocCommentsAttribute = \"Comments\";\n        internal const string LocLocalizabilityAttribute = \"Attributes\";\n\n        //\n        // Tables that map the enum string names into their enum indices.","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Globalization/LocalizationComments.cs#L248-L284","documentation":"ParseLocalizabilityString resolves the [Localization.Attributes] Localizability attribute's category string against the LocalizationCategory enum index table. When the supplied string is not a valid LocalizationCategory name (ignoring the table's aliases), it throws this FormatException.","triggerScenarios":"Passing a category string to LocalizabilityAttribute parsing (via LookupAndSetLocalizabilityAttribute) that is not a LocalizationCategory member, e.g. 'TextBlock' or 'Label' instead of valid values like 'Text', 'Title', 'Button', 'None', or 'Inherit'.","commonSituations":"Typo'd category names in [Localization.Attributes] attributes, using UI element type names as categories, and older project files using category names from a different localization tool's vocabulary.","solutions":["Use an exact LocalizationCategory enum member name (e.g. Text, Button, Title, None, Inherit).","Check spelling and casing against the LocalizationCategory enum in System.Windows.Localization.","Replace invented categories with the closest standard one ('Text' for generic strings, 'NeverLocalize' to exclude).","If a custom grouping is needed, encode it in the Localization.Comments attribute instead of the category."],"exampleFix":"// before\n[Localization.Attributes]\nText(TextBlock, Modifiable)\n// after\n[Localization.Attributes]\nText(Text, Modifiable)","handlingStrategy":"validation","validationCode":"static bool IsValidLocalizationCategory(string value) =>\n    System.Enum.TryParse<System.Windows.LocalizationCategory>(value, out _);","typeGuard":null,"tryCatchPattern":"try { ParseLocalizabilityString(value); } catch (FormatException ex) { log.Warn($\"Unknown LocalizationCategory '{value}': {ex.Message}\"); }","preventionTips":["Only use LocalizationCategory enum member names in [Localization.Attributes].","Let IntelliSense complete the category name instead of typing it manually.","Never use UI element type names as categories."],"tags":["wpf","localization","enum","invalid-value"],"backgroundTag":"invalid-enum-value","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}