/// <summary>
 /// Get a field or property of an object with a given name.
 /// </summary>
 public NamedValue GetMember(string name)
 {
     try
     {
         DebugType currentType = this.Type;
         while (currentType != null)
         {
             foreach (MemberInfo memberInfo in currentType.GetMember(name, BindingFlags.All))
             {
                 if (memberInfo is FieldInfo)
                 {
                     return(((FieldInfo)memberInfo).GetValue(this));
                 }
                 if (memberInfo is PropertyInfo)
                 {
                     return(((PropertyInfo)memberInfo).GetValue(this));
                 }
             }
             currentType = currentType.BaseType;
         }
     }
     catch
     {
     }
     return(null);
 }
Beispiel #2
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());
        }
Beispiel #3
0
 public static PropertyInfo GetProperty(DebugType t, string name)
 {
     return(t.GetMember(name, Debugger.BindingFlags.All)[0] as PropertyInfo);
 }
Beispiel #4
0
 public static MethodInfo GetMethod(DebugType t, string name)
 {
     return(t.GetMember(name, Debugger.BindingFlags.All)[0] as MethodInfo);
 }