Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ArgumentNullException.ThrowIfNull() #16684

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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