Using 'nameof' operator instead of magic strings

This commit is contained in:
Hisham Abdullah Bin Ateya 2015-06-11 22:44:11 +03:00
parent c86b157ad3
commit 208fa4af36
2 changed files with 6 additions and 6 deletions

View File

@ -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);
}
}

View File

@ -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);
}
}