Skip to content

Commit 7b8d59b

Browse files
committed
Remove Castclass from complex constants on .NET Core
It seems that this was introduced to mitigate an issue on .NET Framework, so I left it on this platform. However, it seems unnecessary on .NET Core and seems to create slight performance trouble for me. The NETFRAMEWORK constnant should be automatically defined by C#, so no need to define it in csproj (https://docs.microsoft.com/en-us/dotnet/standard/frameworks#how-to-specify-a-target-framework)
1 parent be17c10 commit 7b8d59b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/FastExpressionCompiler/FastExpressionCompiler.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2991,8 +2991,14 @@ private static bool TryEmitConstantOfNotNullValue(
29912991
il.Emit(OpCodes.Ldelem_Ref);
29922992
if (exprType.IsValueType)
29932993
il.Emit(OpCodes.Unbox_Any, exprType);
2994-
else // todo: @perf it is probably required only for Full CLR starting from NET45, e.g. `Test_283_Case6_MappingSchemaTests_CultureInfo_VerificationException`
2994+
else
2995+
{
2996+
// this is probably required only for Full CLR starting from NET45, e.g. `Test_283_Case6_MappingSchemaTests_CultureInfo_VerificationException`
2997+
// .NET Core does not seem to care about verifiability and it's faster without the explicit cast
2998+
#if NETFRAMEWORK
29952999
il.Emit(OpCodes.Castclass, exprType);
3000+
#endif
3001+
}
29963002
}
29973003
}
29983004
else

0 commit comments

Comments
 (0)