diff --git a/ILSpy/EventTreeNode.cs b/ILSpy/EventTreeNode.cs
new file mode 100644
index 000000000..e64595daa
--- /dev/null
+++ b/ILSpy/EventTreeNode.cs
@@ -0,0 +1,49 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
+
+using System;
+using ICSharpCode.TreeView;
+using Mono.Cecil;
+
+namespace ICSharpCode.ILSpy
+{
+ ///
+ /// Represents an event in the TreeView.
+ ///
+ sealed class EventTreeNode : SharpTreeNode
+ {
+ readonly EventDefinition ev;
+
+ public EventTreeNode(EventDefinition ev)
+ {
+ if (ev == null)
+ throw new ArgumentNullException("ev");
+ this.ev = ev;
+ this.LazyLoading = true;
+ }
+
+ public override object Text {
+ get { return ev.Name + " : " + Language.Current.TypeToString(ev.EventType); }
+ }
+
+ public override object Icon {
+ get {
+ return Images.Event;
+ }
+ }
+
+ protected override void LoadChildren()
+ {
+ if (ev.AddMethod != null)
+ this.Children.Add(new MethodTreeNode(ev.AddMethod));
+ if (ev.RemoveMethod != null)
+ this.Children.Add(new MethodTreeNode(ev.RemoveMethod));
+ if (ev.InvokeMethod != null)
+ this.Children.Add(new MethodTreeNode(ev.InvokeMethod));
+ if (ev.HasOtherMethods) {
+ foreach (var m in ev.OtherMethods)
+ this.Children.Add(new MethodTreeNode(m));
+ }
+ }
+ }
+}
diff --git a/ILSpy/FieldTreeNode.cs b/ILSpy/FieldTreeNode.cs
index 0ef8c60bd..bd42a35ef 100644
--- a/ILSpy/FieldTreeNode.cs
+++ b/ILSpy/FieldTreeNode.cs
@@ -37,25 +37,15 @@ namespace ICSharpCode.ILSpy
}
public override object Text {
- get { return field.Name; }
+ get { return field.Name + " : " + Language.Current.TypeToString(field.FieldType); }
}
public override object Icon {
get {
if (field.IsLiteral)
return Images.Literal;
- switch (field.Attributes & FieldAttributes.FieldAccessMask) {
- case FieldAttributes.Public:
- return Images.Field;
- case FieldAttributes.Assembly:
- case FieldAttributes.FamANDAssem:
- return Images.InternalField;
- case FieldAttributes.Family:
- case FieldAttributes.FamORAssem:
- return Images.ProtectedField;
- default:
- return Images.PrivateField;
- }
+ else
+ return Images.Field;
}
}
}
diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj
index f03dcbf76..0ec838ec5 100644
--- a/ILSpy/ILSpy.csproj
+++ b/ILSpy/ILSpy.csproj
@@ -72,10 +72,12 @@
+
+
@@ -91,6 +93,7 @@
Code
MainWindow.xaml
+
@@ -111,9 +114,7 @@
-
-
@@ -122,16 +123,12 @@
-
-
-
-
@@ -163,5 +160,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ILSpy/Images/Event.png b/ILSpy/Images/Event.png
new file mode 100644
index 000000000..aa3204ebc
Binary files /dev/null and b/ILSpy/Images/Event.png differ
diff --git a/ILSpy/Images/ExtensionMethod.png b/ILSpy/Images/ExtensionMethod.png
new file mode 100644
index 000000000..e76e2fbf3
Binary files /dev/null and b/ILSpy/Images/ExtensionMethod.png differ
diff --git a/ILSpy/Images/Images.cs b/ILSpy/Images/Images.cs
index 0a6bf43e8..8e2a198d6 100644
--- a/ILSpy/Images/Images.cs
+++ b/ILSpy/Images/Images.cs
@@ -32,30 +32,29 @@ namespace ICSharpCode.ILSpy
public static readonly BitmapImage Struct = LoadBitmap("Struct");
public static readonly BitmapImage Field = LoadBitmap("Field");
public static readonly BitmapImage Method = LoadBitmap("Method");
+ public static readonly BitmapImage ExtensionMethod = LoadBitmap("ExtensionMethod");
public static readonly BitmapImage Literal = LoadBitmap("Literal");
+ public static readonly BitmapImage Property = LoadBitmap("Property");
+ public static readonly BitmapImage Event = LoadBitmap("Event");
+ public static readonly BitmapImage Indexer = LoadBitmap("Indexer");
+ public static readonly BitmapImage Operator = LoadBitmap("Operator");
public static readonly BitmapImage InternalClass = LoadBitmap("InternalClass");
public static readonly BitmapImage InternalDelegate = LoadBitmap("InternalDelegate");
public static readonly BitmapImage InternalEnum = LoadBitmap("InternalEnum");
public static readonly BitmapImage InternalInterface = LoadBitmap("InternalInterface");
public static readonly BitmapImage InternalStruct = LoadBitmap("InternalStruct");
- public static readonly BitmapImage InternalField = LoadBitmap("InternalField");
- public static readonly BitmapImage InternalMethod = LoadBitmap("InternalMethod");
public static readonly BitmapImage PrivateClass = LoadBitmap("PrivateClass");
public static readonly BitmapImage PrivateDelegate = LoadBitmap("PrivateDelegate");
public static readonly BitmapImage PrivateEnum = LoadBitmap("PrivateEnum");
public static readonly BitmapImage PrivateInterface = LoadBitmap("PrivateInterface");
public static readonly BitmapImage PrivateStruct = LoadBitmap("PrivateStruct");
- public static readonly BitmapImage PrivateField = LoadBitmap("PrivateField");
- public static readonly BitmapImage PrivateMethod = LoadBitmap("PrivateMethod");
public static readonly BitmapImage ProtectedClass = LoadBitmap("ProtectedClass");
public static readonly BitmapImage ProtectedDelegate = LoadBitmap("ProtectedDelegate");
public static readonly BitmapImage ProtectedEnum = LoadBitmap("ProtectedEnum");
public static readonly BitmapImage ProtectedInterface = LoadBitmap("ProtectedInterface");
public static readonly BitmapImage ProtectedStruct = LoadBitmap("ProtectedStruct");
- public static readonly BitmapImage ProtectedField = LoadBitmap("ProtectedField");
- public static readonly BitmapImage ProtectedMethod = LoadBitmap("ProtectedMethod");
}
}
diff --git a/ILSpy/Images/Indexer.png b/ILSpy/Images/Indexer.png
new file mode 100644
index 000000000..63cee80b1
Binary files /dev/null and b/ILSpy/Images/Indexer.png differ
diff --git a/ILSpy/Images/InternalField.png b/ILSpy/Images/InternalField.png
deleted file mode 100644
index ca17b0fca..000000000
Binary files a/ILSpy/Images/InternalField.png and /dev/null differ
diff --git a/ILSpy/Images/InternalMethod.png b/ILSpy/Images/InternalMethod.png
deleted file mode 100644
index 16fa1738f..000000000
Binary files a/ILSpy/Images/InternalMethod.png and /dev/null differ
diff --git a/ILSpy/Images/Operator.png b/ILSpy/Images/Operator.png
new file mode 100644
index 000000000..fda73d089
Binary files /dev/null and b/ILSpy/Images/Operator.png differ
diff --git a/ILSpy/Images/PrivateField.png b/ILSpy/Images/PrivateField.png
deleted file mode 100644
index 47455f917..000000000
Binary files a/ILSpy/Images/PrivateField.png and /dev/null differ
diff --git a/ILSpy/Images/PrivateMethod.png b/ILSpy/Images/PrivateMethod.png
deleted file mode 100644
index 503df5e64..000000000
Binary files a/ILSpy/Images/PrivateMethod.png and /dev/null differ
diff --git a/ILSpy/Images/Property.png b/ILSpy/Images/Property.png
new file mode 100644
index 000000000..091e7ab2c
Binary files /dev/null and b/ILSpy/Images/Property.png differ
diff --git a/ILSpy/Images/ProtectedField.png b/ILSpy/Images/ProtectedField.png
deleted file mode 100644
index 7849a426a..000000000
Binary files a/ILSpy/Images/ProtectedField.png and /dev/null differ
diff --git a/ILSpy/Images/ProtectedMethod.png b/ILSpy/Images/ProtectedMethod.png
deleted file mode 100644
index 53f15bd5a..000000000
Binary files a/ILSpy/Images/ProtectedMethod.png and /dev/null differ
diff --git a/ILSpy/Images/Reference.png b/ILSpy/Images/Reference.png
deleted file mode 100644
index 85a4dfa0b..000000000
Binary files a/ILSpy/Images/Reference.png and /dev/null differ
diff --git a/ILSpy/Images/TypeImages.cs b/ILSpy/Images/TypeImages.cs
deleted file mode 100644
index a6ef8b5c0..000000000
--- a/ILSpy/Images/TypeImages.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows.Media.Imaging;
-
-namespace ICSharpCode.ILSpy
-{
- static class TypeImages
- {
- static BitmapImage LoadBitmap(string name)
- {
- BitmapImage image = new BitmapImage(new Uri("pack://application:,,,/Images/" + name + ".png"));
- image.Freeze();
- return image;
- }
-
- public static readonly BitmapImage Class = LoadBitmap("Class");
- public static readonly BitmapImage Delegate = LoadBitmap("Delegate");
- public static readonly BitmapImage Enum = LoadBitmap("Enum");
- public static readonly BitmapImage Interface = LoadBitmap("Interface");
- public static readonly BitmapImage Struct = LoadBitmap("Struct");
- public static readonly BitmapImage Field = LoadBitmap("Field");
- public static readonly BitmapImage Method = LoadBitmap("Method");
- public static readonly BitmapImage Literal = LoadBitmap("Literal");
-
- public static readonly BitmapImage InternalClass = LoadBitmap("InternalClass");
- public static readonly BitmapImage InternalDelegate = LoadBitmap("InternalDelegate");
- public static readonly BitmapImage InternalEnum = LoadBitmap("InternalEnum");
- public static readonly BitmapImage InternalInterface = LoadBitmap("InternalInterface");
- public static readonly BitmapImage InternalStruct = LoadBitmap("InternalStruct");
- public static readonly BitmapImage InternalField = LoadBitmap("InternalField");
- public static readonly BitmapImage InternalMethod = LoadBitmap("InternalMethod");
-
- public static readonly BitmapImage PrivateClass = LoadBitmap("PrivateClass");
- public static readonly BitmapImage PrivateDelegate = LoadBitmap("PrivateDelegate");
- public static readonly BitmapImage PrivateEnum = LoadBitmap("PrivateEnum");
- public static readonly BitmapImage PrivateInterface = LoadBitmap("PrivateInterface");
- public static readonly BitmapImage PrivateStruct = LoadBitmap("PrivateStruct");
- public static readonly BitmapImage PrivateField = LoadBitmap("PrivateField");
- public static readonly BitmapImage PrivateMethod = LoadBitmap("PrivateMethod");
-
- public static readonly BitmapImage ProtectedClass = LoadBitmap("ProtectedClass");
- public static readonly BitmapImage ProtectedDelegate = LoadBitmap("ProtectedDelegate");
- public static readonly BitmapImage ProtectedEnum = LoadBitmap("ProtectedEnum");
- public static readonly BitmapImage ProtectedInterface = LoadBitmap("ProtectedInterface");
- public static readonly BitmapImage ProtectedStruct = LoadBitmap("ProtectedStruct");
- public static readonly BitmapImage ProtectedField = LoadBitmap("ProtectedField");
- public static readonly BitmapImage ProtectedMethod = LoadBitmap("ProtectedMethod");
- }
-}
diff --git a/ILSpy/Language.cs b/ILSpy/Language.cs
new file mode 100644
index 000000000..2c0848c78
--- /dev/null
+++ b/ILSpy/Language.cs
@@ -0,0 +1,30 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
+
+using System;
+using Mono.Cecil;
+
+namespace ICSharpCode.ILSpy
+{
+ ///
+ /// Description of ILanguage.
+ ///
+ public abstract class Language
+ {
+ public static readonly Language Current = Languages.IL;
+
+ public virtual string TypeToString(TypeReference t)
+ {
+ return t.Name;
+ }
+ }
+
+ public static class Languages
+ {
+ public static readonly Language IL = new ILLanguage();
+
+ class ILLanguage : Language
+ {
+ }
+ }
+}
diff --git a/ILSpy/MethodTreeNode.cs b/ILSpy/MethodTreeNode.cs
index 7a0633fbd..2b34d2f87 100644
--- a/ILSpy/MethodTreeNode.cs
+++ b/ILSpy/MethodTreeNode.cs
@@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System;
+using System.Text;
using ICSharpCode.TreeView;
using Mono.Cecil;
@@ -37,23 +38,31 @@ namespace ICSharpCode.ILSpy
}
public override object Text {
- get { return method.Name; }
+ get {
+ StringBuilder b = new StringBuilder();
+ b.Append(method.Name);
+ b.Append('(');
+ for (int i = 0; i < method.Parameters.Count; i++) {
+ if (i > 0) b.Append(", ");
+ b.Append(Language.Current.TypeToString(method.Parameters[i].ParameterType));
+ }
+ b.Append(") : ");
+ b.Append(Language.Current.TypeToString(method.ReturnType));
+ return b.ToString();
+ }
}
public override object Icon {
get {
- switch (method.Attributes & MethodAttributes.MemberAccessMask) {
- case MethodAttributes.Public:
- return Images.Method;
- case MethodAttributes.Assembly:
- case MethodAttributes.FamANDAssem:
- return Images.InternalMethod;
- case MethodAttributes.Family:
- case MethodAttributes.FamORAssem:
- return Images.ProtectedMethod;
- default:
- return Images.PrivateMethod;
+ if (method.IsSpecialName && method.Name.StartsWith("op_", StringComparison.Ordinal))
+ return Images.Operator;
+ if (method.IsStatic && method.HasParameters && method.Parameters[0].HasCustomAttributes) {
+ foreach (var ca in method.Parameters[0].CustomAttributes) {
+ if (ca.AttributeType.FullName == "System.Runtime.CompilerServices.ExtensionAttribute")
+ return Images.ExtensionMethod;
+ }
}
+ return Images.Method;
}
}
}
diff --git a/ILSpy/PropertyTreeNode.cs b/ILSpy/PropertyTreeNode.cs
new file mode 100644
index 000000000..a01349375
--- /dev/null
+++ b/ILSpy/PropertyTreeNode.cs
@@ -0,0 +1,49 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
+
+using System;
+using ICSharpCode.TreeView;
+using Mono.Cecil;
+
+namespace ICSharpCode.ILSpy
+{
+ ///
+ /// Represents a property in the TreeView.
+ ///
+ sealed class PropertyTreeNode : SharpTreeNode
+ {
+ readonly PropertyDefinition property;
+ readonly bool isIndexer;
+
+ public PropertyTreeNode(PropertyDefinition property, bool isIndexer)
+ {
+ if (property == null)
+ throw new ArgumentNullException("property");
+ this.property = property;
+ this.isIndexer = isIndexer;
+ this.LazyLoading = true;
+ }
+
+ public override object Text {
+ get { return property.Name + " : " + Language.Current.TypeToString(property.PropertyType); }
+ }
+
+ public override object Icon {
+ get {
+ return isIndexer ? Images.Indexer : Images.Property;
+ }
+ }
+
+ protected override void LoadChildren()
+ {
+ if (property.GetMethod != null)
+ this.Children.Add(new MethodTreeNode(property.GetMethod));
+ if (property.SetMethod != null)
+ this.Children.Add(new MethodTreeNode(property.SetMethod));
+ if (property.HasOtherMethods) {
+ foreach (var m in property.OtherMethods)
+ this.Children.Add(new MethodTreeNode(m));
+ }
+ }
+ }
+}
diff --git a/ILSpy/TypeTreeNode.cs b/ILSpy/TypeTreeNode.cs
index 528f3bd0f..410569baa 100644
--- a/ILSpy/TypeTreeNode.cs
+++ b/ILSpy/TypeTreeNode.cs
@@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Linq;
using System.Windows.Media;
using ICSharpCode.TreeView;
@@ -74,8 +75,39 @@ namespace ICSharpCode.ILSpy
foreach (FieldDefinition field in type.Fields) {
this.Children.Add(new FieldTreeNode(field));
}
+ HashSet accessorMethods = new HashSet();
+
+ // figure out the name of the indexer:
+ string defaultMemberName = null;
+ var defaultMemberAttribute = type.CustomAttributes.FirstOrDefault(
+ a => a.AttributeType.FullName == typeof(System.Reflection.DefaultMemberAttribute).FullName);
+ if (defaultMemberAttribute != null && defaultMemberAttribute.ConstructorArguments.Count == 1) {
+ defaultMemberName = defaultMemberAttribute.ConstructorArguments[0].Value as string;
+ }
+
+ foreach (PropertyDefinition property in type.Properties) {
+ this.Children.Add(new PropertyTreeNode(property, property.Name == defaultMemberName));
+ accessorMethods.Add(property.GetMethod);
+ accessorMethods.Add(property.SetMethod);
+ if (property.HasOtherMethods) {
+ foreach (var m in property.OtherMethods)
+ accessorMethods.Add(m);
+ }
+ }
+ foreach (EventDefinition ev in type.Events) {
+ this.Children.Add(new EventTreeNode(ev));
+ accessorMethods.Add(ev.AddMethod);
+ accessorMethods.Add(ev.RemoveMethod);
+ accessorMethods.Add(ev.InvokeMethod);
+ if (ev.HasOtherMethods) {
+ foreach (var m in ev.OtherMethods)
+ accessorMethods.Add(m);
+ }
+ }
foreach (MethodDefinition method in type.Methods) {
- this.Children.Add(new MethodTreeNode(method));
+ if (!accessorMethods.Contains(method)) {
+ this.Children.Add(new MethodTreeNode(method));
+ }
}
}