diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/FrameContext.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/FrameContext.cs index f18efc6658..ab43df6388 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/FrameContext.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/FrameContext.cs @@ -7,12 +7,10 @@ namespace Microsoft.AspNet.Server.Kestrel.Http { public FrameContext() { - } public FrameContext(ConnectionContext context) : base(context) { - } public IFrameControl FrameControl { get; set; } diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/FrameRequestHeaders.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/FrameRequestHeaders.cs index da9429ac79..731b449468 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/FrameRequestHeaders.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/FrameRequestHeaders.cs @@ -21,11 +21,11 @@ namespace Microsoft.AspNet.Server.Kestrel.Http public partial struct Enumerator : IEnumerator> { - private FrameRequestHeaders _collection; - private long _bits; + private readonly FrameRequestHeaders _collection; + private readonly long _bits; private int _state; private KeyValuePair _current; - private bool _hasUnknown; + private readonly bool _hasUnknown; private Dictionary.Enumerator _unknownEnumerator; internal Enumerator(FrameRequestHeaders collection) diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/FrameResponseHeaders.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/FrameResponseHeaders.cs index a5a42e6a98..840d44ce8b 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/FrameResponseHeaders.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/FrameResponseHeaders.cs @@ -10,8 +10,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Http { public partial class FrameResponseHeaders : FrameHeaders { - private static byte[] _CrLf = new[] { (byte)'\r', (byte)'\n' }; - private static byte[] _colonSpace = new[] { (byte)':', (byte)' ' }; + private static readonly byte[] _CrLf = new[] { (byte)'\r', (byte)'\n' }; + private static readonly byte[] _colonSpace = new[] { (byte)':', (byte)' ' }; public bool HasConnection => HeaderConnection.Count != 0; @@ -53,11 +53,11 @@ namespace Microsoft.AspNet.Server.Kestrel.Http public partial struct Enumerator : IEnumerator> { - private FrameResponseHeaders _collection; - private long _bits; + private readonly FrameResponseHeaders _collection; + private readonly long _bits; private int _state; private KeyValuePair _current; - private bool _hasUnknown; + private readonly bool _hasUnknown; private Dictionary.Enumerator _unknownEnumerator; internal Enumerator(FrameResponseHeaders collection) diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/Listener.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/Listener.cs index 5d8c4e8d0d..3455f93567 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/Listener.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/Listener.cs @@ -3,7 +3,6 @@ using System; using System.Threading.Tasks; -using Microsoft.AspNet.Http; using Microsoft.AspNet.Server.Kestrel.Networking; using Microsoft.Extensions.Logging; diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/ListenerPrimary.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/ListenerPrimary.cs index d3c344ccec..04257ab015 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/ListenerPrimary.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/ListenerPrimary.cs @@ -14,9 +14,9 @@ namespace Microsoft.AspNet.Server.Kestrel.Http /// A primary listener waits for incoming connections on a specified socket. Incoming /// connections may be passed to a secondary listener to handle. /// - abstract public class ListenerPrimary : Listener + public abstract class ListenerPrimary : Listener { - private List _dispatchPipes = new List(); + private readonly List _dispatchPipes = new List(); private int _dispatchIndex; private string _pipeName; @@ -28,7 +28,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http { } - UvPipeHandle ListenPipe { get; set; } + private UvPipeHandle ListenPipe { get; set; } public async Task StartAsync( string pipeName, diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/MessageBody.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/MessageBody.cs index 8edd424a10..60a9121b56 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/MessageBody.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/MessageBody.cs @@ -12,7 +12,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http { public abstract class MessageBody { - private FrameContext _context; + private readonly FrameContext _context; private int _send100Continue = 1; protected MessageBody(FrameContext context) @@ -130,7 +130,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } - class ForRemainingData : MessageBody + private class ForRemainingData : MessageBody { public ForRemainingData(FrameContext context) : base(context) @@ -143,7 +143,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http } } - class ForContentLength : MessageBody + private class ForContentLength : MessageBody { private readonly int _contentLength; private int _inputLength; @@ -182,7 +182,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http /// /// http://tools.ietf.org/html/rfc2616#section-3.6.1 /// - class ForChunkedEncoding : MessageBody + private class ForChunkedEncoding : MessageBody { private int _inputLength; diff --git a/src/Microsoft.AspNet.Server.Kestrel/Http/SocketOutput.cs b/src/Microsoft.AspNet.Server.Kestrel/Http/SocketOutput.cs index 9a0f9f8a14..5e3f8f5a68 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Http/SocketOutput.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Http/SocketOutput.cs @@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http private const int _initialTaskQueues = 64; private const int _maxPooledWriteContexts = 32; - private static WaitCallback _returnBlocks = (state) => ReturnBlocks((MemoryPoolBlock2)state); + private static readonly WaitCallback _returnBlocks = (state) => ReturnBlocks((MemoryPoolBlock2)state); private readonly KestrelThread _thread; private readonly UvStreamHandle _socket; diff --git a/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelThread.cs b/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelThread.cs index 4769d62d6e..5286c05952 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelThread.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelThread.cs @@ -30,21 +30,21 @@ namespace Microsoft.AspNet.Server.Kestrel private static readonly Action _listenerPrimaryCallbackAdapter = (callback, state) => ((Action)callback).Invoke((ListenerPrimary)state); private static readonly Action _listenerSecondaryCallbackAdapter = (callback, state) => ((Action)callback).Invoke((ListenerSecondary)state); - private KestrelEngine _engine; + private readonly KestrelEngine _engine; private readonly IApplicationLifetime _appLifetime; - private Thread _thread; - private UvLoopHandle _loop; - private UvAsyncHandle _post; + private readonly Thread _thread; + private readonly UvLoopHandle _loop; + private readonly UvAsyncHandle _post; private Queue _workAdding = new Queue(1024); private Queue _workRunning = new Queue(1024); private Queue _closeHandleAdding = new Queue(256); private Queue _closeHandleRunning = new Queue(256); - private object _workSync = new Object(); + private readonly object _workSync = new Object(); private bool _stopImmediate = false; private bool _initCompleted = false; private ExceptionDispatchInfo _closeError; - private IKestrelTrace _log; - private IThreadPool _threadPool; + private readonly IKestrelTrace _log; + private readonly IThreadPool _threadPool; public KestrelThread(KestrelEngine engine) { diff --git a/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelTrace.cs b/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelTrace.cs index 9f6d047fdd..1bfd402993 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelTrace.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/KestrelTrace.cs @@ -12,15 +12,15 @@ namespace Microsoft.AspNet.Server.Kestrel /// public class KestrelTrace : IKestrelTrace { - private static Action _connectionStart; - private static Action _connectionStop; - private static Action _connectionPause; - private static Action _connectionResume; - private static Action _connectionReadFin; - private static Action _connectionWriteFin; - private static Action _connectionWroteFin; - private static Action _connectionKeepAlive; - private static Action _connectionDisconnect; + private static readonly Action _connectionStart; + private static readonly Action _connectionStop; + private static readonly Action _connectionPause; + private static readonly Action _connectionResume; + private static readonly Action _connectionReadFin; + private static readonly Action _connectionWriteFin; + private static readonly Action _connectionWroteFin; + private static readonly Action _connectionKeepAlive; + private static readonly Action _connectionDisconnect; protected readonly ILogger _logger; diff --git a/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/MemoryPoolIterator2Extensions.cs b/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/MemoryPoolIterator2Extensions.cs index c9a23db157..b91f455cb4 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/MemoryPoolIterator2Extensions.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Infrastructure/MemoryPoolIterator2Extensions.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Infrastructure { private const int _maxStackAllocBytes = 16384; - private static Encoding _utf8 = Encoding.UTF8; + private static readonly Encoding _utf8 = Encoding.UTF8; public const string HttpConnectMethod = "CONNECT"; public const string HttpDeleteMethod = "DELETE"; @@ -41,7 +41,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Infrastructure private readonly static long _http11VersionLong = GetAsciiStringAsLong("HTTP/1.1"); private const int PerfectHashDivisor = 37; - private static Tuple[] _knownStrings = new Tuple[PerfectHashDivisor]; + private static readonly Tuple[] _knownStrings = new Tuple[PerfectHashDivisor]; static MemoryPoolIterator2Extensions() { diff --git a/src/Microsoft.AspNet.Server.Kestrel/Networking/Libuv.cs b/src/Microsoft.AspNet.Server.Kestrel/Networking/Libuv.cs index f00bfa586e..2f6a74fced 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Networking/Libuv.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Networking/Libuv.cs @@ -103,7 +103,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking } } - public bool IsWindows; + public readonly bool IsWindows; public int Check(int statusCode) { diff --git a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvAsyncHandle.cs b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvAsyncHandle.cs index 03c6ece9e5..32f629c713 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvAsyncHandle.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvAsyncHandle.cs @@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking { public class UvAsyncHandle : UvHandle { - private static Libuv.uv_async_cb _uv_async_cb = (handle) => AsyncCb(handle); + private static readonly Libuv.uv_async_cb _uv_async_cb = (handle) => AsyncCb(handle); private Action _callback; public UvAsyncHandle(IKestrelTrace logger) : base(logger) diff --git a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvHandle.cs b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvHandle.cs index 7fcb2106a9..60c3ba03c8 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvHandle.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvHandle.cs @@ -9,7 +9,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking { public abstract class UvHandle : UvMemory { - private static Libuv.uv_close_cb _destroyMemory = (handle) => DestroyMemory(handle); + private static readonly Libuv.uv_close_cb _destroyMemory = (handle) => DestroyMemory(handle); private Action, IntPtr> _queueCloseHandle; protected UvHandle(IKestrelTrace logger) : base (logger) diff --git a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvMemory.cs b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvMemory.cs index a8389c39a2..3f2bf13a28 100644 --- a/src/Microsoft.AspNet.Server.Kestrel/Networking/UvMemory.cs +++ b/src/Microsoft.AspNet.Server.Kestrel/Networking/UvMemory.cs @@ -16,7 +16,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking { protected Libuv _uv; protected int _threadId; - protected IKestrelTrace _log; + protected readonly IKestrelTrace _log; protected UvMemory(IKestrelTrace logger) : base(IntPtr.Zero, true) { diff --git a/test/Microsoft.AspNet.Server.Kestrel.FunctionalTests/IPv6SupportedConditionAttribute.cs b/test/Microsoft.AspNet.Server.Kestrel.FunctionalTests/IPv6SupportedConditionAttribute.cs index 8415f0f040..5d8d8a0d6b 100644 --- a/test/Microsoft.AspNet.Server.Kestrel.FunctionalTests/IPv6SupportedConditionAttribute.cs +++ b/test/Microsoft.AspNet.Server.Kestrel.FunctionalTests/IPv6SupportedConditionAttribute.cs @@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Server.Kestrel.FunctionalTests [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public class IPv6SupportedConditionAttribute : Attribute, ITestCondition { - private static Lazy _ipv6Supported = new Lazy(CanBindToIPv6Address); + private static readonly Lazy _ipv6Supported = new Lazy(CanBindToIPv6Address); public bool IsMet {