Use nameof operator

This commit is contained in:
Henk Mollema 2015-06-04 14:54:30 +02:00
parent 6407a1672d
commit 40cfc238fe
19 changed files with 31 additions and 31 deletions

View File

@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Builder
{ {
if (pathMatch.HasValue && pathMatch.Value.EndsWith("/", StringComparison.Ordinal)) 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 // create branch

View File

@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Http
{ {
if (!string.IsNullOrEmpty(value) && value[0] != '#') 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; _value = value;
} }

View File

@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Http
{ {
if (!String.IsNullOrEmpty(value) && value[0] != '/') if (!String.IsNullOrEmpty(value) && value[0] != '/')
{ {
throw new ArgumentException(""/*Resources.Exception_PathMustStartWithSlash*/, "value"); throw new ArgumentException(""/*Resources.Exception_PathMustStartWithSlash*/, nameof(value));
} }
_value = value; _value = value;
} }

View File

@ -30,7 +30,7 @@ namespace Microsoft.AspNet.Http
{ {
if (!string.IsNullOrEmpty(value) && value[0] != '?') 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; _value = value;
} }

View File

@ -57,7 +57,7 @@ namespace Microsoft.AspNet.Http.Internal
ThrowIfDisposed(); ThrowIfDisposed();
if (value < 0 || value > Length) 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(); VerifyPosition();
_position = value; _position = value;

View File

@ -37,11 +37,11 @@ namespace Microsoft.AspNet.Owin
{ {
if (context.GetFeature<IHttpRequestFeature>() == null) 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) 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; _context = context;

View File

@ -411,7 +411,7 @@ namespace Microsoft.AspNet.Owin
{ {
if (arrayIndex < 0 || arrayIndex > array.Length) if (arrayIndex < 0 || arrayIndex > array.Length)
{ {
throw new ArgumentOutOfRangeException("arrayIndex", arrayIndex, string.Empty); throw new ArgumentOutOfRangeException(nameof(arrayIndex), arrayIndex, string.Empty);
} }
var keys = Keys; var keys = Keys;
if (keys.Count > array.Length - arrayIndex) if (keys.Count > array.Length - arrayIndex)

View File

@ -169,7 +169,7 @@ namespace Microsoft.AspNet.Owin
case 0x8: case 0x8:
return WebSocketMessageType.Close; return WebSocketMessageType.Close;
default: 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: case WebSocketMessageType.Close:
return 0x8; return 0x8;
default: default:
throw new ArgumentOutOfRangeException("webSocketMessageType", webSocketMessageType, string.Empty); throw new ArgumentOutOfRangeException(nameof(webSocketMessageType), webSocketMessageType, string.Empty);
} }
} }
} }

View File

