From: Jaehyun Cho Date: Thu, 13 Mar 2025 05:57:28 +0000 (+0900) Subject: [NUI] Fix LayoutLength not to take invalid float values X-Git-Tag: submit/tizen/20250318.061413~1^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5114c08d5daa0b9b17e1639b2d1b7caa59b3619e;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Fix LayoutLength not to take invalid float values LayoutLength is fixed not to take invalid float values such as non-finite values, float.MinValue, float.MaxValue. If user wants to use float.MinValue or float.MaxValue, then int.MinValue or int.MaxValue are suggested. --- diff --git a/src/Tizen.NUI/src/public/Layouting/LayoutLength.cs b/src/Tizen.NUI/src/public/Layouting/LayoutLength.cs index 538277f7a..e9331e490 100755 --- a/src/Tizen.NUI/src/public/Layouting/LayoutLength.cs +++ b/src/Tizen.NUI/src/public/Layouting/LayoutLength.cs @@ -41,9 +41,20 @@ namespace Tizen.NUI /// Constructor from a float /// /// Float to initialize with. + /// Thrown when the argument is invalid. /// 6 public LayoutLength(float value) { + if (!float.IsFinite(value)) + { + throw new ArgumentException("LayoutLength cannot take non-finite values."); + } + + if (value == float.MinValue || value == float.MaxValue) + { + throw new ArgumentException("LayoutLength cannot take float.MinValue or float.MaxValue. Please use int.MinValue or int.MaxValue."); + } + this.value = value; } @@ -61,9 +72,20 @@ namespace Tizen.NUI /// Constructor from a LayoutDimension /// /// LayoutSize to initialize with. + /// Thrown when the argument is invalid. [EditorBrowsable(EditorBrowsableState.Never)] public LayoutLength(LayoutDimension layoutDimension) { + if (!float.IsFinite(layoutDimension)) + { + throw new ArgumentException("LayoutLength cannot take non-finite values."); + } + + if (layoutDimension == float.MinValue || layoutDimension == float.MaxValue) + { + throw new ArgumentException("LayoutLength cannot take float.MinValue or float.MaxValue. Please use int.MinValue or int.MaxValue."); + } + this.value = layoutDimension; }