{"record":{"id":"809e1ab503190573","repo":"dotnet/wpf","slug":"paragraphproperties-defaulttextrunproperties","errorCode":null,"errorMessage":"paragraphProperties.DefaultTextRunProperties","messagePattern":"paragraphProperties\\.DefaultTextRunProperties","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextFormatterImp.cs","lineNumber":451,"sourceCode":"        /// <summary>\n        /// Verify all text formatting arguments\n        /// </summary>\n        private void VerifyTextFormattingArguments(\n            TextSource                  textSource,\n            int                         firstCharIndex,\n            double                      paragraphWidth,\n            TextParagraphProperties     paragraphProperties,\n            TextRunCache                textRunCache\n            )\n        {\n            ArgumentNullException.ThrowIfNull(textSource);\n\n            ArgumentNullException.ThrowIfNull(textRunCache);\n\n            ArgumentNullException.ThrowIfNull(paragraphProperties);\n\n            if (paragraphProperties.DefaultTextRunProperties == null)\n                throw new ArgumentNullException(\"paragraphProperties.DefaultTextRunProperties\");\n\n            if (paragraphProperties.DefaultTextRunProperties.Typeface == null)\n                throw new ArgumentNullException(\"paragraphProperties.DefaultTextRunProperties.Typeface\");\n\n            ArgumentOutOfRangeException.ThrowIfEqual(paragraphWidth, double.NaN);\n            ArgumentOutOfRangeException.ThrowIfNegative(paragraphWidth);\n            ArgumentOutOfRangeException.ThrowIfEqual(paragraphWidth, double.PositiveInfinity);\n            ArgumentOutOfRangeException.ThrowIfGreaterThan(paragraphWidth, Constants.RealInfiniteWidth);\n\n            double realMaxFontRenderingEmSize = Constants.RealInfiniteWidth / Constants.GreatestMutiplierOfEm;\n\n            ArgumentOutOfRangeException.ThrowIfNegative(paragraphProperties.DefaultTextRunProperties.FontRenderingEmSize, \"paragraphProperties.DefaultTextRunProperties.FontRenderingEmSize\");\n            ArgumentOutOfRangeException.ThrowIfGreaterThan(paragraphProperties.DefaultTextRunProperties.FontRenderingEmSize, realMaxFontRenderingEmSize, \"paragraphProperties.DefaultTextRunProperties.FontRenderingEmSize\");\n            ArgumentOutOfRangeException.ThrowIfGreaterThan(paragraphProperties.Indent, Constants.RealInfiniteWidth, \"paragraphProperties.Indent\");\n            ArgumentOutOfRangeException.ThrowIfGreaterThan(paragraphProperties.LineHeight, Constants.RealInfiniteWidth, \"paragraphProperties.LineHeight\");\n            ArgumentOutOfRangeException.ThrowIfNegative(paragraphProperties.DefaultIncrementalTab, \"paragraphProperties.DefaultIncrementalTab\");\n            ArgumentOutOfRangeException.ThrowIfGreaterThan(paragraphProperties.DefaultIncrementalTab, Constants.RealInfiniteWidth, \"paragraphProperties.DefaultIncrementalTab\");\n        }","sourceCodeStart":433,"sourceCodeEnd":469,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextFormatterImp.cs#L433-L469","documentation":"TextFormatterImp.VerifyTextFormattingArguments validates arguments to FormatLine/FormatParagraph. It throws ArgumentNullException when TextParagraphProperties.DefaultTextRunProperties is null. The library requires default run properties on the paragraph properties because they supply the typeface and font metrics used for line formatting.","triggerScenarios":"Calling TextFormatter.FormatLine (via PrepareFormatSettings) with a TextParagraphProperties subclass whose DefaultTextRunProperties was never set (left null in the constructor or manually assigned null).","commonSituations":"Custom TextParagraphProperties implementations where the constructor forgot to initialize DefaultTextRunProperties; refactoring that removed the TextRunProperties assignment; passing a default-constructed paragraph properties object.","solutions":["Set DefaultTextRunProperties to a valid TextRunProperties instance (e.g. a new TextRunProperties or SimpleTextProps) in your TextParagraphProperties implementation","Check your custom TextParagraphProperties constructor for a missing DefaultTextRunProperties assignment","Throw your own ArgumentNullException in your paragraph-properties constructor to catch this at construction time"],"exampleFix":"// before\npublic class MyParaProps : TextParagraphProperties { /* never set DefaultTextRunProperties */ }\n// after\npublic class MyParaProps : TextParagraphProperties {\n    public MyParaProps() {\n        DefaultTextRunProperties = new SimpleTextProps(typeface, 12.0); // must be non-null\n    }\n}","handlingStrategy":"validation","validationCode":"if (paragraphProperties == null) throw new ArgumentNullException(nameof(paragraphProperties));\nif (paragraphProperties.DefaultTextRunProperties == null) throw new ArgumentNullException(\"DefaultTextRunProperties\");","typeGuard":"bool IsValidParaProps(TextParagraphProperties p) => p?.DefaultTextRunProperties != null;","tryCatchPattern":"try { formatter.FormatLine(...); } catch (ArgumentNullException) { /* supply valid DefaultTextRunProperties and retry */ }","preventionTips":["Always initialize DefaultTextRunProperties in TextParagraphProperties constructors","Assert non-null DefaultTextRunProperties before calling TextFormatter APIs"],"tags":["wpf","text-formatting","null-argument"],"backgroundTag":"null-argument","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"}