Using [NotNull]

This commit is contained in:
Hisham Abdullah Bin Ateya 2015-06-11 22:49:17 +03:00
parent 208fa4af36
commit e632831c09
4 changed files with 8 additions and 11 deletions

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.WebSockets.Protocol namespace Microsoft.AspNet.WebSockets.Protocol
{ {
@ -123,13 +124,8 @@ namespace Microsoft.AspNet.WebSockets.Protocol
/// </summary> /// </summary>
/// <param name="requestKey"></param> /// <param name="requestKey"></param>
/// <returns></returns> /// <returns></returns>
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()) using (var algorithm = SHA1.Create())
{ {
string merged = requestKey + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; string merged = requestKey + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";

View File

@ -1,6 +1,9 @@
{ {
"version": "1.0.0-*", "version": "1.0.0-*",
"description": "Managed web socket protocol parser.", "description": "Managed web socket protocol parser.",
"dependencies": {
"Microsoft.Framework.NotNullAttribute.Internal": { "type": "build", "version": "1.0.0-*" }
},
"frameworks": { "frameworks": {
"net45": { }, "net45": { },
"dnxcore50": { "dnxcore50": {

View File

@ -7,6 +7,7 @@ using System.Diagnostics.Contracts;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Framework.Internal;
namespace Microsoft.AspNet.WebSockets.Protocol.Test namespace Microsoft.AspNet.WebSockets.Protocol.Test
{ {
@ -255,12 +256,8 @@ namespace Microsoft.AspNet.WebSockets.Protocol.Test
return Task.FromResult<object>(null); return Task.FromResult<object>(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) if (offset < 0 || offset > buffer.Length)
{ {
throw new ArgumentOutOfRangeException(nameof(offset), offset, string.Empty); throw new ArgumentOutOfRangeException(nameof(offset), offset, string.Empty);

View File

@ -1,6 +1,7 @@
{ {
"dependencies": { "dependencies": {
"Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*", "Microsoft.AspNet.WebSockets.Protocol": "1.0.0-*",
"Microsoft.Framework.NotNullAttribute.Internal": { "type": "build", "version": "1.0.0-*" },
"xunit.runner.aspnet": "2.0.0-aspnet-*" "xunit.runner.aspnet": "2.0.0-aspnet-*"
}, },
"frameworks": { "frameworks": {