From e68de43bce316b39a3f956cc86bba1c5d93db236 Mon Sep 17 00:00:00 2001 From: Hisham Abdullah Bin Ateya Date: Thu, 19 Mar 2015 21:37:35 +0300 Subject: [PATCH] Using 'nameof' operator instead of magic strings --- src/Microsoft.AspNet.Session/DistributedSession.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.AspNet.Session/DistributedSession.cs b/src/Microsoft.AspNet.Session/DistributedSession.cs index bc7393a9ca..d77a97a657 100644 --- a/src/Microsoft.AspNet.Session/DistributedSession.cs +++ b/src/Microsoft.AspNet.Session/DistributedSession.cs @@ -60,12 +60,12 @@ namespace Microsoft.AspNet.Session var encodedKey = new EncodedKey(key); if (encodedKey.KeyBytes.Length > KeyLengthLimit) { - throw new ArgumentOutOfRangeException("key", key, + throw new ArgumentOutOfRangeException(nameof(key), string.Format("The key cannot be longer than '{0}' when encoded with UTF-8.", KeyLengthLimit)); } if (value.Array == null) { - throw new ArgumentException("The ArraySegment.Array cannot be null.", "value"); + throw new ArgumentException("The ArraySegment.Array cannot be null.", nameof(value)); } Load(); @@ -174,7 +174,7 @@ namespace Microsoft.AspNet.Session { if (num < 0 || ushort.MaxValue < num) { - throw new ArgumentOutOfRangeException("num", num, "The value cannot be serialized in two bytes."); + throw new ArgumentOutOfRangeException(nameof(num), "The value cannot be serialized in two bytes."); } output.WriteByte((byte)(num >> 8)); output.WriteByte((byte)(0xFF & num)); @@ -189,7 +189,7 @@ namespace Microsoft.AspNet.Session { if (num < 0 || 0xFFFFFF < num) { - throw new ArgumentOutOfRangeException("num", num, "The value cannot be serialized in three bytes."); + throw new ArgumentOutOfRangeException(nameof(num), "The value cannot be serialized in three bytes."); } output.WriteByte((byte)(num >> 16)); output.WriteByte((byte)(0xFF & (num >> 8))); @@ -205,7 +205,7 @@ namespace Microsoft.AspNet.Session { if (num < 0) { - throw new ArgumentOutOfRangeException("num", num, "The value cannot be negative."); + throw new ArgumentOutOfRangeException(nameof(num), "The value cannot be negative."); } output.WriteByte((byte)(num >> 24)); output.WriteByte((byte)(0xFF & (num >> 16)));