Browse Source

DebugMethodInfo derives from System.Reflection.MethodInfo

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5099 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 17 years ago
parent
commit
0443ba3f9a
  1. 3
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  2. 68
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugMemberInfo.cs
  3. 135
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugMethodInfo.cs
  4. 32
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugParameterInfo.cs
  5. 87
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/MemberInfo.cs
  6. 165
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/MethodInfo.cs

3
src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj

@ -220,14 +220,11 @@ @@ -220,14 +220,11 @@
<Compile Include="Src\Interop\MetaData\COR_FIELD_OFFSET.cs" />
<Compile Include="Src\Interop\MetaData\IMetaDataImport.cs" />
<Compile Include="Src\Metadata\BindingFlags.cs" />
<Compile Include="Src\Metadata\DebugMemberInfo.cs" />
<Compile Include="Src\Metadata\DebugMethodInfo.cs" />
<Compile Include="Src\Metadata\DebugParameterInfo.cs" />
<Compile Include="Src\Metadata\DebugType-Helpers.cs" />
<Compile Include="Src\Metadata\DebugType.cs" />
<Compile Include="Src\Metadata\DebugType2.cs" />
<Compile Include="Src\Metadata\FieldInfo.cs" />
<Compile Include="Src\Metadata\MemberInfo.cs" />
<Compile Include="Src\Metadata\MethodInfo.cs" />
<Compile Include="Src\Metadata\PropertyInfo.cs" />
<Compile Include="Src\Mono.Cecil\Mono.Cecil.Binary\ImageFormatException.cs" />

68
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugMemberInfo.cs

@ -1,68 +0,0 @@ @@ -1,68 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Globalization;
using Debugger.Wrappers.CorDebug;
using Debugger.Wrappers.MetaData;
using ICSharpCode.NRefactory.Ast;
using Mono.Cecil.Signatures;
namespace Debugger.MetaData2
{
using System.Reflection;
public class DebugMemberInfo: System.Reflection.MemberInfo
{
public override Type DeclaringType {
get {
throw new NotSupportedException();
}
}
public override MemberTypes MemberType {
get {
throw new NotSupportedException();
}
}
// public virtual int MetadataToken { get; }
// internal virtual int MetadataTokenInternal { get; }
// public virtual Module Module { get; }
public override string Name {
get {
throw new NotSupportedException();
}
}
public override Type ReflectedType {
get {
throw new NotSupportedException();
}
}
// internal virtual bool CacheEquals(object o);
public override object[] GetCustomAttributes(bool inherit)
{
throw new NotSupportedException();
}
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
{
throw new NotSupportedException();
}
public override bool IsDefined(Type attributeType, bool inherit)
{
throw new NotSupportedException();
}
}
}

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

