Browse Source

Fixed a bug caused by extending the search scope to supertypes

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3460 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 17 years ago
parent
commit
0e7d5082dd
  1. 5
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/BindingFlags.cs
  2. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs
  3. 31
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Object.cs
  4. 18
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Expressions.cs
  5. 2
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/GenericDictionary.cs
  6. 200
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Metadata.cs
  7. 4
      src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ObjectValue.cs

5
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/BindingFlags.cs

@ -19,7 +19,8 @@ namespace Debugger.MetaData
[Flags] [Flags]
public enum BindingFlags: uint { public enum BindingFlags: uint {
/// Return all members /// Return all members
All = 0xFFFF, All = 0xFFFFFFFF,
AllInThisType = 0xFFFF,
AccessMask = 0x0F, AccessMask = 0x0F,
Public = 0x01, Public = 0x01,
@ -35,6 +36,6 @@ namespace Debugger.MetaData
Method = 0x0400, Method = 0x0400,
GetProperty = 0x0800, GetProperty = 0x0800,
IncludeSuperType = 0x1000 IncludeSuperType = 0x10000
}; };
} }

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

@ -531,7 +531,7 @@ namespace Debugger.MetaData
// Collect data // Collect data
Dictionary<string, MethodInfo> accessors = new Dictionary<string, MethodInfo>(); Dictionary<string, MethodInfo> accessors = new Dictionary<string, MethodInfo>();
Dictionary<string, object> propertyNames = new Dictionary<string, object>(); Dictionary<string, object> propertyNames = new Dictionary<string, object>();
foreach(MethodInfo method in this.GetMethods(BindingFlags.All)) { foreach(MethodInfo method in this.GetMethods(BindingFlags.AllInThisType)) {
if (method.IsSpecialName && (method.Name.StartsWith("get_") || method.Name.StartsWith("set_"))) { if (method.IsSpecialName && (method.Name.StartsWith("get_") || method.Name.StartsWith("set_"))) {
// There can be many get_Items // There can be many get_Items
// TODO: This returns only last, return all // TODO: This returns only last, return all

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

@ -290,7 +290,7 @@ namespace Debugger
/// <summary> Get all fields and properties of an object. </summary> /// <summary> Get all fields and properties of an object. </summary>
public Value[] GetMemberValues() public Value[] GetMemberValues()
{ {
return GetMemberValues(null, BindingFlags.All); return GetMemberValues(BindingFlags.All);
} }
/// <summary> /// <summary>
@ -298,35 +298,22 @@ namespace Debugger
/// </summary> /// </summary>
/// <param name="type"> Limit to type, null for all types </param> /// <param name="type"> Limit to type, null for all types </param>
/// <param name="bindingFlags"> Get only members with certain flags </param> /// <param name="bindingFlags"> Get only members with certain flags </param>
public Value[] GetMemberValues(DebugType type, BindingFlags bindingFlags) public Value[] GetMemberValues(BindingFlags bindingFlags)
{ {
if (this.Type.IsClass || this.Type.IsValueType) { if (this.Type.IsClass || this.Type.IsValueType) {
return new List<Value>(GetObjectMembersEnum(type, bindingFlags)).ToArray(); return new List<Value>(GetObjectMembersEnum(bindingFlags)).ToArray();
} else { } else {
return new Value[0]; return new Value[0];
} }
} }
IEnumerable<Value> GetObjectMembersEnum(DebugType type, BindingFlags bindingFlags) IEnumerable<Value> GetObjectMembersEnum(BindingFlags bindingFlags)
{ {
if (type != null) { foreach(FieldInfo field in this.Type.GetFields(bindingFlags)) {
foreach(FieldInfo field in type.GetFields(bindingFlags)) { yield return this.GetFieldValue(field);
yield return this.GetFieldValue(field); }
} foreach(PropertyInfo property in this.Type.GetProperties(bindingFlags)) {
foreach(PropertyInfo property in type.GetProperties(bindingFlags)) { yield return this.GetPropertyValue(property);
yield return this.GetPropertyValue(property);
}
} else {
DebugType currentType = this.Type;
while (currentType != null) {
foreach(FieldInfo field in currentType.GetFields(bindingFlags)) {
yield return this.GetFieldValue(field);
}
foreach(PropertyInfo property in currentType.GetProperties(bindingFlags)) {
yield return this.GetPropertyValue(property);
}
currentType = currentType.BaseType;
}
} }
} }
} }

18
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Expressions.cs

@ -195,12 +195,12 @@ namespace Debugger.Tests {
ArrayDimensions="{Exception: Value is not an array}" ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}" ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}" ArrayRank="{Exception: Value is not an array}"
AsString="derived name" AsString="base name"
Expression="this.Name" Expression="this.name"
IsInvalid="False" IsInvalid="False"
IsNull="False" IsNull="False"
IsReference="True" IsReference="True"
PrimitiveValue="derived name" PrimitiveValue="base name"
Type="System.String" /> Type="System.String" />
</Item> </Item>
<Item> <Item>
@ -208,12 +208,12 @@ namespace Debugger.Tests {
ArrayDimensions="{Exception: Value is not an array}" ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}" ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}" ArrayRank="{Exception: Value is not an array}"
AsString="base name" AsString="base value"
Expression="this.name" Expression="this.Value"
IsInvalid="False" IsInvalid="False"
IsNull="False" IsNull="False"
IsReference="True" IsReference="True"
PrimitiveValue="base name" PrimitiveValue="base value"
Type="System.String" /> Type="System.String" />
</Item> </Item>
<Item> <Item>
@ -221,12 +221,12 @@ namespace Debugger.Tests {
ArrayDimensions="{Exception: Value is not an array}" ArrayDimensions="{Exception: Value is not an array}"
ArrayLength="{Exception: Value is not an array}" ArrayLength="{Exception: Value is not an array}"
ArrayRank="{Exception: Value is not an array}" ArrayRank="{Exception: Value is not an array}"
AsString="base value" AsString="derived name"
Expression="this.Value" Expression="this.Name"
IsInvalid="False" IsInvalid="False"
IsNull="False" IsNull="False"
IsReference="True" IsReference="True"
PrimitiveValue="base value" PrimitiveValue="derived name"
Type="System.String" /> Type="System.String" />
</Item> </Item>
<Item> <Item>

2
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/GenericDictionary.cs

@ -35,7 +35,7 @@ namespace Debugger.Tests {
StartTest("GenericDictionary.cs"); StartTest("GenericDictionary.cs");
ObjectDump("dict", process.SelectedStackFrame.GetLocalVariableValue("dict")); ObjectDump("dict", process.SelectedStackFrame.GetLocalVariableValue("dict"));
ObjectDump("dict members", process.SelectedStackFrame.GetLocalVariableValue("dict").GetMemberValues(null, BindingFlags.All)); ObjectDump("dict members", process.SelectedStackFrame.GetLocalVariableValue("dict").GetMemberValues());
EndTest(); EndTest();
} }

200
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Metadata.cs

@ -78,8 +78,8 @@ namespace Debugger.Tests {
<ModuleLoaded>Metadata.exe (Has symbols)</ModuleLoaded> <ModuleLoaded>Metadata.exe (Has symbols)</ModuleLoaded>
<DebuggingPaused>Break Metadata.cs:39,4-39,40</DebuggingPaused> <DebuggingPaused>Break Metadata.cs:39,4-39,40</DebuggingPaused>
<Members <Members
Capacity="32" Capacity="64"
Count="22"> Count="36">
<Item> <Item>
<FieldInfo <FieldInfo
DeclaringType="Debugger.Tests.TestPrograms.Metadata" DeclaringType="Debugger.Tests.TestPrograms.Metadata"
@ -383,6 +383,202 @@ namespace Debugger.Tests {
Name="staticProperty" Name="staticProperty"
SetMethod="null" /> SetMethod="null" />
</Item> </Item>
<Item>
<MethodInfo
DeclaringType="System.Object"
FullName="System.Object..ctor"
IsInternal="False"
IsPrivate="False"
IsProtected="False"
IsPublic="True"
IsSpecialName="True"
IsStatic="False"
Module="mscorlib.dll"
Name=".ctor"
StepOver="True" />
</Item>
<Item>
<MethodInfo
DeclaringType="System.Object"
FullName="System.Object.ToString"
IsInternal="False"
IsPrivate="False"
IsProtected="False"
IsPublic="True"
IsSpecialName="False"
IsStatic="False"
Module="mscorlib.dll"
Name="ToString"
StepOver="True" />
</Item>
<Item>
<MethodInfo
DeclaringType="System.Object"
FullName="System.Object.Equals"
IsInternal="False"
IsPrivate="False"
IsProtected="False"
IsPublic="True"
IsSpecialName="False"
IsStatic="False"
Module="mscorlib.dll"
Name="Equals"
StepOver="True" />
</Item>
<Item>
<MethodInfo
DeclaringType="System.Object"
FullName="System.Object.InternalEquals"
IsInternal="True"
IsPrivate="False"
IsProtected="False"
IsPublic="False"
IsSpecialName="False"
IsStatic="True"
Module="mscorlib.dll"
Name="InternalEquals"
StepOver="True" />
</Item>
<Item>
<MethodInfo
DeclaringType="System.Object"
FullName="System.Object.Equals"
IsInternal="False"
IsPrivate="False"
IsProtected="False"
IsPublic="True"
IsSpecialName="False"
IsStatic="True"
Module="mscorlib.dll"
Name="Equals"
StepOver="True" />
</Item>
<Item>
<MethodInfo
DeclaringType="System.Object"
FullName="System.Object.ReferenceEquals"
IsInternal="False"
IsPrivate="False"
IsProtected="False"
IsPublic="True"
IsSpecialName="False"
IsStatic="True"
Module="mscorlib.dll"
Name="ReferenceEquals"
StepOver="True" />
</Item>
<Item>
<MethodInfo
DeclaringType="System.Object"
FullName="System.Object.GetHashCode"
IsInternal="False"
IsPrivate="False"
IsProtected="False"
IsPublic="True"
IsSpecialName="False"
IsStatic="False"
Module="mscorlib.dll"
Name="GetHashCode"
StepOver="True" />
</Item>
<Item>
<MethodInfo
DeclaringType="System.Object"
FullName="System.Object.InternalGetHashCode"
IsInternal="True"
IsPrivate="False"
IsProtected="False"
IsPublic="False"
IsSpecialName="False"
IsStatic="True"
Module="mscorlib.dll"
Name="InternalGetHashCode"
StepOver="True" />
</Item>
<Item>
<MethodInfo
DeclaringType="System.Object"
FullName="System.Object.GetType"
IsInternal="False"
IsPrivate="False"
IsProtected="False"
IsPublic="True"
IsSpecialName="False"
IsStatic="False"
Module="mscorlib.dll"
Name="GetType"
StepOver="True" />
</Item>
<Item>
<MethodInfo
DeclaringType="System.Object"
FullName="System.Object.Finalize"
IsInternal="False"
IsPrivate="False"
IsProtected="True"
IsPublic="False"
IsSpecialName="False"
IsStatic="False"
Module="mscorlib.dll"
Name="Finalize"
StepOver="True" />
</Item>
<Item>
<MethodInfo
DeclaringType="System.Object"
FullName="System.Object.MemberwiseClone"
IsInternal="False"
IsPrivate="False"
IsProtected="True"
IsPublic="False"
IsSpecialName="False"
IsStatic="False"
Module="mscorlib.dll"
Name="MemberwiseClone"
StepOver="True" />
</Item>
<Item>
<MethodInfo
DeclaringType="System.Object"
FullName="System.Object.FieldSetter"
IsInternal="False"
IsPrivate="True"
IsProtected="False"
IsPublic="False"
IsSpecialName="False"
IsStatic="False"
Module="mscorlib.dll"
Name="FieldSetter"
StepOver="True" />
</Item>
<Item>
<MethodInfo
DeclaringType="System.Object"
FullName="System.Object.FieldGetter"
IsInternal="False"
IsPrivate="True"
IsProtected="False"
IsPublic="False"
IsSpecialName="False"
IsStatic="False"
Module="mscorlib.dll"
Name="FieldGetter"
StepOver="True" />
</Item>
<Item>
<MethodInfo
DeclaringType="System.Object"
FullName="System.Object.GetFieldInfo"
IsInternal="False"
IsPrivate="True"
IsProtected="False"
IsPublic="False"
IsSpecialName="False"
IsStatic="False"
Module="mscorlib.dll"
Name="GetFieldInfo"
StepOver="True" />
</Item>
</Members> </Members>
<Types <Types
Capacity="8" Capacity="8"

4
src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/ObjectValue.cs

@ -51,11 +51,11 @@ namespace Debugger.Tests {
val = process.SelectedStackFrame.GetLocalVariableValue("val"); val = process.SelectedStackFrame.GetLocalVariableValue("val");
ObjectDump("val", val); ObjectDump("val", val);
ObjectDump("val members", val.GetMemberValues(null, BindingFlags.All)); ObjectDump("val members", val.GetMemberValues());
process.Continue(); process.Continue();
ObjectDump("val", val); ObjectDump("val", val);
ObjectDump("val members", val.GetMemberValues(null, BindingFlags.All)); ObjectDump("val members", val.GetMemberValues());
EndTest(); EndTest();
} }

Loading…
Cancel
Save