Browse Source

Reactivate SearchMsdnContextMenuEntry.

pull/1440/head
Siegfried Pammer 7 years ago
parent
commit
d420a302ec
  1. 38
      ILSpy/TreeNodes/SearchMsdnContextMenuEntry.cs

38
ILSpy/TreeNodes/SearchMsdnContextMenuEntry.cs

@ -17,11 +17,11 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.Linq; using System.Linq;
using System.Diagnostics; using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.ILSpy.TreeNodes namespace ICSharpCode.ILSpy.TreeNodes
{ {
/*[ExportContextMenuEntry(Header = "Search MSDN...", Icon = "images/SearchMsdn.png", Order = 9999)] [ExportContextMenuEntry(Header = "Search MSDN...", Icon = "images/SearchMsdn.png", Order = 9999)]
internal sealed class SearchMsdnContextMenuEntry : IContextMenuEntry internal sealed class SearchMsdnContextMenuEntry : IContextMenuEntry
{ {
private static string msdnAddress = "http://msdn.microsoft.com/en-us/library/{0}"; private static string msdnAddress = "http://msdn.microsoft.com/en-us/library/{0}";
@ -47,34 +47,42 @@ namespace ICSharpCode.ILSpy.TreeNodes
foreach (var node in context.SelectedTreeNodes) foreach (var node in context.SelectedTreeNodes)
{ {
var typeNode = node as TypeTreeNode; if (node is TypeTreeNode typeNode && !typeNode.IsPublicAPI)
if (typeNode != null && !typeNode.IsPublicAPI)
return false; return false;
var eventNode = node as EventTreeNode; if (node is EventTreeNode eventNode && (!eventNode.IsPublicAPI || !IsAccessible(eventNode.EventDefinition)))
if (eventNode != null && (!eventNode.IsPublicAPI || !eventNode.EventDefinition.DeclaringType.IsPublic))
return false; return false;
var fieldNode = node as FieldTreeNode; if (node is FieldTreeNode fieldNode && (!fieldNode.IsPublicAPI || !IsAccessible(fieldNode.FieldDefinition)))
if (fieldNode != null && (!fieldNode.IsPublicAPI || !fieldNode.FieldDefinition.DeclaringType.IsPublic))
return false; return false;
var propertyNode = node as PropertyTreeNode; if (node is PropertyTreeNode propertyNode && (!propertyNode.IsPublicAPI || !IsAccessible(propertyNode.PropertyDefinition)))
if (propertyNode != null && (!propertyNode.IsPublicAPI || !propertyNode.PropertyDefinition.DeclaringType.IsPublic))
return false; return false;
var methodNode = node as MethodTreeNode; if (node is MethodTreeNode methodNode && (!methodNode.IsPublicAPI || !IsAccessible(methodNode.MethodDefinition)))
if (methodNode != null && (!methodNode.IsPublicAPI || !methodNode.MethodDefinition.DeclaringType.IsPublic))
return false; return false;
var namespaceNode = node as NamespaceTreeNode; if (node is NamespaceTreeNode namespaceNode && string.IsNullOrEmpty(namespaceNode.Name))
if (namespaceNode != null && string.IsNullOrEmpty(namespaceNode.Name))
return false; return false;
} }
return true; return true;
} }
bool IsAccessible(IEntity entity)
{
if (entity.DeclaringTypeDefinition == null)
return false;
switch (entity.DeclaringTypeDefinition.Accessibility) {
case Accessibility.Public:
case Accessibility.Protected:
case Accessibility.ProtectedOrInternal:
return true;
default:
return false;
}
}
public void Execute(TextViewContext context) public void Execute(TextViewContext context)
{ {
if (context.SelectedTreeNodes != null) { if (context.SelectedTreeNodes != null) {
@ -108,5 +116,5 @@ namespace ICSharpCode.ILSpy.TreeNodes
if (!string.IsNullOrEmpty(address)) if (!string.IsNullOrEmpty(address))
MainWindow.OpenLink(address); MainWindow.OpenLink(address);
} }
}*/ }
} }
Loading…
Cancel
Save