@ -1,135 +0,0 @@ @@ -1,135 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Globalization;
using Debugger.Wrappers.CorDebug;
using Debugger.Wrappers.MetaData;
using ICSharpCode.NRefactory.Ast;
using Mono.Cecil.Signatures;
namespace Debugger.MetaData2
{
using System.Reflection;
public class DebugMethodInfo: System.Reflection.MethodInfo
{
public override Type DeclaringType {
get {
throw new NotSupportedException();
}
}
public override MemberTypes MemberType {
get {
throw new NotSupportedException();
}
}
// public virtual int MetadataToken { get; }
// internal virtual int MetadataTokenInternal { get; }
// public virtual Module Module { get; }
public override string Name {
get {
throw new NotSupportedException();
}
}
public override Type ReflectedType {
get {
throw new NotSupportedException();
}
}
// internal virtual bool CacheEquals(object o);
public override object[] GetCustomAttributes(bool inherit)
{
throw new NotSupportedException();
}
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
{
throw new NotSupportedException();
}
public override bool IsDefined(Type attributeType, bool inherit)
{
throw new NotSupportedException();
}
// public virtual Type[] GetGenericArguments();
// public virtual MethodBody GetMethodBody();
// internal virtual RuntimeMethodHandle GetMethodHandle();
public override MethodImplAttributes GetMethodImplementationFlags()
{
throw new NotSupportedException();
}
// internal virtual uint GetOneTimeFlags();
// internal virtual uint GetOneTimeSpecificFlags();
public override ParameterInfo[] GetParameters()
{
throw new NotSupportedException();
}
// internal virtual ParameterInfo[] GetParametersNoCopy();
// internal virtual Type[] GetParameterTypes();
// internal virtual Type GetReturnType();
public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
{
throw new NotSupportedException();
}
public override MethodAttributes Attributes {
get {
throw new NotSupportedException();
}
}
// public virtual CallingConventions CallingConvention { get; }
// public virtual bool ContainsGenericParameters { get; }
// public virtual bool IsGenericMethod { get; }
// public virtual bool IsGenericMethodDefinition { get; }
// internal virtual bool IsOverloaded { get; }
public override RuntimeMethodHandle MethodHandle {
get {
throw new NotSupportedException();
}
}
public override MethodInfo GetBaseDefinition()
{
throw new NotSupportedException();
}
// public override Type[] GetGenericArguments();
// public virtual MethodInfo GetGenericMethodDefinition();
// internal virtual MethodInfo GetParentDefinition();
// internal override Type GetReturnType();
// public virtual MethodInfo MakeGenericMethod(params Type[] typeArguments);
// public override bool ContainsGenericParameters { get; }
// public override bool IsGenericMethod { get; }
// public override bool IsGenericMethodDefinition { get; }
// public override MemberTypes MemberType { get; }
// public virtual ParameterInfo ReturnParameter { get; }
// public virtual Type ReturnType { get; }
public override ICustomAttributeProvider ReturnTypeCustomAttributes {
get {
throw new NotSupportedException();
}
}
}
}

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

@ -8,29 +8,29 @@ @@ -8,29 +8,29 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using Debugger.Wrappers.CorDebug;
using Debugger.Wrappers.MetaData;
using ICSharpCode.NRefactory.Ast;
using Mono.Cecil.Signatures;
namespace Debugger.MetaData2
namespace Debugger.MetaData
{
using System.Reflection;
public class DebugParameterInfo : System.Reflection.ParameterInfo
{
// public virtual ParameterAttributes Attributes { get; }
// public virtual object DefaultValue { get; }
// public virtual MemberInfo Member { get; }
// public virtual string Name { get; }
// public virtual Type ParameterType { get; }
// public virtual int Position { get; }
// public virtual object RawDefaultValue { get; }
//
// public virtual object[] GetCustomAttributes(bool inherit);
// public virtual object[] GetCustomAttributes(Type attributeType, bool inherit);
// public virtual Type[] GetOptionalCustomModifiers();
// public virtual Type[] GetRequiredCustomModifiers();
// public virtual bool IsDefined(Type attributeType, bool inherit);
public override MemberInfo Member { get; internal set; }
public override string Name { get; internal set; }
public override Type ParameterType { get; internal set; }
public override int Position { get; internal set; }
// public virtual ParameterAttributes Attributes { get; }
// public virtual object DefaultValue { get; }
// public virtual object RawDefaultValue { get; }
//
// public virtual object[] GetCustomAttributes(bool inherit);
// public virtual object[] GetCustomAttributes(Type attributeType, bool inherit);
// public virtual Type[] GetOptionalCustomModifiers();
// public virtual Type[] GetRequiredCustomModifiers();
// public virtual bool IsDefined(Type attributeType, bool inherit);
}
}

87
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/MemberInfo.cs

