From 40cfc238fe9f855645107d4a7c057deb29e899ce Mon Sep 17 00:00:00 2001 From: Henk Mollema Date: Thu, 4 Jun 2015 14:54:30 +0200 Subject: [PATCH] Use nameof operator --- .../Extensions/MapExtensions.cs | 2 +- .../FragmentString.cs | 2 +- src/Microsoft.AspNet.Http.Abstractions/PathString.cs | 2 +- .../QueryString.cs | 2 +- src/Microsoft.AspNet.Http/ReferenceReadStream.cs | 2 +- src/Microsoft.AspNet.Owin/OwinEnvironment.cs | 4 ++-- src/Microsoft.AspNet.Owin/OwinFeatureCollection.cs | 2 +- .../WebSockets/OwinWebSocketAdapter.cs | 4 ++-- .../BufferedReadStream.cs | 2 +- .../MultipartReaderStream.cs | 4 ++-- src/Microsoft.AspNet.WebUtilities/WebEncoders.cs | 4 ++-- .../ContentDispositionHeaderValue.cs | 4 ++-- .../ContentRangeHeaderValue.cs | 12 ++++++------ .../EntityTagHeaderValue.cs | 2 +- src/Microsoft.Net.Http.Headers/HeaderUtilities.cs | 2 +- src/Microsoft.Net.Http.Headers/ObjectCollection.cs | 2 +- .../RangeConditionHeaderValue.cs | 2 +- .../RangeItemHeaderValue.cs | 6 +++--- .../StringWithQualityHeaderValue.cs | 2 +- 19 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/Microsoft.AspNet.Http.Abstractions/Extensions/MapExtensions.cs b/src/Microsoft.AspNet.Http.Abstractions/Extensions/MapExtensions.cs index 8885632152..3af199d519 100644 --- a/src/Microsoft.AspNet.Http.Abstractions/Extensions/MapExtensions.cs +++ b/src/Microsoft.AspNet.Http.Abstractions/Extensions/MapExtensions.cs @@ -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 diff --git a/src/Microsoft.AspNet.Http.Abstractions/FragmentString.cs b/src/Microsoft.AspNet.Http.Abstractions/FragmentString.cs index 3e5544407b..794b800b63 100644 --- a/src/Microsoft.AspNet.Http.Abstractions/FragmentString.cs +++ b/src/Microsoft.AspNet.Http.Abstractions/FragmentString.cs @@ -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; } diff --git a/src/Microsoft.AspNet.Http.Abstractions/PathString.cs b/src/Microsoft.AspNet.Http.Abstractions/PathString.cs index 7bc00e6ab1..62cfd74bd6 100644 --- a/src/Microsoft.AspNet.Http.Abstractions/PathString.cs +++ b/src/Microsoft.AspNet.Http.Abstractions/PathString.cs @@ -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; } diff --git a/src/Microsoft.AspNet.Http.Abstractions/QueryString.cs b/src/Microsoft.AspNet.Http.Abstractions/QueryString.cs index 7ad1300622..8717638aa5 100644 --- a/src/Microsoft.AspNet.Http.Abstractions/QueryString.cs +++ b/src/Microsoft.AspNet.Http.Abstractions/QueryString.cs @@ -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; } diff --git a/src/Microsoft.AspNet.Http/ReferenceReadStream.cs b/src/Microsoft.AspNet.Http/ReferenceReadStream.cs index 6fa2c34f04..87f2959eef 100644 --- a/src/Microsoft.AspNet.Http/ReferenceReadStream.cs +++ b/src/Microsoft.AspNet.Http/ReferenceReadStream.cs @@ -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; diff --git a/src/Microsoft.AspNet.Owin/OwinEnvironment.cs b/src/Microsoft.AspNet.Owin/OwinEnvironment.cs index 96102f6bf4..b96396f73a 100644 --- a/src/Microsoft.AspNet.Owin/OwinEnvironment.cs +++ b/src/Microsoft.AspNet.Owin/OwinEnvironment.cs @@ -37,11 +37,11 @@ namespace Microsoft.AspNet.Owin { if (context.GetFeature() == null) { - throw new ArgumentException("Missing required feature: " + nameof(IHttpRequestFeature) + ".", "context"); + throw new ArgumentException("Missing required feature: " + nameof(IHttpRequestFeature) + ".", nameof(context)); } if (context.GetFeature() == null) { - throw new ArgumentException("Missing required feature: " + nameof(IHttpResponseFeature) + ".", "context"); + throw new ArgumentException("Missing required feature: " + nameof(IHttpResponseFeature) + ".", nameof(context)); } _context = context; diff --git a/src/Microsoft.AspNet.Owin/OwinFeatureCollection.cs b/src/Microsoft.AspNet.Owin/OwinFeatureCollection.cs index b54f38b69a..ec50c50928 100644 --- a/src/Microsoft.AspNet.Owin/OwinFeatureCollection.cs +++ b/src/Microsoft.AspNet.Owin/OwinFeatureCollection.cs @@ -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) diff --git a/src/Microsoft.AspNet.Owin/WebSockets/OwinWebSocketAdapter.cs b/src/Microsoft.AspNet.Owin/WebSockets/OwinWebSocketAdapter.cs index bdaeef8eda..4a7a056463 100644 --- a/src/Microsoft.AspNet.Owin/WebSockets/OwinWebSocketAdapter.cs +++ b/src/Microsoft.AspNet.Owin/WebSockets/OwinWebSocketAdapter.cs @@ -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); } } } diff --git a/src/Microsoft.AspNet.WebUtilities/BufferedReadStream.cs b/src/Microsoft.AspNet.WebUtilities/BufferedReadStream.cs index 0b3ec59363..94bb03efce 100644 --- a/src/Microsoft.AspNet.WebUtilities/BufferedReadStream.cs +++ b/src/Microsoft.AspNet.WebUtilities/BufferedReadStream.cs @@ -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) { diff --git a/src/Microsoft.AspNet.WebUtilities/MultipartReaderStream.cs b/src/Microsoft.AspNet.WebUtilities/MultipartReaderStream.cs index 02d99a33d4..5e3059280d 100644 --- a/src/Microsoft.AspNet.WebUtilities/MultipartReaderStream.cs +++ b/src/Microsoft.AspNet.WebUtilities/MultipartReaderStream.cs @@ -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) diff --git a/src/Microsoft.AspNet.WebUtilities/WebEncoders.cs b/src/Microsoft.AspNet.WebUtilities/WebEncoders.cs index bef8b5463a..132f106e07 100644 --- a/src/Microsoft.AspNet.WebUtilities/WebEncoders.cs +++ b/src/Microsoft.AspNet.WebUtilities/WebEncoders.cs @@ -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) { diff --git a/src/Microsoft.Net.Http.Headers/ContentDispositionHeaderValue.cs b/src/Microsoft.Net.Http.Headers/ContentDispositionHeaderValue.cs index b6b1aabe8c..25fe03cd9a 100644 --- a/src/Microsoft.Net.Http.Headers/ContentDispositionHeaderValue.cs +++ b/src/Microsoft.Net.Http.Headers/ContentDispositionHeaderValue.cs @@ -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)) diff --git a/src/Microsoft.Net.Http.Headers/ContentRangeHeaderValue.cs b/src/Microsoft.Net.Http.Headers/ContentRangeHeaderValue.cs index 634278e3a9..abce604280 100644 --- a/src/Microsoft.Net.Http.Headers/ContentRangeHeaderValue.cs +++ b/src/Microsoft.Net.Http.Headers/ContentRangeHeaderValue.cs @@ -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; diff --git a/src/Microsoft.Net.Http.Headers/EntityTagHeaderValue.cs b/src/Microsoft.Net.Http.Headers/EntityTagHeaderValue.cs index 4cc5c38dfa..216fa942a8 100644 --- a/src/Microsoft.Net.Http.Headers/EntityTagHeaderValue.cs +++ b/src/Microsoft.Net.Http.Headers/EntityTagHeaderValue.cs @@ -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; diff --git a/src/Microsoft.Net.Http.Headers/HeaderUtilities.cs b/src/Microsoft.Net.Http.Headers/HeaderUtilities.cs index d344d992aa..e42240a1dd 100644 --- a/src/Microsoft.Net.Http.Headers/HeaderUtilities.cs +++ b/src/Microsoft.Net.Http.Headers/HeaderUtilities.cs @@ -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); diff --git a/src/Microsoft.Net.Http.Headers/ObjectCollection.cs b/src/Microsoft.Net.Http.Headers/ObjectCollection.cs index 6ec2883d3b..90e7718c4c 100644 --- a/src/Microsoft.Net.Http.Headers/ObjectCollection.cs +++ b/src/Microsoft.Net.Http.Headers/ObjectCollection.cs @@ -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)); } } } diff --git a/src/Microsoft.Net.Http.Headers/RangeConditionHeaderValue.cs b/src/Microsoft.Net.Http.Headers/RangeConditionHeaderValue.cs index 189d775d61..c564722d51 100644 --- a/src/Microsoft.Net.Http.Headers/RangeConditionHeaderValue.cs +++ b/src/Microsoft.Net.Http.Headers/RangeConditionHeaderValue.cs @@ -28,7 +28,7 @@ namespace Microsoft.Net.Http.Headers { if (entityTag == null) { - throw new ArgumentNullException("entityTag"); + throw new ArgumentNullException(nameof(entityTag)); } _entityTag = entityTag; diff --git a/src/Microsoft.Net.Http.Headers/RangeItemHeaderValue.cs b/src/Microsoft.Net.Http.Headers/RangeItemHeaderValue.cs index f4893ba5dc..772a1c923a 100644 --- a/src/Microsoft.Net.Http.Headers/RangeItemHeaderValue.cs +++ b/src/Microsoft.Net.Http.Headers/RangeItemHeaderValue.cs @@ -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; diff --git a/src/Microsoft.Net.Http.Headers/StringWithQualityHeaderValue.cs b/src/Microsoft.Net.Http.Headers/StringWithQualityHeaderValue.cs index e845c84fe8..ab33ba4a0f 100644 --- a/src/Microsoft.Net.Http.Headers/StringWithQualityHeaderValue.cs +++ b/src/Microsoft.Net.Http.Headers/StringWithQualityHeaderValue.cs @@ -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;