Adds coding standards (#22)

* Adds code requirements

* Update to coding standard
This commit is contained in:
Tim Seaward
2017-11-14 00:45:54 +00:00
committed by Ben Adams
parent fa0ad4ca52
commit 77ba50dff9
8 changed files with 135 additions and 78 deletions

View File

@@ -1,4 +1,4 @@
// Copyright (c) Ben A Adams. All rights reserved.
// Copyright (c) Ben A Adams. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// 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.
@@ -86,10 +86,12 @@ namespace System.Diagnostics
return null;
}
MethodBase method = originMethod;
var method = originMethod;
var methodDisplayInfo = new ResolvedMethod();
methodDisplayInfo.SubMethodBase = method;
var methodDisplayInfo = new ResolvedMethod
{
SubMethodBase = method
};
// Type name
var type = method.DeclaringType;
@@ -240,7 +242,7 @@ namespace System.Diagnostics
var generatedName = methodName;
if (!TryParseGeneratedName(generatedName, out kind, out int openBracketOffset, out int closeBracketOffset))
if (!TryParseGeneratedName(generatedName, out kind, out var openBracketOffset, out var closeBracketOffset))
{
return false;
}
@@ -464,10 +466,10 @@ namespace System.Diagnostics
private static int IndexOfBalancedParenthesis(string str, int openingOffset, char closing)
{
char opening = str[openingOffset];
var opening = str[openingOffset];
int depth = 1;
for (int i = openingOffset + 1; i < str.Length; i++)
var depth = 1;
for (var i = openingOffset + 1; i < str.Length; i++)
{
var c = str[i];
if (c == opening)

View File

@@ -1,4 +1,4 @@
// Copyright (c) Ben A Adams. All rights reserved.
// Copyright (c) Ben A Adams. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace System.Collections.Generic.Enumerable
@@ -12,10 +12,7 @@ namespace System.Collections.Generic.Enumerable
{
private readonly IList<T> _list;
public EnumerableIList(IList<T> list)
{
_list = list;
}
public EnumerableIList(IList<T> list) => _list = list;
public EnumeratorIList<T> GetEnumerator() => new EnumeratorIList<T>(_list);

View File

@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Reflection.Emit;
namespace System.Diagnostics.Internal
@@ -12,10 +12,7 @@ namespace System.Diagnostics.Internal
private int ptr;
public ILReader(byte[] cil)
{
_cil = cil;
}
public ILReader(byte[] cil) => _cil = cil;
public OpCode OpCode { get; private set; }
public int MetadataToken { get; private set; }
@@ -34,7 +31,7 @@ namespace System.Diagnostics.Internal
OpCode ReadOpCode()
{
byte instruction = ReadByte();
var instruction = ReadByte();
if (instruction < 254)
return singleByteOpCode[instruction];
else
@@ -71,18 +68,15 @@ namespace System.Diagnostics.Internal
return null;
}
byte ReadByte()
{
return _cil[ptr++];
}
byte ReadByte() => _cil[ptr++];
int ReadInt()
{
byte b1 = ReadByte();
byte b2 = ReadByte();
byte b3 = ReadByte();
byte b4 = ReadByte();
return (int)b1 | (((int)b2) << 8) | (((int)b3) << 16) | (((int)b4) << 24);
var b1 = ReadByte();
var b2 = ReadByte();
var b3 = ReadByte();
var b4 = ReadByte();
return b1 | b2 << 8 | b3 << 16 | b4 << 24;
}
static ILReader()
@@ -90,11 +84,11 @@ namespace System.Diagnostics.Internal
singleByteOpCode = new OpCode[225];
doubleByteOpCode = new OpCode[31];
FieldInfo[] fields = GetOpCodeFields();
var fields = GetOpCodeFields();
for (int i = 0; i < fields.Length; i++)
for (var i = 0; i < fields.Length; i++)
{
OpCode code = (OpCode)fields[i].GetValue(null);
var code = (OpCode)fields[i].GetValue(null);
if (code.OpCodeType == OpCodeType.Nternal)
continue;
@@ -105,9 +99,6 @@ namespace System.Diagnostics.Internal
}
}
static FieldInfo[] GetOpCodeFields()
{
return typeof(OpCodes).GetFields(BindingFlags.Public | BindingFlags.Static);
}
static FieldInfo[] GetOpCodeFields() => typeof(OpCodes).GetFields(BindingFlags.Public | BindingFlags.Static);
}
}

View File

@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// 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.Collections.Generic;
@@ -70,8 +70,7 @@ namespace System.Diagnostics.Internal
private MetadataReader GetMetadataReader(string assemblyPath)
{
MetadataReaderProvider provider = null;
if (!_cache.TryGetValue(assemblyPath, out provider))
if (!_cache.TryGetValue(assemblyPath, out var provider))
{
var pdbPath = GetPdbPath(assemblyPath);