{"record":{"id":"4e40a2a496588b96","repo":"dotnet/wpf","slug":"sr-format-sr-propertycannotbenegative-propertyname","errorCode":null,"errorMessage":"SR.Format(SR.PropertyCannotBeNegative, propertyName)","messagePattern":"SR\\.Format\\(SR\\.PropertyCannotBeNegative, propertyName\\)","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontFace/CompositeFontParser.cs","lineNumber":65,"sourceCode":"            else if (value <= 0)\n            {\n                throw new ArgumentException(SR.Format(SR.PropertyMustBeGreaterThanZero, propertyName));\n            }\n        }\n\n        internal static void VerifyNonNegativeMultiplierOfEm(string propertyName, ref double value)\n        {\n            if (double.IsNaN(value))\n            {\n                throw new ArgumentException(SR.Format(SR.PropertyValueCannotBeNaN, propertyName));\n            }\n            else if (value > Constants.GreatestMutiplierOfEm)\n            {\n                value = Constants.GreatestMutiplierOfEm;\n            }\n            else if (value < 0)\n            {\n                throw new ArgumentException(SR.Format(SR.PropertyCannotBeNegative, propertyName));\n            }\n        }\n\n        private double GetAttributeAsDouble()\n        {\n            object value = null;\n\n            try\n            {\n                value = _doubleTypeConverter.ConvertFromString(\n                    null, // type converter context\n                    System.Windows.Markup.TypeConverterHelper.InvariantEnglishUS,\n                    GetAttributeValue()\n                    );\n            }\n            catch (NotSupportedException)\n            {\n                FailAttributeValue();","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontFace/CompositeFontParser.cs#L47-L83","documentation":"VerifyNonNegativeMultiplierOfEm throws ArgumentException when a composite font multiplier property is negative (but not NaN, which hits the earlier branch). Values above Constants.GreatestMutiplierOfEm are clamped; negative values are considered invalid data and fail the parse.","triggerScenarios":"A .CompositeFont attribute such as a width, height, or scale factor is set to a negative number and the value flows through GetAttributeAsDouble into VerifyNonNegativeMultiplierOfEm.","commonSituations":"Typo in font family XML (e.g. Scale=\"-0.5\"), corrupted resources after a bad merge or partial file copy, generated font definitions from faulty tooling.","solutions":["Set the attribute to a non-negative value (0 is allowed on this variant)","Validate with v >= 0 before invoking the parser","Re-deploy unmodified font resource files from source control"],"exampleFix":"<!-- before -->\n<Family Scale=\"-0.5\" />\n<!-- after -->\n<Family Scale=\"0.5\" />","handlingStrategy":"validation","validationCode":"if (value < 0) throw new ArgumentException($\"{name} must be >= 0, got {value}\");","typeGuard":"bool IsNonNegative(double v) => !double.IsNaN(v) && v >= 0;","tryCatchPattern":null,"preventionTips":["Clamp negative values to 0 at config load if a default is acceptable","Schema-validate font XML with minInclusive=0","Review hand-edited font resources in code review"],"tags":["wpf","fonts","negative-value","composite-font"],"backgroundTag":"argument-out-of-range","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"}