Utilize `nameof` operator
This commit is contained in:
parent
7b7667e338
commit
92554fa634
|
|
@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "url");
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(url));
|
||||
}
|
||||
|
||||
Permanent = permanent;
|
||||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "value");
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(value));
|
||||
}
|
||||
|
||||
_url = value;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
if (string.IsNullOrEmpty(formToken))
|
||||
{
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, formToken);
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(formToken));
|
||||
}
|
||||
|
||||
FormToken = formToken;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
if (string.IsNullOrEmpty(areaName))
|
||||
{
|
||||
throw new ArgumentException("Area name must not be empty", "areaName");
|
||||
throw new ArgumentException("Area name must not be empty", nameof(areaName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "url");
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(url));
|
||||
}
|
||||
|
||||
return new RedirectResult(url);
|
||||
|
|
@ -413,7 +413,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "url");
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(url));
|
||||
}
|
||||
|
||||
return new RedirectResult(url, permanent: true);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
if (format == "")
|
||||
{
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "format");
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(format));
|
||||
}
|
||||
|
||||
if (format.StartsWith("."))
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
if (string.IsNullOrEmpty(property))
|
||||
{
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "property");
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(property));
|
||||
}
|
||||
|
||||
var delimitedAdditionalFields = string.Join(",", _additionalFieldsSplit);
|
||||
|
|
@ -180,7 +180,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
{
|
||||
if (string.IsNullOrEmpty(property))
|
||||
{
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "property");
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(property));
|
||||
}
|
||||
|
||||
return "*." + property;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
|||
{
|
||||
if (string.IsNullOrEmpty(tagName))
|
||||
{
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "tagName");
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(tagName));
|
||||
}
|
||||
|
||||
TagName = tagName;
|
||||
|
|
@ -142,7 +142,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
|||
{
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "key");
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(key));
|
||||
}
|
||||
|
||||
if (replaceExisting || !Attributes.ContainsKey(key))
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
|||
{
|
||||
throw new ArgumentException(
|
||||
Resources.FormatUnobtrusiveJavascript_ValidationTypeCannotBeEmpty(rule.GetType().FullName),
|
||||
"rule");
|
||||
nameof(rule));
|
||||
}
|
||||
|
||||
if (resultsDictionary.ContainsKey(dictionaryKey))
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
var message = Resources.FormatRouteConstraintAttribute_InvalidKeyHandlingValue(
|
||||
Enum.GetName(typeof(RouteKeyHandling), RouteKeyHandling.CatchAll),
|
||||
Enum.GetName(typeof(RouteKeyHandling), RouteKeyHandling.DenyKey));
|
||||
throw new ArgumentException(message, "keyHandling");
|
||||
throw new ArgumentException(message, nameof(keyHandling));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
|||
{
|
||||
throw new ArgumentException(
|
||||
Resources.FormatAttributeRoute_DifferentLinkGenerationEntries_SameName(entry.Name),
|
||||
"linkGenerationEntries");
|
||||
nameof(linkGenerationEntries));
|
||||
}
|
||||
else if (namedEntry == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
|||
var message = Resources.FormatBindingSource_CannotBeGreedy(
|
||||
bindingSource.DisplayName,
|
||||
nameof(CompositeBindingSource));
|
||||
throw new ArgumentException(message, "bindingSources");
|
||||
throw new ArgumentException(message, nameof(bindingSources));
|
||||
}
|
||||
|
||||
if (!bindingSource.IsFromRequest)
|
||||
|
|
@ -41,7 +41,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
|||
var message = Resources.FormatBindingSource_MustBeFromRequest(
|
||||
bindingSource.DisplayName,
|
||||
nameof(CompositeBindingSource));
|
||||
throw new ArgumentException(message, "bindingSources");
|
||||
throw new ArgumentException(message, nameof(bindingSources));
|
||||
}
|
||||
|
||||
if (bindingSource is CompositeBindingSource)
|
||||
|
|
@ -49,7 +49,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
|||
var message = Resources.FormatBindingSource_CannotBeComposite(
|
||||
bindingSource.DisplayName,
|
||||
nameof(CompositeBindingSource));
|
||||
throw new ArgumentException(message, "bindingSources");
|
||||
throw new ArgumentException(message, nameof(bindingSources));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Internal
|
|||
{
|
||||
if (bindingContext.ModelMetadata == null)
|
||||
{
|
||||
throw new ArgumentException(Resources.ModelBinderUtil_ModelMetadataCannotBeNull, "bindingContext");
|
||||
throw new ArgumentException(Resources.ModelBinderUtil_ModelMetadataCannotBeNull, nameof(bindingContext));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -78,13 +78,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Internal
|
|||
if (bindingContext.ModelType != requiredType)
|
||||
{
|
||||
var message = Resources.FormatModelBinderUtil_ModelTypeIsWrong(bindingContext.ModelType, requiredType);
|
||||
throw new ArgumentException(message, "bindingContext");
|
||||
throw new ArgumentException(message, nameof(bindingContext));
|
||||
}
|
||||
|
||||
if (!allowNullModel && bindingContext.Model == null)
|
||||
{
|
||||
var message = Resources.FormatModelBinderUtil_ModelCannotBeNull(requiredType);
|
||||
throw new ArgumentException(message, "bindingContext");
|
||||
throw new ArgumentException(message, nameof(bindingContext));
|
||||
}
|
||||
|
||||
if (bindingContext.Model != null &&
|
||||
|
|
@ -93,7 +93,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Internal
|
|||
var message = Resources.FormatModelBinderUtil_ModelInstanceIsWrong(
|
||||
bindingContext.Model.GetType(),
|
||||
requiredType);
|
||||
throw new ArgumentException(message, "bindingContext");
|
||||
throw new ArgumentException(message, nameof(bindingContext));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
|
|||
{
|
||||
if (string.IsNullOrEmpty(ruleName))
|
||||
{
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "ruleName");
|
||||
throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(ruleName));
|
||||
}
|
||||
RuleName = ruleName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Mvc.Razor.Directives
|
|||
if (chunkOfT == null)
|
||||
{
|
||||
var message = Resources.FormatArgumentMustBeOfType(typeof(TChunk).FullName);
|
||||
throw new ArgumentException(message, "chunk");
|
||||
throw new ArgumentException(message, nameof(chunk));
|
||||
}
|
||||
|
||||
return chunkOfT;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim
|
|||
var indexClose = key.IndexOf(']', indexOpen);
|
||||
if (indexClose == -1)
|
||||
{
|
||||
throw new ArgumentException(Resources.JQuerySyntaxMissingClosingBracket, "key");
|
||||
throw new ArgumentException(Resources.JQuerySyntaxMissingClosingBracket, nameof(key));
|
||||
}
|
||||
|
||||
if (indexClose == indexOpen + 1)
|
||||
|
|
|
|||
Loading…
Reference in New Issue