System.Reflection.RuntimeMethodInfo.InternalGetCurrentMethod C# (CSharp) Method

InternalGetCurrentMethod() static private method

static private InternalGetCurrentMethod ( System.Threading.StackCrawlMark &stackMark ) : MethodBase
stackMark System.Threading.StackCrawlMark
return MethodBase
        internal static MethodBase InternalGetCurrentMethod(ref StackCrawlMark stackMark)
        {
            RuntimeMethodHandle method = RuntimeMethodHandle.GetCurrentMethod(ref stackMark);

            if (method.IsNullHandle()) 
                return null;

            // If C<Foo>.m<Bar> was called, GetCurrentMethod returns C<object>.m<object>. We cannot
            // get know that the instantiation used Foo or Bar at that point. So the next best thing
            // is to return C<T>.m<P> and that's what GetTypicalMethodDefinition will do for us. 
            method = method.GetTypicalMethodDefinition();
            
            return RuntimeType.GetMethodBase(method);
        }
        #endregion

Usage Example

Esempio n. 1
0
        [MethodImplAttribute(MethodImplOptions.NoInlining)] // Methods containing StackCrawlMark local var has to be marked non-inlineable
        public static MethodBase GetCurrentMethod()
        {
            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;

            return(RuntimeMethodInfo.InternalGetCurrentMethod(ref stackMark));
        }