Use nameof operator
This commit is contained in:
parent
6407a1672d
commit
40cfc238fe
|
|
@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Builder
|
|||
{
|
||||
if (pathMatch.HasValue && pathMatch.Value.EndsWith("/", StringComparison.Ordinal))
|
||||
{
|
||||
throw new ArgumentException("The path must not end with a '/'", "pathMatch");
|
||||
throw new ArgumentException("The path must not end with a '/'", nameof(pathMatch));
|
||||
}
|
||||
|
||||
// create branch
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Http
|
|||
{
|
||||
if (!string.IsNullOrEmpty(value) && value[0] != '#')
|
||||
{
|
||||
throw new ArgumentException("The leading '#' must be included for a non-empty fragment.", "value");
|
||||
throw new ArgumentException("The leading '#' must be included for a non-empty fragment.", nameof(value));
|
||||
}
|
||||
_value = value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Http
|
|||
{
|
||||
if (!String.IsNullOrEmpty(value) && value[0] != '/')
|
||||
{
|
||||
throw new ArgumentException(""/*Resources.Exception_PathMustStartWithSlash*/, "value");
|
||||
throw new ArgumentException(""/*Resources.Exception_PathMustStartWithSlash*/, nameof(value));
|
||||
}
|
||||
_value = value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Http
|
|||
{
|
||||
if (!string.IsNullOrEmpty(value) && value[0] != '?')
|
||||
{
|
||||
throw new ArgumentException("The leading '?' must be included for a non-empty query.", "value");
|
||||
throw new ArgumentException("The leading '?' must be included for a non-empty query.", nameof(value));
|
||||
}
|
||||
_value = value;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ namespace Microsoft.AspNet.Http.Internal
|
|||
ThrowIfDisposed();
|
||||
if (value < 0 || value > Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("value", value, "The Position must be within the length of the Stream: " + Length);
|
||||
throw new ArgumentOutOfRangeException(nameof(value), value, "The Position must be within the length of the Stream: " + Length);
|
||||
}
|
||||
VerifyPosition();
|
||||
_position = value;
|
||||
|
|
|
|||
|
|
@ -37,11 +37,11 @@ namespace Microsoft.AspNet.Owin
|
|||
{
|
||||
if (context.GetFeature<IHttpRequestFeature>() == null)
|
||||
{
|
||||
throw new ArgumentException("Missing required feature: " + nameof(IHttpRequestFeature) + ".", "context");
|
||||
throw new ArgumentException("Missing required feature: " + nameof(IHttpRequestFeature) + ".", nameof(context));
|
||||
}
|
||||
if (context.GetFeature<IHttpResponseFeature>() == null)
|
||||
{
|
||||
throw new ArgumentException("Missing required feature: " + nameof(IHttpResponseFeature) + ".", "context");
|
||||
throw new ArgumentException("Missing required feature: " + nameof(IHttpResponseFeature) + ".", nameof(context));
|
||||
}
|
||||
|
||||
_context = context;
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ namespace Microsoft.AspNet.Owin
|
|||
{
|
||||
if (arrayIndex < 0 || arrayIndex > array.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("arrayIndex", arrayIndex, string.Empty);
|
||||
throw new ArgumentOutOfRangeException(nameof(arrayIndex), arrayIndex, string.Empty);
|
||||
}
|
||||
var keys = Keys;
|
||||
if (keys.Count > array.Length - arrayIndex)
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ namespace Microsoft.AspNet.Owin
|
|||
case 0x8:
|
||||
return WebSocketMessageType.Close;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException("messageType", messageType, string.Empty);
|
||||
throw new ArgumentOutOfRangeException(nameof(messageType), messageType, string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -184,7 +184,7 @@ namespace Microsoft.AspNet.Owin
|
|||
case WebSocketMessageType.Close:
|
||||
return 0x8;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException("webSocketMessageType", webSocketMessageType, string.Empty);
|
||||
throw new ArgumentOutOfRangeException(nameof(webSocketMessageType), webSocketMessageType, string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ namespace Microsoft.AspNet.WebUtilities
|
|||
{
|
||||
if (value < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("value", value, "Position must be positive.");
|
||||
throw new ArgumentOutOfRangeException(nameof(value), value, "Position must be positive.");
|
||||
}
|
||||
if (value == Position)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -70,11 +70,11 @@ namespace Microsoft.AspNet.WebUtilities
|
|||
{
|
||||
if (value < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("value", value, "The Position must be positive.");
|
||||
throw new ArgumentOutOfRangeException(nameof(value), value, "The Position must be positive.");
|
||||
}
|
||||
if (value > _observedLength)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("value", value, "The Position must be less than length.");
|
||||
throw new ArgumentOutOfRangeException(nameof(value), value, "The Position must be less than length.");
|
||||
}
|
||||
_position = value;
|
||||
if (_position < _observedLength)
|
||||
|
|
|
|||
|
|
@ -175,11 +175,11 @@ namespace Microsoft.AspNet.WebUtilities
|
|||
{
|
||||
if (offset < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("offset");
|
||||
throw new ArgumentOutOfRangeException(nameof(offset));
|
||||
}
|
||||
if (count < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("count");
|
||||
throw new ArgumentOutOfRangeException(nameof(count));
|
||||
}
|
||||
if (bufferLength - offset < count)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ namespace Microsoft.Net.Http.Headers
|
|||
}
|
||||
else if (value < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("value");
|
||||
throw new ArgumentOutOfRangeException(nameof(value));
|
||||
}
|
||||
else if (sizeParameter != null)
|
||||
{
|
||||
|
|
@ -656,7 +656,7 @@ namespace Microsoft.Net.Http.Headers
|
|||
{
|
||||
if ((index < 0) || (index >= pattern.Length))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("index");
|
||||
throw new ArgumentOutOfRangeException(nameof(index));
|
||||
}
|
||||
if ((pattern[index] == '%')
|
||||
&& (pattern.Length - index >= 3))
|
||||
|
|
|
|||
|
|
@ -29,15 +29,15 @@ namespace Microsoft.Net.Http.Headers
|
|||
|
||||
if (length < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("length");
|
||||
throw new ArgumentOutOfRangeException(nameof(length));
|
||||
}
|
||||
if ((to < 0) || (to > length))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("to");
|
||||
throw new ArgumentOutOfRangeException(nameof(to));
|
||||
}
|
||||
if ((from < 0) || (from > to))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("from");
|
||||
throw new ArgumentOutOfRangeException(nameof(from));
|
||||
}
|
||||
|
||||
_from = from;
|
||||
|
|
@ -52,7 +52,7 @@ namespace Microsoft.Net.Http.Headers
|
|||
|
||||
if (length < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("length");
|
||||
throw new ArgumentOutOfRangeException(nameof(length));
|
||||
}
|
||||
|
||||
_length = length;
|
||||
|
|
@ -65,11 +65,11 @@ namespace Microsoft.Net.Http.Headers
|
|||
|
||||
if (to < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("to");
|
||||
throw new ArgumentOutOfRangeException(nameof(to));
|
||||
}
|
||||
if ((from < 0) || (from > to))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("from");
|
||||
throw new ArgumentOutOfRangeException(nameof(@from));
|
||||
}
|
||||
|
||||
_from = from;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace Microsoft.Net.Http.Headers
|
|||
{
|
||||
if (string.IsNullOrEmpty(tag))
|
||||
{
|
||||
throw new ArgumentException("An empty string is not allowed.", "tag");
|
||||
throw new ArgumentException("An empty string is not allowed.", nameof(tag));
|
||||
}
|
||||
|
||||
int length = 0;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace Microsoft.Net.Http.Headers
|
|||
// value.
|
||||
if ((value < 0) || (value > 1))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("value");
|
||||
throw new ArgumentOutOfRangeException(nameof(value));
|
||||
}
|
||||
|
||||
var qualityString = ((double)value).ToString("0.0##", NumberFormatInfo.InvariantInfo);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ namespace Microsoft.Net.Http.Headers
|
|||
// null values cannot be added to the collection.
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException("item");
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace Microsoft.Net.Http.Headers
|
|||
{
|
||||
if (entityTag == null)
|
||||
{
|
||||
throw new ArgumentNullException("entityTag");
|
||||
throw new ArgumentNullException(nameof(entityTag));
|
||||
}
|
||||
|
||||
_entityTag = entityTag;
|
||||
|
|
|
|||
|
|
@ -21,15 +21,15 @@ namespace Microsoft.Net.Http.Headers
|
|||
}
|
||||
if (from.HasValue && (from.Value < 0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("from");
|
||||
throw new ArgumentOutOfRangeException(nameof(from));
|
||||
}
|
||||
if (to.HasValue && (to.Value < 0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("to");
|
||||
throw new ArgumentOutOfRangeException(nameof(to));
|
||||
}
|
||||
if (from.HasValue && to.HasValue && (from.Value > to.Value))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("from");
|
||||
throw new ArgumentOutOfRangeException(nameof(from));
|
||||
}
|
||||
|
||||
_from = from;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace Microsoft.Net.Http.Headers
|
|||
|
||||
if ((quality < 0) || (quality > 1))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("quality");
|
||||
throw new ArgumentOutOfRangeException(nameof(quality));
|
||||
}
|
||||
|
||||
_value = value;
|
||||
|
|
|
|||
Loading…
Reference in New Issue