Initial commit for style cleanup #184

* adding private keyword to fields
* one type per file
This commit is contained in:
Louis DeJardin 2015-09-01 22:25:51 -07:00
parent c2192d7bd1
commit 46604d68b3
28 changed files with 465 additions and 229 deletions

View File

@ -29,6 +29,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Server.Kes
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{327F7880-D9AF-46BD-B45C-3B7E34A01DFD}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{327F7880-D9AF-46BD-B45C-3B7E34A01DFD}"
EndProject EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.StandardsPolice", "tools\Microsoft.StandardsPolice\Microsoft.StandardsPolice.xproj", "{82295647-7C1C-4671-BAB6-0FEF58F949EC}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -55,6 +57,10 @@ Global
{BD2D4D29-1BD9-40D0-BB31-337D5416B63C}.Debug|Any CPU.Build.0 = Debug|Any CPU {BD2D4D29-1BD9-40D0-BB31-337D5416B63C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD2D4D29-1BD9-40D0-BB31-337D5416B63C}.Release|Any CPU.ActiveCfg = Release|Any CPU {BD2D4D29-1BD9-40D0-BB31-337D5416B63C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BD2D4D29-1BD9-40D0-BB31-337D5416B63C}.Release|Any CPU.Build.0 = Release|Any CPU {BD2D4D29-1BD9-40D0-BB31-337D5416B63C}.Release|Any CPU.Build.0 = Release|Any CPU
{82295647-7C1C-4671-BAB6-0FEF58F949EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{82295647-7C1C-4671-BAB6-0FEF58F949EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82295647-7C1C-4671-BAB6-0FEF58F949EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82295647-7C1C-4671-BAB6-0FEF58F949EC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -65,5 +71,6 @@ Global
{2C3CB3DC-EEBF-4F52-9E1C-4F2F972E76C3} = {8A3D00B8-1CCF-4BE6-A060-11104CE2D9CE} {2C3CB3DC-EEBF-4F52-9E1C-4F2F972E76C3} = {8A3D00B8-1CCF-4BE6-A060-11104CE2D9CE}
{B35D4D31-E74C-4646-8A11-7A7A40F0021E} = {8A3D00B8-1CCF-4BE6-A060-11104CE2D9CE} {B35D4D31-E74C-4646-8A11-7A7A40F0021E} = {8A3D00B8-1CCF-4BE6-A060-11104CE2D9CE}
{BD2D4D29-1BD9-40D0-BB31-337D5416B63C} = {327F7880-D9AF-46BD-B45C-3B7E34A01DFD} {BD2D4D29-1BD9-40D0-BB31-337D5416B63C} = {327F7880-D9AF-46BD-B45C-3B7E34A01DFD}
{82295647-7C1C-4671-BAB6-0FEF58F949EC} = {327F7880-D9AF-46BD-B45C-3B7E34A01DFD}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -1,5 +1,6 @@
{ {
"projects": [ "projects": [
"src" "src",
"tools"
] ]
} }

View File

@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
private readonly UvStreamHandle _socket; private readonly UvStreamHandle _socket;
private Frame _frame; private Frame _frame;
long _connectionId = 0; private long _connectionId = 0;
private readonly object _stateLock = new object(); private readonly object _stateLock = new object();
private ConnectionState _connectionState; private ConnectionState _connectionState;

View File

@ -24,8 +24,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
Terminated, Terminated,
} }
static Encoding _ascii = Encoding.ASCII; private static Encoding _ascii = Encoding.ASCII;
Mode _mode; private Mode _mode;
private bool _responseStarted; private bool _responseStarted;
private bool _keepAlive; private bool _keepAlive;
private bool _autoChunk; private bool _autoChunk;
@ -38,10 +38,10 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
CancellationTokenSource _cts = new CancellationTokenSource(); CancellationTokenSource _cts = new CancellationTokenSource();
*/ */
List<KeyValuePair<Func<object, Task>, object>> _onStarting; private List<KeyValuePair<Func<object, Task>, object>> _onStarting;
List<KeyValuePair<Func<object, Task>, object>> _onCompleted; private List<KeyValuePair<Func<object, Task>, object>> _onCompleted;
object _onStartingSync = new Object(); private object _onStartingSync = new Object();
object _onCompletedSync = new Object(); private object _onCompletedSync = new Object();
public Frame(ConnectionContext context) : base(context) public Frame(ConnectionContext context) : base(context)
{ {

View File

@ -12,8 +12,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
{ {
class FrameDuplexStream : Stream class FrameDuplexStream : Stream
{ {
readonly Stream _requestStream; private readonly Stream _requestStream;
readonly Stream _responseStream; private readonly Stream _responseStream;
public FrameDuplexStream(Stream requestStream, Stream responseStream) public FrameDuplexStream(Stream requestStream, Stream responseStream)
{ {

View File

@ -17,49 +17,49 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
public partial class FrameRequestHeaders public partial class FrameRequestHeaders
{ {
long _bits = 0; private long _bits = 0;
StringValues _CacheControl; private StringValues _CacheControl;
StringValues _Connection; private StringValues _Connection;
StringValues _Date; private StringValues _Date;
StringValues _KeepAlive; private StringValues _KeepAlive;
StringValues _Pragma; private StringValues _Pragma;
StringValues _Trailer; private StringValues _Trailer;
StringValues _TransferEncoding; private StringValues _TransferEncoding;
StringValues _Upgrade; private StringValues _Upgrade;
StringValues _Via; private StringValues _Via;
StringValues _Warning; private StringValues _Warning;
StringValues _Allow; private StringValues _Allow;
StringValues _ContentLength; private StringValues _ContentLength;
StringValues _ContentType; private StringValues _ContentType;
StringValues _ContentEncoding; private StringValues _ContentEncoding;
StringValues _ContentLanguage; private StringValues _ContentLanguage;
StringValues _ContentLocation; private StringValues _ContentLocation;
StringValues _ContentMD5; private StringValues _ContentMD5;
StringValues _ContentRange; private StringValues _ContentRange;
StringValues _Expires; private StringValues _Expires;
StringValues _LastModified; private StringValues _LastModified;
StringValues _Accept; private StringValues _Accept;
StringValues _AcceptCharset; private StringValues _AcceptCharset;
StringValues _AcceptEncoding; private StringValues _AcceptEncoding;
StringValues _AcceptLanguage; private StringValues _AcceptLanguage;
StringValues _Authorization; private StringValues _Authorization;
StringValues _Cookie; private StringValues _Cookie;
StringValues _Expect; private StringValues _Expect;
StringValues _From; private StringValues _From;
StringValues _Host; private StringValues _Host;
StringValues _IfMatch; private StringValues _IfMatch;
StringValues _IfModifiedSince; private StringValues _IfModifiedSince;
StringValues _IfNoneMatch; private StringValues _IfNoneMatch;
StringValues _IfRange; private StringValues _IfRange;
StringValues _IfUnmodifiedSince; private StringValues _IfUnmodifiedSince;
StringValues _MaxForwards; private StringValues _MaxForwards;
StringValues _ProxyAuthorization; private StringValues _ProxyAuthorization;
StringValues _Referer; private StringValues _Referer;
StringValues _Range; private StringValues _Range;
StringValues _TE; private StringValues _TE;
StringValues _Translate; private StringValues _Translate;
StringValues _UserAgent; private StringValues _UserAgent;
protected override int GetCountFast() protected override int GetCountFast()
{ {
@ -4587,38 +4587,38 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
public partial class FrameResponseHeaders public partial class FrameResponseHeaders
{ {
long _bits = 0; private long _bits = 0;
StringValues _CacheControl; private StringValues _CacheControl;
StringValues _Connection; private StringValues _Connection;
StringValues _Date; private StringValues _Date;
StringValues _KeepAlive; private StringValues _KeepAlive;
StringValues _Pragma; private StringValues _Pragma;
StringValues _Trailer; private StringValues _Trailer;
StringValues _TransferEncoding; private StringValues _TransferEncoding;
StringValues _Upgrade; private StringValues _Upgrade;
StringValues _Via; private StringValues _Via;
StringValues _Warning; private StringValues _Warning;
StringValues _Allow; private StringValues _Allow;
StringValues _ContentLength; private StringValues _ContentLength;
StringValues _ContentType; private StringValues _ContentType;
StringValues _ContentEncoding; private StringValues _ContentEncoding;
StringValues _ContentLanguage; private StringValues _ContentLanguage;
StringValues _ContentLocation; private StringValues _ContentLocation;
StringValues _ContentMD5; private StringValues _ContentMD5;
StringValues _ContentRange; private StringValues _ContentRange;
StringValues _Expires; private StringValues _Expires;
StringValues _LastModified; private StringValues _LastModified;
StringValues _AcceptRanges; private StringValues _AcceptRanges;
StringValues _Age; private StringValues _Age;
StringValues _ETag; private StringValues _ETag;
StringValues _Location; private StringValues _Location;
StringValues _ProxyAutheticate; private StringValues _ProxyAutheticate;
StringValues _RetryAfter; private StringValues _RetryAfter;
StringValues _Server; private StringValues _Server;
StringValues _SetCookie; private StringValues _SetCookie;
StringValues _Vary; private StringValues _Vary;
StringValues _WWWAuthenticate; private StringValues _WWWAuthenticate;
protected override int GetCountFast() protected override int GetCountFast()
{ {

View File

@ -1,4 +1,7 @@
using System; // 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;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -129,100 +132,4 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
return TryGetValueFast(key, out value); return TryGetValueFast(key, out value);
} }
} }
public partial class FrameRequestHeaders : FrameHeaders
{
public Enumerator GetEnumerator()
{
return new Enumerator(this);
}
protected override IEnumerator<KeyValuePair<string, StringValues>> GetEnumeratorFast()
{
return GetEnumerator();
}
public partial struct Enumerator : IEnumerator<KeyValuePair<string, StringValues>>
{
FrameRequestHeaders _collection;
long _bits;
int _state;
KeyValuePair<string, StringValues> _current;
bool _hasUnknown;
Dictionary<string, StringValues>.Enumerator _unknownEnumerator;
internal Enumerator(FrameRequestHeaders collection)
{
_collection = collection;
_bits = collection._bits;
_state = 0;
_current = default(KeyValuePair<string, StringValues>);
_hasUnknown = collection.MaybeUnknown != null;
_unknownEnumerator = _hasUnknown
? collection.MaybeUnknown.GetEnumerator()
: default(Dictionary<string, StringValues>.Enumerator);
}
public KeyValuePair<string, StringValues> Current => _current;
object IEnumerator.Current => _current;
public void Dispose()
{
}
public void Reset()
{
_state = 0;
}
}
}
public partial class FrameResponseHeaders : FrameHeaders
{
public Enumerator GetEnumerator()
{
return new Enumerator(this);
}
protected override IEnumerator<KeyValuePair<string, StringValues>> GetEnumeratorFast()
{
return GetEnumerator();
}
public partial struct Enumerator : IEnumerator<KeyValuePair<string, StringValues>>
{
FrameResponseHeaders _collection;
long _bits;
int _state;
KeyValuePair<string, StringValues> _current;
bool _hasUnknown;
Dictionary<string, StringValues>.Enumerator _unknownEnumerator;
internal Enumerator(FrameResponseHeaders collection)
{
_collection = collection;
_bits = collection._bits;
_state = 0;
_current = default(KeyValuePair<string, StringValues>);
_hasUnknown = collection.MaybeUnknown != null;
_unknownEnumerator = _hasUnknown
? collection.MaybeUnknown.GetEnumerator()
: default(Dictionary<string, StringValues>.Enumerator);
}
public KeyValuePair<string, StringValues> Current => _current;
object IEnumerator.Current => _current;
public void Dispose()
{
}
public void Reset()
{
_state = 0;
}
}
}
} }

View File

@ -0,0 +1,57 @@
// 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 Microsoft.Framework.Primitives;
using System.Collections;
using System.Collections.Generic;
namespace Microsoft.AspNet.Server.Kestrel.Http
{
public partial class FrameRequestHeaders : FrameHeaders
{
public Enumerator GetEnumerator()
{
return new Enumerator(this);
}
protected override IEnumerator<KeyValuePair<string, StringValues>> GetEnumeratorFast()
{
return GetEnumerator();
}
public partial struct Enumerator : IEnumerator<KeyValuePair<string, StringValues>>
{
private FrameRequestHeaders _collection;
private long _bits;
private int _state;
private KeyValuePair<string, StringValues> _current;
private bool _hasUnknown;
private Dictionary<string, StringValues>.Enumerator _unknownEnumerator;
internal Enumerator(FrameRequestHeaders collection)
{
_collection = collection;
_bits = collection._bits;
_state = 0;
_current = default(KeyValuePair<string, StringValues>);
_hasUnknown = collection.MaybeUnknown != null;
_unknownEnumerator = _hasUnknown
? collection.MaybeUnknown.GetEnumerator()
: default(Dictionary<string, StringValues>.Enumerator);
}
public KeyValuePair<string, StringValues> Current => _current;
object IEnumerator.Current => _current;
public void Dispose()
{
}
public void Reset()
{
_state = 0;
}
}
}
}

View File

@ -10,7 +10,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
{ {
public class FrameRequestStream : Stream public class FrameRequestStream : Stream
{ {
readonly MessageBody _body; private readonly MessageBody _body;
//int _readLength; //int _readLength;
//bool _readFin; //bool _readFin;

View File

@ -0,0 +1,57 @@
// 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 Microsoft.Framework.Primitives;
using System.Collections;
using System.Collections.Generic;
namespace Microsoft.AspNet.Server.Kestrel.Http
{
public partial class FrameResponseHeaders : FrameHeaders
{
public Enumerator GetEnumerator()
{
return new Enumerator(this);
}
protected override IEnumerator<KeyValuePair<string, StringValues>> GetEnumeratorFast()
{
return GetEnumerator();
}
public partial struct Enumerator : IEnumerator<KeyValuePair<string, StringValues>>
{
private FrameResponseHeaders _collection;
private long _bits;
private int _state;
private KeyValuePair<string, StringValues> _current;
private bool _hasUnknown;
private Dictionary<string, StringValues>.Enumerator _unknownEnumerator;
internal Enumerator(FrameResponseHeaders collection)
{
_collection = collection;
_bits = collection._bits;
_state = 0;
_current = default(KeyValuePair<string, StringValues>);
_hasUnknown = collection.MaybeUnknown != null;
_unknownEnumerator = _hasUnknown
? collection.MaybeUnknown.GetEnumerator()
: default(Dictionary<string, StringValues>.Enumerator);
}
public KeyValuePair<string, StringValues> Current => _current;
object IEnumerator.Current => _current;
public void Dispose()
{
}
public void Reset()
{
_state = 0;
}
}
}
}

View File

@ -17,9 +17,9 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
{ {
UvPipeHandle ListenPipe { get; set; } UvPipeHandle ListenPipe { get; set; }
List<UvPipeHandle> _dispatchPipes = new List<UvPipeHandle>(); private List<UvPipeHandle> _dispatchPipes = new List<UvPipeHandle>();
int _dispatchIndex; private int _dispatchIndex;
ArraySegment<ArraySegment<byte>> _1234 = new ArraySegment<ArraySegment<byte>>(new[] { new ArraySegment<byte>(new byte[] { 1, 2, 3, 4 }) }); private ArraySegment<ArraySegment<byte>> _1234 = new ArraySegment<ArraySegment<byte>>(new[] { new ArraySegment<byte>(new byte[] { 1, 2, 3, 4 }) });
protected ListenerPrimary(IMemoryPool memory) : base(memory) protected ListenerPrimary(IMemoryPool memory) : base(memory)
{ {

View File

@ -8,12 +8,12 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
{ {
public class MemoryPool : IMemoryPool public class MemoryPool : IMemoryPool
{ {
static readonly byte[] EmptyArray = new byte[0]; private static readonly byte[] EmptyArray = new byte[0];
class Pool<T> class Pool<T>
{ {
readonly Stack<T[]> _stack = new Stack<T[]>(); private readonly Stack<T[]> _stack = new Stack<T[]>();
readonly object _sync = new object(); private readonly object _sync = new object();
public T[] Alloc(int size) public T[] Alloc(int size)
{ {
@ -39,9 +39,9 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
} }
} }
readonly Pool<byte> _pool1 = new Pool<byte>(); private readonly Pool<byte> _pool1 = new Pool<byte>();
readonly Pool<byte> _pool2 = new Pool<byte>(); private readonly Pool<byte> _pool2 = new Pool<byte>();
readonly Pool<char> _pool3 = new Pool<char>(); private readonly Pool<char> _pool3 = new Pool<char>();
public byte[] Empty public byte[] Empty
{ {

View File

@ -17,11 +17,11 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
private static readonly WaitCallback _completePending = CompletePending; private static readonly WaitCallback _completePending = CompletePending;
protected readonly FrameContext _context; protected readonly FrameContext _context;
object _sync = new Object(); private object _sync = new Object();
ArraySegment<byte> _buffer; private ArraySegment<byte> _buffer;
Queue<ReadOperation> _reads = new Queue<ReadOperation>(); private Queue<ReadOperation> _reads = new Queue<ReadOperation>();
bool _send100Continue = true; private bool _send100Continue = true;
public MessageBodyExchanger(FrameContext context) public MessageBodyExchanger(FrameContext context)
{ {

View File

@ -16,16 +16,16 @@ namespace Microsoft.AspNet.Server.Kestrel
/// </summary> /// </summary>
public class KestrelThread public class KestrelThread
{ {
KestrelEngine _engine; private KestrelEngine _engine;
Thread _thread; private Thread _thread;
UvLoopHandle _loop; private UvLoopHandle _loop;
UvAsyncHandle _post; private UvAsyncHandle _post;
Queue<Work> _workAdding = new Queue<Work>(); private Queue<Work> _workAdding = new Queue<Work>();
Queue<Work> _workRunning = new Queue<Work>(); private Queue<Work> _workRunning = new Queue<Work>();
Queue<CloseHandle> _closeHandleAdding = new Queue<CloseHandle>(); private Queue<CloseHandle> _closeHandleAdding = new Queue<CloseHandle>();
Queue<CloseHandle> _closeHandleRunning = new Queue<CloseHandle>(); private Queue<CloseHandle> _closeHandleRunning = new Queue<CloseHandle>();
object _workSync = new Object(); private object _workSync = new Object();
bool _stopImmediate = false; private bool _stopImmediate = false;
private ExceptionDispatchInfo _closeError; private ExceptionDispatchInfo _closeError;
public KestrelThread(KestrelEngine engine) public KestrelThread(KestrelEngine engine)

View File

@ -397,10 +397,10 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
{ {
public sockaddr(long ignored) { x3 = x0 = x1 = x2 = x3 = 0; } public sockaddr(long ignored) { x3 = x0 = x1 = x2 = x3 = 0; }
long x0; private long x0;
long x1; private long x1;
long x2; private long x2;
long x3; private long x3;
} }
public struct uv_buf_t public struct uv_buf_t

View File

@ -15,8 +15,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
{ {
private readonly static Libuv.uv_connect_cb _uv_connect_cb = UvConnectCb; private readonly static Libuv.uv_connect_cb _uv_connect_cb = UvConnectCb;
Action<UvConnectRequest, int, Exception, object> _callback; private Action<UvConnectRequest, int, Exception, object> _callback;
object _state; private object _state;
public void Init(UvLoopHandle loop) public void Init(UvLoopHandle loop)
{ {

View File

@ -8,8 +8,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
{ {
public abstract class UvHandle : UvMemory public abstract class UvHandle : UvMemory
{ {
static Libuv.uv_close_cb _destroyMemory = DestroyMemory; private static Libuv.uv_close_cb _destroyMemory = DestroyMemory;
Action<Action<IntPtr>, IntPtr> _queueCloseHandle; private Action<Action<IntPtr>, IntPtr> _queueCloseHandle;
unsafe protected void CreateHandle( unsafe protected void CreateHandle(
Libuv uv, Libuv uv,

View File

@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
{ {
public class UvRequest : UvMemory public class UvRequest : UvMemory
{ {
GCHandle _pin; private GCHandle _pin;
protected override bool ReleaseHandle() protected override bool ReleaseHandle()
{ {

View File

@ -13,8 +13,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
{ {
private readonly static Libuv.uv_shutdown_cb _uv_shutdown_cb = UvShutdownCb; private readonly static Libuv.uv_shutdown_cb _uv_shutdown_cb = UvShutdownCb;
Action<UvShutdownReq, int, object> _callback; private Action<UvShutdownReq, int, object> _callback;
object _state; private object _state;
public void Init(UvLoopHandle loop) public void Init(UvLoopHandle loop)
{ {

View File

@ -15,13 +15,13 @@ namespace Microsoft.AspNet.Server.Kestrel.Networking
{ {
private readonly static Libuv.uv_write_cb _uv_write_cb = UvWriteCb; private readonly static Libuv.uv_write_cb _uv_write_cb = UvWriteCb;
IntPtr _bufs; private IntPtr _bufs;
Action<UvWriteReq, int, Exception, object> _callback; private Action<UvWriteReq, int, Exception, object> _callback;
object _state; private object _state;
const int BUFFER_COUNT = 4; private const int BUFFER_COUNT = 4;
List<GCHandle> _pins = new List<GCHandle>(); private List<GCHandle> _pins = new List<GCHandle>();
public void Init(UvLoopHandle loop) public void Init(UvLoopHandle loop)
{ {

View File

@ -14,9 +14,9 @@ namespace Microsoft.AspNet.Server.Kestrel
{ {
public class ServerRequest : IHttpRequestFeature, IHttpResponseFeature, IHttpUpgradeFeature public class ServerRequest : IHttpRequestFeature, IHttpResponseFeature, IHttpUpgradeFeature
{ {
Frame _frame; private Frame _frame;
string _scheme; private string _scheme;
string _pathBase; private string _pathBase;
private FeatureCollection _features; private FeatureCollection _features;
public ServerRequest(Frame frame) public ServerRequest(Frame frame)

View File

@ -7,7 +7,11 @@
}, },
"dependencies": { "dependencies": {
"Microsoft.AspNet.Hosting": "1.0.0-*", "Microsoft.AspNet.Hosting": "1.0.0-*",
"Microsoft.Dnx.Runtime.Abstractions": "1.0.0-*" "Microsoft.Dnx.Runtime.Abstractions": "1.0.0-*",
"Microsoft.StandardsPolice": {
"version": "1.0.0-*",
"type": "build"
}
}, },
"frameworks": { "frameworks": {
"dnx451": { }, "dnx451": { },

View File

@ -186,9 +186,9 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
{Each(loops, loop => $@" {Each(loops, loop => $@"
public partial class {loop.ClassName} public partial class {loop.ClassName}
{{ {{
long _bits = 0; private long _bits = 0;
{Each(loop.Headers, header => @" {Each(loop.Headers, header => @"
StringValues _" + header.Identifier + ";")} private StringValues _" + header.Identifier + ";")}
protected override int GetCountFast() protected override int GetCountFast()
{{ {{

View File

@ -1,8 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.AspNet.Server.Kestrel.GeneratedCode namespace Microsoft.AspNet.Server.Kestrel.GeneratedCode
{ {

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>82295647-7c1c-4671-bab6-0fef58f949ec</ProjectGuid>
<RootNamespace>Microsoft.StandardsPolice</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View File

@ -0,0 +1,49 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.StandardsPolice
{
public class Program
{
public int Main(string[] args)
{
var tree = CSharpSyntaxTree.ParseText(@"
public class Hello { protected int _foo; int _bar; }
public class World { protected int _foo; int _bar; }
");
var diags = new List<Diagnostic>();
var comp = CSharpCompilation.Create("Comp", new[] { tree });
StandardsPoliceCompileModule.ScanSyntaxTree(diags, tree);
var hello = comp.GetTypeByMetadataName("Hello");
foreach (var f in hello.GetMembers().OfType<IFieldSymbol>())
{
var syntax = f.DeclaringSyntaxReferences.Single().GetSyntax();
Console.WriteLine($"{syntax.ToFullString()}");
var fds = syntax.Parent.Parent as FieldDeclarationSyntax;
var toks = syntax.DescendantTokens().ToArray();
var nods = syntax.DescendantNodesAndSelf().ToArray();
var mods = fds.Modifiers;
foreach (var mod in fds.Modifiers)
{
Console.WriteLine($"{mod.Kind()} {mod.ToFullString()}");
}
var locs = f.Locations.ToArray();
}
foreach(var d in diags)
{
Console.WriteLine(d);
}
return 0;
}
}
}

View File

@ -0,0 +1,109 @@
using Microsoft.Dnx.Compilation.CSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace Microsoft.StandardsPolice
{
// This project can output the Class library as a NuGet Package.
// To enable this option, right-click on the project and select the Properties menu item. In the Build tab select "Produce outputs on build".
public class StandardsPoliceCompileModule : ICompileModule
{
public void BeforeCompile(BeforeCompileContext context)
{
ScanNamespace(context.Diagnostics, context.Compilation.GlobalNamespace);
foreach (var st in context.Compilation.SyntaxTrees)
{
if (!st.FilePath.EndsWith(".Generated.cs"))
{
ScanSyntaxTree(context.Diagnostics, st);
}
}
}
internal static void ScanSyntaxTree(IList<Diagnostic> diagnostics, SyntaxTree syntaxTree)
{
var root = syntaxTree.GetRoot();
var typeDeclarations = root.DescendantNodes(descendIntoChildren: node => !(node is TypeDeclarationSyntax))
.OfType<TypeDeclarationSyntax>()
.ToArray();
if (typeDeclarations.Length > 1)
{
foreach (var typeDeclaration in typeDeclarations)
{
diagnostics.Add(Diagnostic.Create(
"SP1002", "StandardsPolice", "more than one type per file",
DiagnosticSeverity.Warning,
DiagnosticSeverity.Warning,
false,
3,
location: typeDeclaration.GetLocation()));
}
}
}
private static void ScanNamespace(IList<Diagnostic> diagnostics, INamespaceSymbol namespaceSymbol)
{
foreach (var member in namespaceSymbol.GetNamespaceMembers())
{
ScanNamespace(diagnostics, member);
}
foreach (var member in namespaceSymbol.GetTypeMembers())
{
ScanType(diagnostics, member);
}
}
private static void ScanType(IList<Diagnostic> diagnostics, INamedTypeSymbol typeSymbol)
{
foreach (var member in typeSymbol.GetMembers().OfType<IFieldSymbol>())
{
if (member.DeclaredAccessibility != Accessibility.Private)
{
continue;
}
foreach (var syntaxReference in member.DeclaringSyntaxReferences)
{
var fieldHasPrivateKeyword = false;
var syntax = syntaxReference.GetSyntax();
var fds = syntax?.Parent?.Parent as FieldDeclarationSyntax;
if (fds == null)
{
continue;
}
foreach (var mod in fds.Modifiers)
{
if (mod.IsKind(CodeAnalysis.CSharp.SyntaxKind.PrivateKeyword))
{
fieldHasPrivateKeyword = true;
}
}
if (!fieldHasPrivateKeyword)
{
diagnostics.Add(Diagnostic.Create(
"SP1001", "StandardsPolice", "private keyword missing",
DiagnosticSeverity.Warning,
DiagnosticSeverity.Warning,
false,
3,
location: member.Locations.SingleOrDefault()));
}
}
}
foreach (var member in typeSymbol.GetTypeMembers())
{
ScanType(diagnostics, member);
}
}
public void AfterCompile(AfterCompileContext context)
{
}
}
}

View File

@ -0,0 +1,28 @@
{
"version": "1.0.0-*",
"description": "Microsoft.StandardsPolice Class Library",
"dependencies": {
"Microsoft.Dnx.Compilation.CSharp.Abstractions": "1.0.0-beta8-*"
},
"commands": {
"Microsoft.StandardsPolice": "Microsoft.StandardsPolice"
},
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
"System.Runtime": "",
"System.Text.Encoding": "",
"System.Threading.Tasks": ""
}
},
"dnxcore50": {
"dependencies": {
"System.Console": "4.0.0-beta-*"
}
}
}
}