From e632831c09429aaa0ccb18bfc028987247f1e898 Mon Sep 17 00:00:00 2001 From: Hisham Abdullah Bin Ateya Date: Thu, 11 Jun 2015 22:49:17 +0300 Subject: [PATCH] Using [NotNull] --- .../HandshakeHelpers.cs | 8 ++------ src/Microsoft.AspNet.WebSockets.Protocol/project.json | 3 +++ .../BufferStream.cs | 7 ++----- .../project.json | 1 + 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs b/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs index 15998f2afd..b3aa119609 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs +++ b/src/Microsoft.AspNet.WebSockets.Protocol/HandshakeHelpers.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using System.Security.Cryptography; using System.Text; +using Microsoft.Framework.Internal; namespace Microsoft.AspNet.WebSockets.Protocol { @@ -123,13 +124,8 @@ namespace Microsoft.AspNet.WebSockets.Protocol /// /// /// - public static string CreateResponseKey(string requestKey) + public static string CreateResponseKey([NotNull] string requestKey) { - if (string.IsNullOrWhiteSpace(requestKey)) - { - throw new ArgumentNullException("requestKey"); - } - using (var algorithm = SHA1.Create()) { string merged = requestKey + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; diff --git a/src/Microsoft.AspNet.WebSockets.Protocol/project.json b/src/Microsoft.AspNet.WebSockets.Protocol/project.json index b525974346..a0fce33e1d 100644 --- a/src/Microsoft.AspNet.WebSockets.Protocol/project.json +++ b/src/Microsoft.AspNet.WebSockets.Protocol/project.json @@ -1,6 +1,9 @@ { "version": "1.0.0-*", "description": "Managed web socket protocol parser.", + "dependencies": { + "Microsoft.Framework.NotNullAttribute.Internal": { "type": "build", "version": "1.0.0-*" } + }, "frameworks": { "net45": { }, "dnxcore50": { diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs b/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs index ca1c1c969f..e2ff11e792 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/BufferStream.cs @@ -7,6 +7,7 @@ using System.Diagnostics.Contracts; using System.IO; using System.Threading; using System.Threading.Tasks; +using Microsoft.Framework.Internal; namespace Microsoft.AspNet.WebSockets.Protocol.Test { @@ -255,12 +256,8 @@ namespace Microsoft.AspNet.WebSockets.Protocol.Test return Task.FromResult(null); } - private static void VerifyBuffer(byte[] buffer, int offset, int count, bool allowEmpty) + private static void VerifyBuffer([NotNull] byte[] buffer, int offset, int count, bool allowEmpty) { - if (buffer == null) - { - throw new ArgumentNullException("buffer"); - } if (offset < 0 || offset > buffer.Length) { throw new ArgumentOutOfRangeException(nameof(offset), offset, string.Empty); diff --git a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json index 182337015c..86111c50e7 100644 --- a/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json +++ b/test/Microsoft.AspNet.WebSockets.Protocol.Test/project.json @@ -1,6 +1,7 @@ { "dependencies": { "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", + "Microsoft.Framework.NotNullAttribute.Internal": { "type": "build", "version": "1.0.0-*" }, "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "frameworks": {