Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Strehovsky <michals@microsoft.com>2017-08-19 00:21:01 +0300
committerMichal Strehovsky <michals@microsoft.com>2017-08-19 00:21:01 +0300
commit52e15b8fc4497582dd1112b01c46c76f6203e1b3 (patch)
tree43bce6919a86167ec028307140748d872ec85d79 /src/System.Private.Reflection.Execution
parent3870ea4d5914e3255031bb613a24cd541157288d (diff)
Improve diagnosability of Expression.Lambda(Expression.Constant(123)).Compile().GetMethodInfo()
Entity framework would like to inspect the MethodInfo obtained from a delegate that points to the LINQ expression interpreter. This will currently throw a very unhelpful exception that makes it look like we're missing metadata - when in fact, we're missing a feature. EF will ship with a workaround in their 2.0.1 release, but if anyone tries with 2.0.0 (or hits this in any other way), let's give them something more diagnosable. [tfs-changeset: 1670903]
Diffstat (limited to 'src/System.Private.Reflection.Execution')
-rw-r--r--src/System.Private.Reflection.Execution/src/Internal/Reflection/Extensions/NonPortable/DelegateMethodInfoRetriever.cs13
-rw-r--r--src/System.Private.Reflection.Execution/src/Resources/Strings.resx3
2 files changed, 13 insertions, 3 deletions
diff --git a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Extensions/NonPortable/DelegateMethodInfoRetriever.cs b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Extensions/NonPortable/DelegateMethodInfoRetriever.cs
index ed1255ed9..c40196a1c 100644
--- a/src/System.Private.Reflection.Execution/src/Internal/Reflection/Extensions/NonPortable/DelegateMethodInfoRetriever.cs
+++ b/src/System.Private.Reflection.Execution/src/Internal/Reflection/Extensions/NonPortable/DelegateMethodInfoRetriever.cs
@@ -24,9 +24,16 @@ namespace Internal.Reflection.Extensions.NonPortable
throw new ArgumentException();
Delegate[] invokeList = del.GetInvocationList();
del = invokeList[invokeList.Length - 1];
- RuntimeTypeHandle typeOfFirstParameterIfInstanceDelegate;
- bool isOpenResolver;
- IntPtr originalLdFtnResult = RuntimeAugments.GetDelegateLdFtnResult(del, out typeOfFirstParameterIfInstanceDelegate, out isOpenResolver);
+ IntPtr originalLdFtnResult = RuntimeAugments.GetDelegateLdFtnResult(del, out RuntimeTypeHandle typeOfFirstParameterIfInstanceDelegate, out bool isOpenResolver, out bool isInterpreterEntrypoint);
+
+ if (isInterpreterEntrypoint)
+ {
+ // This is a special kind of delegate where the invoke method is "ObjectArrayThunk". Typically,
+ // this will be a delegate that points the the LINQ Expression interpreter. We could manufacture
+ // a MethodInfo based on the delegate's Invoke signature, but let's just throw for now.
+ throw new PlatformNotSupportedException(SR.DelegateGetMethodInfo_ObjectArrayDelegate);
+ }
+
if (originalLdFtnResult == (IntPtr)0)
return null;
diff --git a/src/System.Private.Reflection.Execution/src/Resources/Strings.resx b/src/System.Private.Reflection.Execution/src/Resources/Strings.resx
index e4e0e5324..b64eab36f 100644
--- a/src/System.Private.Reflection.Execution/src/Resources/Strings.resx
+++ b/src/System.Private.Reflection.Execution/src/Resources/Strings.resx
@@ -237,4 +237,7 @@
<data name="DelegateGetMethodInfo_NoInstantiation" xml:space="preserve">
<value>Cannot retrieve a MethodInfo for this delegate because the necessary generic instantiation was not metadata-enabled. For more information, please visit http://go.microsoft.com/fwlink/?LinkID=616868</value>
</data>
+ <data name="DelegateGetMethodInfo_ObjectArrayDelegate" xml:space="preserve">
+ <value>Cannot retrieve a MethodInfo for this delegate because the delegate target is an interpreted LINQ expression.</value>
+ </data>
</root>