.NET Decompiler with support for PDB generation, ReadyToRun, Metadata (&more) - cross-platform!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

44 lines
1.4 KiB

using System;
using System.Windows;
using ICSharpCode.Decompiler.Metadata;
namespace ICSharpCode.ILSpy.TreeNodes
{
[ExportContextMenuEntry(Header = "Copy FQ Name", Icon = "images/Copy.png", Order = 9999)]
public class CopyFullyQualifiedNameContextMenuEntry : IContextMenuEntry
{
public bool IsVisible(TextViewContext context)
{
return GetMemberNodeFromContext(context) != null;
}
public bool IsEnabled(TextViewContext context) => true;
public void Execute(TextViewContext context)
{
var member = GetMemberNodeFromContext(context)?.Member;
if (member == null) return;
Clipboard.SetText(GetFullyQualifiedName(member));
}
private IMemberTreeNode GetMemberNodeFromContext(TextViewContext context)
{
return context.SelectedTreeNodes?.Length == 1 ? context.SelectedTreeNodes[0] as IMemberTreeNode : null;
}
/// <summary>
/// Resolve full type name using .NET type representation for nested types.
/// </summary>
private string GetFullyQualifiedName(IMetadataEntity member)
{
/*if (member.DeclaringType != null) {
if (member is TypeReference)
return GetFullyQualifiedName(member.DeclaringType) + "+" + member.Name;
else
return GetFullyQualifiedName(member.DeclaringType) + "." + member.Name;
}
return (member is TypeReference t ? t.Namespace + "." : "") + member.Name;*/
throw new NotImplementedException();
}
}
}