Beispiel #1
0
        internal StackFrame(Thread thread, ICorDebugILFrame corILFrame, uint chainIndex, uint frameIndex)
        {
            this.process                = thread.Process;
            this.thread                 = thread;
            this.appDomain              = process.AppDomains[corILFrame.GetFunction().GetClass().GetModule().GetAssembly().GetAppDomain()];
            this.corILFrame             = corILFrame;
            this.corILFramePauseSession = process.PauseSession;
            this.corFunction            = corILFrame.GetFunction();
            this.chainIndex             = chainIndex;
            this.frameIndex             = frameIndex;

            MetaDataImport metaData      = thread.Process.Modules[corFunction.GetClass().GetModule()].MetaData;
            int            methodGenArgs = metaData.EnumGenericParams(corFunction.GetToken()).Length;
            // Class parameters are first, then the method ones
            List <ICorDebugType> corGenArgs = ((ICorDebugILFrame2)corILFrame).EnumerateTypeParameters().ToList();

            // Remove method parametrs at the end
            corGenArgs.RemoveRange(corGenArgs.Count - methodGenArgs, methodGenArgs);
            List <DebugType> genArgs = new List <DebugType>(corGenArgs.Count);

            foreach (ICorDebugType corGenArg in corGenArgs)
            {
                genArgs.Add(DebugType.CreateFromCorType(this.AppDomain, corGenArg));
            }

            DebugType debugType = DebugType.CreateFromCorClass(
                this.AppDomain,
                null,
                corFunction.GetClass(),
                genArgs.ToArray()
                );

            this.methodInfo = (DebugMethodInfo)debugType.GetMember(corFunction.GetToken());
        }