{"record":{"id":"20ff17c5d0f68653","repo":"dotnet/wpf","slug":"readability","errorCode":null,"errorMessage":"Readability","messagePattern":"Readability","errorType":"validation","errorClass":"InvalidEnumArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/LocalizabilityAttribute.cs","lineNumber":76,"sourceCode":"        {\n            // should have only getter, because it is a required parameter to the constructor\n            get { return _category; }         \n        }      \n\n        /// <summary>\n        /// Get or set the readability of the attribute's targeted value\n        /// </summary>\n        /// <value>Readability</value>\n        public Readability Readability\n        {\n            get { return _readability; }\n            set \n            { \n                if (  value != Readability.Unreadable \n                   && value != Readability.Readable \n                   && value != Readability.Inherit)\n                {\n                    throw new InvalidEnumArgumentException(\"Readability\", (int) value, typeof(Readability));\n                }\n\n                _readability = value;\n            }\n        }\n\n        /// <summary>\n        /// Get or set the modifiability of the attribute's targeted value\n        /// </summary>\n        /// <value>Modifiability</value>\n        public Modifiability Modifiability\n        {\n            get { return _modifiability; }\n            set \n            {\n                if (   value != Modifiability.Unmodifiable\n                    && value != Modifiability.Modifiable\n                    && value != Modifiability.Inherit)","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/LocalizabilityAttribute.cs#L58-L94","documentation":"The Readability property setter of LocalizabilityAttribute accepts only Readability.Unreadable, Readable, or Inherit; any other value throws InvalidEnumArgumentException. This restricts the property to the three defined readability levels.","triggerScenarios":"Assigning attribute.Readability = (Readability)otherInt with an undefined int, or assigning a value from a different enum (e.g. a LocalizationCategory or Modifiability value) to Readability.","commonSituations":"Reflection-driven or generated code mapping legacy readability codes; copy-paste errors where a Modifiability value is assigned to Readability; config-driven attribute construction with invalid ints.","solutions":["Whitelist-check the value against Enum.IsDefined(typeof(Readability), value) and the three valid members before assigning","Assign named constants (Readability.Readable / Unreadable / Inherit) instead of casts","Fix cross-enum assignment bugs where a wrong enum's value is passed to the setter"],"exampleFix":"// before\nattr.Readability = (Readability)modifiabilityValue; // wrong enum\n// after\nReadability r = (Readability)rawValue;\nattr.Readability = (r == Readability.Readable || r == Readability.Unreadable || r == Readability.Inherit)\n    ? r : Readability.Inherit;","handlingStrategy":"validation","validationCode":"if (value != Readability.Unreadable && value != Readability.Readable && value != Readability.Inherit) throw new ArgumentException(\"Invalid Readability\");","typeGuard":"static bool IsValidReadability(Readability r) => r is Readability.Unreadable or Readability.Readable or Readability.Inherit;","tryCatchPattern":"try { attr.Readability = value; }\ncatch (InvalidEnumArgumentException) { attr.Readability = Readability.Inherit; }","preventionTips":["Assign only named Readability constants","Watch for cross-enum copy-paste (Modifiability vs Readability)","Validate raw ints with Enum.IsDefined before casting"],"tags":["wpf","localization","enum","property"],"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"}