Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Habersack <grendel@twistedcode.net>2009-02-25 03:02:38 +0300
committerMarek Habersack <grendel@twistedcode.net>2009-02-25 03:02:38 +0300
commita1d208f3dae752b01583581a2d307a1a1a2da3d4 (patch)
tree1e53e9939bbd8e4738b2f1c3cae03a4508947078 /gui-compare
parent05195b13abe0343f1a77015457ed40138bf19ad2 (diff)
2009-02-25 Marek Habersack <mhabersack@novell.com>
* MainWindow.cs, CecilMetadata.cs, Metadata.cs, CompareContext.cs, Comparison.cs: added support for MSDN documentation URLs attached to the tree nodes. URLs can be opened in the user's browser by double-clicking on the nodes which, when selected, show an MSDN URL in the status bar. svn path=/trunk/mono-tools/; revision=127918
Diffstat (limited to 'gui-compare')
-rw-r--r--gui-compare/CecilMetadata.cs62
-rw-r--r--gui-compare/ChangeLog8
-rw-r--r--gui-compare/CompareContext.cs3
-rw-r--r--gui-compare/Comparison.cs71
-rw-r--r--gui-compare/MainWindow.cs34
-rw-r--r--gui-compare/Metadata.cs8
6 files changed, 177 insertions, 9 deletions
diff --git a/gui-compare/CecilMetadata.cs b/gui-compare/CecilMetadata.cs
index 83be7931..b1155446 100644
--- a/gui-compare/CecilMetadata.cs
+++ b/gui-compare/CecilMetadata.cs
@@ -385,7 +385,8 @@ namespace GuiCompare {
delegate_list = new List<CompNamed>();
interface_list = new List<CompNamed>();
struct_list = new List<CompNamed>();
-
+ MemberName = name;
+
foreach (string type_name in type_mapping.Keys) {
TypeDefinition type_def = type_mapping[type_name];
if (type_def.IsNotPublic)
@@ -458,7 +459,10 @@ namespace GuiCompare {
properties = new List<CompNamed>();
fields = new List<CompNamed>();
events = new List<CompNamed>();
-
+ if (!type_def.IsNotPublic || type_def.IsPublic || type_def.IsNestedPublic || type_def.IsNestedFamily ||
+ type_def.IsNestedFamilyAndAssembly || type_def.IsNestedFamilyOrAssembly)
+ MemberName = type_def.FullName;
+
CecilUtils.PopulateMemberLists (type_def,
interfaces,
constructors,
@@ -538,6 +542,9 @@ namespace GuiCompare {
: base (type_def.Name)
{
this.type_def = type_def;
+ if (!type_def.IsNotPublic || type_def.IsPublic || type_def.IsNestedPublic || type_def.IsNestedFamily ||
+ type_def.IsNestedFamilyAndAssembly || type_def.IsNestedFamilyOrAssembly)
+ MemberName = type_def.FullName;
}
public override string GetBaseType ()
@@ -555,7 +562,10 @@ namespace GuiCompare {
this.type_def = type_def;
fields = new List<CompNamed>();
-
+ if (!type_def.IsNotPublic || type_def.IsPublic || type_def.IsNestedPublic || type_def.IsNestedFamily ||
+ type_def.IsNestedFamilyAndAssembly || type_def.IsNestedFamilyOrAssembly)
+ MemberName = type_def.FullName;
+
CecilUtils.PopulateMemberLists (type_def,
null,
null,
@@ -613,6 +623,10 @@ namespace GuiCompare {
fields = new List<CompNamed>();
events = new List<CompNamed>();
+ if (!type_def.IsNotPublic || type_def.IsPublic || type_def.IsNestedPublic || type_def.IsNestedFamily ||
+ type_def.IsNestedFamilyAndAssembly || type_def.IsNestedFamilyOrAssembly)
+ MemberName = type_def.FullName;
+
CecilUtils.PopulateMemberLists (type_def,
interfaces,
constructors,
@@ -711,6 +725,11 @@ namespace GuiCompare {
{
this.field_def = field_def;
this.attributes = CecilUtils.GetCustomAttributes (field_def, todos);
+ if (field_def.IsPublic || field_def.IsFamily || field_def.IsFamilyAndAssembly || field_def.IsFamilyOrAssembly) {
+ TypeDefinition declType = field_def.DeclaringType;
+ if (declType != null)
+ MemberName = declType.FullName + "." + field_def.Name;
+ }
}
public override string GetMemberType ()
@@ -759,6 +778,11 @@ namespace GuiCompare {
this.method_def = method_def;
this.attributes = CecilUtils.GetCustomAttributes (method_def, todos);
DisplayName = FormatName (method_def, true);
+ if (method_def.IsFamily || method_def.IsFamilyAndAssembly || method_def.IsFamilyOrAssembly || method_def.IsPublic) {
+ TypeReference declType = method_def.DeclaringType;
+ if (declType != null)
+ MemberName = declType.FullName + "." + method_def.Name;
+ }
}
public override string GetMemberType ()
@@ -894,6 +918,22 @@ namespace GuiCompare {
this.pd = pd;
this.attributes = CecilUtils.GetCustomAttributes (pd, todos);
this.DisplayName = FormatName (pd, true);
+
+ MethodDefinition getMethod = pd.GetMethod, setMethod = pd.SetMethod;
+ if (getMethod != null || setMethod != null) {
+ bool interesting = false;
+
+ if (getMethod != null && (getMethod.IsPublic || getMethod.IsFamily || getMethod.IsFamilyAndAssembly || getMethod.IsFamilyOrAssembly))
+ interesting = true;
+ else if (setMethod != null && (setMethod.IsPublic || setMethod.IsFamily || setMethod.IsFamilyAndAssembly || setMethod.IsFamilyOrAssembly))
+ interesting = true;
+
+ if (interesting) {
+ TypeDefinition declType = pd.DeclaringType;
+ if (declType != null)
+ MemberName = declType.FullName + "." + pd.Name;
+ }
+ }
}
public override string GetMemberType()
@@ -972,6 +1012,22 @@ namespace GuiCompare {
{
this.ed = ed;
this.attributes = CecilUtils.GetCustomAttributes (ed, todos);
+
+ MethodDefinition addMethod = ed.AddMethod, removeMethod = ed.RemoveMethod;
+ if (addMethod != null || removeMethod != null) {
+ bool interesting = false;
+
+ if (addMethod != null && (addMethod.IsPublic || addMethod.IsFamily || addMethod.IsFamilyAndAssembly || addMethod.IsFamilyOrAssembly))
+ interesting = true;
+ else if (removeMethod != null && (removeMethod.IsPublic || removeMethod.IsFamily || removeMethod.IsFamilyAndAssembly || removeMethod.IsFamilyOrAssembly))
+ interesting = true;
+
+ if (interesting) {
+ TypeDefinition declType = ed.DeclaringType;
+ if (declType != null)
+ MemberName = declType.FullName + "." + ed.Name;
+ }
+ }
}
public override string GetMemberType()
diff --git a/gui-compare/ChangeLog b/gui-compare/ChangeLog
index 8be67389..298d525d 100644
--- a/gui-compare/ChangeLog
+++ b/gui-compare/ChangeLog
@@ -1,3 +1,11 @@
+2009-02-25 Marek Habersack <mhabersack@novell.com>
+
+ * MainWindow.cs, CecilMetadata.cs, Metadata.cs, CompareContext.cs,
+ Comparison.cs: added support for MSDN documentation URLs attached
+ to the tree nodes. URLs can be opened in the user's browser by
+ double-clicking on the nodes which, when selected, show an MSDN
+ URL in the status bar.
+
2009-01-29 Jb Evain <jbevain@novell.com>
* Makefile.am: reference directly cecil from the gac as gendarme
diff --git a/gui-compare/CompareContext.cs b/gui-compare/CompareContext.cs
index ebfe59ae..350f027a 100644
--- a/gui-compare/CompareContext.cs
+++ b/gui-compare/CompareContext.cs
@@ -427,7 +427,8 @@ namespace GuiCompare {
if (!string.IsNullOrEmpty (baseTypeName)) {
ComparisonNode baseTypeNode = new ComparisonNode (CompType.Class,
string.Format ("BaseType: {0}",
- baseTypeName));
+ baseTypeName),
+ baseTypeName);
baseTypeNode.Status = ComparisonStatus.Missing;
node.AddChild (baseTypeNode);
}
diff --git a/gui-compare/Comparison.cs b/gui-compare/Comparison.cs
index 70cb8319..b979e333 100644
--- a/gui-compare/Comparison.cs
+++ b/gui-compare/Comparison.cs
@@ -25,6 +25,7 @@
using System;
using System.Collections.Generic;
+using System.Text;
namespace GuiCompare {
@@ -36,11 +37,16 @@ namespace GuiCompare {
}
public class ComparisonNode {
- public ComparisonNode (CompType type,
- string name)
+ public ComparisonNode (CompType type, string displayName)
+ : this (type, displayName, null)
+ {
+ }
+
+ public ComparisonNode (CompType type, string displayName, string typeName)
{
Type = type;
- Name = name;
+ Name = displayName;
+ TypeName = typeName;
Children = new List<ComparisonNode>();
Messages = new List<string>();
Todos = new List<string>();
@@ -72,6 +78,60 @@ namespace GuiCompare {
Status = ComparisonStatus.Error;
Messages.Add (msg);
}
+
+ // TODO: detect user's locale and reflect that in the url
+ public string MSDNUrl {
+ get {
+ if (msdnUrl != null)
+ return msdnUrl;
+
+ if (String.IsNullOrEmpty (TypeName)) {
+ msdnUrl = MSDN_BASE_URL + ConstructMSDNUrl ();
+ return msdnUrl;
+ }
+
+ if (msdnUrl == null)
+ msdnUrl = MSDN_BASE_URL + TypeName.ToLower () + ".aspx";
+
+ return msdnUrl;
+ }
+ }
+
+ string FormatMyName ()
+ {
+ string name = Name;
+ int start = name.IndexOf (' ') + 1;
+ int end = name.IndexOf ('(');
+ int len = end - start;
+
+ if (len <= 0)
+ return name;
+
+ return name.Substring (start, end - start).Trim ();
+ }
+
+ string ConstructMSDNUrl ()
+ {
+ StringBuilder sb = new StringBuilder (Name);
+ ComparisonNode n = Parent;
+ List <string> segments = new List <string> ();
+ string name;
+
+ segments.Add ("aspx");
+ segments.Insert (0, FormatMyName ().ToLower ());
+ n = Parent;
+ while (n != null) {
+ name = n.Name.ToLower ();
+ if (name.EndsWith (".dll"))
+ break;
+
+ segments.Insert (0, n.Name.ToLower ());
+ n = n.Parent;
+ }
+
+ string[] path = segments.ToArray ();
+ return String.Join (".", path);
+ }
public ComparisonStatus Status;
public readonly CompType Type;
@@ -79,6 +139,7 @@ namespace GuiCompare {
public ComparisonNode Parent;
public readonly string Name;
+ public readonly string TypeName;
public readonly List<string> Messages;
public readonly List<string> Todos;
public bool ThrowsNIE;
@@ -91,5 +152,9 @@ namespace GuiCompare {
public int Niex;
public readonly List<ComparisonNode> Children;
+
+ string msdnUrl;
+
+ const string MSDN_BASE_URL = "http://msdn.microsoft.com/en-us/library/";
}
}
diff --git a/gui-compare/MainWindow.cs b/gui-compare/MainWindow.cs
index ffd390f9..9919121a 100644
--- a/gui-compare/MainWindow.cs
+++ b/gui-compare/MainWindow.cs
@@ -27,6 +27,7 @@ using System.Collections.Generic;
using System.Reflection;
using System.Net;
using Gtk;
+using GLib;
using System.Threading;
using System.Text;
using GuiCompare;
@@ -216,9 +217,30 @@ public partial class MainWindow: Gtk.Window
else {
summary.Visible = false;
}
+
+ string msdnUrl = n != null ? n.MSDNUrl : null;
+ if (!String.IsNullOrEmpty (msdnUrl))
+ Status = msdnUrl;
+ else
+ Status = String.Empty;
}
};
+ tree.RowActivated += delegate (object sender, RowActivatedArgs args) {
+ Gtk.TreeIter iter;
+ if (!tree.Model.GetIter (out iter, args.Path))
+ return;
+
+ ComparisonNode n = tree.Model.GetValue (iter, (int)TreeCol.Node) as ComparisonNode;
+ if (n == null || String.IsNullOrEmpty (n.MSDNUrl))
+ return;
+
+ System.Diagnostics.Process browser = new System.Diagnostics.Process ();
+ browser.StartInfo.FileName = n.MSDNUrl;
+ browser.StartInfo.UseShellExecute = true;
+ browser.Start ();
+ };
+
//
// Load configuration
//
@@ -397,9 +419,19 @@ public partial class MainWindow: Gtk.Window
case ComparisonStatus.Error: return "red";
case ComparisonStatus.None:
default:
- return "black";
+ if (String.IsNullOrEmpty (node.MSDNUrl))
+ return "black";
+ else
+ return "navyblue";
}
}
+
+ bool StatusUnderlineFromComparisonNode (ComparisonNode node)
+ {
+ if (String.IsNullOrEmpty (node.MSDNUrl))
+ return false;
+ return true;
+ }
void PopulateTreeFromComparison (ComparisonNode root)
{
diff --git a/gui-compare/Metadata.cs b/gui-compare/Metadata.cs
index 4bd95333..f14549d1 100644
--- a/gui-compare/Metadata.cs
+++ b/gui-compare/Metadata.cs
@@ -81,6 +81,11 @@ namespace GuiCompare {
this.todos = new List<string>();
}
+ public string MemberName {
+ set { memberName = value; }
+ get { return memberName; }
+ }
+
public string Name {
set { name = value; }
get { return name; }
@@ -98,7 +103,7 @@ namespace GuiCompare {
public ComparisonNode GetComparisonNode ()
{
- ComparisonNode node = new ComparisonNode (type, DisplayName);
+ ComparisonNode node = new ComparisonNode (type, DisplayName, MemberName);
node.Todos.AddRange (todos);
return node;
}
@@ -110,6 +115,7 @@ namespace GuiCompare {
string displayName;
string name;
+ string memberName;
CompType type;
public List<string> todos;
}