diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextFormatterImp.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextFormatterImp.cs index 938501e9c0a..0cd1a1ee3d3 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextFormatterImp.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/TextFormatterImp.cs @@ -477,34 +477,19 @@ TextRunCache textRunCache if (paragraphProperties.DefaultTextRunProperties.Typeface == null) throw new ArgumentNullException("paragraphProperties.DefaultTextRunProperties.Typeface"); - if (double.IsNaN(paragraphWidth)) - throw new ArgumentOutOfRangeException("paragraphWidth", SR.ParameterValueCannotBeNaN); - - if (double.IsInfinity(paragraphWidth)) - throw new ArgumentOutOfRangeException("paragraphWidth", SR.ParameterValueCannotBeInfinity); - - if ( paragraphWidth < 0 - || paragraphWidth > Constants.RealInfiniteWidth) - { - throw new ArgumentOutOfRangeException("paragraphWidth", SR.Format(SR.ParameterMustBeBetween, 0, Constants.RealInfiniteWidth)); - } + ArgumentOutOfRangeException.ThrowIfEqual(paragraphWidth, double.NaN); + ArgumentOutOfRangeException.ThrowIfNegative(paragraphWidth); + ArgumentOutOfRangeException.ThrowIfEqual(paragraphWidth, double.PositiveInfinity); + ArgumentOutOfRangeException.ThrowIfGreaterThan(paragraphWidth, Constants.RealInfiniteWidth); double realMaxFontRenderingEmSize = Constants.RealInfiniteWidth / Constants.GreatestMutiplierOfEm; - if ( paragraphProperties.DefaultTextRunProperties.FontRenderingEmSize < 0 - || paragraphProperties.DefaultTextRunProperties.FontRenderingEmSize > realMaxFontRenderingEmSize) - { - throw new ArgumentOutOfRangeException("paragraphProperties.DefaultTextRunProperties.FontRenderingEmSize", SR.Format(SR.ParameterMustBeBetween, 0, realMaxFontRenderingEmSize)); - } - + ArgumentOutOfRangeException.ThrowIfNegative(paragraphProperties.DefaultTextRunProperties.FontRenderingEmSize, "paragraphProperties.DefaultTextRunProperties.FontRenderingEmSize"); + ArgumentOutOfRangeException.ThrowIfGreaterThan(paragraphProperties.DefaultTextRunProperties.FontRenderingEmSize, realMaxFontRenderingEmSize, "paragraphProperties.DefaultTextRunProperties.FontRenderingEmSize"); ArgumentOutOfRangeException.ThrowIfGreaterThan(paragraphProperties.Indent, Constants.RealInfiniteWidth, "paragraphProperties.Indent"); ArgumentOutOfRangeException.ThrowIfGreaterThan(paragraphProperties.LineHeight, Constants.RealInfiniteWidth, "paragraphProperties.LineHeight"); - - if ( paragraphProperties.DefaultIncrementalTab < 0 - || paragraphProperties.DefaultIncrementalTab > Constants.RealInfiniteWidth) - { - throw new ArgumentOutOfRangeException("paragraphProperties.DefaultIncrementalTab", SR.Format(SR.ParameterMustBeBetween, 0, Constants.RealInfiniteWidth)); - } + ArgumentOutOfRangeException.ThrowIfNegative(paragraphProperties.DefaultIncrementalTab, "paragraphProperties.DefaultIncrementalTab"); + ArgumentOutOfRangeException.ThrowIfGreaterThan(paragraphProperties.DefaultIncrementalTab, Constants.RealInfiniteWidth, "paragraphProperties.DefaultIncrementalTab"); } @@ -517,11 +502,8 @@ internal static void VerifyCaretCharacterHit( int cchLength ) { - if ( characterHit.FirstCharacterIndex < cpFirst - || characterHit.FirstCharacterIndex > cpFirst + cchLength) - { - throw new ArgumentOutOfRangeException("cpFirst", SR.Format(SR.ParameterMustBeBetween, cpFirst, cpFirst + cchLength)); - } + ArgumentOutOfRangeException.ThrowIfGreaterThan(cpFirst, characterHit.FirstCharacterIndex); + ArgumentOutOfRangeException.ThrowIfLessThan(cpFirst, characterHit.FirstCharacterIndex - cchLength); ArgumentOutOfRangeException.ThrowIfNegative(characterHit.TrailingLength, nameof(cchLength)); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/ExceptionStringTable.txt b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/ExceptionStringTable.txt index 973c97b36cc..b906cd7fee6 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/ExceptionStringTable.txt +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/ExceptionStringTable.txt @@ -11,14 +11,6 @@ HwndSourceDisposed=Cannot access a disposed HwndSource. NullHwnd=Hwnd of zero is not valid. UsesPerPixelOpacityIsObsolete=UsesPerPixelOpacity is obsolete and should not be set when using UsesPerPixelTransparency -;ParameterValidation -ParameterMustBeGreaterThanZero=The parameter value must be greater than zero. -ParameterCannotBeLessThan=The parameter value cannot be less than '{0}'. -ParameterCannotBeGreaterThan=The parameter value cannot be greater than '{0}'. -ParameterMustBeBetween=The parameter value must be between '{0}' and '{1}'. -ParameterValueCannotBeInfinity=The parameter value must be finite. -ParameterValueCannotBeNegative='{0}' parameter value cannot be negative. - ; General General_BadType=The object passed to '{0}' is not a valid type. General_Expected_Type=Expected object of type '{0}'. @@ -1031,4 +1023,4 @@ CompatibilityPreferencesSealed=The property '{0}' cannot be changed. The '{1}' c ;Visual Diagnostics MethodCallNotAllowed=The '{0}' method cannot be called at this time. ReentrantVisualTreeChangeWarning=WARNING. The visual tree has been changed during a '{0}' event. This is not supported in a production application. Be sure to correct this before shipping the application. -ReentrantVisualTreeChangeError=The visual tree has been changed during a '{0}' event. \ No newline at end of file +ReentrantVisualTreeChangeError=The visual tree has been changed during a '{0}' event. diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/Strings.resx b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/Strings.resx index f140c96cb8b..c09cd36a28d 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/Strings.resx +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/Strings.resx @@ -1822,15 +1822,6 @@ Page number cannot be negative. - - The parameter value must be between '{0}' and '{1}'. - - - The parameter value must be finite. - - - The parameter value must be a number. - Token is not valid. diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.cs.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.cs.xlf index 932ac4882c9..28182c82b38 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.cs.xlf +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.cs.xlf @@ -2522,21 +2522,6 @@ Číslo stránky nemůže být záporné. - - The parameter value must be between '{0}' and '{1}'. - Hodnota tohoto parametru musí být v rozsahu od {0} do {1}. - - - - The parameter value must be finite. - Hodnota tohoto parametru nesmí být nekonečno. - - - - The parameter value must be a number. - Hodnota tohoto parametru musí být číslo. - - Incorrect form '{0}' found parsing '{1}' string. Nalezena nesprávná forma {0} při analýze řetězce {1}. diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.de.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.de.xlf index 5548e6cd80f..80c833b01b4 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.de.xlf +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.de.xlf @@ -2522,21 +2522,6 @@ Die Seitenzahl kann nicht negativ sein. - - The parameter value must be between '{0}' and '{1}'. - Der Parameterwert muss zwischen "{0}" und "{1}" liegen. - - - - The parameter value must be finite. - Der Parameterwert muss endlich sein. - - - - The parameter value must be a number. - Der Parameterwert muss eine Zahl sein. - - Incorrect form '{0}' found parsing '{1}' string. Beim Analysieren der Zeichenfolge "{1}" wurde die ungültige Form "{0}" gefunden. diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.es.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.es.xlf index 28a0972f048..1c6c639a806 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.es.xlf +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.es.xlf @@ -2522,21 +2522,6 @@ El número de página no puede ser negativo. - - The parameter value must be between '{0}' and '{1}'. - El valor del parámetro debe estar comprendido entre "{0}" y "{1}". - - - - The parameter value must be finite. - El valor del parámetro debe ser finito. - - - - The parameter value must be a number. - El valor del parámetro debe ser un número. - - Incorrect form '{0}' found parsing '{1}' string. Se encontró un formato incorrecto "{0}" al analizar la cadena "{1}". diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.fr.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.fr.xlf index ac298fdf804..9ace80fdde9 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.fr.xlf +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.fr.xlf @@ -2522,21 +2522,6 @@ Le numéro de page ne peut pas être négatif. - - The parameter value must be between '{0}' and '{1}'. - La valeur du paramètre doit être comprise entre '{0}' et '{1}'. - - - - The parameter value must be finite. - La valeur du paramètre doit être finie. - - - - The parameter value must be a number. - La valeur du paramètre doit être numérique. - - Incorrect form '{0}' found parsing '{1}' string. Forme '{0}' incorrecte trouvée durant l'analyse de la chaîne '{1}'. diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.it.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.it.xlf index 904667253e4..941c4337265 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.it.xlf +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.it.xlf @@ -2522,21 +2522,6 @@ Il numero di pagina non può essere negativo. - - The parameter value must be between '{0}' and '{1}'. - Il valore del parametro deve essere compreso tra '{0}' e '{1}'. - - - - The parameter value must be finite. - Il valore del parametro deve essere finito. - - - - The parameter value must be a number. - Il valore del parametro deve essere un numero. - - Incorrect form '{0}' found parsing '{1}' string. È stato trovato un formato non corretto '{0}' durante l'analisi della stringa '{1}'. diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.ja.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.ja.xlf index d70b6a78297..76433580725 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.ja.xlf +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.ja.xlf @@ -2522,21 +2522,6 @@ ページ番号は負の数にできません。 - - The parameter value must be between '{0}' and '{1}'. - パラメーター値は、'{0}' と '{1}' の間である必要があります。 - - - - The parameter value must be finite. - パラメーター値は、有限である必要があります。 - - - - The parameter value must be a number. - パラメーター値は、数値である必要があります。 - - Incorrect form '{0}' found parsing '{1}' string. '{1}' 文字列の解析中に無効なフォーム '{0}' が見つかりました。 diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.ko.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.ko.xlf index 30aa6fae416..c200c38efbb 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.ko.xlf +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.ko.xlf @@ -2522,21 +2522,6 @@ 페이지 번호는 음수일 수 없습니다. - - The parameter value must be between '{0}' and '{1}'. - 매개 변수 값은 '{0}'과(와) '{1}' 사이에 있어야 합니다. - - - - The parameter value must be finite. - 매개 변수는 유한한 값이어야 합니다. - - - - The parameter value must be a number. - 매개 변수 값은 숫자여야 합니다. - - Incorrect form '{0}' found parsing '{1}' string. '{1}' 문자열을 구문 분석하는 동안 잘못된 '{0}' 형식이 검색되었습니다. diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.pl.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.pl.xlf index 7a0da67e3fc..f73dc1738d9 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.pl.xlf +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.pl.xlf @@ -2522,21 +2522,6 @@ Numer strony nie może być ujemny. - - The parameter value must be between '{0}' and '{1}'. - Wartość parametru musi należeć do przedziału od „{0}” do „{1}”. - - - - The parameter value must be finite. - Wartość parametru musi być skończona. - - - - The parameter value must be a number. - Wartość parametru musi być liczbą. - - Incorrect form '{0}' found parsing '{1}' string. Znaleziono nieprawidłową formę „{0}” podczas analizy ciągu „{1}”. diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.pt-BR.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.pt-BR.xlf index 98c91f0574e..9274d41065a 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.pt-BR.xlf +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.pt-BR.xlf @@ -2522,21 +2522,6 @@ O número da página não pode ser negativo. - - The parameter value must be between '{0}' and '{1}'. - O valor do parâmetro precisa estar entre '{0}' e '{1}'. - - - - The parameter value must be finite. - O valor do parâmetro deve ser finito. - - - - The parameter value must be a number. - O valor do parâmetro deve ser um número. - - Incorrect form '{0}' found parsing '{1}' string. Forma incorreta de '{0}' encontrada na análise da cadeia de caracteres '{1}'. diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.ru.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.ru.xlf index d55139f0945..d5bc8ca1928 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.ru.xlf +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.ru.xlf @@ -2522,21 +2522,6 @@ Номер страницы не может быть отрицательным. - - The parameter value must be between '{0}' and '{1}'. - Параметр должен принимать значения от "{0}" до "{1}". - - - - The parameter value must be finite. - Значение параметра должно быть конечным. - - - - The parameter value must be a number. - Значение параметра должно быть числом. - - Incorrect form '{0}' found parsing '{1}' string. При синтаксическом анализе строки "{1}" обнаружена неправильная форма "{0}". diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.tr.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.tr.xlf index 58f5dba646e..a6fcf7b86bd 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.tr.xlf +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.tr.xlf @@ -2522,21 +2522,6 @@ Sayfa numarası negatif olamaz. - - The parameter value must be between '{0}' and '{1}'. - Parametre değeri '{0}' ile '{1}' arasında olmalıdır. - - - - The parameter value must be finite. - Parametre değeri sonlu olmalıdır. - - - - The parameter value must be a number. - Parametre değeri bir sayı olmalıdır. - - Incorrect form '{0}' found parsing '{1}' string. '{1}' dizesi ayrıştırılırken yanlış '{0}' biçimi bulundu. diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.zh-Hans.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.zh-Hans.xlf index 744f5f72318..505815d98d1 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.zh-Hans.xlf @@ -2522,21 +2522,6 @@ 页码不能为负数。 - - The parameter value must be between '{0}' and '{1}'. - 参数值必须介于“{0}”到“{1}”之间。 - - - - The parameter value must be finite. - 参数值必须有限。 - - - - The parameter value must be a number. - 参数值必须是一个数。 - - Incorrect form '{0}' found parsing '{1}' string. 解析“{1}”字符串时发现格式“{0}”错误。 diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.zh-Hant.xlf b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.zh-Hant.xlf index 1bc50bdb567..fbb45eede52 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/Resources/xlf/Strings.zh-Hant.xlf @@ -2522,21 +2522,6 @@ 頁碼不能為負數。 - - The parameter value must be between '{0}' and '{1}'. - 參數值必須介於 '{0}' 到 '{1}' 之間。 - - - - The parameter value must be finite. - 參數值必須有限制。 - - - - The parameter value must be a number. - 參數值必須是數字。 - - Incorrect form '{0}' found parsing '{1}' string. 剖析 '{1}' 字串時發現不正確的格式 '{0}'。 diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/FontStretch.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/FontStretch.cs index b9ea67325a9..ba146b2e0f8 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/FontStretch.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/FontStretch.cs @@ -43,8 +43,8 @@ internal FontStretch(int stretch) // Important note: when changing this method signature please make sure to update FontStretchConverter accordingly. public static FontStretch FromOpenTypeStretch(int stretchValue) { - if (stretchValue < 1 || stretchValue > 9) - throw new ArgumentOutOfRangeException("stretchValue", SR.Format(SR.ParameterMustBeBetween, 1, 9)); + ArgumentOutOfRangeException.ThrowIfLessThan(stretchValue, 1); + ArgumentOutOfRangeException.ThrowIfGreaterThan(stretchValue, 9); return new FontStretch(stretchValue); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/FontWeight.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/FontWeight.cs index d3a550d5fef..a59ccd14e8c 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/FontWeight.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/FontWeight.cs @@ -41,8 +41,8 @@ internal FontWeight(int weight) // Important note: when changing this method signature please make sure to update FontWeightConverter accordingly. public static FontWeight FromOpenTypeWeight(int weightValue) { - if (weightValue < 1 || weightValue > 999) - throw new ArgumentOutOfRangeException("weightValue", SR.Format(SR.ParameterMustBeBetween, 1, 999)); + ArgumentOutOfRangeException.ThrowIfLessThan(weightValue, 1); + ArgumentOutOfRangeException.ThrowIfGreaterThan(weightValue, 999); return new FontWeight(weightValue); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/FormattedText.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/FormattedText.cs index 2002f5c6300..93577a4bdac 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/FormattedText.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/FormattedText.cs @@ -292,9 +292,7 @@ private static void ValidateFontSize(double emSize) { ArgumentOutOfRangeException.ThrowIfNegativeOrZero(emSize); ArgumentOutOfRangeException.ThrowIfGreaterThan(emSize, MaxFontEmSize); - - if (double.IsNaN(emSize)) - throw new ArgumentOutOfRangeException("emSize", SR.ParameterValueCannotBeNaN); + ArgumentOutOfRangeException.ThrowIfEqual(emSize, double.NaN); } private static void ValidateFlowDirection(FlowDirection flowDirection, string parameterName) diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/GlyphRun.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/GlyphRun.cs index 0365e9116a7..f953acf4dc7 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/GlyphRun.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/GlyphRun.cs @@ -453,9 +453,7 @@ TextFormattingMode textFormattingMode } else { - if (double.IsNaN(renderingEmSize)) - throw new ArgumentOutOfRangeException("renderingEmSize", SR.ParameterValueCannotBeNaN); - + ArgumentOutOfRangeException.ThrowIfEqual(renderingEmSize, double.NaN); ArgumentOutOfRangeException.ThrowIfNegative(renderingEmSize); ArgumentNullException.ThrowIfNull(glyphTypeface); ArgumentNullException.ThrowIfNull(glyphIndices); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/JpegBitmapEncoder.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/JpegBitmapEncoder.cs index 80f6d375a37..a01ba35a9e4 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/JpegBitmapEncoder.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/JpegBitmapEncoder.cs @@ -63,10 +63,8 @@ public int QualityLevel } set { - if ((value < 1) || (value > 100)) - { - throw new System.ArgumentOutOfRangeException("value", SR.Format(SR.ParameterMustBeBetween, 1, 100)); - } + ArgumentOutOfRangeException.ThrowIfLessThan(value, 1); + ArgumentOutOfRangeException.ThrowIfGreaterThan(value, 100); _qualityLevel = value; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WmpBitmapEncoder.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WmpBitmapEncoder.cs index 511e7d3be79..dd6eff0f41b 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WmpBitmapEncoder.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WmpBitmapEncoder.cs @@ -63,12 +63,10 @@ public float ImageQualityLevel } set { - if ((value < 0.0) || (value > 1.0)) - { - throw new System.ArgumentOutOfRangeException("value", SR.Format(SR.ParameterMustBeBetween, 0.0, 1.0)); - } + ArgumentOutOfRangeException.ThrowIfNegative(value); + ArgumentOutOfRangeException.ThrowIfGreaterThan(value, 1); - _imagequalitylevel= value; + _imagequalitylevel = value; } } @@ -227,10 +225,7 @@ public byte QualityLevel } set { - if ((value < 1) || (value > 255)) - { - throw new System.ArgumentOutOfRangeException("value", SR.Format(SR.ParameterMustBeBetween, 1, 255)); - } + ArgumentOutOfRangeException.ThrowIfZero(value); _qualitylevel = value; } @@ -248,10 +243,7 @@ public byte SubsamplingLevel } set { - if ((value < 0) || (value > 3)) - { - throw new System.ArgumentOutOfRangeException("value", SR.Format(SR.ParameterMustBeBetween, 0, 3)); - } + ArgumentOutOfRangeException.ThrowIfGreaterThan(value, 3); _subsamplinglevel = value; } @@ -269,10 +261,7 @@ public byte OverlapLevel } set { - if ((value < 0) || (value > 2)) - { - throw new System.ArgumentOutOfRangeException("value", SR.Format(SR.ParameterMustBeBetween, 0, 2)); - } + ArgumentOutOfRangeException.ThrowIfGreaterThan(value, 2); _overlaplevel = value; } @@ -290,10 +279,8 @@ public short HorizontalTileSlices } set { - if ((value < 0) || (value > 4096)) - { - throw new System.ArgumentOutOfRangeException("value", SR.Format(SR.ParameterMustBeBetween, 0, 4096)); - } + ArgumentOutOfRangeException.ThrowIfNegative(value); + ArgumentOutOfRangeException.ThrowIfGreaterThan(value, 4096); _horizontaltileslices = value; } @@ -311,10 +298,8 @@ public short VerticalTileSlices } set { - if ((value < 0) || (value > 4096)) - { - throw new System.ArgumentOutOfRangeException("value", SR.Format(SR.ParameterMustBeBetween, 0, 4096)); - } + ArgumentOutOfRangeException.ThrowIfNegative(value); + ArgumentOutOfRangeException.ThrowIfGreaterThan(value, 4096); _verticaltileslices = value; } @@ -362,11 +347,6 @@ public byte AlphaQualityLevel } set { - if ((value < 0) || (value > 255)) - { - throw new System.ArgumentOutOfRangeException("value", SR.Format(SR.ParameterMustBeBetween, 0, 255)); - } - _alphaqualitylevel = value; } } @@ -398,10 +378,7 @@ public byte ImageDataDiscardLevel } set { - if ((value < 0) || (value > 3)) - { - throw new System.ArgumentOutOfRangeException("value", SR.Format(SR.ParameterMustBeBetween, 0, 3)); - } + ArgumentOutOfRangeException.ThrowIfGreaterThan(value, 3); _imagedatadiscardlevel = value; } @@ -419,10 +396,7 @@ public byte AlphaDataDiscardLevel } set { - if ((value < 0) || (value > 4)) - { - throw new System.ArgumentOutOfRangeException("value", SR.Format(SR.ParameterMustBeBetween, 0, 4)); - } + ArgumentOutOfRangeException.ThrowIfGreaterThan(value, 4); _alphadatadiscardlevel = value; } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WriteableBitmap.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WriteableBitmap.cs index fed100eeecd..b4d9e146f58 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WriteableBitmap.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Imaging/WriteableBitmap.cs @@ -831,92 +831,28 @@ bool backwardsCompat // // Sanitize the source rect and assure it will fit within the back buffer. // - Debug.Assert(!(backwardsCompat && (sourceRect.X < 0 || sourceRect.Y < 0))); + Debug.Assert(!(backwardsCompat && (sourceRect.X < 0 || sourceRect.Y < 0 || sourceRect.Width < 0 || sourceRect.Height < 0))); ArgumentOutOfRangeException.ThrowIfNegative(sourceRect.X, nameof(sourceRect)); ArgumentOutOfRangeException.ThrowIfNegative(sourceRect.Y, nameof(sourceRect)); - - if (sourceRect.Width < 0) - { - Debug.Assert(!backwardsCompat); - throw new ArgumentOutOfRangeException("sourceRect", SR.Format(SR.ParameterMustBeBetween, 0, _pixelWidth)); - } - - if (sourceRect.Width > _pixelWidth) - { - if (backwardsCompat) - { - HRESULT.Check(MS.Win32.NativeMethods.E_INVALIDARG); - } - else - { - throw new ArgumentOutOfRangeException("sourceRect", SR.Format(SR.ParameterMustBeBetween, 0, _pixelWidth)); - } - } - - if (sourceRect.Height < 0) - { - Debug.Assert(!backwardsCompat); - throw new ArgumentOutOfRangeException("sourceRect", SR.Format(SR.ParameterMustBeBetween, 0, _pixelHeight)); - } - - if (sourceRect.Height > _pixelHeight) - { - if (backwardsCompat) - { - HRESULT.Check(MS.Win32.NativeMethods.E_INVALIDARG); - } - else - { - throw new ArgumentOutOfRangeException("sourceRect", SR.Format(SR.ParameterMustBeBetween, 0, _pixelHeight)); - } - } + ArgumentOutOfRangeException.ThrowIfNegative(sourceRect.Width, nameof(sourceRect)); + ArgumentOutOfRangeException.ThrowIfNegative(sourceRect.Height, nameof(sourceRect)); if (!backwardsCompat) { + ArgumentOutOfRangeException.ThrowIfGreaterThan(sourceRect.Width, _pixelWidth, nameof(sourceRect)); + ArgumentOutOfRangeException.ThrowIfGreaterThan(sourceRect.Height, _pixelHeight, nameof(sourceRect)); ArgumentOutOfRangeException.ThrowIfNegative(destinationX); + ArgumentOutOfRangeException.ThrowIfNegative(destinationY); + ArgumentOutOfRangeException.ThrowIfGreaterThan(destinationX, _pixelWidth - sourceRect.Width); + ArgumentOutOfRangeException.ThrowIfGreaterThan(destinationY, _pixelHeight - sourceRect.Height); } - else + else if(sourceRect.Width > _pixelWidth || sourceRect.Height > _pixelHeight || destinationX > _pixelWidth - sourceRect.Width || destinationY > _pixelHeight - sourceRect.Height) { - if (destinationX < 0) - { - HRESULT.Check((int)WinCodecErrors.WINCODEC_ERR_VALUEOVERFLOW); - } - } - - if (destinationX > _pixelWidth - sourceRect.Width) - { - if (backwardsCompat) - { - HRESULT.Check(MS.Win32.NativeMethods.E_INVALIDARG); - } - else - { - throw new ArgumentOutOfRangeException("destinationX", SR.Format(SR.ParameterMustBeBetween, 0, _pixelWidth - sourceRect.Width)); - } - } - - if (destinationY < 0) - { - if (backwardsCompat) - { - HRESULT.Check((int)WinCodecErrors.WINCODEC_ERR_VALUEOVERFLOW); - } - else - { - throw new ArgumentOutOfRangeException("destinationY", SR.Format(SR.ParameterMustBeBetween, 0, _pixelHeight - sourceRect.Height)); - } + HRESULT.Check(MS.Win32.NativeMethods.E_INVALIDARG); } - - if (destinationY > _pixelHeight - sourceRect.Height) + else if (destinationX < 0 || destinationY < 0) { - if (backwardsCompat) - { - HRESULT.Check(MS.Win32.NativeMethods.E_INVALIDARG); - } - else - { - throw new ArgumentOutOfRangeException("destinationY", SR.Format(SR.ParameterMustBeBetween, 0, _pixelHeight - sourceRect.Height)); - } + HRESULT.Check((int)WinCodecErrors.WINCODEC_ERR_VALUEOVERFLOW); } // diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaPlayerState.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaPlayerState.cs index a4e8c451732..de7dcbde464 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaPlayerState.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/MediaPlayerState.cs @@ -262,10 +262,8 @@ internal double Volume set { VerifyAPI(); - if (Double.IsNaN(value)) - { - throw new ArgumentException(SR.ParameterValueCannotBeNaN, "value"); - } + + ArgumentOutOfRangeException.ThrowIfEqual(value, double.NaN); if (DoubleUtil.GreaterThanOrClose(value, 1)) { @@ -312,10 +310,8 @@ internal double Balance set { VerifyAPI(); - if (Double.IsNaN(value)) - { - throw new ArgumentException(SR.ParameterValueCannotBeNaN, "value"); - } + + ArgumentOutOfRangeException.ThrowIfEqual(value, double.NaN); if (DoubleUtil.GreaterThanOrClose(value, 1)) { @@ -932,10 +928,7 @@ private double PrivateSpeedRatio { VerifyAPI(); - if (Double.IsNaN(value)) - { - throw new ArgumentException(SR.ParameterValueCannotBeNaN, "value"); - } + ArgumentOutOfRangeException.ThrowIfEqual(value, double.NaN); HRESULT.Check(MILMedia.SetRate(_nativeMedia, value)); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextParagraphCache.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextParagraphCache.cs index 2f51438c565..0f87b4b7f71 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextParagraphCache.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextParagraphCache.cs @@ -177,20 +177,16 @@ private void Dispose(bool disposing) /// private int VerifyMaxLineWidth(double maxLineWidth) { - if (double.IsNaN(maxLineWidth)) - throw new ArgumentOutOfRangeException("maxLineWidth", SR.ParameterValueCannotBeNaN); + ArgumentOutOfRangeException.ThrowIfEqual(maxLineWidth, double.NaN); if (maxLineWidth == 0 || double.IsPositiveInfinity(maxLineWidth)) { // consider 0 or positive infinity as maximum ideal width return Constants.IdealInfiniteWidth; } - - if ( maxLineWidth < 0 - || maxLineWidth > Constants.RealInfiniteWidth) - { - throw new ArgumentOutOfRangeException("maxLineWidth", SR.Format(SR.ParameterMustBeBetween, 0, Constants.RealInfiniteWidth)); - } + + ArgumentOutOfRangeException.ThrowIfNegative(maxLineWidth); + ArgumentOutOfRangeException.ThrowIfGreaterThan(maxLineWidth, Constants.RealInfiniteWidth); // convert real value to ideal value return TextFormatterImp.RealToIdeal(maxLineWidth); diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/CharacterBuffer.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/CharacterBuffer.cs index dec5d4a7aa2..ac92ec12ec6 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/CharacterBuffer.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Internal/CharacterBuffer.cs @@ -400,8 +400,9 @@ int length public override char this[int characterOffset] { get { - if (characterOffset >= _length || characterOffset < 0) - throw new ArgumentOutOfRangeException("characterOffset", SR.Format(SR.ParameterMustBeBetween,0,_length)); + ArgumentOutOfRangeException.ThrowIfNegative(characterOffset); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(characterOffset, _length); + return _unsafeString[characterOffset]; } set { throw new NotSupportedException(); } @@ -456,15 +457,11 @@ int characterLength ) { - if (characterOffset >= _length || characterOffset < 0) - { - throw new ArgumentOutOfRangeException("characterOffset", SR.Format(SR.ParameterMustBeBetween,0,_length)); - } + ArgumentOutOfRangeException.ThrowIfNegative(characterOffset); + ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(characterOffset, _length); - if (characterLength < 0 || characterOffset + characterLength > _length) - { - throw new ArgumentOutOfRangeException("characterLength", SR.Format(SR.ParameterMustBeBetween,0, _length - characterOffset)); - } + ArgumentOutOfRangeException.ThrowIfNegative(characterLength); + ArgumentOutOfRangeException.ThrowIfGreaterThan(characterLength, _length - characterOffset); stringBuilder.Append(new string(_unsafeString, characterOffset, characterLength)); } diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/Strings.resx b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/Strings.resx index 36c1ffc869f..6a9af6aa942 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/Strings.resx +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/Strings.resx @@ -147,9 +147,6 @@ Value cannot be null. Object reference: '{0}'. - - The parameter value must be between '{0}' and '{1}'. - Handler has not been registered with this event. diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.cs.xlf b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.cs.xlf index 09b764d793f..65a6f5751e6 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.cs.xlf +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.cs.xlf @@ -1292,11 +1292,6 @@ Zadaný objekt odkazu je v konfliktu s předdefinovaným odkazem specifickým pro balíček. - - The parameter value must be between '{0}' and '{1}'. - Hodnota tohoto parametru musí být v rozsahu od {0} do {1}. - - Cannot access part because parent package was closed. K součásti se nedá přistoupit, protože nadřazený balíček se uzavřel. diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.de.xlf b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.de.xlf index 4f02c8dd9a6..105b31f6b97 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.de.xlf +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.de.xlf @@ -1292,11 +1292,6 @@ Das angegebene Verweisobjekt verursacht einen Konflikt mit dem vordefinierten Package-spezifischen Verweis. - - The parameter value must be between '{0}' and '{1}'. - Der Parameterwert muss zwischen "{0}" und "{1}" liegen. - - Cannot access part because parent package was closed. Auf das Teil kann nicht zugegriffen werden, weil das übergeordnete Paket geschlossen wurde. diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.es.xlf b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.es.xlf index 4a8c64fb204..c775efd3f39 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.es.xlf +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.es.xlf @@ -1292,11 +1292,6 @@ El objeto de referencia especificado entra en conflicto con la referencia específica de paquete predefinida. - - The parameter value must be between '{0}' and '{1}'. - El valor del parámetro debe estar comprendido entre "{0}" y "{1}". - - Cannot access part because parent package was closed. No se puede acceder a la parte porque el paquete principal se cerró. diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.fr.xlf b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.fr.xlf index 58a574c1a0b..be6e1a79b3c 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.fr.xlf +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.fr.xlf @@ -1292,11 +1292,6 @@ L'objet de référence spécifié est en conflit avec la référence prédéfinie spécifique au package. - - The parameter value must be between '{0}' and '{1}'. - La valeur du paramètre doit être comprise entre '{0}' et '{1}'. - - Cannot access part because parent package was closed. Impossible d'accéder au composant, car le package parent a été fermé. diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.it.xlf b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.it.xlf index 2d45be21294..65d924e776f 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.it.xlf +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.it.xlf @@ -1292,11 +1292,6 @@ L'oggetto di riferimento specificato è in conflitto con il riferimento predefinito specifico di Package. - - The parameter value must be between '{0}' and '{1}'. - Il valore del parametro deve essere compreso tra '{0}' e '{1}'. - - Cannot access part because parent package was closed. Non è possibile accedere alla parte perché il pacchetto padre è stato chiuso. diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.ja.xlf b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.ja.xlf index ba54a56012a..7c49f0a8aff 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.ja.xlf +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.ja.xlf @@ -1292,11 +1292,6 @@ 指定された参照オブジェクトは、定義済みの Package 固有の参照と競合しています。 - - The parameter value must be between '{0}' and '{1}'. - パラメーター値は、'{0}' と '{1}' の間である必要があります。 - - Cannot access part because parent package was closed. 親パッケージが閉じられたため、パートにアクセスできません。 diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.ko.xlf b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.ko.xlf index 2c5573e3fc7..8f6e3e670fb 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.ko.xlf +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.ko.xlf @@ -1292,11 +1292,6 @@ 지정한 참조 개체가 미리 정의된 Package 특정 참조와 충돌합니다. - - The parameter value must be between '{0}' and '{1}'. - 매개 변수 값은 '{0}'과(와) '{1}' 사이에 있어야 합니다. - - Cannot access part because parent package was closed. 부모 패키지가 닫혔으므로 파트에 액세스할 수 없습니다. diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.pl.xlf b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.pl.xlf index b5d62f4d382..4b88a9f24c2 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.pl.xlf +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.pl.xlf @@ -1292,11 +1292,6 @@ Określony obiekt odwołania wywołuje konflikt ze wstępnie zdefiniowanym odwołaniem specyficznym dla elementu Package. - - The parameter value must be between '{0}' and '{1}'. - Wartość parametru musi należeć do przedziału od „{0}” do „{1}”. - - Cannot access part because parent package was closed. Nie można uzyskać dostępu do części, ponieważ pakiet nadrzędny został zamknięty. diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.pt-BR.xlf b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.pt-BR.xlf index 619e21ba325..a08ff1dc3a1 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.pt-BR.xlf +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.pt-BR.xlf @@ -1292,11 +1292,6 @@ O objeto de referência especificado é conflitante com a referência específica do Pacote predefinida. - - The parameter value must be between '{0}' and '{1}'. - O valor do parâmetro precisa estar entre '{0}' e '{1}'. - - Cannot access part because parent package was closed. Não é possível acessar a parte porque o pacote pai foi fechado. diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.ru.xlf b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.ru.xlf index 4bcb5a9b7dd..ccddfc2af3c 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.ru.xlf +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.ru.xlf @@ -1292,11 +1292,6 @@ Указанный эталонный объект конфликтует с предопределенной ссылкой для заданного пакета. - - The parameter value must be between '{0}' and '{1}'. - Параметр должен принимать значения от "{0}" до "{1}". - - Cannot access part because parent package was closed. Не удается получить доступ к части, так как родительский пакет был закрыт. diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.tr.xlf b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.tr.xlf index 1506d768c62..de6a0e89912 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.tr.xlf +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.tr.xlf @@ -1292,11 +1292,6 @@ Belirtilen başvuru nesnesi önceden tanımlı Pakete özgü başvuru ile çakışıyor. - - The parameter value must be between '{0}' and '{1}'. - Parametre değeri '{0}' ile '{1}' arasında olmalıdır. - - Cannot access part because parent package was closed. Üst paket kapatıldığından bölüme erişilemiyor. diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.zh-Hans.xlf b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.zh-Hans.xlf index 76dce9f4e06..cca31b0bcca 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.zh-Hans.xlf @@ -1292,11 +1292,6 @@ 指定的引用对象与预定义的 Package 专属引用冲突。 - - The parameter value must be between '{0}' and '{1}'. - 参数值必须介于“{0}”到“{1}”之间。 - - Cannot access part because parent package was closed. 由于父包已关闭,因此无法访问部分包。 diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.zh-Hant.xlf b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.zh-Hant.xlf index dd3e7b78159..f2852db8aeb 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/Resources/xlf/Strings.zh-Hant.xlf @@ -1292,11 +1292,6 @@ 指定的參考物件與預先定義的 Package 專屬參考相衝突。 - - The parameter value must be between '{0}' and '{1}'. - 參數值必須介於 '{0}' 到 '{1}' 之間。 - - Cannot access part because parent package was closed. 因為父套件已關閉,所以無法存取組件。 diff --git a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Int32Rect.cs b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Int32Rect.cs index d02044de87a..05154da4654 100644 --- a/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Int32Rect.cs +++ b/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/Windows/Int32Rect.cs @@ -81,16 +81,10 @@ internal void ValidateForDirtyRect(string paramName, int width, int height) { ArgumentOutOfRangeException.ThrowIfNegative(_x, paramName); ArgumentOutOfRangeException.ThrowIfNegative(_y, paramName); - - if (_width < 0 || _width > width) - { - throw new ArgumentOutOfRangeException(paramName, SR.Format(SR.ParameterMustBeBetween, 0, width)); - } - - if (_height < 0 || _height > height) - { - throw new ArgumentOutOfRangeException(paramName, SR.Format(SR.ParameterMustBeBetween, 0, height)); - } + ArgumentOutOfRangeException.ThrowIfNegative(_width, paramName); + ArgumentOutOfRangeException.ThrowIfNegative(_height, paramName); + ArgumentOutOfRangeException.ThrowIfGreaterThan(_width, width, paramName); + ArgumentOutOfRangeException.ThrowIfGreaterThan(_height, height, paramName); } private readonly static Int32Rect s_empty = new Int32Rect(0,0,0,0);