File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Linq . Expressions ;
3
+ using System . Reflection ;
3
4
4
5
namespace NHibernate . Impl
5
6
{
6
7
#if NET461
7
8
internal static class LambdaExpressionExtensions
8
9
{
9
- public static Delegate Compile ( this LambdaExpression expression , bool preferInterpretation ) =>
10
- expression . Compile ( ) ; //Concurrent Compile() call causes "Garbage Collector" suspend all threads too often
10
+ //NET4.6.1 does not have this method exposed,
11
+ //however it might be available in runtime
12
+ private static readonly MethodInfo CompileWithPreference = typeof ( LambdaExpression )
13
+ . GetMethod ( "Compile" , new [ ] { typeof ( bool ) } ) ;
14
+
15
+ public static Delegate Compile ( this LambdaExpression expression , bool preferInterpretation )
16
+ {
17
+ if ( CompileWithPreference != null )
18
+ {
19
+ return ( Delegate ) CompileWithPreference . Invoke ( expression , new object [ ] { preferInterpretation } ) ;
20
+ }
21
+
22
+ return expression . Compile ( ) ; //Concurrent Compile() call causes "Garbage Collector" suspend all threads too often
23
+ }
11
24
}
12
25
#endif
13
26
}
You can’t perform that action at this time.
0 commit comments