Browse Source

add tooltip with extra information to AssemblyTreeNode

pull/488/merge
Siegfried Pammer 11 years ago
parent
commit
1745793830
  1. 31
      ILSpy/Languages/CSharpLanguage.cs
  2. 2
      ILSpy/LoadedAssembly.cs
  3. 32
      ILSpy/TreeNodes/AssemblyTreeNode.cs

31
ILSpy/Languages/CSharpLanguage.cs

@ -257,6 +257,21 @@ namespace ICSharpCode.ILSpy
return module.Architecture.ToString(); return module.Architecture.ToString();
} }
} }
public static string GetRuntimeDisplayName(ModuleDefinition module)
{
switch (module.Runtime) {
case TargetRuntime.Net_1_0:
return ".NET 1.0";
case TargetRuntime.Net_1_1:
return ".NET 1.1";
case TargetRuntime.Net_2_0:
return ".NET 2.0";
case TargetRuntime.Net_4_0:
return ".NET 4.0";
}
return null;
}
public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options) public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
{ {
@ -278,19 +293,9 @@ namespace ICSharpCode.ILSpy
if ((mainModule.Attributes & ModuleAttributes.ILOnly) == 0) { if ((mainModule.Attributes & ModuleAttributes.ILOnly) == 0) {
output.WriteLine("// This assembly contains unmanaged code."); output.WriteLine("// This assembly contains unmanaged code.");
} }
switch (mainModule.Runtime) { string runtimeName = GetRuntimeDisplayName(mainModule);
case TargetRuntime.Net_1_0: if (runtimeName != null) {
output.WriteLine("// Runtime: .NET 1.0"); output.WriteLine("// Runtime: " + runtimeName);
break;
case TargetRuntime.Net_1_1:
output.WriteLine("// Runtime: .NET 1.1");
break;
case TargetRuntime.Net_2_0:
output.WriteLine("// Runtime: .NET 2.0");
break;
case TargetRuntime.Net_4_0:
output.WriteLine("// Runtime: .NET 4.0");
break;
} }
output.WriteLine(); output.WriteLine();

2
ILSpy/LoadedAssembly.cs

@ -87,7 +87,7 @@ namespace ICSharpCode.ILSpy
public string Text { public string Text {
get { get {
if (IsLoaded && AssemblyDefinition != null) { if (AssemblyDefinition != null) {
return String.Format("{0} ({1})", ShortName, AssemblyDefinition.Name.Version); return String.Format("{0} ({1})", ShortName, AssemblyDefinition.Name.Version);
} else { } else {
return ShortName; return ShortName;

32
ILSpy/TreeNodes/AssemblyTreeNode.cs

@ -22,6 +22,8 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using ICSharpCode.Decompiler; using ICSharpCode.Decompiler;
using ICSharpCode.ILSpy.TextView; using ICSharpCode.ILSpy.TextView;
using ICSharpCode.TreeView; using ICSharpCode.TreeView;
@ -78,6 +80,36 @@ namespace ICSharpCode.ILSpy.TreeNodes
} }
} }
TextBlock tooltip;
public override object ToolTip
{
get {
if (assembly.HasLoadError)
return "Assembly could not be loaded. Click here for details.";
if (tooltip == null) {
tooltip = new TextBlock();
tooltip.Inlines.Add(new Bold(new Run("Name: ")));
tooltip.Inlines.Add(new Run(assembly.AssemblyDefinition.FullName));
tooltip.Inlines.Add(new LineBreak());
tooltip.Inlines.Add(new Bold(new Run("Location: ")));
tooltip.Inlines.Add(new Run(assembly.FileName));
tooltip.Inlines.Add(new LineBreak());
tooltip.Inlines.Add(new Bold(new Run("Architecture: ")));
tooltip.Inlines.Add(new Run(CSharpLanguage.GetPlatformDisplayName(assembly.AssemblyDefinition.MainModule)));
string runtimeName = CSharpLanguage.GetRuntimeDisplayName(assembly.AssemblyDefinition.MainModule);
if (runtimeName != null) {
tooltip.Inlines.Add(new LineBreak());
tooltip.Inlines.Add(new Bold(new Run("Runtime: ")));
tooltip.Inlines.Add(new Run(runtimeName));
}
}
return tooltip;
}
}
public override bool ShowExpander public override bool ShowExpander
{ {
get { return !assembly.HasLoadError; } get { return !assembly.HasLoadError; }

Loading…
Cancel
Save