Browse Source

Polishing API and implemented more reflection methods

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5106 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 17 years ago
parent
commit
345570538f
  1. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/CallStackPad.cs
  2. 5
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/StackFrameNode.cs
  3. 10
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Eval.cs
  4. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/StackFrame.cs
  5. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Expressions/ExpressionEvaluator.cs
  6. 60
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugFieldInfo.cs
  7. 27
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugLocalVariableInfo.cs
  8. 295
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugMethodInfo.cs
  9. 13
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugParameterInfo.cs
  10. 83
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugPropertyInfo.cs
  11. 140
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs
  12. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/IDebugMemberInfo.cs
  13. 9
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Object.cs

2
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/CallStackPad.cs

@ -215,7 +215,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
string argValue = null; string argValue = null;
if (showArgumentNames) { if (showArgumentNames) {
try { try {
parameterName = frame.MethodInfo.GetParameterName(i); parameterName = frame.MethodInfo.GetParameters()[i].Name;
} catch { } } catch { }
if (parameterName == "") parameterName = null; if (parameterName == "") parameterName = null;
} }

5
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/StackFrameNode.cs

@ -4,6 +4,7 @@
// <version>$Revision$</version> // <version>$Revision$</version>
// </file> // </file>
using Debugger.MetaData;
using System.Collections.Generic; using System.Collections.Generic;
using ICSharpCode.NRefactory.Ast; using ICSharpCode.NRefactory.Ast;
@ -27,8 +28,8 @@ namespace Debugger.AddIn.TreeModel
IEnumerable<TreeNode> LazyGetChildNodes() IEnumerable<TreeNode> LazyGetChildNodes()
{ {
foreach(string arg in stackFrame.MethodInfo.ParameterNames) { foreach(DebugParameterInfo par in stackFrame.MethodInfo.GetParameters()) {
yield return new ExpressionNode(ExpressionNode.GetImageForParameter(), arg, new IdentifierExpression(arg)); yield return new ExpressionNode(ExpressionNode.GetImageForParameter(), par.Name, new IdentifierExpression(par.Name));
} }
foreach(string loc in stackFrame.MethodInfo.LocalVariableNames) { foreach(string loc in stackFrame.MethodInfo.LocalVariableNames) {
yield return new ExpressionNode(ExpressionNode.GetImageForLocalVariable(), loc, new IdentifierExpression(loc)); yield return new ExpressionNode(ExpressionNode.GetImageForLocalVariable(), loc, new IdentifierExpression(loc));

10
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Eval.cs

@ -191,16 +191,6 @@ namespace Debugger
} }
} }
#region Convenience methods
/// <summary> Synchronously calls a function and returns its return value </summary>
public static Value InvokeMethod(AppDomain appDomain, System.Type type, string name, Value thisValue, Value[] args)
{
return InvokeMethod(DebugMethodInfo.GetFromName(appDomain, type, name, args.Length), thisValue, args);
}
#endregion
/// <summary> Synchronously calls a function and returns its return value </summary> /// <summary> Synchronously calls a function and returns its return value </summary>
public static Value InvokeMethod(DebugMethodInfo method, Value thisValue, Value[] args) public static Value InvokeMethod(DebugMethodInfo method, Value thisValue, Value[] args)
{ {

6
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/StackFrame.cs

@ -357,7 +357,7 @@ namespace Debugger
public Value GetArgumentValue(string name) public Value GetArgumentValue(string name)
{ {
for(int i = 0; i < this.ArgumentCount; i++) { for(int i = 0; i < this.ArgumentCount; i++) {
if (this.MethodInfo.GetParameterName(i) == name) { if (this.MethodInfo.GetParameters()[i].Name == name) {
return GetArgumentValue(i); return GetArgumentValue(i);
} }
} }
@ -382,7 +382,7 @@ namespace Debugger
/// <returns> Null if not found </returns> /// <returns> Null if not found </returns>
public Value GetLocalVariableValue(string name) public Value GetLocalVariableValue(string name)
{ {
foreach(DebugLocalVariableInfo locVar in this.MethodInfo.LocalVariables) { foreach(DebugLocalVariableInfo locVar in this.MethodInfo.GetLocalVariables()) {
if (locVar.Name == name) { if (locVar.Name == name) {
return locVar.GetValue(this); return locVar.GetValue(this);
} }
@ -394,7 +394,7 @@ namespace Debugger
public List<Value> GetLocalVariableValues() public List<Value> GetLocalVariableValues()
{ {
List<Value> values = new List<Value>(); List<Value> values = new List<Value>();
foreach(DebugLocalVariableInfo locVar in this.MethodInfo.LocalVariables) { foreach(DebugLocalVariableInfo locVar in this.MethodInfo.GetLocalVariables()) {
values.Add(locVar.GetValue(this)); values.Add(locVar.GetValue(this));
} }
return values; return values;

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Expressions/ExpressionEvaluator.cs

@ -407,7 +407,7 @@ namespace Debugger
public override object VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, object data) public override object VisitThisReferenceExpression(ThisReferenceExpression thisReferenceExpression, object data)
{ {
// This is needed so that captured 'this' is supported // This is needed so that captured 'this' is supported
foreach(DebugLocalVariableInfo locVar in context.MethodInfo.LocalVariables) { foreach(DebugLocalVariableInfo locVar in context.MethodInfo.GetLocalVariables()) {
if (locVar.IsThis) if (locVar.IsThis)
return locVar.GetValue(context); return locVar.GetValue(context);
} }

60
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugFieldInfo.cs

@ -28,51 +28,42 @@ namespace Debugger.MetaData
} }
public override Type DeclaringType { public override Type DeclaringType {
get { get { return declaringType; }
return declaringType;
}
} }
/// <summary> The AppDomain in which this member is loaded </summary> /// <summary> The AppDomain in which this member is declared </summary>
[Debugger.Tests.Ignore]
public AppDomain AppDomain { public AppDomain AppDomain {
get { get { return declaringType.AppDomain; }
return declaringType.AppDomain;
}
} }
/// <summary> The Process in which this member is loaded </summary> /// <summary> The Process in which this member is declared </summary>
[Debugger.Tests.Ignore]
public Process Process { public Process Process {
get { get { return declaringType.Process; }
return declaringType.Process;
}
} }
/// <summary> The Module in which this member is loaded </summary> /// <summary> The Module in which this member is declared </summary>
[Debugger.Tests.Ignore]
public Debugger.Module DebugModule { public Debugger.Module DebugModule {
get { get { return declaringType.DebugModule; }
return declaringType.DebugModule;
}
} }
[Debugger.Tests.Ignore] [Debugger.Tests.Ignore]
public override int MetadataToken { public override int MetadataToken {
get { get { return (int)fieldProps.Token; }
return (int)fieldProps.Token;
}
} }
// public virtual Module Module { get; } public override System.Reflection.Module Module {
get { throw new NotSupportedException(); }
}
public override string Name { public override string Name {
get { get { return fieldProps.Name; }
return fieldProps.Name;
}
} }
public override Type ReflectedType { public override Type ReflectedType {
get { get { throw new NotSupportedException(); }
throw new NotSupportedException();
}
} }
public override object[] GetCustomAttributes(bool inherit) public override object[] GetCustomAttributes(bool inherit)
@ -87,19 +78,15 @@ namespace Debugger.MetaData
public override bool IsDefined(Type attributeType, bool inherit) public override bool IsDefined(Type attributeType, bool inherit)
{ {
throw new NotSupportedException(); return DebugType.IsDefined(this, inherit, attributeType);
} }
public override FieldAttributes Attributes { public override FieldAttributes Attributes {
get { get { return (FieldAttributes)fieldProps.Flags; }
return (FieldAttributes)fieldProps.Flags;
}
} }
public override RuntimeFieldHandle FieldHandle { public override RuntimeFieldHandle FieldHandle {
get { get { throw new NotSupportedException(); }
throw new NotSupportedException();
}
} }
public override Type FieldType { public override Type FieldType {
@ -116,12 +103,17 @@ namespace Debugger.MetaData
public override object GetValue(object obj) public override object GetValue(object obj)
{ {
throw new NotSupportedException(); return Value.GetFieldValue((Value)obj, this);
} }
public override void SetValue(object obj, object value, System.Reflection.BindingFlags invokeAttr, Binder binder, CultureInfo culture) public override void SetValue(object obj, object value, System.Reflection.BindingFlags invokeAttr, Binder binder, CultureInfo culture)
{ {
throw new NotSupportedException(); Value.SetFieldValue((Value)obj, this, (Value)value);
}
public override string ToString()
{
return this.FieldType + " " + this.Name;
} }
} }
} }

27
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugLocalVariableInfo.cs

@ -19,19 +19,33 @@ using Mono.Cecil.Signatures;
namespace Debugger.MetaData namespace Debugger.MetaData
{ {
public class DebugLocalVariableInfo public class DebugLocalVariableInfo: System.Reflection.LocalVariableInfo
{ {
ValueGetter getter; ValueGetter getter;
int localIndex;
DebugType localType;
public override int LocalIndex {
get { return localIndex; }
}
public override Type LocalType {
get { return localType; }
}
public override bool IsPinned {
get { throw new NotSupportedException(); }
}
public string Name { get; internal set; } public string Name { get; internal set; }
public DebugType Type { get; private set; }
public bool IsThis { get; internal set; } public bool IsThis { get; internal set; }
public bool IsCaptured { get; internal set; } public bool IsCaptured { get; internal set; }
public DebugLocalVariableInfo(string name, DebugType type, ValueGetter getter) public DebugLocalVariableInfo(string name, int localIndex, DebugType localType, ValueGetter getter)
{ {
this.Name = name; this.Name = name;
this.Type = type; this.localIndex = localIndex;
this.localType = localType;
this.getter = getter; this.getter = getter;
} }
@ -42,7 +56,10 @@ namespace Debugger.MetaData
public override string ToString() public override string ToString()
{ {
return this.Type.ToString() + " " + this.Name; string msg = this.LocalType + " " + this.Name;
if (IsCaptured)
msg += " (captured)";
return msg;
} }
} }
} }

295
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugMethodInfo.cs

@ -16,6 +16,7 @@ using Debugger.Wrappers.CorSym;
using Debugger.Wrappers.MetaData; using Debugger.Wrappers.MetaData;
using ICSharpCode.NRefactory.Ast; using ICSharpCode.NRefactory.Ast;
using Mono.Cecil.Signatures; using Mono.Cecil.Signatures;
using System.Text;
namespace Debugger.MetaData namespace Debugger.MetaData
{ {
@ -31,55 +32,64 @@ namespace Debugger.MetaData
} }
public override Type DeclaringType { public override Type DeclaringType {
get { get { return declaringType; }
return declaringType;
}
} }
/// <summary> The AppDomain in which this member is loaded </summary> /// <summary> The AppDomain in which this member is declared </summary>
[Debugger.Tests.Ignore]
public AppDomain AppDomain { public AppDomain AppDomain {
get { get { return declaringType.AppDomain; }
return declaringType.AppDomain;
}
} }
/// <summary> The Process in which this member is loaded </summary> /// <summary> The Process in which this member is declared </summary>
[Debugger.Tests.Ignore]
public Process Process { public Process Process {
get { get { return declaringType.Process; }
return declaringType.Process;
}
} }
/// <summary> The Module in which this member is loaded </summary> /// <summary> The Module in which this member is declared </summary>
[Debugger.Tests.Ignore]
public Debugger.Module DebugModule { public Debugger.Module DebugModule {
get { get { return declaringType.DebugModule; }
return declaringType.DebugModule;
}
} }
[Debugger.Tests.Ignore]
public override int MetadataToken { public override int MetadataToken {
get { get { return (int)methodProps.Token; }
return (int)methodProps.Token; }
}
public override System.Reflection.Module Module {
get { throw new NotSupportedException(); }
} }
// public virtual Module Module { get; }
/// <summary> Name including the declaring type and parameters </summary>
public string FullName { public string FullName {
get { get {
return this.DeclaringType.FullName + "." + this.Name; StringBuilder sb = new StringBuilder();
sb.Append(this.DeclaringType.FullName);
sb.Append(".");
sb.Append(this.Name);
sb.Append("(");
bool first = true;
foreach(DebugParameterInfo p in GetParameters()) {
if (!first)
sb.Append(", ");
first = false;
sb.Append(p.ParameterType.Name);
sb.Append(" ");
sb.Append(p.Name);
}
sb.Append(")");
return sb.ToString();
} }
} }
public override string Name { public override string Name {
get { get { return methodProps.Name; }
return methodProps.Name;
}
} }
public override Type ReflectedType { public override Type ReflectedType {
get { get { throw new NotSupportedException(); }
throw new NotSupportedException();
}
} }
public override object[] GetCustomAttributes(bool inherit) public override object[] GetCustomAttributes(bool inherit)
@ -94,42 +104,46 @@ namespace Debugger.MetaData
public override bool IsDefined(Type attributeType, bool inherit) public override bool IsDefined(Type attributeType, bool inherit)
{ {
throw new NotSupportedException(); return DebugType.IsDefined(this, inherit, attributeType);
} }
// public virtual Type[] GetGenericArguments(); // public virtual Type[] GetGenericArguments();
// public virtual MethodBody GetMethodBody(); // public virtual MethodBody GetMethodBody();
// internal virtual RuntimeMethodHandle GetMethodHandle();
public override MethodImplAttributes GetMethodImplementationFlags() public override MethodImplAttributes GetMethodImplementationFlags()
{ {
return (MethodImplAttributes)methodProps.ImplFlags; return (MethodImplAttributes)methodProps.ImplFlags;
} }
// internal virtual uint GetOneTimeFlags();
// internal virtual uint GetOneTimeSpecificFlags();
public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
{ {
throw new NotSupportedException(); List<Value> args = new List<Value>();
foreach(object arg in parameters) {
args.Add((Value)arg);
}
return Eval.InvokeMethod(this, (Value)obj, args.ToArray());
} }
public override MethodAttributes Attributes { public override MethodAttributes Attributes {
get { get { return (MethodAttributes)methodProps.Flags; }
return (MethodAttributes)methodProps.Flags;
}
} }
// public virtual CallingConventions CallingConvention { get; } // public virtual CallingConventions CallingConvention { get; }
// public virtual bool ContainsGenericParameters { get; }
// public virtual bool IsGenericMethod { get; } public override bool ContainsGenericParameters {
// public virtual bool IsGenericMethodDefinition { get; } get { throw new NotSupportedException(); }
// internal virtual bool IsOverloaded { get; } }
public override bool IsGenericMethod {
get { throw new NotSupportedException(); }
}
public override bool IsGenericMethodDefinition {
get { throw new NotSupportedException(); }
}
public override RuntimeMethodHandle MethodHandle { public override RuntimeMethodHandle MethodHandle {
get { get { throw new NotSupportedException(); }
throw new NotSupportedException();
}
} }
public override MethodInfo GetBaseDefinition() public override MethodInfo GetBaseDefinition()
@ -139,27 +153,24 @@ namespace Debugger.MetaData
// public override Type[] GetGenericArguments(); // public override Type[] GetGenericArguments();
// public virtual MethodInfo GetGenericMethodDefinition(); // public virtual MethodInfo GetGenericMethodDefinition();
// internal virtual MethodInfo GetParentDefinition();
// internal override Type GetReturnType();
// public virtual MethodInfo MakeGenericMethod(params Type[] typeArguments); // public virtual MethodInfo MakeGenericMethod(params Type[] typeArguments);
// public override bool ContainsGenericParameters { get; } // public override bool ContainsGenericParameters { get; }
// public override bool IsGenericMethod { get; }
// public override bool IsGenericMethodDefinition { get; }
// public virtual ParameterInfo ReturnParameter { get; }
public Type GetReturnType() public override ParameterInfo ReturnParameter {
{ get {
if (this.MethodDefSig.RetType.Void) return null; return new DebugParameterInfo(
if (returnType == null) { this,
returnType = DebugType.CreateFromSignature(this.DebugModule, this.MethodDefSig.RetType.Type, declaringType); string.Empty,
this.MethodDefSig.RetType.Void ?
null :
DebugType.CreateFromSignature(this.DebugModule, this.MethodDefSig.RetType.Type, declaringType),
-1
);
} }
return returnType;
} }
public override ICustomAttributeProvider ReturnTypeCustomAttributes { public override ICustomAttributeProvider ReturnTypeCustomAttributes {
get { get { throw new NotSupportedException(); }
throw new NotSupportedException();
}
} }
MethodDefSig methodDefSig; MethodDefSig methodDefSig;
@ -174,7 +185,10 @@ namespace Debugger.MetaData
} }
} }
DebugType returnType; /// <summary> Gets the number of paramters of this method </summary>
public int ParameterCount {
get { return this.MethodDefSig.ParamCount; }
}
ParameterInfo[] parameters; ParameterInfo[] parameters;
@ -183,10 +197,17 @@ namespace Debugger.MetaData
if (parameters == null) { if (parameters == null) {
parameters = new ParameterInfo[this.MethodDefSig.ParamCount]; parameters = new ParameterInfo[this.MethodDefSig.ParamCount];
for(int i = 0; i < parameters.Length; i++) { for(int i = 0; i < parameters.Length; i++) {
string name;
try {
// index = 0 is return parameter
name = this.DebugModule.MetaData.GetParamPropsForMethodIndex((uint)this.MetadataToken, (uint)i + 1).Name;
} catch {
name = String.Empty;
}
parameters[i] = parameters[i] =
new DebugParameterInfo( new DebugParameterInfo(
this, this,
this.GetParameterName(i), name,
DebugType.CreateFromSignature(this.DebugModule, this.MethodDefSig.Parameters[i].Type, declaringType), DebugType.CreateFromSignature(this.DebugModule, this.MethodDefSig.Parameters[i].Type, declaringType),
i i
); );
@ -195,9 +216,6 @@ namespace Debugger.MetaData
return parameters; return parameters;
} }
// internal virtual Type[] GetParameterTypes();
// internal virtual ParameterInfo[] GetParametersNoCopy();
internal ICorDebugFunction CorFunction { internal ICorDebugFunction CorFunction {
get { get {
return this.DebugModule.CorModule.GetFunctionFromToken((uint)this.MetadataToken); return this.DebugModule.CorModule.GetFunctionFromToken((uint)this.MetadataToken);
@ -241,7 +259,7 @@ namespace Debugger.MetaData
/// <summary> /// <summary>
/// Backing field that can be used to obtain the same value as by calling this method. /// Backing field that can be used to obtain the same value as by calling this method.
/// </summary> /// </summary>
internal DebugFieldInfo BackingField { public DebugFieldInfo BackingField {
get { get {
if (!getBackingFieldCalled) { if (!getBackingFieldCalled) {
backingFieldCache = GetBackingField(); backingFieldCache = GetBackingField();
@ -294,7 +312,7 @@ namespace Debugger.MetaData
code[10] == 0x06 && // ldloc.0 code[10] == 0x06 && // ldloc.0
code[11] == 0x2A) // ret code[11] == 0x2A) // ret
{ {
token = getTokenFromIL(code, 06); token = GetTokenFromIL(code, 06);
} }
// code generated for getter 'public int Prop { get; [set;] }' // code generated for getter 'public int Prop { get; [set;] }'
@ -309,7 +327,7 @@ namespace Debugger.MetaData
code[09] == 0x06 && // ldloc.0 code[09] == 0x06 && // ldloc.0
code[10] == 0x2A) // ret code[10] == 0x2A) // ret
{ {
token = getTokenFromIL(code, 05); token = GetTokenFromIL(code, 05);
} }
if (code.Length == 7 && if (code.Length == 7 &&
@ -318,7 +336,7 @@ namespace Debugger.MetaData
code[05] == 0x04 && // <field token> code[05] == 0x04 && // <field token>
code[06] == 0x2A) // ret code[06] == 0x2A) // ret
{ {
token = getTokenFromIL(code, 05); token = GetTokenFromIL(code, 05);
} }
if (token != 0) { if (token != 0) {
@ -344,7 +362,7 @@ namespace Debugger.MetaData
/// <param name="ilCode">Bytes representing the code.</param> /// <param name="ilCode">Bytes representing the code.</param>
/// <param name="tokenEndIndex">Index of last byte of the token.</param> /// <param name="tokenEndIndex">Index of last byte of the token.</param>
/// <returns>IL token.</returns> /// <returns>IL token.</returns>
uint getTokenFromIL(byte[] ilCode, uint tokenEndIndex) uint GetTokenFromIL(byte[] ilCode, uint tokenEndIndex)
{ {
return ((uint)ilCode[tokenEndIndex] << 24) + return ((uint)ilCode[tokenEndIndex] << 24) +
((uint)ilCode[tokenEndIndex - 1] << 16) + ((uint)ilCode[tokenEndIndex - 1] << 16) +
@ -352,7 +370,7 @@ namespace Debugger.MetaData
((uint)ilCode[tokenEndIndex - 3]); ((uint)ilCode[tokenEndIndex - 3]);
} }
bool? isSingleLineCache; bool? isSingleLine;
bool IsSingleLine { bool IsSingleLine {
get { get {
@ -360,7 +378,7 @@ namespace Debugger.MetaData
ISymUnmanagedMethod symMethod = this.SymMethod; ISymUnmanagedMethod symMethod = this.SymMethod;
if (symMethod == null) return false; // No symbols - can not determine if (symMethod == null) return false; // No symbols - can not determine
if (isSingleLineCache.HasValue) return isSingleLineCache.Value; if (isSingleLine.HasValue) return isSingleLine.Value;
List<SequencePoint> seqPoints = new List<SequencePoint>(symMethod.SequencePoints); List<SequencePoint> seqPoints = new List<SequencePoint>(symMethod.SequencePoints);
seqPoints.Sort(); seqPoints.Sort();
@ -381,53 +399,36 @@ namespace Debugger.MetaData
} }
// Is single line // Is single line
isSingleLineCache = seqPoints.Count == 0 || seqPoints[0].Line == seqPoints[seqPoints.Count - 1].EndLine; isSingleLine = seqPoints.Count == 0 || seqPoints[0].Line == seqPoints[seqPoints.Count - 1].EndLine;
return isSingleLineCache.Value; return isSingleLine.Value;
} }
} }
bool? hasDebuggerAttributeCache; bool? hasDebuggerAttribute;
bool HasDebuggerAttribute { bool HasDebuggerAttribute {
get { get {
if (hasDebuggerAttributeCache.HasValue) return hasDebuggerAttributeCache.Value; if (hasDebuggerAttribute.HasValue) return hasDebuggerAttribute.Value;
hasDebuggerAttributeCache = hasDebuggerAttribute =
// Look on the method // Look on the method
HasAnyAttribute(this.DebugModule.MetaData, methodProps.Token, DebugType.IsDefined(
typeof(System.Diagnostics.DebuggerStepThroughAttribute), this,
typeof(System.Diagnostics.DebuggerNonUserCodeAttribute), false,
typeof(System.Diagnostics.DebuggerHiddenAttribute)) typeof(System.Diagnostics.DebuggerStepThroughAttribute),
typeof(System.Diagnostics.DebuggerNonUserCodeAttribute),
typeof(System.Diagnostics.DebuggerHiddenAttribute))
|| ||
// Look on the type // Look on the type
HasAnyAttribute(this.DebugModule.MetaData, (uint)this.DeclaringType.MetadataToken, DebugType.IsDefined(
typeof(System.Diagnostics.DebuggerStepThroughAttribute), declaringType,
typeof(System.Diagnostics.DebuggerNonUserCodeAttribute), false,
typeof(System.Diagnostics.DebuggerHiddenAttribute)); typeof(System.Diagnostics.DebuggerStepThroughAttribute),
return hasDebuggerAttributeCache.Value; typeof(System.Diagnostics.DebuggerNonUserCodeAttribute),
} typeof(System.Diagnostics.DebuggerHiddenAttribute));
}
internal static bool HasAnyAttribute(MetaDataImport metaData, uint token, params Type[] wantedAttrTypes) return hasDebuggerAttribute.Value;
{
foreach(CustomAttributeProps ca in metaData.EnumCustomAttributeProps(token, 0)) {
CorTokenType tkType = (CorTokenType)(ca.Type & 0xFF000000);
string attributeName;
if (tkType == CorTokenType.MemberRef) {
MemberRefProps constructorMethod = metaData.GetMemberRefProps(ca.Type);
attributeName = metaData.GetTypeRefProps(constructorMethod.DeclaringType).Name;
} else if (tkType == CorTokenType.MethodDef) {
MethodProps constructorMethod = metaData.GetMethodProps(ca.Type);
attributeName = metaData.GetTypeDefProps(constructorMethod.ClassToken).Name;
} else {
throw new DebuggerException("Not expected: " + tkType);
}
foreach(Type wantedAttrType in wantedAttrTypes) {
if (attributeName == wantedAttrType.FullName)
return true;
}
} }
return false;
} }
internal void MarkAsNonUserCode() internal void MarkAsNonUserCode()
@ -439,28 +440,6 @@ namespace Debugger.MetaData
} }
} }
/// <summary>
/// Get a method from a managed type, method name and argument count
/// </summary>
public static DebugMethodInfo GetFromName(AppDomain appDomain, System.Type type, string methodName, int paramCount)
{
if (type.IsNested) throw new DebuggerException("Not implemented for nested types");
if (type.IsGenericType) throw new DebuggerException("Not implemented for generic types");
if (type.IsGenericParameter) throw new DebuggerException("Type can not be generic parameter");
DebugType debugType = DebugType.CreateFromType(appDomain, type);
if (debugType == null) {
throw new DebuggerException("Type " + type.FullName + " not found");
}
foreach(DebugMethodInfo methodInfo in debugType.GetMethods(methodName, DebugType.BindingFlagsAll)) {
if (methodInfo.ParameterCount == paramCount) {
return methodInfo;
}
}
throw new DebuggerException("Method " + methodName + " not found");
}
internal ISymUnmanagedMethod SymMethod { internal ISymUnmanagedMethod SymMethod {
get { get {
if (this.DebugModule.SymReader == null) return null; if (this.DebugModule.SymReader == null) return null;
@ -472,62 +451,14 @@ namespace Debugger.MetaData
} }
} }
/// <summary> Gets the number of paramters of this method </summary> List<DebugLocalVariableInfo> localVariables;
public int ParameterCount {
get {
return this.MethodDefSig.ParamCount;
}
}
/// <summary> Gets the name of given parameter </summary> public List<DebugLocalVariableInfo> GetLocalVariables()
/// <param name="index"> Zero-based index </param>
public string GetParameterName(int index)
{ {
// index = 0 is return parameter // TODO: Is this needed?
try { if (this.SymMethod == null)
return this.DebugModule.MetaData.GetParamPropsForMethodIndex((uint)this.MetadataToken, (uint)index + 1).Name; return new List<DebugLocalVariableInfo>();
} catch {
return String.Empty;
}
}
/// <summary> Get names of all parameters in order </summary>
public string[] ParameterNames {
get {
List<string> names = new List<string>();
for(int i = 0; i < ParameterCount; i++) {
names.Add(GetParameterName(i));
}
return names.ToArray();
}
}
public List<DebugLocalVariableInfo> LocalVariables {
get {
if (this.SymMethod != null) { // TODO: Is this needed?
return GetLocalVariables();
} else {
return new List<DebugLocalVariableInfo>();
}
}
}
public string[] LocalVariableNames {
get {
List<DebugLocalVariableInfo> vars = this.LocalVariables;
List<string> names = new List<string>();
for(int i = 0; i < vars.Count; i++) {
names.Add(vars[i].Name);
}
names.Sort();
return names.ToArray();
}
}
List<DebugLocalVariableInfo> localVariables; // Cache
List<DebugLocalVariableInfo> GetLocalVariables()
{
if (localVariables != null) return localVariables; if (localVariables != null) return localVariables;
localVariables = GetLocalVariablesInScope(this.SymMethod.RootScope); localVariables = GetLocalVariablesInScope(this.SymMethod.RootScope);
@ -558,6 +489,7 @@ namespace Debugger.MetaData
if (!this.IsStatic) { if (!this.IsStatic) {
DebugLocalVariableInfo thisVar = new DebugLocalVariableInfo( DebugLocalVariableInfo thisVar = new DebugLocalVariableInfo(
"this", "this",
-1,
declaringType, declaringType,
delegate(StackFrame context) { delegate(StackFrame context) {
return context.GetThisValue(); return context.GetThisValue();
@ -578,6 +510,7 @@ namespace Debugger.MetaData
if (fieldInfo.Name.StartsWith("CS$")) continue; // Ignore if (fieldInfo.Name.StartsWith("CS$")) continue; // Ignore
DebugLocalVariableInfo locVar = new DebugLocalVariableInfo( DebugLocalVariableInfo locVar = new DebugLocalVariableInfo(
fieldInfo.Name, fieldInfo.Name,
-1,
(DebugType)fieldInfo.FieldType, (DebugType)fieldInfo.FieldType,
delegate(StackFrame context) { delegate(StackFrame context) {
return getCaptureClass(context).GetFieldValue(fieldInfoCopy); return getCaptureClass(context).GetFieldValue(fieldInfoCopy);
@ -634,6 +567,7 @@ namespace Debugger.MetaData
} else { } else {
DebugLocalVariableInfo locVar = new DebugLocalVariableInfo( DebugLocalVariableInfo locVar = new DebugLocalVariableInfo(
symVar.Name, symVar.Name,
(int)symVar.AddressField1,
locVarType, locVarType,
delegate(StackFrame context) { delegate(StackFrame context) {
return GetLocalVariableValue(context, symVarCopy); return GetLocalVariableValue(context, symVarCopy);
@ -659,5 +593,10 @@ namespace Debugger.MetaData
} }
return new Value(context.AppDomain, corVal); return new Value(context.AppDomain, corVal);
} }
public override string ToString()
{
return this.FullName;
}
} }
} }

13
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugParameterInfo.cs

@ -18,10 +18,10 @@ namespace Debugger.MetaData
{ {
public class DebugParameterInfo : System.Reflection.ParameterInfo public class DebugParameterInfo : System.Reflection.ParameterInfo
{ {
public MemberInfo member; MemberInfo member;
public string name; string name;
public Type parameterType; Type parameterType;
public int position; int position;
public override MemberInfo Member { public override MemberInfo Member {
get { return member; } get { return member; }
@ -56,5 +56,10 @@ namespace Debugger.MetaData
// public virtual Type[] GetOptionalCustomModifiers(); // public virtual Type[] GetOptionalCustomModifiers();
// public virtual Type[] GetRequiredCustomModifiers(); // public virtual Type[] GetRequiredCustomModifiers();
// public virtual bool IsDefined(Type attributeType, bool inherit); // public virtual bool IsDefined(Type attributeType, bool inherit);
public override string ToString()
{
return this.ParameterType + " " + this.Name;
}
} }
} }

83
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugPropertyInfo.cs

@ -31,39 +31,35 @@ namespace Debugger.MetaData
} }
public override Type DeclaringType { public override Type DeclaringType {
get { get { return declaringType; }
return declaringType;
}
} }
/// <summary> The AppDomain in which this member is loaded </summary> /// <summary> The AppDomain in which this member is declared </summary>
[Debugger.Tests.Ignore]
public AppDomain AppDomain { public AppDomain AppDomain {
get { get { return declaringType.AppDomain; }
return declaringType.AppDomain;
}
} }
/// <summary> The Process in which this member is loaded </summary> /// <summary> The Process in which this member is declared </summary>
[Debugger.Tests.Ignore]
public Process Process { public Process Process {
get { get { return declaringType.Process; }
return declaringType.Process;
}
} }
/// <summary> The Module in which this member is loaded </summary> /// <summary> The Module in which this member is declared </summary>
[Debugger.Tests.Ignore]
public Debugger.Module DebugModule { public Debugger.Module DebugModule {
get { get { return declaringType.DebugModule; }
return declaringType.DebugModule;
}
} }
[Debugger.Tests.Ignore]
public override int MetadataToken { public override int MetadataToken {
get { get { return (getMethod ?? setMethod).MetadataToken; }
return (getMethod ?? setMethod).MetadataToken;
}
} }
// public virtual Module Module { get; } public override System.Reflection.Module Module {
get { throw new NotSupportedException(); }
}
public override string Name { public override string Name {
get { get {
@ -72,9 +68,7 @@ namespace Debugger.MetaData
} }
public override Type ReflectedType { public override Type ReflectedType {
get { get { throw new NotSupportedException(); }
throw new NotSupportedException();
}
} }
public override object[] GetCustomAttributes(bool inherit) public override object[] GetCustomAttributes(bool inherit)
@ -89,31 +83,23 @@ namespace Debugger.MetaData
public override bool IsDefined(Type attributeType, bool inherit) public override bool IsDefined(Type attributeType, bool inherit)
{ {
throw new NotSupportedException(); return DebugType.IsDefined(this, inherit, attributeType);
} }
public override PropertyAttributes Attributes { public override PropertyAttributes Attributes {
get { get { throw new NotSupportedException(); }
throw new NotSupportedException();
}
} }
public override bool CanRead { public override bool CanRead {
get { get { return getMethod != null; }
return getMethod != null;
}
} }
public override bool CanWrite { public override bool CanWrite {
get { get { return setMethod != null; }
return setMethod != null;
}
} }
public override Type PropertyType { public override Type PropertyType {
get { get { return getMethod.ReturnType; }
return getMethod.ReturnType;
}
} }
public override MethodInfo[] GetAccessors(bool nonPublic) public override MethodInfo[] GetAccessors(bool nonPublic)
@ -130,7 +116,11 @@ namespace Debugger.MetaData
public override ParameterInfo[] GetIndexParameters() public override ParameterInfo[] GetIndexParameters()
{ {
throw new NotSupportedException(); if (GetGetMethod() != null) {
return GetGetMethod().GetParameters();
} else {
return null;
}
} }
// public virtual Type[] GetOptionalCustomModifiers(); // public virtual Type[] GetOptionalCustomModifiers();
@ -142,18 +132,22 @@ namespace Debugger.MetaData
return setMethod; return setMethod;
} }
// public virtual object GetValue(object obj, object[] index);
public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
{ {
throw new NotSupportedException(); List<Value> args = new List<Value>();
foreach(object arg in index) {
args.Add((Value)arg);
}
return Value.GetPropertyValue((Value)obj, this, args.ToArray());
} }
// public virtual void SetValue(object obj, object value, object[] index);
public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
{ {
throw new NotSupportedException(); List<Value> args = new List<Value>();
foreach(object arg in index) {
args.Add((Value)arg);
}
Value.SetPropertyValue((Value)obj, this, args.ToArray(), (Value)value);
} }
public bool IsPublic { public bool IsPublic {
@ -169,5 +163,10 @@ namespace Debugger.MetaData
return (getMethod ?? setMethod).IsStatic; return (getMethod ?? setMethod).IsStatic;
} }
} }
public override string ToString()
{
return this.PropertyType + " " + this.Name;
}
} }
} }

140
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs

@ -27,7 +27,7 @@ namespace Debugger.MetaData
/// If two types are identical, the references to DebugType will also be identical /// If two types are identical, the references to DebugType will also be identical
/// Type will be loaded once per each appdomain. /// Type will be loaded once per each appdomain.
/// </remarks> /// </remarks>
public class DebugType: System.Type public class DebugType: System.Type, IDebugMemberInfo
{ {
public const BindingFlags BindingFlagsAll = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance; public const BindingFlags BindingFlagsAll = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance;
public const BindingFlags BindingFlagsAllDeclared = BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance; public const BindingFlags BindingFlagsAllDeclared = BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance;
@ -55,34 +55,28 @@ namespace Debugger.MetaData
static Dictionary<ICorDebugType, DebugType> loadedTypes = new Dictionary<ICorDebugType, DebugType>(); static Dictionary<ICorDebugType, DebugType> loadedTypes = new Dictionary<ICorDebugType, DebugType>();
public override Type DeclaringType { public override Type DeclaringType {
get { get { throw new NotSupportedException(); }
throw new NotSupportedException();
}
} }
/// <summary> The AppDomain in which this type is loaded </summary> /// <summary> The AppDomain in which this type is loaded </summary>
[Debugger.Tests.Ignore] [Debugger.Tests.Ignore]
public AppDomain AppDomain { public AppDomain AppDomain {
get { get { return appDomain; }
return appDomain;
}
} }
/// <summary> The Process in which this member is loaded </summary> /// <summary> The Process in which this type is loaded </summary>
[Debugger.Tests.Ignore] [Debugger.Tests.Ignore]
public Process Process { public Process Process {
get { get { return process; }
return process;
}
} }
/// <summary> The Module in which this member is loaded </summary> /// <summary> The Module in which this type is loaded </summary>
[Debugger.Tests.Ignore]
public Debugger.Module DebugModule { public Debugger.Module DebugModule {
get { get { return module; }
return module;
}
} }
[Debugger.Tests.Ignore]
public override int MetadataToken { public override int MetadataToken {
get { get {
AssertClassOrValueType(); AssertClassOrValueType();
@ -90,18 +84,16 @@ namespace Debugger.MetaData
} }
} }
// public virtual Module Module { get; } public override System.Reflection.Module Module {
get { throw new NotSupportedException(); }
}
public override string Name { public override string Name {
get { get { return name; }
return name;
}
} }
public override Type ReflectedType { public override Type ReflectedType {
get { get { throw new NotSupportedException(); }
throw new NotSupportedException();
}
} }
public override object[] GetCustomAttributes(bool inherit) public override object[] GetCustomAttributes(bool inherit)
@ -116,20 +108,40 @@ namespace Debugger.MetaData
public override bool IsDefined(Type attributeType, bool inherit) public override bool IsDefined(Type attributeType, bool inherit)
{ {
throw new NotSupportedException(); return IsDefined(this, inherit, attributeType);
} }
public static bool IsDefined(IDebugMemberInfo member, bool inherit, params Type[] attributeTypes)
{
// TODO: Support inherit
MetaDataImport metaData = member.DebugModule.MetaData;
uint token = (uint)member.MetadataToken;
foreach(CustomAttributeProps ca in metaData.EnumCustomAttributeProps(token, 0)) {
CorTokenType tkType = (CorTokenType)(ca.Type & 0xFF000000);
string attributeName;
if (tkType == CorTokenType.MemberRef) {
MemberRefProps constructorMethod = metaData.GetMemberRefProps(ca.Type);
attributeName = metaData.GetTypeRefProps(constructorMethod.DeclaringType).Name;
} else if (tkType == CorTokenType.MethodDef) {
MethodProps constructorMethod = metaData.GetMethodProps(ca.Type);
attributeName = metaData.GetTypeDefProps(constructorMethod.ClassToken).Name;
} else {
throw new DebuggerException("Not expected: " + tkType);
}
foreach(Type attributeType in attributeTypes) {
if (attributeName == attributeType.FullName)
return true;
}
}
return false;
}
public override Assembly Assembly { public override Assembly Assembly {
get { get { throw new NotSupportedException(); }
throw new NotSupportedException();
}
} }
public override string AssemblyQualifiedName { public override string AssemblyQualifiedName {
get { get { throw new NotSupportedException(); }
throw new NotSupportedException();
}
} }
public override Type BaseType { public override Type BaseType {
@ -162,50 +174,38 @@ namespace Debugger.MetaData
// public virtual MethodBase DeclaringMethod { get; } // public virtual MethodBase DeclaringMethod { get; }
public override string FullName { public override string FullName {
get { get { return fullName; }
return fullName;
}
} }
// public virtual GenericParameterAttributes GenericParameterAttributes { get; }
// public virtual int GenericParameterPosition { get; }
public override Guid GUID { public override Guid GUID {
get { get { throw new NotSupportedException(); }
throw new NotSupportedException();
}
} }
// public virtual GenericParameterAttributes GenericParameterAttributes { get; }
// public virtual int GenericParameterPosition { get; }
// public virtual bool IsGenericParameter { get; } // public virtual bool IsGenericParameter { get; }
// public virtual bool IsGenericType { get; }
// public virtual bool IsGenericTypeDefinition { get; } // public virtual bool IsGenericTypeDefinition { get; }
// internal virtual bool IsSzArray { get; }
// public override MemberTypes MemberType { get; }
public override System.Reflection.Module Module { public override bool IsGenericType {
get { get {
throw new NotSupportedException(); return this.GetGenericArguments().Length > 0;
} }
} }
// TODO
public override string Namespace { public override string Namespace {
get { get { throw new NotSupportedException(); }
throw new NotSupportedException();
}
} }
// public override Type ReflectedType { get; }
// public virtual StructLayoutAttribute StructLayoutAttribute { get; } // public virtual StructLayoutAttribute StructLayoutAttribute { get; }
// public virtual RuntimeTypeHandle TypeHandle { get; }
public override Type UnderlyingSystemType { public override RuntimeTypeHandle TypeHandle {
get { get { throw new NotSupportedException(); }
throw new NotSupportedException();
}
} }
// public virtual Type[] FindInterfaces(TypeFilter filter, object filterCriteria); public override Type UnderlyingSystemType {
// public virtual MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bindingAttr, MemberFilter filter, object filterCriteria); get { throw new NotSupportedException(); }
}
public override int GetArrayRank() public override int GetArrayRank()
{ {
@ -221,6 +221,7 @@ namespace Debugger.MetaData
protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
{ {
// TODO
throw new NotSupportedException(); throw new NotSupportedException();
} }
@ -229,7 +230,6 @@ namespace Debugger.MetaData
throw new NotSupportedException(); throw new NotSupportedException();
} }
// internal virtual string GetDefaultMemberName();
// public virtual MemberInfo[] GetDefaultMembers(); // public virtual MemberInfo[] GetDefaultMembers();
public override Type GetElementType() public override Type GetElementType()
@ -362,7 +362,7 @@ namespace Debugger.MetaData
public override Type GetInterface(string name, bool ignoreCase) public override Type GetInterface(string name, bool ignoreCase)
{ {
foreach(DebugType inter in this.Interfaces) { foreach(DebugType inter in this.GetInterfaces()) {
if (string.Equals(inter.FullName, fullName, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal)) { if (string.Equals(inter.FullName, fullName, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal)) {
return inter; return inter;
} }
@ -399,7 +399,7 @@ namespace Debugger.MetaData
if (candidate.ParameterCount == paramNames.Length) { if (candidate.ParameterCount == paramNames.Length) {
bool match = true; bool match = true;
for(int i = 0; i < paramNames.Length; i++) { for(int i = 0; i < paramNames.Length; i++) {
if (paramNames[i] != candidate.ParameterNames[i]) if (paramNames[i] != candidate.GetParameters()[i].Name)
match = false; match = false;
} }
if (match) if (match)
@ -472,13 +472,9 @@ namespace Debugger.MetaData
return GetMember<PropertyInfo>(name, bindingAttr, null); return GetMember<PropertyInfo>(name, bindingAttr, null);
} }
// internal virtual Type GetRootElementType();
// internal virtual TypeCode GetTypeCodeInternal();
// internal virtual RuntimeTypeHandle GetTypeHandleInternal();
protected override bool HasElementTypeImpl() protected override bool HasElementTypeImpl()
{ {
throw new NotSupportedException(); return this.IsArray || this.IsPointer;
} }
// internal virtual bool HasProxyAttributeImpl(); // internal virtual bool HasProxyAttributeImpl();
@ -540,11 +536,6 @@ namespace Debugger.MetaData
get { return corType; } get { return corType; }
} }
/// <summary> Gets a list of all interfaces that this type implements </summary>
public List<DebugType> Interfaces {
get { return interfaces; }
}
/// <summary> Returns what kind of type this is. (eg. value type) </summary> /// <summary> Returns what kind of type this is. (eg. value type) </summary>
public DebugTypeKind Kind { public DebugTypeKind Kind {
get { get {
@ -964,7 +955,7 @@ namespace Debugger.MetaData
if (appDomain.Process.Options.Verbose) { if (appDomain.Process.Options.Verbose) {
string prefix = this.IsInterface ? "interface" : "type"; string prefix = this.IsInterface ? "interface" : "type";
appDomain.Process.TraceMessage("Loaded {0} {1} ({2} ms)", prefix, this.FullName, totalTime2.TotalMilliseconds); appDomain.Process.TraceMessage("Loaded {0} {1} ({2} ms)", prefix, this.FullName, totalTime2.TotalMilliseconds);
foreach(DebugType inter in this.Interfaces) { foreach(DebugType inter in GetInterfaces()) {
appDomain.Process.TraceMessage(" - Implements {0}", inter.FullName); appDomain.Process.TraceMessage(" - Implements {0}", inter.FullName);
} }
} }
@ -1081,7 +1072,7 @@ namespace Debugger.MetaData
public bool IsCompilerGenerated { public bool IsCompilerGenerated {
get { get {
if (this.IsClass || this.IsValueType) { if (this.IsClass || this.IsValueType) {
return DebugMethodInfo.HasAnyAttribute(this.DebugModule.MetaData, (uint)this.MetadataToken, typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute)); return IsDefined(typeof(System.Runtime.CompilerServices.CompilerGeneratedAttribute), false);
} else { } else {
return false; return false;
} }
@ -1097,18 +1088,19 @@ namespace Debugger.MetaData
public bool IsYieldEnumerator { public bool IsYieldEnumerator {
get { get {
if (this.IsCompilerGenerated) { if (this.IsCompilerGenerated) {
foreach(DebugType intf in this.Interfaces) { return GetInterface(typeof(System.Collections.IEnumerator).FullName) != null;
if (intf.FullName == typeof(System.Collections.IEnumerator).FullName)
return true;
}
} }
return false; return false;
} }
} }
bool IDebugMemberInfo.IsStatic {
get { return false; }
}
public override string ToString() public override string ToString()
{ {
return string.Format("{0}", this.FullName); return this.FullName;
} }
} }
} }

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/IDebugMemberInfo.cs

@ -11,7 +11,9 @@ namespace Debugger.MetaData
public interface IDebugMemberInfo public interface IDebugMemberInfo
{ {
Type DeclaringType { get; } Type DeclaringType { get; }
Module DebugModule { get; }
string Name { get; } string Name { get; }
int MetadataToken { get; }
bool IsStatic { get; } bool IsStatic { get; }
bool IsPublic { get; } bool IsPublic { get; }
} }

9
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Object.cs

@ -98,6 +98,12 @@ namespace Debugger
); );
} }
public static Value SetFieldValue(Value objectInstance, DebugFieldInfo fieldInfo, Value newValue)
{
// TODO
throw new NotImplementedException();
}
static ICorDebugValue GetFieldCorValue(Value objectInstance, DebugFieldInfo fieldInfo) static ICorDebugValue GetFieldCorValue(Value objectInstance, DebugFieldInfo fieldInfo)
{ {
CheckObject(objectInstance, fieldInfo); CheckObject(objectInstance, fieldInfo);
@ -211,7 +217,8 @@ namespace Debugger
if (this.Type.IsPrimitive) return AsString; if (this.Type.IsPrimitive) return AsString;
if (this.Type.IsPointer) return "0x" + this.PointerAddress.ToString("X"); if (this.Type.IsPointer) return "0x" + this.PointerAddress.ToString("X");
// if (!IsObject) // Can invoke on primitives // if (!IsObject) // Can invoke on primitives
return Eval.InvokeMethod(this.AppDomain, typeof(object), "ToString", this, new Value[] {}).AsString; DebugMethodInfo methodInfo = (DebugMethodInfo)DebugType.CreateFromType(this.AppDomain, typeof(object)).GetMethod("ToString", new DebugType[] {});
return Eval.InvokeMethod(methodInfo, this, new Value[] {}).AsString;
} }
#region Convenience overload methods #region Convenience overload methods

Loading…
Cancel
Save