@ -1,87 +0,0 @@ @@ -1,87 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using Debugger.Wrappers.CorDebug;
using Debugger.Wrappers.MetaData;
namespace Debugger.MetaData
{
/// <summary>
/// Provides information about a member of some class
/// (eg. a field or a method).
/// </summary>
public abstract class MemberInfo: DebuggerObject
{
DebugType declaringType;
/// <summary> Gets the process in which the type was loaded </summary>
[Debugger.Tests.Ignore]
public AppDomain AppDomain {
get { return declaringType.AppDomain; }
}
[Debugger.Tests.Ignore]
public Process Process {
get { return this.AppDomain.Process; }
}
/// <summary> Gets the name of this member </summary>
public abstract string Name { get; }
/// <summary> Gets name of the method including the full name of the declaring type </summary>
public string FullName {
get {
return this.DeclaringType.FullName + "." + this.Name;
}
}
/// <summary> Gets the module in which this member is defined </summary>
public Module Module {
get {
return declaringType.Module;
}
}
/// <summary> Gets the type that declares this member element </summary>
public DebugType DeclaringType {
get {
return declaringType;
}
}
/// <summary> Gets a value indicating whether this member has the private access modifier</summary>
public abstract bool IsPrivate { get; }
/// <summary> Gets a value indicating whether this member has the internal access modifier</summary>
public abstract bool IsInternal { get; }
/// <summary> Gets a value indicating whether this member has the protected access modifier</summary>
public abstract bool IsProtected { get; }
/// <summary> Gets a value indicating whether this member has the public access modifier</summary>
public abstract bool IsPublic { get; }
/// <summary> Gets a value indicating whether this member is static </summary>
public abstract bool IsStatic { get; }
/// <summary> Gets the metadata token associated with this member </summary>
[Debugger.Tests.Ignore]
public abstract uint MetadataToken { get; }
internal MemberInfo(DebugType declaringType)
{
this.declaringType = declaringType;
}
public override string ToString()
{
return this.Name;
}
}
}

165
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/MethodInfo.cs