@ -64,7 +64,7 @@ namespace Microsoft.AspNet.WebUtilities
{ {
if (value < 0) 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) if (value == Position)
{ {

View File

@ -70,11 +70,11 @@ namespace Microsoft.AspNet.WebUtilities
{ {
if (value < 0) 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) 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; _position = value;
if (_position < _observedLength) if (_position < _observedLength)

View File

@ -175,11 +175,11 @@ namespace Microsoft.AspNet.WebUtilities
{ {
if (offset < 0) if (offset < 0)
{ {
throw new ArgumentOutOfRangeException("offset"); throw new ArgumentOutOfRangeException(nameof(offset));
} }
if (count < 0) if (count < 0)
{ {
throw new ArgumentOutOfRangeException("count"); throw new ArgumentOutOfRangeException(nameof(count));
} }
if (bufferLength - offset < count) if (bufferLength - offset < count)
{ {

View File

@ -127,7 +127,7 @@ namespace Microsoft.Net.Http.Headers
} }
else if (value < 0) else if (value < 0)
{ {
throw new ArgumentOutOfRangeException("value"); throw new ArgumentOutOfRangeException(nameof(value));
} }
else if (sizeParameter != null) else if (sizeParameter != null)
{ {
@ -656,7 +656,7 @@ namespace Microsoft.Net.Http.Headers
{ {
if ((index < 0) || (index >= pattern.Length)) if ((index < 0) || (index >= pattern.Length))
{ {
throw new ArgumentOutOfRangeException("index"); throw new ArgumentOutOfRangeException(nameof(index));
} }
if ((pattern[index] == '%') if ((pattern[index] == '%')
&& (pattern.Length - index >= 3)) && (pattern.Length - index >= 3))

View File

@ -29,15 +29,15 @@ namespace Microsoft.Net.Http.Headers
if (length < 0) if (length < 0)
{ {
throw new ArgumentOutOfRangeException("length"); throw new ArgumentOutOfRangeException(nameof(length));
} }
if ((to < 0) || (to > length)) if ((to < 0) || (to > length))
{ {
throw new ArgumentOutOfRangeException("to"); throw new ArgumentOutOfRangeException(nameof(to));
} }
if ((from < 0) || (from > to)) if ((from < 0) || (from > to))
{ {
throw new ArgumentOutOfRangeException("from"); throw new ArgumentOutOfRangeException(nameof(from));
} }
_from = from; _from = from;
@ -52,7 +52,7 @@ namespace Microsoft.Net.Http.Headers
if (length < 0) if (length < 0)
{ {
throw new ArgumentOutOfRangeException("length"); throw new ArgumentOutOfRangeException(nameof(length));
} }
_length = length; _length = length;
@ -65,11 +65,11 @@ namespace Microsoft.Net.Http.Headers
if (to < 0) if (to < 0)
{ {
throw new ArgumentOutOfRangeException("to"); throw new ArgumentOutOfRangeException(nameof(to));
} }
if ((from < 0) || (from > to)) if ((from < 0) || (from > to))
{ {
throw new ArgumentOutOfRangeException("from"); throw new ArgumentOutOfRangeException(nameof(@from));
} }
_from = from; _from = from;

View File

@ -39,7 +39,7 @@ namespace Microsoft.Net.Http.Headers
{ {
if (string.IsNullOrEmpty(tag)) 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; int length = 0;

View File

@ -27,7 +27,7 @@ namespace Microsoft.Net.Http.Headers
// value. // value.
if ((value < 0) || (value > 1)) if ((value < 0) || (value > 1))
{ {
throw new ArgumentOutOfRangeException("value"); throw new ArgumentOutOfRangeException(nameof(value));
} }
var qualityString = ((double)value).ToString("0.0##", NumberFormatInfo.InvariantInfo); var qualityString = ((double)value).ToString("0.0##", NumberFormatInfo.InvariantInfo);

View File

@ -49,7 +49,7 @@ namespace Microsoft.Net.Http.Headers
// null values cannot be added to the collection. // null values cannot be added to the collection.
if (item == null) if (item == null)
{ {
throw new ArgumentNullException("item"); throw new ArgumentNullException(nameof(item));
} }
} }
} }

View File

@ -28,7 +28,7 @@ namespace Microsoft.Net.Http.Headers
{ {
if (entityTag == null) if (entityTag == null)
{ {
throw new ArgumentNullException("entityTag"); throw new ArgumentNullException(nameof(entityTag));
} }
_entityTag = entityTag; _entityTag = entityTag;

View File

@ -21,15 +21,15 @@ namespace Microsoft.Net.Http.Headers
} }
if (from.HasValue && (from.Value < 0)) if (from.HasValue && (from.Value < 0))
{ {
throw new ArgumentOutOfRangeException("from"); throw new ArgumentOutOfRangeException(nameof(from));
} }
if (to.HasValue && (to.Value < 0)) if (to.HasValue && (to.Value < 0))
{ {
throw new ArgumentOutOfRangeException("to"); throw new ArgumentOutOfRangeException(nameof(to));
} }
if (from.HasValue && to.HasValue && (from.Value > to.Value)) if (from.HasValue && to.HasValue && (from.Value > to.Value))
{ {
throw new ArgumentOutOfRangeException("from"); throw new ArgumentOutOfRangeException(nameof(from));
} }
_from = from; _from = from;

View File

@ -36,7 +36,7 @@ namespace Microsoft.Net.Http.Headers
if ((quality < 0) || (quality > 1)) if ((quality < 0) || (quality > 1))
{ {
throw new ArgumentOutOfRangeException("quality"); throw new ArgumentOutOfRangeException(nameof(quality));
} }
_value = value; _value = value;