From 208fa4af366e23b51f2b943f709e00b6d48eec22 Mon Sep 17 00:00:00 2001 From: Hisham Abdullah Bin Ateya Date: Thu, 11 Jun 2015 22:44:11 +0300 Subject: [PATCH] Using 'nameof' operator instead of magic strings --- .../CommonWebSocket.cs | 8 ++++---- .../BufferStream.cs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs index ea74b29133..02a040af77 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/CommonWebSocket.cs @@ -117,7 +117,7 @@ namespace Microsoft.AspNet.WebSockets.Protocol if (messageType != WebSocketMessageType.Binary && messageType != WebSocketMessageType.Text) { // Block control frames - throw new ArgumentOutOfRangeException("messageType", messageType, string.Empty); + throw new ArgumentOutOfRangeException(nameof(messageType), messageType, string.Empty); } // Check concurrent writes, pings & pongs, or closes @@ -588,15 +588,15 @@ namespace Microsoft.AspNet.WebSockets.Protocol { if (buffer.Array == null) { - throw new ArgumentNullException("buffer"); + throw new ArgumentNullException(nameof(buffer)); } if (buffer.Offset < 0 || buffer.Offset > buffer.Array.Length) { - throw new ArgumentOutOfRangeException("buffer.Offset", buffer.Offset, string.Empty); + throw new ArgumentOutOfRangeException(nameof(buffer.Offset), buffer.Offset, string.Empty); } if (buffer.Count < 0 || buffer.Count > buffer.Array.Length - buffer.Offset) { - throw new ArgumentOutOfRangeException("buffer.Count", buffer.Count, string.Empty); + throw new ArgumentOutOfRangeException(nameof(buffer.Count), buffer.Count, string.Empty); } } diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs index 556bb42052..ca1c1c969f 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs @@ -263,12 +263,12 @@ namespace Microsoft.AspNet.WebSockets.Protocol.Test } if (offset < 0 || offset > buffer.Length) { - throw new ArgumentOutOfRangeException("offset", offset, string.Empty); + throw new ArgumentOutOfRangeException(nameof(offset), offset, string.Empty); } if (count < 0 || count > buffer.Length - offset || (!allowEmpty && count == 0)) { - throw new ArgumentOutOfRangeException("count", count, string.Empty); + throw new ArgumentOutOfRangeException(nameof(count), count, string.Empty); } }