@ -7,70 +7,131 @@ @@ -7,70 +7,131 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
using Debugger.Wrappers.CorDebug;
using Debugger.Wrappers.CorSym;
using Debugger.Wrappers.MetaData;
using ICSharpCode.NRefactory.Ast;
using Mono.Cecil.Signatures;
using System.Runtime.InteropServices;
namespace Debugger.MetaData
{
/// <summary>
/// Provides information about a method in a class
/// </summary>
public class MethodInfo: MemberInfo
public class DebugMethodInfo: System.Reflection.MethodInfo
{
DebugType declaringType;
MethodProps methodProps;
/// <summary> Gets the name of this method </summary>
internal DebugMethodInfo(DebugType declaringType, MethodProps methodProps)
{
this.declaringType = declaringType;
this.methodProps = methodProps;
}
public override Type DeclaringType {
get {
return declaringType;
}
}
public override uint MetadataToken {
get {
return methodProps.Token;
}
}
// public virtual Module Module { get; }
public override string Name {
get {
return methodProps.Name;
}
}
/// <summary> Gets a value indicating whether this member has the private access modifier</summary>
public override bool IsPrivate {
get { return methodProps.IsPrivate; }
public override Type ReflectedType {
get {
throw new NotSupportedException();
}
}
/// <summary> Gets a value indicating whether this member has the internal access modifier</summary>
public override bool IsInternal {
get { return methodProps.IsInternal; }
public override object[] GetCustomAttributes(bool inherit)
{
throw new NotSupportedException();
}
/// <summary> Gets a value indicating whether this member has the protected access modifier</summary>
public override bool IsProtected {
get { return methodProps.IsProtected; }
public override object[] GetCustomAttributes(Type attributeType, bool inherit)
{
throw new NotSupportedException();
}
public override bool IsDefined(Type attributeType, bool inherit)
{
throw new NotSupportedException();
}
// public virtual Type[] GetGenericArguments();
// public virtual MethodBody GetMethodBody();
// internal virtual RuntimeMethodHandle GetMethodHandle();
public override MethodImplAttributes GetMethodImplementationFlags()
{
return methodProps.ImplFlags;
}
/// <summary> Gets a value indicating whether this member has the public access modifier</summary>
public override bool IsPublic {
get { return methodProps.IsPublic; }
// internal virtual uint GetOneTimeFlags();
// internal virtual uint GetOneTimeSpecificFlags();
public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
{
throw new NotSupportedException();
}
/// <summary> Gets a value indicating whether the name of this method
/// is marked as specail.</summary>
/// <remarks> For example, property accessors are marked as special </remarks>
public bool IsSpecialName {
public override MethodAttributes Attributes {
get {
return methodProps.HasSpecialName;
return (MethodAttributes)methodProps.Flags;
}
}
/// <summary> Gets a value indicating whether this method is static </summary>
public override bool IsStatic {
// public virtual CallingConventions CallingConvention { get; }
// public virtual bool ContainsGenericParameters { get; }
// public virtual bool IsGenericMethod { get; }
// public virtual bool IsGenericMethodDefinition { get; }
// internal virtual bool IsOverloaded { get; }
public override RuntimeMethodHandle MethodHandle {
get {
return methodProps.IsStatic;
throw new NotSupportedException();
}
}
/// <summary> Gets the metadata token associated with this method </summary>
[Debugger.Tests.Ignore]
public override uint MetadataToken {
public override MethodInfo GetBaseDefinition()
{
throw new NotSupportedException();
}
// public override Type[] GetGenericArguments();
// public virtual MethodInfo GetGenericMethodDefinition();
// internal virtual MethodInfo GetParentDefinition();
// internal override Type GetReturnType();
// public virtual MethodInfo MakeGenericMethod(params Type[] typeArguments);
// public override bool ContainsGenericParameters { get; }
// public override bool IsGenericMethod { get; }
// public override bool IsGenericMethodDefinition { get; }
// public virtual ParameterInfo ReturnParameter { get; }
public override Type GetReturnType()
{
if (this.MethodDefSig.RetType.Void) return null;
if (returnType == null) {
returnType = DebugType.CreateFromSignature(this.Module, this.MethodDefSig.RetType.Type, this.DeclaringType);
}
return returnType;
}
public override ICustomAttributeProvider ReturnTypeCustomAttributes {
get {
return methodProps.Token;
throw new NotSupportedException();
}
}
@ -88,31 +149,28 @@ namespace Debugger.MetaData @@ -88,31 +149,28 @@ namespace Debugger.MetaData
DebugType returnType;
/// <summary> The type of the return value as specified in the method signature </summary>
/// <returns> Null if the return type is Void</returns>
public DebugType ReturnType {
get {
if (this.MethodDefSig.RetType.Void) return null;
if (returnType == null) {
returnType = DebugType.CreateFromSignature(this.Module, this.MethodDefSig.RetType.Type, this.DeclaringType);
}
return returnType;
}
}
ParameterInfo[] parameters;
/// <summary>
/// Gets the types of the parameters of the method
/// </summary>
public DebugType[] ParameterTypes {
get {
List<DebugType> types = new List<DebugType>();
foreach(Param param in this.methodDefSig.Parameters) {
types.Add(DebugType.CreateFromSignature(this.Module, param.Type, this.DeclaringType));
public override ParameterInfo[] GetParameters()
{
if (parameters == null) {
parameters = new ParameterInfo[this.MethodDefSig.ParamCount];
for(int i = 0; i < parameters.Length; i++) {
parameters[i] =
new DebugParameterInfo() {
Member = this,
Name = this.GetParameterName(i),
Position = i,
ParameterType = DebugType.CreateFromSignature(this.Module, this.MethodDefSig.Parameters[i].Type, this.DeclaringType),
};
}
return types.ToArray();
}
return parameters;
}
// internal virtual Type[] GetParameterTypes();
// internal virtual ParameterInfo[] GetParametersNoCopy();
internal ICorDebugFunction CorFunction {
get {
return this.Module.CorModule.GetFunctionFromToken(this.MetadataToken);
@ -143,11 +201,6 @@ namespace Debugger.MetaData @@ -143,11 +201,6 @@ namespace Debugger.MetaData
}
}
internal MethodInfo(DebugType declaringType, MethodProps methodProps):base (declaringType)
{
this.methodProps = methodProps;
}
// TODO: More accurate
bool IsProperty {
get {
@ -412,7 +465,6 @@ namespace Debugger.MetaData @@ -412,7 +465,6 @@ namespace Debugger.MetaData
}
/// <summary> Get names of all parameters in order </summary>
[Tests.Ignore]
public string[] ParameterNames {
get {
List<string> names = new List<string>();
@ -423,7 +475,6 @@ namespace Debugger.MetaData @@ -423,7 +475,6 @@ namespace Debugger.MetaData
}
}
[Debugger.Tests.Ignore]
public List<LocalVariableInfo> LocalVariables {
get {
if (this.SymMethod != null) { // TODO: Is this needed?

Loading…
Cancel
Save