Browse Source

Fixed DebugType.GetMember in case of explicit interface implementation and interface inheritance

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6204 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
David Srbecký 16 years ago
parent
commit
63dc0ae3b5
  1. 34
      src/AddIns/Debugger/Debugger.Core/MetaData/DebugType.cs

34
src/AddIns/Debugger/Debugger.Core/MetaData/DebugType.cs

@ -291,6 +291,10 @@ namespace Debugger.MetaData
} }
} }
/// <remarks>
/// Note that at the moment the function will return two methods for interface implementations:
/// the acutual implementation and the method in the interface
/// </remarks>
public T[] GetMembers<T>(string name, BindingFlags bindingFlags, Predicate<T> filter) where T:MemberInfo public T[] GetMembers<T>(string name, BindingFlags bindingFlags, Predicate<T> filter) where T:MemberInfo
{ {
BindingFlags unsupported = bindingFlags & ~SupportedFlags; BindingFlags unsupported = bindingFlags & ~SupportedFlags;
@ -342,16 +346,27 @@ namespace Debugger.MetaData
} }
} }
// Query supertype if ((bindingFlags & BindingFlags.DeclaredOnly) == 0) {
if ((bindingFlags & BindingFlags.DeclaredOnly) == 0 && this.BaseType != null) { // Query supertype
if ((bindingFlags & BindingFlags.FlattenHierarchy) == 0) { if (this.BaseType != null) {
// Do not include static types if ((bindingFlags & BindingFlags.FlattenHierarchy) == 0) {
bindingFlags = bindingFlags & ~BindingFlags.Static; // Do not include static types
bindingFlags = bindingFlags & ~BindingFlags.Static;
}
// Any flags left?
if ((bindingFlags & (BindingFlags.Instance | BindingFlags.Static)) != 0) {
T[] superResults = ((DebugType)this.BaseType).GetMembers<T>(name, bindingFlags, filter);
results.AddRange(superResults);
}
} }
// Any flags left? // Query interfaces
if ((bindingFlags & (BindingFlags.Instance | BindingFlags.Static)) != 0) { // - needed to obtain explicitly defined methods of a type
T[] superResults = ((DebugType)this.BaseType).GetMembers<T>(name, bindingFlags, filter); // - needed to get inherited methods of an interface
results.AddRange(superResults); foreach (DebugType inter in this.GetInterfaces()) {
// GetInterfaces will return all interfaces - no need to recurse
bindingFlags |= BindingFlags.DeclaredOnly;
T[] interResults = inter.GetMembers<T>(name, bindingFlags, filter);
results.AddRange(interResults);
} }
} }
@ -538,6 +553,7 @@ namespace Debugger.MetaData
// public virtual InterfaceMapping GetInterfaceMap(Type interfaceType); // public virtual InterfaceMapping GetInterfaceMap(Type interfaceType);
/// <inheritdoc/> /// <inheritdoc/>
/// <returns> All interfaces implemented by the type </returns>
public override Type[] GetInterfaces() public override Type[] GetInterfaces()
{ {
return this.interfaces.ToArray(); return this.interfaces.ToArray();

Loading…
Cancel
Save