From dfa651c2a194e79244998e9d9f4fe1cbb35c5082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Sun, 6 Jul 2008 00:07:34 +0000 Subject: [PATCH] Use richer set of icons in the local variables pad git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3179 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Debugger.AddIn.csproj | 1 - .../Project/Src/Service/DebuggerIcons.cs | 83 ---- .../Src/TreeModel/ChildNodesOfObject.cs | 9 +- .../Project/Src/TreeModel/ValueNode.cs | 62 ++- .../Project/Src/Metadata/FieldInfo.cs | 24 +- .../Project/Src/Metadata/MemberInfo.cs | 10 +- .../Project/Src/Metadata/MethodInfo.cs | 24 +- .../Project/Src/Metadata/PropertyInfo.cs | 24 +- .../Src/Wrappers/MetaData/MetaDataImport.cs | 44 ++- .../Project/Debugger.Tests.csproj | 1 + .../Project/Src/TestPrograms/Generics.cs | 16 + .../Project/Src/TestPrograms/Metadata.cs | 370 ++++++++++++++++++ 12 files changed, 534 insertions(+), 134 deletions(-) delete mode 100644 src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DebuggerIcons.cs create mode 100644 src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Metadata.cs diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj index 95914b82c4..4438dea046 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj @@ -80,7 +80,6 @@ DebuggerEventForm.cs - Configuration\GlobalAssemblyInfo.cs diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DebuggerIcons.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DebuggerIcons.cs deleted file mode 100644 index bda8c5654a..0000000000 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DebuggerIcons.cs +++ /dev/null @@ -1,83 +0,0 @@ -// -// -// -// $Revision$ -// -#region License -// -// Copyright (c) 2007, ic#code -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the ic#code nor the names of its contributors may be -// used to endorse or promote products derived from this software without -// specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -// -#endregion - -using System; -using System.Drawing; -using System.Windows.Forms; - -using ICSharpCode.SharpDevelop; - -namespace Debugger -{ - /// - /// Description of DebuggerIcons. - /// - public static class DebuggerIcons - { - static ImageList imageList; - - public static ImageList ImageList { - get { - return imageList; - } - } - - static DebuggerIcons() - { - imageList = new ImageList(); - imageList.Images.Add(IconService.GetBitmap("Icons.16x16.Class")); - imageList.Images.Add(IconService.GetBitmap("Icons.16x16.Field")); - imageList.Images.Add(IconService.GetBitmap("Icons.16x16.Property")); - } - - public static Image GetImage(Value val) - { - return imageList.Images[GetImageListIndex(val)]; - } - - public static int GetImageListIndex(Value val) - { - if (val.IsObject) { - return 0; // Class - } else { - return 1; // Field - } - } - } -} diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ChildNodesOfObject.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ChildNodesOfObject.cs index 7e42398f5d..c7e3a6174c 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ChildNodesOfObject.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ChildNodesOfObject.cs @@ -4,15 +4,14 @@ // $Revision$ // +using ICSharpCode.SharpDevelop; using System; using System.Collections; using System.Collections.Generic; - -using ICSharpCode.Core; - using Debugger; -using Debugger.MetaData; using Debugger.Expressions; +using Debugger.MetaData; +using ICSharpCode.Core; namespace Debugger.AddIn.TreeModel { @@ -52,7 +51,7 @@ namespace Debugger.AddIn.TreeModel this.targetObject = targetObject; this.shownType = shownType; - this.Image = DebuggerIcons.ImageList.Images[0]; // Class + this.Image = IconService.GetBitmap("Icons.16x16.Class"); this.Name = StringParser.Parse("${res:MainWindow.Windows.Debug.LocalVariables.BaseClass}"); this.Type = shownType.FullName; if (shownType.FullName == "System.Object") { diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ValueNode.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ValueNode.cs index 269b82d2da..1165d31e9b 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ValueNode.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ValueNode.cs @@ -4,19 +4,18 @@ // $Revision$ // +using ICSharpCode.SharpDevelop; using System; using System.Collections; using System.Collections.Generic; using System.Windows.Forms; - +using Debugger; +using Debugger.Expressions; +using Debugger.MetaData; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Debugging; using ICSharpCode.SharpDevelop.Services; -using Debugger; -using Debugger.MetaData; -using Debugger.Expressions; - namespace Debugger.AddIn.TreeModel { /// @@ -70,11 +69,7 @@ namespace Debugger.AddIn.TreeModel (val.Expression is MemberReferenceExpression && ((MemberReferenceExpression)val.Expression).MemberInfo is FieldInfo); } - if (val.IsObject) { - this.Image = DebuggerIcons.ImageList.Images[0]; // Class - } else { - this.Image = DebuggerIcons.ImageList.Images[1]; // Field - } + this.Image = IconService.GetBitmap("Icons.16x16." + GetImageName(val)); this.Name = val.Expression.CodeTail; @@ -132,6 +127,53 @@ namespace Debugger.AddIn.TreeModel return false; } + string GetImageName(Value val) + { + Expression expr = val.Expression; + if (expr is ThisReferenceExpression) { + if (val.Type.IsClass) { + return "Class"; + } + if (val.Type.IsValueType) { + return "Struct"; + } + } + if (expr is ParameterIdentifierExpression) { + return "Parameter"; + } + if (expr is MemberReferenceExpression) { + MemberInfo memberInfo = ((MemberReferenceExpression)expr).MemberInfo; + string prefix; + if (memberInfo.IsPublic) { + prefix = ""; + } else if (memberInfo.IsInternal) { + prefix = "Internal"; + } else if (memberInfo.IsProtected) { + prefix = "Protected"; + } else if (memberInfo.IsPrivate) { + prefix = "Private"; + } else { + prefix = ""; + } + if (memberInfo is FieldInfo) { + return prefix + "Field"; + } + if (memberInfo is PropertyInfo) { + return prefix + "Property"; + } + if (memberInfo is MethodInfo) { + return prefix + "Method"; + } + } + if (expr is LocalVariableIdentifierExpression) { + return "Local"; + } + if (expr is ArrayIndexerExpression) { + return "Field"; + } + return "Field"; + } + public ContextMenuStrip GetContextMenu() { ContextMenuStrip menu = new ContextMenuStrip(); diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/FieldInfo.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/FieldInfo.cs index 0ed4462a03..b70d7dae7a 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/FieldInfo.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/FieldInfo.cs @@ -26,18 +26,24 @@ namespace Debugger.MetaData } } - /// Gets a value indicating whether this field is private - public override bool IsPrivate { - get { - return !fieldProps.IsPublic; - } + /// Gets a value indicating whether this member has the private access modifier + public override bool IsPrivate { + get { return fieldProps.IsPrivate; } + } + + /// Gets a value indicating whether this member has the internal access modifier + public override bool IsInternal { + get { return fieldProps.IsInternal; } } - /// Gets a value indicating whether this field is public + /// Gets a value indicating whether this member has the protected access modifier + public override bool IsProtected { + get { return fieldProps.IsProtected; } + } + + /// Gets a value indicating whether this member has the public access modifier public override bool IsPublic { - get { - return fieldProps.IsPublic; - } + get { return fieldProps.IsPublic; } } /// Gets a value indicating whether this field is static diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/MemberInfo.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/MemberInfo.cs index 624ab67277..e13b9f5f0b 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/MemberInfo.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/MemberInfo.cs @@ -52,10 +52,16 @@ namespace Debugger.MetaData } } - /// Gets a value indicating whether this member is private + /// Gets a value indicating whether this member has the private access modifier public abstract bool IsPrivate { get; } - /// Gets a value indicating whether this member is public + /// Gets a value indicating whether this member has the internal access modifier + public abstract bool IsInternal { get; } + + /// Gets a value indicating whether this member has the protected access modifier + public abstract bool IsProtected { get; } + + /// Gets a value indicating whether this member has the public access modifier public abstract bool IsPublic { get; } /// Gets a value indicating whether this member is static diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/MethodInfo.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/MethodInfo.cs index 9650fb9f85..080486c507 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/MethodInfo.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/MethodInfo.cs @@ -33,18 +33,24 @@ namespace Debugger.MetaData get { return backingField; } } - /// Gets a value indicating whether this method is private - public override bool IsPrivate { - get { - return !methodProps.IsPublic; - } + /// Gets a value indicating whether this member has the private access modifier + public override bool IsPrivate { + get { return methodProps.IsPrivate; } + } + + /// Gets a value indicating whether this member has the internal access modifier + public override bool IsInternal { + get { return methodProps.IsInternal; } } - /// Gets a value indicating whether this method is public + /// Gets a value indicating whether this member has the protected access modifier + public override bool IsProtected { + get { return methodProps.IsProtected; } + } + + /// Gets a value indicating whether this member has the public access modifier public override bool IsPublic { - get { - return methodProps.IsPublic; - } + get { return methodProps.IsPublic; } } /// Gets a value indicating whether the name of this method diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/PropertyInfo.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/PropertyInfo.cs index 0b3a3eee6d..70230e10b7 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/PropertyInfo.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/PropertyInfo.cs @@ -20,18 +20,24 @@ namespace Debugger.MetaData MethodInfo getMethod; MethodInfo setMethod; - /// Gets a value indicating whether this property is private - public override bool IsPrivate { - get { - return !(getMethod ?? setMethod).IsPublic; - } + /// Gets a value indicating whether this member has the private access modifier + public override bool IsPrivate { + get { return (getMethod ?? setMethod).IsPrivate; } + } + + /// Gets a value indicating whether this member has the internal access modifier + public override bool IsInternal { + get { return (getMethod ?? setMethod).IsInternal; } } - /// Gets a value indicating whether this property is public + /// Gets a value indicating whether this member has the protected access modifier + public override bool IsProtected { + get { return (getMethod ?? setMethod).IsProtected; } + } + + /// Gets a value indicating whether this member has the public access modifier public override bool IsPublic { - get { - return (getMethod ?? setMethod).IsPublic; - } + get { return (getMethod ?? setMethod).IsPublic; } } /// Gets a value indicating whether this property is static diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaDataImport.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaDataImport.cs index ed0f6c44f4..ad1e4a67ae 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaDataImport.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/MetaData/MetaDataImport.cs @@ -976,12 +976,28 @@ namespace Debugger.Wrappers.MetaData public uint CPlusTypeFlag; public Blob ConstantValue; - public bool IsStatic { - get { return (Flags & (uint)ClassFieldAttribute.fdStatic) != 0; } + private ClassFieldAttribute access { + get { return (ClassFieldAttribute)(Flags & (uint)ClassFieldAttribute.fdFieldAccessMask); } + } + + public bool IsPrivate { + get { return access == ClassFieldAttribute.fdPrivate; } + } + + public bool IsInternal { + get { return access == ClassFieldAttribute.fdAssembly; } + } + + public bool IsProtected { + get { return access == ClassFieldAttribute.fdFamily; } } public bool IsPublic { - get { return (Flags & (uint)ClassFieldAttribute.fdPublic) != 0; } + get { return access == ClassFieldAttribute.fdPublic; } + } + + public bool IsStatic { + get { return (Flags & (uint)ClassFieldAttribute.fdStatic) != 0; } } public bool IsLiteral { @@ -1033,12 +1049,28 @@ namespace Debugger.Wrappers.MetaData public uint CodeRVA; public uint ImplFlags; - public bool IsStatic { - get { return (Flags & (uint)CorMethodAttr.mdStatic) != 0; } + private CorMethodAttr access { + get { return (CorMethodAttr)(Flags & (uint)CorMethodAttr.mdMemberAccessMask); } + } + + public bool IsPrivate { + get { return access == CorMethodAttr.mdPrivate; } + } + + public bool IsInternal { + get { return access == CorMethodAttr.mdAssem; } + } + + public bool IsProtected { + get { return access == CorMethodAttr.mdFamily; } } public bool IsPublic { - get { return (Flags & (uint)CorMethodAttr.mdPublic) != 0; } + get { return access == CorMethodAttr.mdPublic; } + } + + public bool IsStatic { + get { return (Flags & (uint)CorMethodAttr.mdStatic) != 0; } } public bool HasSpecialName { diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj index 71f83b60a0..b6afcaed0e 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Debugger.Tests.csproj @@ -60,6 +60,7 @@ + diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Generics.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Generics.cs index 9f05fb8305..227315e8f1 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Generics.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/Generics.cs @@ -144,7 +144,9 @@ namespace Debugger.Tests { +// +// +// +// $Revision$ +// + +// Never used field +#pragma warning disable 0169 +// Field will always have default value +#pragma warning disable 0649 + +using System; + +namespace Debugger.Tests.TestPrograms +{ + public class Metadata + { + private int privateField; + public int publicField; + protected int protectedField; + internal int internalField; + static int staticField; + + private int privateProperty { get { return 0; } } + public int publicProperty { get { return 0; } } + protected int protectedProperty { get { return 0; } } + internal int internalProperty { get { return 0; } } + static int staticProperty { get { return 0; } } + + private void privateMethod() {} + public void publicMethod() {} + protected void protectedMethod() {} + internal void internalMethod() {} + static void staticMethod() {} + + public static void Main() + { + System.Diagnostics.Debugger.Break(); + } + } +} + +#if TEST_CODE +namespace Debugger.Tests { + using Debugger.MetaData; + + public partial class DebuggerTests + { + [NUnit.Framework.Test] + public void Metadata() + { + StartTest("Metadata.cs"); + + ObjectDump("Members", process.SelectedStackFrame.MethodInfo.DeclaringType.GetMembers(BindingFlags.All)); + + EndTest(); + } + } +} +#endif + +#if EXPECTED_OUTPUT + + + + + mscorlib.dll (No symbols) + Metadata.exe (Has symbols) + Break + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#endif // EXPECTED_OUTPUT \ No newline at end of file