Skip to content

Commit cd59c8e

Browse files
author
Maksim Volkau
committed
handling enum in CodePrinter.ToCode(this Type)
1 parent 58cca84 commit cd59c8e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/FastExpressionCompiler/FastExpressionCompiler.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11356,6 +11356,13 @@ public static string ToCode(this Type type,
1135611356
type = type.GetElementType();
1135711357
}
1135811358

11359+
if (type.IsEnum)
11360+
{
11361+
var result = !stripNamespace && !string.IsNullOrEmpty(type.Namespace)
11362+
? string.Concat(type.Namespace, ".", type.Name) : type.Name;
11363+
return printType?.Invoke(type, result) ?? result;
11364+
}
11365+
1135911366
var buildInTypeString = type.GetPrimitiveTypeNameAliasOrNull();
1136011367
if (buildInTypeString != null)
1136111368
{

test/FastExpressionCompiler.IssueTests/Issue476_System_ExecutionEngineException_with_nullables_on_repeated_calls_to_ConcurrentDictionary copy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void Original_case(TestContext t)
3333
expr.PrintCSharp();
3434

3535
var fs = expr.CompileSys();
36-
fs.PrintIL();
36+
fs.PrintIL(format: ILDecoder.ILFormat.AssertOpCodes);
3737

3838
// make reader and advance to the Null token
3939
var reader = new Utf8JsonReader("null"u8);
@@ -45,7 +45,7 @@ public void Original_case(TestContext t)
4545
t.AreEqual(default, a);
4646

4747
var ff = expr.CompileFast(false);
48-
ff.PrintIL();
48+
ff.PrintIL(format: ILDecoder.ILFormat.AssertOpCodes);
4949

5050
var b = ff(ref reader);
5151
t.AreEqual(default, b);

0 commit comments

Comments
 (0)