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 @@ -19,7 +19,8 @@ namespace Debugger.MetaData
[Flags]
public enum BindingFlags: uint {
/// Return all members
All = 0xFFFF,
All = 0xFFFFFFFF,
AllInThisType = 0xFFFF,
AccessMask = 0x0F,
Public = 0x01,
@ -35,6 +36,6 @@ namespace Debugger.MetaData @@ -35,6 +36,6 @@ namespace Debugger.MetaData
Method = 0x0400,
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 @@ -531,7 +531,7 @@ namespace Debugger.MetaData
// Collect data
Dictionary<string, MethodInfo> accessors = new Dictionary<string, MethodInfo>();
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_"))) {
// There can be many get_Items
// 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 @@ -290,7 +290,7 @@ namespace Debugger
/// <summary> Get all fields and properties of an object. </summary>
public Value[] GetMemberValues()
{
return GetMemberValues(null, BindingFlags.All);
return GetMemberValues(BindingFlags.All);
}
/// <summary>
@ -298,35 +298,22 @@ namespace Debugger @@ -298,35 +298,22 @@ namespace Debugger
/// </summary>
/// <param name="type"> Limit to type, null for all types </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) {
return new List<Value>(GetObjectMembersEnum(type, bindingFlags)).ToArray();
return new List<Value>(GetObjectMembersEnum(bindingFlags)).ToArray();
} else {
return new Value[0];
}
}
IEnumerable<Value> GetObjectMembersEnum(DebugType type, BindingFlags bindingFlags)
IEnumerable<Value> GetObjectMembersEnum(BindingFlags bindingFlags)
{
if (type != null) {
foreach(FieldInfo field in type.GetFields(bindingFlags)) {
yield return this.GetFieldValue(field);
}
foreach(PropertyInfo property in type.GetProperties(bindingFlags)) {
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;
}
foreach(FieldInfo field in this.Type.GetFields(bindingFlags)) {
yield return this.GetFieldValue(field);
}
foreach(PropertyInfo property in this.Type.GetProperties(bindingFlags)) {
yield return this.GetPropertyValue(property);
}
}
}

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

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

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

@ -35,7 +35,7 @@ namespace Debugger.Tests { @@ -35,7 +35,7 @@ namespace Debugger.Tests {
StartTest("GenericDictionary.cs");
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();
}

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

@ -78,8 +78,8 @@ namespace Debugger.Tests { @@ -78,8 +78,8 @@ namespace Debugger.Tests {
<ModuleLoaded>Metadata.exe (Has symbols)</ModuleLoaded>
<DebuggingPaused>Break Metadata.cs:39,4-39,40</DebuggingPaused>
<Members
Capacity="32"
Count="22">
Capacity="64"
Count="36">
<Item>
<FieldInfo
DeclaringType="Debugger.Tests.TestPrograms.Metadata"
@ -383,6 +383,202 @@ namespace Debugger.Tests { @@ -383,6 +383,202 @@ namespace Debugger.Tests {
Name="staticProperty"
SetMethod="null" />
</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>
<Types
Capacity="8"

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

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

Loading…
Cancel
Save