rotor2.0的runtimetype之谜

不是说Rotor是公开的源码吗?怎么找不到RumtimeType这个源文件啊。

最近在研究它的reflection机制。在一句代码

Type t = cust.GetType();//cust是一个对象
MethodInfo method = t.GetMethod("DoSomething");

我寻根究底找到Type的源文件("C:\sscli20\clr\src\bcl\system"目录下),发现它是个abstrace的类,

并且GetMethod方法调用了GetMethodImpl方法。而GetMethodImpl方法也是一个abstrace。

所以找到它的派生类typedelegator("C:\sscli20\clr\src\bcl\system\reflection"目录下)。我就迷糊了

protected Type typeImpl;

public TypeDelegator(Type delegatingType) {
            if (delegatingType == null)
                throw new ArgumentNullException("delegatingType");
               
            typeImpl = delegatingType;
        }

protected override MethodInfo GetMethodImpl(String name,BindingFlags bindingAttr,Binder binder,
                CallingConventions callConvention, Type[] types,ParameterModifier[] modifiers)
        {
            // This is interesting there are two paths into the impl.  One that validates
            //  type as non-null and one where type may be null.
            if (types == null)
                return typeImpl.GetMethod(name,bindingAttr);
            else
                return typeImpl.GetMethod(name,bindingAttr,binder,callConvention,types,modifiers);
        }

怎么又调用了Type类的GetMethod啊??????why???????????

后来我在rotor里运行了一下我的试验程序。

set COMPlus_JitTrace=1

clix Program.exe

发现

 GetMethodImpl是由RuntimeType类运行的。顺藤摸瓜去找那个类的源文件,发现找不到。反编译mscorlib里面也没有,msdn上也没有。到底是什么回事啊????????

 

后来我无意之中心血来潮,看了了下rotor1.1版本的源文件。我居然发现了runtimetype!why????

posted on 2009-10-25 11:57  John Connor  阅读(312)  评论(0编辑  收藏  举报

导航