Browse Source

add tooltip with extra information to AssemblyTreeNode

pull/488/merge
Siegfried Pammer 10 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 @@ -257,6 +257,21 @@ namespace ICSharpCode.ILSpy
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)
{
@ -278,19 +293,9 @@ namespace ICSharpCode.ILSpy @@ -278,19 +293,9 @@ namespace ICSharpCode.ILSpy
if ((mainModule.Attributes & ModuleAttributes.ILOnly) == 0) {
output.WriteLine("// This assembly contains unmanaged code.");
}
switch (mainModule.Runtime) {
case TargetRuntime.Net_1_0:
output.WriteLine("// Runtime: .NET 1.0");
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;
string runtimeName = GetRuntimeDisplayName(mainModule);
if (runtimeName != null) {
output.WriteLine("// Runtime: " + runtimeName);
}
output.WriteLine();

2
ILSpy/LoadedAssembly.cs

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

32
ILSpy/TreeNodes/AssemblyTreeNode.cs

@ -22,6 +22,8 @@ using System.IO; @@ -22,6 +22,8 @@ using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using ICSharpCode.Decompiler;
using ICSharpCode.ILSpy.TextView;
using ICSharpCode.TreeView;
@ -78,6 +80,36 @@ namespace ICSharpCode.ILSpy.TreeNodes @@ -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
{
get { return !assembly.HasLoadError; }

Loading…
Cancel
Save