{"record":{"id":"cfea135c0c6d066b","repo":"dotnet/wpf","slug":"sr-format-sr-invalidctorparameternoinfinity-value","errorCode":null,"errorMessage":"SR.Format(SR.InvalidCtorParameterNoInfinity, \"value\")","messagePattern":"SR\\.Format\\(SR\\.InvalidCtorParameterNoInfinity, \"value\"\\)","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/FigureLength.cs","lineNumber":107,"sourceCode":"        /// </remarks>\n        /// <exception cref=\"ArgumentException\">\n        /// If <c>value</c> parameter is <c>double.NaN</c>\n        /// or <c>value</c> parameter is <c>double.NegativeInfinity</c>\n        /// or <c>value</c> parameter is <c>double.PositiveInfinity</c>.\n        /// or <c>value</c> parameter is <c>negative</c>.\n        /// </exception>\n        public FigureLength(double value, FigureUnitType type)\n        {\n            double maxColumns = PTS.Restrictions.tscColumnRestriction;\n            double maxPixel = Math.Min(1000000, PTS.MaxPageSize);\n\n            if (double.IsNaN(value))\n            {\n                throw new ArgumentException(SR.Format(SR.InvalidCtorParameterNoNaN, \"value\"));\n            }\n            if (double.IsInfinity(value))\n            {\n                throw new ArgumentException(SR.Format(SR.InvalidCtorParameterNoInfinity, \"value\"));\n            }\n            if (value < 0.0)\n            {\n                throw new ArgumentOutOfRangeException(SR.Format(SR.InvalidCtorParameterNoNegative, \"value\"));\n            }\n            if (    type != FigureUnitType.Auto\n                &&  type != FigureUnitType.Pixel\n                &&  type != FigureUnitType.Column\n                &&  type != FigureUnitType.Content\n                &&  type != FigureUnitType.Page   )\n            {\n                throw new ArgumentException(SR.Format(SR.InvalidCtorParameterUnknownFigureUnitType, \"type\"));\n            }\n            if (type is FigureUnitType.Content or FigureUnitType.Page)\n            {\n                ArgumentOutOfRangeException.ThrowIfGreaterThan(value, 1.0);\n            }\n","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/FigureLength.cs#L89-L125","documentation":"The FigureLength constructor rejects a value of double.PositiveInfinity or double.NegativeInfinity. Infinity is not a valid figure length; the constructor throws ArgumentException with InvalidCtorParameterNoInfinity.","triggerScenarios":"Calling new FigureLength(double.PositiveInfinity, ...) or with NegativeInfinity — e.g. passing double.PositiveInfinity to mean 'fill available space'.","commonSituations":"Using double.PositiveInfinity as a 'stretch to max' convention in layout code; values computed from unbounded measurements; interop with code that uses infinity as a default.","solutions":["Clamp or validate with double.IsInfinity before constructing the FigureLength.","Use FigureUnitType.Page or Content to express 'fill' semantics instead of infinity.","Fix upstream math that yields infinity (e.g. division by zero or max on empty collections)."],"exampleFix":"// before\nvar length = new FigureLength(double.PositiveInfinity, FigureUnitType.Pixel); // throws\n\n// after\nvar length = double.IsInfinity(requested)\n    ? new FigureLength(1.0, FigureUnitType.Page)\n    : new FigureLength(requested, FigureUnitType.Pixel);","handlingStrategy":"validation","validationCode":"if (double.IsInfinity(value))\n    throw new ArgumentException(\"value must not be infinite.\");\nvar length = new FigureLength(value, unit);","typeGuard":"bool IsFiniteLength(double v) => !double.IsNaN(v) && !double.IsInfinity(v);","tryCatchPattern":"try { var len = new FigureLength(value, unit); }\ncatch (ArgumentException) { /* clamp or fall back to Page/Content unit */ }","preventionTips":["Never use double.PositiveInfinity as a 'fill' convention; use FigureUnitType.Page or Content.","Guard division and Max operations that can yield infinity.","Clamp values to PTS restrictions (max pixel/page sizes) before constructing."],"tags":["wpf","invalid-argument-value","infinity","constructor"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}