{"record":{"id":"e2176c3570e46e1e","repo":"dotnet/wpf","slug":"sr-format-sr-propertyvaluecannotbenan-propertyname","errorCode":null,"errorMessage":"SR.Format(SR.PropertyValueCannotBeNaN, propertyName)","messagePattern":"SR\\.Format\\(SR\\.PropertyValueCannotBeNaN, propertyName\\)","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontFace/CompositeFontParser.cs","lineNumber":25,"sourceCode":"using System.Windows;\nusing System.Windows.Interop;\nusing System.Windows.Media;\nusing System.Windows.Markup;\nusing System.Xml;\nusing System.Globalization;\nusing System.Collections;\nusing System.ComponentModel;\nusing MS.Internal.TextFormatting;\n\nnamespace MS.Internal.FontFace\n{\n    internal class CompositeFontParser\n    {\n        internal static void VerifyMultiplierOfEm(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 < -Constants.GreatestMutiplierOfEm)\n            {\n                value = -Constants.GreatestMutiplierOfEm;\n            }\n        }\n\n        internal static void VerifyPositiveMultiplierOfEm(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)","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontFace/CompositeFontParser.cs#L7-L43","documentation":"CompositeFontParser.VerifyMultiplierOfEm rejects NaN values for any em-relative multiplier property of a composite font. NaN cannot be meaningfully clamped or scaled, so it throws ArgumentException(SR.Format(SR.PropertyValueCannotBeNaN, propertyName)); finite values are clamped to Constants.GreatestMutiplierOfEm bounds.","triggerScenarios":"Parsing a composite font (.CompositeFont XAML) where a multiplier attribute (e.g. Stretch, Bold, Scale on a FontFamilyMap, or similar em multiplier) is set to \"NaN\"/\"Auto\", triggering VerifyMultiplierOfEm with a NaN double.","commonSituations":"Hand-edited or tool-generated CompositeFont resources using NaN as a sentinel; data binding or computed values producing double.NaN before serialization; culture/parse issues yielding NaN from attribute text.","solutions":["Replace NaN in the composite font source with a valid finite multiplier (e.g. 1.0).","Sanitize values before assignment: substitute a default when double.IsNaN(value).","Fix the generator/exporter producing NaN attribute values."],"exampleFix":"// before\nmap.ScaleInEm = double.NaN; // ArgumentException on verify\n// after\nmap.ScaleInEm = double.IsNaN(v) ? 1.0 : v;","handlingStrategy":"validation","validationCode":"if (double.IsNaN(value))\n    throw new ArgumentException($\"{propertyName} cannot be NaN.\");\n// or sanitize:\nif (double.IsNaN(value)) value = 1.0;","typeGuard":"bool IsValidMultiplier(double v) => !double.IsNaN(v) && !double.IsInfinity(v);","tryCatchPattern":"try { CompositeFontParser.VerifyMultiplierOfEm(prop, ref value); }\ncatch (ArgumentException) { value = 1.0; /* default */ }","preventionTips":["Never emit NaN into composite font attributes.","Sanitize computed doubles before serialization.","Check CompositeFont files for \"NaN\" attribute values.","Use invariant-culture parsing of numeric attributes."],"tags":["wpf","fonts","composite-font","nan","argumentexception"],"backgroundTag":"invalid-config-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"}