Skip to content

Commit 2fb3e59

Browse files
committed
remove noise
1 parent fae0be3 commit 2fb3e59

File tree

4 files changed

+12
-39
lines changed

4 files changed

+12
-39
lines changed

src/FastExpressionCompiler.ILDecoder/DynamicScopeTokenResolver.cs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ namespace FastExpressionCompiler.ILDecoder;
77

88
internal class DynamicScopeTokenResolver : ITokenResolver
99
{
10-
#region Static stuff
11-
1210
private static readonly PropertyInfo s_indexer;
1311
private static readonly FieldInfo s_scopeFi;
1412

@@ -43,21 +41,16 @@ static DynamicScopeTokenResolver()
4341
s_genfieldFi2 = s_genFieldInfoType?.GetField("m_context", flags);
4442
}
4543

46-
#endregion
47-
4844
private readonly object m_scope;
4945

50-
private object this[int token] => s_indexer.GetValue(m_scope, new object[] {token});
46+
private object this[int token] => s_indexer.GetValue(m_scope, new object[] { token });
5147

5248
public DynamicScopeTokenResolver(DynamicMethod dm)
5349
{
5450
m_scope = s_scopeFi.GetValue(dm.GetILGenerator());
5551
}
5652

57-
public string AsString(int token)
58-
{
59-
return this[token] as string;
60-
}
53+
public string AsString(int token) => this[token] as string;
6154

6255
public FieldInfo AsField(int token)
6356
{
@@ -114,8 +107,5 @@ public MemberInfo AsMember(int token)
114107
return null;
115108
}
116109

117-
public byte[] AsSignature(int token)
118-
{
119-
return this[token] as byte[];
120-
}
110+
public byte[] AsSignature(int token) => this[token] as byte[];
121111
}

src/FastExpressionCompiler.ILDecoder/ILReader.cs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,8 @@ public ILReader(MethodBase method)
3535

3636
public ILReader(IILProvider ilProvider, ITokenResolver tokenResolver)
3737
{
38-
if (ilProvider == null)
39-
throw new ArgumentNullException(nameof(ilProvider));
40-
4138
_resolver = tokenResolver;
42-
_byteArray = ilProvider.GetByteArray();
39+
_byteArray = ilProvider?.GetByteArray() ?? throw new ArgumentNullException(nameof(ilProvider));
4340
}
4441

4542
public IEnumerator<ILInstruction> GetEnumerator()
@@ -184,20 +181,6 @@ private ushort ReadUInt16(ref int position)
184181
return value;
185182
}
186183

187-
private uint ReadUInt32(ref int position)
188-
{
189-
var value = BitConverter.ToUInt32(_byteArray, position);
190-
position += 4;
191-
return value;
192-
}
193-
194-
private ulong ReadUInt64(ref int position)
195-
{
196-
var value = BitConverter.ToUInt64(_byteArray, position);
197-
position += 8;
198-
return value;
199-
}
200-
201184
private int ReadInt32(ref int position)
202185
{
203186
var value = BitConverter.ToInt32(_byteArray, position);

src/FastExpressionCompiler.ILDecoder/ILReaderFactory.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,5 @@ public static string TypeToCode(this Type type,
294294
}
295295
}
296296

297+
298+

src/FastExpressionCompiler/TestTools.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#if DEBUG
33
#define PRINTIL
44
#define PRINTCS
5+
#define PRINTEXPR
56
#endif
67

78
using System;
@@ -60,18 +61,20 @@ public static void AssertOpCodes(this MethodInfo method, params OpCode[] expecte
6061

6162
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
6263
Justification = "The method is used for the testing purposes only.")]
63-
[Conditional("DEBUG")]
64-
public static void PrintExpression(this Expression expr, bool completeTypeNames = false) =>
64+
public static void PrintExpression(this Expression expr, bool completeTypeNames = false)
65+
{
66+
#if PRINTEXPR
6567
Console.WriteLine(
6668
expr.ToExpressionString(out var _, out var _, out var _,
6769
stripNamespace: true,
6870
printType: completeTypeNames ? null : CodePrinter.PrintTypeStripOuterClasses,
6971
indentSpaces: 4)
7072
);
73+
#endif
74+
}
7175

7276
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
7377
Justification = "The method is used for the testing purposes only.")]
74-
[Conditional("DEBUG")]
7578
public static void PrintCSharp(this Expression expr, bool completeTypeNames = false,
7679
[CallerMemberName] string caller = "", [CallerFilePath] string filePath = "")
7780
{
@@ -93,7 +96,6 @@ public static void PrintCSharp(this Expression expr, bool completeTypeNames = fa
9396

9497
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
9598
Justification = "The method is used for the testing purposes only.")]
96-
[Conditional("DEBUG")]
9799
public static void PrintCSharp(this Expression expr, Func<string, string> transform,
98100
[CallerMemberName] string caller = "", [CallerFilePath] string filePath = "")
99101
{
@@ -106,7 +108,6 @@ public static void PrintCSharp(this Expression expr, Func<string, string> transf
106108

107109
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
108110
Justification = "The method is used for the testing purposes only.")]
109-
[Conditional("DEBUG")]
110111
public static void PrintCSharp(this Expression expr, CodePrinter.ObjectToCode objectToCode,
111112
[CallerMemberName] string caller = "", [CallerFilePath] string filePath = "")
112113
{
@@ -119,23 +120,20 @@ public static void PrintCSharp(this Expression expr, CodePrinter.ObjectToCode ob
119120

120121
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode",
121122
Justification = "The method is used for the testing purposes only.")]
122-
[Conditional("DEBUG")]
123123
public static void PrintCSharp(this Expression expr, ref string result)
124124
{
125125
#if PRINTCS
126126
Console.WriteLine(result = expr.ToCSharpString());
127127
#endif
128128
}
129129

130-
[Conditional("DEBUG")]
131130
public static void PrintIL(this Delegate @delegate, [CallerMemberName] string tag = null)
132131
{
133132
#if PRINTIL
134133
@delegate.Method.PrintIL(tag);
135134
#endif
136135
}
137136

138-
[Conditional("DEBUG")]
139137
public static void PrintIL(this MethodInfo method, string tag = null)
140138
{
141139
#if PRINTIL

0 commit comments

Comments
 (0)