Skip to content

Commit

Permalink
Use ArgumentNullException.ThrowIfNull() (#16684)
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamco authored Sep 6, 2024
1 parent 0eb711a commit 5400486
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ public static class HtmlLocalizerExtensions
/// <param name="arguments">The parameters used in the key.</param>
public static LocalizedHtmlString Plural(this IHtmlLocalizer localizer, int count, string singular, string plural, params object[] arguments)
{
if (plural == null)
{
throw new ArgumentNullException(nameof(plural), "Plural text can't be null. If you don't want to specify the plural text, use IStringLocalizer without Plural extension.");
}
ArgumentNullException.ThrowIfNull(plural);

return localizer[singular, new PluralizationArgument { Count = count, Forms = [singular, plural], Arguments = arguments }];
}
Expand All @@ -34,10 +31,7 @@ public static LocalizedHtmlString Plural(this IHtmlLocalizer localizer, int coun
/// <param name="arguments">The parameters used in the key.</param>
public static LocalizedHtmlString Plural(this IHtmlLocalizer localizer, int count, string[] pluralForms, params object[] arguments)
{
if (pluralForms == null)
{
throw new ArgumentNullException(nameof(pluralForms), "PluralForms array can't be null. If you don't want to specify the plural text, use IStringLocalizer without Plural extension.");
}
ArgumentNullException.ThrowIfNull(pluralForms);

if (pluralForms.Length == 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ public static class StringLocalizerExtensions
/// <param name="arguments">The parameters used in the key.</param>
public static LocalizedString Plural(this IStringLocalizer localizer, int count, string singular, string plural, params object[] arguments)
{
if (plural == null)
{
throw new ArgumentNullException(nameof(plural), "Plural text can't be null. If you don't want to specify the plural text, use IStringLocalizer without Plural extension.");
}
ArgumentNullException.ThrowIfNull(plural);

return localizer[singular, new PluralizationArgument { Count = count, Forms = [singular, plural], Arguments = arguments }];
}
Expand All @@ -34,10 +31,7 @@ public static LocalizedString Plural(this IStringLocalizer localizer, int count,
/// <param name="arguments">The parameters used in the key.</param>
public static LocalizedString Plural(this IStringLocalizer localizer, int count, string[] pluralForms, params object[] arguments)
{
if (pluralForms == null)
{
throw new ArgumentNullException(nameof(pluralForms), "PluralForms array can't be null. If you don't want to specify the plural text, use IStringLocalizer without Plural extension.");
}
ArgumentNullException.ThrowIfNull(pluralForms);

if (pluralForms.Length == 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ public static class ViewLocalizerExtensions
/// <returns></returns>
public static LocalizedHtmlString Plural(this IViewLocalizer localizer, int count, string singular, string plural, params object[] arguments)
{
if (plural == null)
{
throw new ArgumentNullException(nameof(plural), "Plural text can't be null. If you don't want to specify the plural text, use IStringLocalizer without Plural extension.");
}
ArgumentNullException.ThrowIfNull(plural);

return localizer[singular, new PluralizationArgument { Count = count, Forms = [singular, plural], Arguments = arguments }];
}
Expand All @@ -35,10 +32,7 @@ public static LocalizedHtmlString Plural(this IViewLocalizer localizer, int coun
/// <param name="arguments">The parameters used in the key.</param>
public static LocalizedHtmlString Plural(this IViewLocalizer localizer, int count, string[] pluralForms, params object[] arguments)
{
if (pluralForms == null)
{
throw new ArgumentNullException(nameof(pluralForms), "PluralForms array can't be null. If you don't want to specify the plural text, use IStringLocalizer without Plural extension.");
}
ArgumentNullException.ThrowIfNull(pluralForms);

if (pluralForms.Length == 0)
{
Expand Down

0 comments on commit 5400486

Please sign in to comment.