From 0e7d5082dd4340b8eb5e6e9b860e69c44bdd5ccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Sat, 30 Aug 2008 18:27:12 +0000 Subject: [PATCH] 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 --- .../Project/Src/Metadata/BindingFlags.cs | 5 +- .../Project/Src/Metadata/DebugType.cs | 2 +- .../Project/Src/Values/Value.Object.cs | 31 +-- .../Project/Src/TestPrograms/Expressions.cs | 18 +- .../Src/TestPrograms/GenericDictionary.cs | 2 +- .../Project/Src/TestPrograms/Metadata.cs | 200 +++++++++++++++++- .../Project/Src/TestPrograms/ObjectValue.cs | 4 +- 7 files changed, 223 insertions(+), 39 deletions(-) diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/BindingFlags.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/BindingFlags.cs index 94c3f21e82..bff8ae884c 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/BindingFlags.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/BindingFlags.cs @@ -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 Method = 0x0400, GetProperty = 0x0800, - IncludeSuperType = 0x1000 + IncludeSuperType = 0x10000 }; } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs index ce69377dfc..ea0148f7f4 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs @@ -531,7 +531,7 @@ namespace Debugger.MetaData // Collect data Dictionary accessors = new Dictionary(); Dictionary propertyNames = new Dictionary(); - 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 diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Object.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Object.cs index 400affd614..79a00d0070 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Object.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Values/Value.Object.cs @@ -290,7 +290,7 @@ namespace Debugger /// Get all fields and properties of an object. public Value[] GetMemberValues() { - return GetMemberValues(null, BindingFlags.All); + return GetMemberValues(BindingFlags.All); } /// @@ -298,35 +298,22 @@ namespace Debugger /// /// Limit to type, null for all types /// Get only members with certain flags - public Value[] GetMemberValues(DebugType type, BindingFlags bindingFlags) + public Value[] GetMemberValues(BindingFlags bindingFlags) { if (this.Type.IsClass || this.Type.IsValueType) { - return new List(GetObjectMembersEnum(type, bindingFlags)).ToArray(); + return new List(GetObjectMembersEnum(bindingFlags)).ToArray(); } else { return new Value[0]; } } - IEnumerable GetObjectMembersEnum(DebugType type, BindingFlags bindingFlags) + IEnumerable 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); } } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Expressions.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Expressions.cs index 3d60d23460..6543c4325e 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Expressions.cs +++ b/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}" 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" /> @@ -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" /> @@ -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" /> diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/GenericDictionary.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/GenericDictionary.cs index 6308ebe96d..ee5d3bac76 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/GenericDictionary.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/GenericDictionary.cs @@ -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(); } diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Metadata.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Metadata.cs index 060b18e794..c1091f013f 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Metadata.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Metadata.cs @@ -78,8 +78,8 @@ namespace Debugger.Tests { Metadata.exe (Has symbols) Break Metadata.cs:39,4-39,40 + Capacity="64" + Count="36"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +