typos, inline outs, redundant usings (#2965)

This commit is contained in:
Simon Cropp 2018-09-29 04:14:59 +10:00 committed by Chris Ross
parent 7cf1cf2a54
commit d4ab8b27a9
78 changed files with 83 additions and 168 deletions

View File

@ -3,7 +3,6 @@
using System;
using System.Net;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.Configuration;

View File

@ -4,7 +4,6 @@
using System;
using System.Buffers;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace PlatformBenchmarks
{

View File

@ -6,14 +6,13 @@ using System.Buffers.Text;
using System.Diagnostics;
using System.Text;
using System.Threading;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
/// <summary>
/// Manages the generation of the date header value.
/// </summary>
internal static class DateHeader
internal static class DateHeader
{
const int prefixLength = 8; // "\r\nDate: ".Length
const int dateTimeRLength = 29; // Wed, 14 Mar 2018 14:20:00 GMT

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Builder;
namespace PlatformBenchmarks
@ -10,7 +9,7 @@ namespace PlatformBenchmarks
{
public void Configure(IApplicationBuilder app)
{
}
}
}

View File

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Buffers;
using System.IO.Pipelines;
using System.Runtime.CompilerServices;
using System.Threading;

View File

@ -3,7 +3,6 @@
using BenchmarkDotNet.Attributes;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Buffers;
using System.IO.Pipelines;
using System.Threading.Tasks;

View File

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Buffers;
using System.IO.Pipelines;
using System.Runtime.CompilerServices;
using System.Text;

View File

@ -20,9 +20,8 @@ namespace LargeResponseApp
{
app.Run(async (context) =>
{
int numChunks;
var path = context.Request.Path;
if (!path.HasValue || !int.TryParse(path.Value.Substring(1), out numChunks))
if (!path.HasValue || !int.TryParse(path.Value.Substring(1), out var numChunks))
{
numChunks = _defaultNumChunks;
}

View File

@ -11,7 +11,6 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.Server.Kestrel.Https.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
using Microsoft.Extensions.Configuration;

View File

@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Connections

View File

@ -1,9 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
namespace Microsoft.AspNetCore.Connections
@ -98,8 +96,7 @@ namespace Microsoft.AspNetCore.Connections
bool ICollection<KeyValuePair<object, object>>.Remove(KeyValuePair<object, object> item)
{
object value;
if (Items.TryGetValue(item.Key, out value) && Equals(item.Value, value))
if (Items.TryGetValue(item.Key, out var value) && Equals(item.Value, value))
{
return Items.Remove(item.Key);
}

View File

@ -1,10 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Text;
namespace Microsoft.AspNetCore.Connections.Features
{
/// <summary>

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
namespace Microsoft.AspNetCore.Connections.Features

View File

@ -1,9 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Buffers;
using System.IO.Pipelines;
using System.Threading;
namespace Microsoft.AspNetCore.Connections.Features
{

View File

@ -2,8 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Buffers;
using System.IO.Pipelines;
using System.Threading;
namespace Microsoft.AspNetCore.Connections.Features
{

View File

@ -41,7 +41,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Https
/// <summary>
/// <para>
/// A callback that will be invoked to dynamically select a server certificate. This is higher priority than ServerCertificate.
/// If SNI is not avialable then the name parameter will be null.
/// If SNI is not available then the name parameter will be null.
/// </para>
/// <para>
/// If the server certificate has an Extended Key Usage extension, the usages must include Server Authentication (OID 1.3.6.1.5.5.7.3.1).

View File

@ -1,8 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Buffers;
using System.Runtime.CompilerServices;
namespace System.Buffers

View File

@ -82,7 +82,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
private void ReadEndpointDefaults()
{
var configSection = _configuration.GetSection(EndpointDefaultsKey);
_endpointDefaults = new EndpointDefaults()
_endpointDefaults = new EndpointDefaults
{
Protocols = ParseProtocols(configSection[ProtocolsKey])
};
@ -110,7 +110,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
throw new InvalidOperationException(CoreStrings.FormatEndpointMissingUrl(endpointConfig.Key));
}
var endpoint = new EndpointConfig()
var endpoint = new EndpointConfig
{
Name = endpointConfig.Key,
Url = url,

View File

@ -1,6 +1,4 @@
using System.Buffers;
namespace System.IO.Pipelines
namespace System.IO.Pipelines
{
internal class DuplexPipe : IDuplexPipe
{

View File

@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
Buffer.BlockCopy(_datePreambleBytes, 0, dateBytes, 0, _datePreambleBytes.Length);
Encoding.ASCII.GetBytes(dateValue, 0, dateValue.Length, dateBytes, _datePreambleBytes.Length);
var dateValues = new DateHeaderValues()
var dateValues = new DateHeaderValues
{
Bytes = dateBytes,
String = dateValue

View File

@ -159,7 +159,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
catch (OperationCanceledException)
{
// TryRead can throw OperationCanceledException https://github.com/dotnet/corefx/issues/32029
// beacuse of buggy logic, this works around that for now
// because of buggy logic, this works around that for now
}
catch (BadHttpRequestException ex)
{
@ -596,9 +596,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
}
suffixBuffer = suffixBuffer.Slice(0, 2);
var sufixSpan = suffixBuffer.ToSpan();
var suffixSpan = suffixBuffer.ToSpan();
if (sufixSpan[1] == '\n')
if (suffixSpan[1] == '\n')
{
// We consumed the \r\n at the end of the extension, so switch modes.
_mode = _inputLength > 0 ? Mode.Data : Mode.Trailer;

View File

@ -36,8 +36,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
get
{
StringValues value;
TryGetValueFast(key, out value);
TryGetValueFast(key, out var value);
return value;
}
set
@ -66,8 +65,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
get
{
// Unlike the IHeaderDictionary version, this getter will throw a KeyNotFoundException.
StringValues value;
if (!TryGetValueFast(key, out value))
if (!TryGetValueFast(key, out var value))
{
ThrowKeyNotFoundException();
}
@ -197,9 +195,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
bool ICollection<KeyValuePair<string, StringValues>>.Contains(KeyValuePair<string, StringValues> item)
{
StringValues value;
return
TryGetValueFast(item.Key, out value) &&
TryGetValueFast(item.Key, out var value) &&
value.Equals(item.Value);
}
@ -229,9 +226,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
bool ICollection<KeyValuePair<string, StringValues>>.Remove(KeyValuePair<string, StringValues> item)
{
StringValues value;
return
TryGetValueFast(item.Key, out value) &&
TryGetValueFast(item.Key, out var value) &&
value.Equals(item.Value) &&
RemoveFast(item.Key);
}

View File

@ -5,7 +5,6 @@ using System;
using System.Buffers;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
@ -73,9 +72,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
private unsafe void ParseRequestLine(TRequestHandler handler, byte* data, int length)
{
int offset;
// Get Method and set the offset
var method = HttpUtilities.GetKnownMethod(data, length, out offset);
var method = HttpUtilities.GetKnownMethod(data, length, out var offset);
Span<byte> customMethod = method == HttpMethod.Custom ?
GetUnknownMethod(data, length, out offset) :

View File

@ -5,7 +5,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
@ -16,8 +15,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
{
private static long ParseContentLength(string value)
{
long parsed;
if (!HeaderUtilities.TryParseNonNegativeInt64(value, out parsed))
if (!HeaderUtilities.TryParseNonNegativeInt64(value, out var parsed))
{
BadHttpRequestException.Throw(RequestRejectionReason.InvalidContentLength, value);
}
@ -51,8 +49,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
}
}
StringValues existing;
Unknown.TryGetValue(key, out existing);
Unknown.TryGetValue(key, out var existing);
Unknown[key] = AppendValue(existing, value);
}

View File

@ -50,8 +50,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http
private static long ParseContentLength(string value)
{
long parsed;
if (!HeaderUtilities.TryParseNonNegativeInt64(value, out parsed))
if (!HeaderUtilities.TryParseNonNegativeInt64(value, out var parsed))
{
ThrowInvalidContentLengthException(value);
}

View File

@ -3,7 +3,6 @@
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.AspNetCore.Connections.Abstractions;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;

View File

@ -977,7 +977,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2
// https://github.com/aspnet/KestrelHttpServer/issues/2051
if (_requestHeaderParsingState != RequestHeaderParsingState.Trailers)
{
// Throws BadReqeust for header count limit breaches.
// Throws BadRequest for header count limit breaches.
// Throws InvalidOperation for bad encoding.
_currentHeadersStream.OnHeader(name, value);
}

View File

@ -116,7 +116,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
using (connectionLifetimeNotificationFeature?.ConnectionClosedRequested.Register(state => ((HttpConnection)state).StopProcessingNextRequest(), this))
{
// Ensure TimeoutControl._lastTimestamp is intialized before anything that could set timeouts runs.
// Ensure TimeoutControl._lastTimestamp is initialized before anything that could set timeouts runs.
_timeoutControl.Initialize(_systemClock.UtcNow);
_context.ConnectionFeatures.Set<IConnectionTimeoutFeature>(_timeoutControl);
@ -375,7 +375,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
public void OnTimeout(TimeoutReason reason)
{
// In the cases that don't log directly here, we expect the setter of the timeout to also be the input
// reader, so when the read is canceled or arborted, the reader should write the appropriate log.
// reader, so when the read is canceled or aborted, the reader should write the appropriate log.
switch (reason)
{
case TimeoutReason.KeepAlive:

View File

@ -3,14 +3,12 @@
using System.Collections.Generic;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Connections.Features;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal
{

View File

@ -148,7 +148,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Https.Internal
};
}
var sslOptions = new SslServerAuthenticationOptions()
var sslOptions = new SslServerAuthenticationOptions
{
ServerCertificate = _serverCertificate,
ServerCertificateSelectionCallback = selector,

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Hosting.Server;

View File

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.AspNetCore.Connections;
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
{

View File

@ -4,7 +4,6 @@
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;

View File

@ -1,10 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Diagnostics.Tracing;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure

View File

@ -4,7 +4,6 @@
using System.Diagnostics.Tracing;
using System.Net;
using System.Runtime.CompilerServices;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;

View File

@ -105,8 +105,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core
int portDelimiterEnd = portDelimiterStart + ":".Length;
string portString = url.Substring(portDelimiterEnd, pathDelimiterStart - portDelimiterEnd);
int portNumber;
if (int.TryParse(portString, NumberStyles.Integer, CultureInfo.InvariantCulture, out portNumber))
if (int.TryParse(portString, NumberStyles.Integer, CultureInfo.InvariantCulture, out var portNumber))
{
hasSpecifiedPort = true;
serverAddress.Host = url.Substring(schemeDelimiterEnd, portDelimiterStart - schemeDelimiterEnd);

View File

@ -1,9 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Buffers;
using System.IO.Pipelines;
using System.Threading;
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal
{

View File

@ -1,9 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Buffers;
using System.IO.Pipelines;
using System.Threading;
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal
{

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.IO.Pipelines;
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Connections.Features;
using Microsoft.AspNetCore.Http.Features;

View File

@ -3,7 +3,6 @@
using System;
using System.IO.Pipelines;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking;

View File

@ -10,7 +10,6 @@ using System.Runtime.ExceptionServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking;
using Microsoft.Extensions.Logging;

View File

@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal
if (_fileCompletionInfoPtr == IntPtr.Zero)
{
var fileCompletionInfo = new FILE_COMPLETION_INFORMATION() { Key = IntPtr.Zero, Port = IntPtr.Zero };
var fileCompletionInfo = new FILE_COMPLETION_INFORMATION { Key = IntPtr.Zero, Port = IntPtr.Zero };
_fileCompletionInfoPtr = Marshal.AllocHGlobal(Marshal.SizeOf(fileCompletionInfo));
Marshal.StructureToPtr(fileCompletionInfo, _fileCompletionInfoPtr, false);
}

View File

@ -92,7 +92,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networkin
[MethodImpl(MethodImplOptions.NoInlining)]
private UvException GetError(int statusCode)
{
// Note: method marked as NoInlining so it doesn't bloat either of the two preceeding functions
// Note: method marked as NoInlining so it doesn't bloat either of the two preceding functions
// Check and ThrowError and alter their jit heuristics.
var errorName = err_name(statusCode);
var errorDescription = strerror(statusCode);

View File

@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networkin
// Quick calculate the port by mask the field and locate the byte 3 and byte 4
// and then shift them to correct place to form a int.
var port = ((int)(_field0 & 0x00FF0000) >> 8) | (int)((_field0 & 0xFF000000) >> 24);
int family = (int)_field0;
if (PlatformApis.IsDarwin)
{

View File

@ -30,10 +30,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networkin
public void Bind(IPEndPoint endPoint)
{
SockAddr addr;
var addressText = endPoint.Address.ToString();
_uv.ip4_addr(addressText, endPoint.Port, out addr, out var error1);
_uv.ip4_addr(addressText, endPoint.Port, out var addr, out var error1);
if (error1 != null)
{
@ -56,18 +55,16 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networkin
public IPEndPoint GetPeerIPEndPoint()
{
SockAddr socketAddress;
int namelen = Marshal.SizeOf<SockAddr>();
_uv.tcp_getpeername(this, out socketAddress, ref namelen);
_uv.tcp_getpeername(this, out var socketAddress, ref namelen);
return socketAddress.GetIPEndPoint();
}
public IPEndPoint GetSockIPEndPoint()
{
SockAddr socketAddress;
int namelen = Marshal.SizeOf<SockAddr>();
_uv.tcp_getsockname(this, out socketAddress, ref namelen);
_uv.tcp_getsockname(this, out var socketAddress, ref namelen);
return socketAddress.GetIPEndPoint();
}

View File

@ -102,7 +102,7 @@ namespace System.Buffers.Tests
}
[Fact]
public void PeekReturnsMinuOneByteInTheEnd()
public void PeekReturnsMinusOneByteInTheEnd()
{
var reader = new BufferReader(Factory.CreateWithContent(new byte[] { 1, 2 }));
Assert.Equal(1, reader.Read());
@ -221,7 +221,7 @@ namespace System.Buffers.Tests
}
[Fact]
public void PeekWorkesWithEmptySegments()
public void PeekWorksWithEmptySegments()
{
var buffer = Factory.CreateWithContent(new byte[] { 1 });
var reader = new BufferReader(buffer);
@ -235,7 +235,7 @@ namespace System.Buffers.Tests
}
[Fact]
public void WorkesWithEmptyBuffer()
public void WorksWithEmptyBuffer()
{
var reader = new BufferReader(Factory.CreateWithContent(new byte[] { }));

View File

@ -4,7 +4,6 @@
using System.Buffers;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
namespace System.IO.Pipelines.Tests

View File

@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
var tcs = new TaskCompletionSource<object>();
var dispatcher = new ConnectionDispatcher(serviceContext, _ => tcs.Task);
var connection = new Mock<TransportConnection>() { CallBase = true }.Object;
var connection = new Mock<TransportConnection> { CallBase = true }.Object;
connection.ConnectionClosed = new CancellationToken(canceled: true);
dispatcher.OnConnection(connection);
@ -53,7 +53,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
var serviceContext = new TestServiceContext();
var dispatcher = new ConnectionDispatcher(serviceContext, _ => Task.CompletedTask);
var mockConnection = new Mock<TransportConnection>() { CallBase = true };
var mockConnection = new Mock<TransportConnection> { CallBase = true };
mockConnection.Object.ConnectionClosed = new CancellationToken(canceled: true);
var mockPipeReader = new Mock<PipeReader>();
var mockPipeWriter = new Mock<PipeWriter>();

View File

@ -104,9 +104,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
var testKestrelTrace = new TestKestrelTrace();
using (var heatbeat = new Heartbeat(new IHeartbeatHandler[] { dateHeaderValueManager }, systemClock, DebuggerWrapper.Singleton, testKestrelTrace))
using (var heartbeat = new Heartbeat(new IHeartbeatHandler[] { dateHeaderValueManager }, systemClock, DebuggerWrapper.Singleton, testKestrelTrace))
{
heatbeat.OnHeartbeat();
heartbeat.OnHeartbeat();
Assert.Equal(now.ToString(Rfc1123DateFormat), dateHeaderValueManager.GetDateHeaderValues().String);
}

View File

@ -3,11 +3,8 @@
using System;
using System.Runtime.CompilerServices;
using Microsoft.AspNetCore.Connections;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
using Microsoft.AspNetCore.Testing;
using Moq;
using Xunit;

View File

@ -225,9 +225,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
{
IDictionary<string, StringValues> headers = httpHeaders;
StringValues value;
Assert.False(headers.TryGetValue("Content-Length", out value));
Assert.False(headers.TryGetValue("Content-Length", out var value));
Assert.Null(httpHeaders.ContentLength);
Assert.False(httpHeaders.ContentLength.HasValue);

View File

@ -34,8 +34,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
var block = new Span<byte>(Encoding.ASCII.GetBytes(input));
// Act
HttpMethod knownMethod;
var result = block.GetKnownMethod(out knownMethod, out var length);
var result = block.GetKnownMethod(out var knownMethod, out var length);
string toString = null;
if (knownMethod != HttpMethod.Custom)
@ -136,7 +135,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
{
get
{
return new TheoryData<string>() {
return new TheoryData<string> {
"z",
"1",
"y:1",
@ -178,7 +177,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
get
{
// see https://tools.ietf.org/html/rfc7230#section-5.4
var data = new TheoryData<string>() {
var data = new TheoryData<string> {
"[]", // Too short
"[::]", // Too short
"[ghijkl]", // Non-hex

View File

@ -390,7 +390,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
[Fact]
public void StartingServerInitializesHeartbeat()
{
var testContext = new TestServiceContext()
var testContext = new TestServiceContext
{
ServerOptions =
{

View File

@ -23,8 +23,8 @@ namespace Microsoft.AspNetCore.Server.KestrelTests
static byte[] _methodOptions = Encoding.ASCII.GetBytes("OPTIONS ");
static byte[] _methodTrace = Encoding.ASCII.GetBytes("TRACE \0\0");
const int MagicNumer = 0x0600000C;
static byte[] _invalidMethod1 = BitConverter.GetBytes((ulong)MagicNumer);
const int MagicNumber = 0x0600000C;
static byte[] _invalidMethod1 = BitConverter.GetBytes((ulong)MagicNumber);
static byte[] _invalidMethod2 = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
static byte[] _invalidMethod3 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static byte[] _invalidMethod4 = Encoding.ASCII.GetBytes("CONNECT_");

View File

@ -1,10 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
@ -26,7 +24,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
var localhostListenOptions = new LocalhostListenOptions(1004);
localhostListenOptions.ConnectionAdapters.Add(new PassThroughConnectionAdapter());
var serviceProvider = new ServiceCollection().BuildServiceProvider();
localhostListenOptions.KestrelServerOptions = new KestrelServerOptions()
localhostListenOptions.KestrelServerOptions = new KestrelServerOptions
{
ApplicationServices = serviceProvider
};

View File

@ -407,7 +407,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
{
var writeCount = 0;
var writeTcs = new TaskCompletionSource<(byte[], int, int)>(TaskCreationOptions.RunContinuationsAsynchronously);
var mockDestination = new Mock<Stream>() { CallBase = true };
var mockDestination = new Mock<Stream> { CallBase = true };
mockDestination
.Setup(m => m.WriteAsync(It.IsAny<byte[]>(), It.IsAny<int>(), It.IsAny<int>(), CancellationToken.None))
@ -443,8 +443,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
var bytes = Encoding.ASCII.GetBytes("Hello ");
var buffer = http1Connection.RequestBodyPipe.Writer.GetMemory(2048);
ArraySegment<byte> segment;
Assert.True(MemoryMarshal.TryGetArray(buffer, out segment));
Assert.True(MemoryMarshal.TryGetArray(buffer, out ArraySegment<byte> segment));
Buffer.BlockCopy(bytes, 0, segment.Array, segment.Offset, bytes.Length);
http1Connection.RequestBodyPipe.Writer.Advance(bytes.Length);
await http1Connection.RequestBodyPipe.Writer.FlushAsync();

View File

@ -1,11 +1,8 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Buffers;
using System.IO.Pipelines;
using System.Threading;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.Internal;
using Microsoft.AspNetCore.Testing;
using Moq;

View File

@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.Server.Kestrel.Core.Adapter.Internal;
using Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests.TestTransport;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.Logging.Testing;
using Xunit;
namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests

View File

@ -1970,7 +1970,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
await SendRstStreamAsync(1);
// Any paused writes for stream 1 should complete after an RST_STREAM
// even without any preceeding window updates.
// even without any preceding window updates.
await _runningStreams[1].Task.DefaultTimeout();
// A connection-level window update allows the non-reset stream to continue.
@ -2771,7 +2771,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
}
[Fact]
public async Task GOAWAY_Received_ContinuesAppsAwaitingStreamOutputFlowControle()
public async Task GOAWAY_Received_ContinuesAppsAwaitingStreamOutputFlowControl()
{
var writeTasks = new Task[6];
var initialWindowSize = _helloWorldBytes.Length / 2;

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Connections;
@ -14,7 +13,6 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core.Features;
using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http2;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.Logging;
using Microsoft.Net.Http.Headers;
using Xunit;
@ -43,7 +41,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
}
[Fact]
public async Task HEADERS_Received_InvlaidCustomMethod_Reset()
public async Task HEADERS_Received_InvalidCustomMethod_Reset()
{
var headers = new[]
{
@ -189,7 +187,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
}
[Fact]
public async Task HEADERS_Received_PathAndQuery_Seperated()
public async Task HEADERS_Received_PathAndQuery_Separated()
{
await InitializeConnectionAsync(context =>
{
@ -1343,7 +1341,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
}
[Fact]
public async Task ApplicationExeption_BeforeFirstWrite_Sends500()
public async Task ApplicationException_BeforeFirstWrite_Sends500()
{
var headers = new[]
{
@ -1380,7 +1378,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Tests
}
[Fact]
public async Task ApplicationExeption_AfterFirstWrite_Resets()
public async Task ApplicationException_AfterFirstWrite_Resets()
{
var headers = new[]
{

View File

@ -55,11 +55,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.InMemory.FunctionalTests.Http2
using (var connection = server.CreateConnection())
{
var sslStream = new SslStream(connection.Stream);
await sslStream.AuthenticateAsClientAsync(new SslClientAuthenticationOptions()
await sslStream.AuthenticateAsClientAsync(new SslClientAuthenticationOptions
{
TargetHost = "localhost",
RemoteCertificateValidationCallback = (_, __, ___, ____) => true,
ApplicationProtocols = new List<SslApplicationProtocol>() { SslApplicationProtocol.Http2, SslApplicationProtocol.Http11 },
ApplicationProtocols = new List<SslApplicationProtocol> { SslApplicationProtocol.Http2, SslApplicationProtocol.Http11 },
EnabledSslProtocols = SslProtocols.Tls11, // Intentionally less than the required 1.2
}, CancellationToken.None);

View File

@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Tests
}
[Fact]
public void ReadCertificatesWhenEmptyCertificatsSection_ReturnsEmptyCollection()
public void ReadCertificatesWhenEmptyCertificatesSection_ReturnsEmptyCollection()
{
var config = new ConfigurationBuilder().AddInMemoryCollection(new[]
{
@ -36,7 +36,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Tests
}
[Fact]
public void ReadCertificatsSection_ReturnsCollection()
public void ReadCertificatesSection_ReturnsCollection()
{
var config = new ConfigurationBuilder().AddInMemoryCollection(new[]
{

View File

@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Tests
var serverOptions = new KestrelServerOptions();
serverOptions.ApplicationServices = new ServiceCollection()
.AddLogging()
.AddSingleton<IHostingEnvironment>(new HostingEnvironment() { ApplicationName = "TestApplication" })
.AddSingleton<IHostingEnvironment>(new HostingEnvironment { ApplicationName = "TestApplication" })
.BuildServiceProvider();
return serverOptions;
}
@ -91,7 +91,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Tests
}
[Fact]
public void Configure_IsReplacable()
public void Configure_IsReplaceable()
{
var run1 = false;
var serverOptions = CreateServerOptions();

View File

@ -65,7 +65,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2
skip = "https://github.com/aspnet/KestrelHttpServer/issues/2154";
}
dataset.Add(new H2SpecTestCase()
dataset.Add(new H2SpecTestCase
{
Id = testcase.Item1,
Description = testcase.Item2,
@ -73,7 +73,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2
Skip = skip,
});
dataset.Add(new H2SpecTestCase()
dataset.Add(new H2SpecTestCase
{
Id = testcase.Item1,
Description = testcase.Item2,

View File

@ -4,7 +4,6 @@
#if NETCOREAPP2_2
using System;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Security;
@ -36,14 +35,14 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// We don't want the default SocketsHttpHandler, it doesn't support HTTP/2 yet.
Client = new HttpClient(new WinHttpHandler()
Client = new HttpClient(new WinHttpHandler
{
ServerCertificateValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
});
}
}
[ConditionalFact]
[ConditionalFact]
public async Task TlsAlpnHandshakeSelectsHttp2From1and2()
{
using (var server = new TestServer(context =>

View File

@ -3,7 +3,6 @@
#if NETCOREAPP2_2
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
@ -38,7 +37,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests.Http2
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// We don't want the default SocketsHttpHandler, it doesn't support HTTP/2 yet.
Client = new HttpClient(new WinHttpHandler()
Client = new HttpClient(new WinHttpHandler
{
ServerCertificateValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator
});

View File

@ -177,17 +177,17 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
public async Task CanHandleMultipleConcurrentRequests()
{
var requestNumber = 0;
var ensureConcurrentReqeustTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
var ensureConcurrentRequestTcs = new TaskCompletionSource<object>(TaskCreationOptions.RunContinuationsAsynchronously);
using (var server = new TestServer(async context =>
{
if (Interlocked.Increment(ref requestNumber) == 1)
{
await ensureConcurrentReqeustTcs.Task.DefaultTimeout();
await ensureConcurrentRequestTcs.Task.DefaultTimeout();
}
else
{
ensureConcurrentReqeustTcs.SetResult(null);
ensureConcurrentRequestTcs.SetResult(null);
}
}, new TestServiceContext(LoggerFactory)))
{

View File

@ -22,7 +22,6 @@ using Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure;
using Microsoft.AspNetCore.Server.Kestrel.Https;
using Microsoft.AspNetCore.Server.Kestrel.Https.Internal;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
using Moq;

View File

@ -21,7 +21,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
{
var mockConnectionDispatcher = new MockConnectionDispatcher();
var mockLibuv = new MockLibuv();
var transportContext = new TestLibuvTransportContext() { ConnectionDispatcher = mockConnectionDispatcher };
var transportContext = new TestLibuvTransportContext { ConnectionDispatcher = mockConnectionDispatcher };
var transport = new LibuvTransport(mockLibuv, transportContext, null);
var thread = new LibuvThread(transport);
Task connectionTask = null;
@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
{
var mockConnectionDispatcher = new MockConnectionDispatcher();
var mockLibuv = new MockLibuv();
var transportContext = new TestLibuvTransportContext() { ConnectionDispatcher = mockConnectionDispatcher };
var transportContext = new TestLibuvTransportContext { ConnectionDispatcher = mockConnectionDispatcher };
var transport = new LibuvTransport(mockLibuv, transportContext, null);
var thread = new LibuvThread(transport);
mockConnectionDispatcher.InputOptions = pool =>
@ -126,7 +126,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
{
var mockConnectionDispatcher = new MockConnectionDispatcher();
var mockLibuv = new MockLibuv();
var transportContext = new TestLibuvTransportContext() { ConnectionDispatcher = mockConnectionDispatcher };
var transportContext = new TestLibuvTransportContext { ConnectionDispatcher = mockConnectionDispatcher };
var transport = new LibuvTransport(mockLibuv, transportContext, null);
var thread = new LibuvThread(transport);
var mockScheduler = new Mock<PipeScheduler>();
@ -211,7 +211,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
{
var mockConnectionDispatcher = new MockConnectionDispatcher();
var mockLibuv = new MockLibuv();
var transportContext = new TestLibuvTransportContext() { ConnectionDispatcher = mockConnectionDispatcher };
var transportContext = new TestLibuvTransportContext { ConnectionDispatcher = mockConnectionDispatcher };
var transport = new LibuvTransport(mockLibuv, transportContext, null);
var thread = new LibuvThread(transport);

View File

@ -5,10 +5,6 @@ using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests.TestHelpers;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Moq;
using Xunit;
namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
@ -20,7 +16,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
{
var mockConnectionDispatcher = new MockConnectionDispatcher();
var mockLibuv = new MockLibuv();
var transportContext = new TestLibuvTransportContext() { ConnectionDispatcher = mockConnectionDispatcher };
var transportContext = new TestLibuvTransportContext { ConnectionDispatcher = mockConnectionDispatcher };
var transport = new LibuvTransport(mockLibuv, transportContext, null);
var thread = new LibuvThread(transport);
var ranOne = false;

View File

@ -18,7 +18,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
[InlineData(-1337)]
public void StartWithNonPositiveThreadCountThrows(int threadCount)
{
var options = new LibuvTransportOptions() { ThreadCount = threadCount };
var options = new LibuvTransportOptions { ThreadCount = threadCount };
var exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
new LibuvTransportFactory(Options.Create(options), new LifetimeNotImplemented(), Mock.Of<ILoggerFactory>()));

View File

@ -64,7 +64,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
var serviceContext = new TestServiceContext();
listenOptions.UseHttpServer(listenOptions.ConnectionAdapters, serviceContext, new DummyApplication(TestApp.EchoApp), HttpProtocols.Http1);
var transportContext = new TestLibuvTransportContext()
var transportContext = new TestLibuvTransportContext
{
ConnectionDispatcher = new ConnectionDispatcher(serviceContext, listenOptions.Build())
};
@ -104,7 +104,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
listenOptions.UseHttpServer(listenOptions.ConnectionAdapters, serviceContext, testApplication, HttpProtocols.Http1);
var transportContext = new TestLibuvTransportContext()
var transportContext = new TestLibuvTransportContext
{
ConnectionDispatcher = new ConnectionDispatcher(serviceContext, listenOptions.Build()),
Options = new LibuvTransportOptions { ThreadCount = threadCount }

View File

@ -102,7 +102,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
var serviceContextPrimary = new TestServiceContext();
var builderPrimary = new ConnectionBuilder();
builderPrimary.UseHttpServer(serviceContextPrimary, new DummyApplication(c => c.Response.WriteAsync("Primary")), HttpProtocols.Http1);
var transportContextPrimary = new TestLibuvTransportContext() { Log = new LibuvTrace(logger) };
var transportContextPrimary = new TestLibuvTransportContext { Log = new LibuvTrace(logger) };
transportContextPrimary.ConnectionDispatcher = new ConnectionDispatcher(serviceContextPrimary, builderPrimary.Build());
var serviceContextSecondary = new TestServiceContext
@ -213,7 +213,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Tests
var serviceContextPrimary = new TestServiceContext();
var builderPrimary = new ConnectionBuilder();
builderPrimary.UseHttpServer(serviceContextPrimary, new DummyApplication(c => c.Response.WriteAsync("Primary")), HttpProtocols.Http1);
var transportContextPrimary = new TestLibuvTransportContext() { Log = new LibuvTrace(logger) };
var transportContextPrimary = new TestLibuvTransportContext { Log = new LibuvTrace(logger) };
transportContextPrimary.ConnectionDispatcher = new ConnectionDispatcher(serviceContextPrimary, builderPrimary.Build());
var serviceContextSecondary = new TestServiceContext

View File

@ -1,7 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Testing
@ -11,7 +10,7 @@ namespace Microsoft.AspNetCore.Testing
private readonly ILogger _testLogger;
public KestrelTestLoggerProvider(bool throwOnCriticalErrors = true)
: this(new TestApplicationErrorLogger() { ThrowOnCriticalErrors = throwOnCriticalErrors })
: this(new TestApplicationErrorLogger { ThrowOnCriticalErrors = throwOnCriticalErrors })
{
}

View File

@ -4,8 +4,6 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using Xunit;

View File

@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
public static IList<Tuple<string, string>> EnumerateTestCases()
{
var testCases = new List<Tuple<string, string>>();
var processOptions = new ProcessStartInfo()
var processOptions = new ProcessStartInfo
{
FileName = GetToolLocation(),
RedirectStandardOutput = true,
@ -165,11 +165,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
description = string.Empty;
return false;
}
public static void RunTest(string testId, int port, bool https, ILogger logger)
{
var tempFile = Path.GetTempPath() + Guid.NewGuid() + ".xml";
var processOptions = new ProcessStartInfo()
var processOptions = new ProcessStartInfo
{
FileName = GetToolLocation(),
RedirectStandardOutput = true,

View File

@ -4,7 +4,6 @@
using System;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;