mirror of https://github.com/icsharpcode/ILSpy.git
28 changed files with 817 additions and 97 deletions
@ -0,0 +1,40 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy |
||||||
|
{ |
||||||
|
sealed class CommandLineArguments |
||||||
|
{ |
||||||
|
// see /doc/Command Line.txt for details
|
||||||
|
public List<string> AssembliesToLoad = new List<string>(); |
||||||
|
public bool? SingleInstance; |
||||||
|
public string NavigateTo; |
||||||
|
public string Language; |
||||||
|
public bool NoActivate; |
||||||
|
|
||||||
|
public CommandLineArguments(IEnumerable<string> arguments) |
||||||
|
{ |
||||||
|
foreach (string arg in arguments) { |
||||||
|
if (arg.Length == 0) |
||||||
|
continue; |
||||||
|
if (arg[0] == '/') { |
||||||
|
if (arg.Equals("/singleInstance", StringComparison.OrdinalIgnoreCase)) |
||||||
|
this.SingleInstance = true; |
||||||
|
else if (arg.Equals("/separate", StringComparison.OrdinalIgnoreCase)) |
||||||
|
this.SingleInstance = false; |
||||||
|
else if (arg.StartsWith("/navigateTo:", StringComparison.OrdinalIgnoreCase)) |
||||||
|
this.NavigateTo = arg.Substring("/navigateTo:".Length); |
||||||
|
else if (arg.StartsWith("/language:", StringComparison.OrdinalIgnoreCase)) |
||||||
|
this.Language = arg.Substring("/language:".Length); |
||||||
|
else if (arg.Equals("/noActivate", StringComparison.OrdinalIgnoreCase)) |
||||||
|
this.NoActivate = true; |
||||||
|
} else { |
||||||
|
this.AssembliesToLoad.Add(arg); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,122 @@ |
|||||||
|
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||||
|
// software and associated documentation files (the "Software"), to deal in the Software
|
||||||
|
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||||
|
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||||
|
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all copies or
|
||||||
|
// substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.ComponentModel.Composition; |
||||||
|
using System.Linq; |
||||||
|
using System.Windows.Controls; |
||||||
|
|
||||||
|
using ICSharpCode.TreeView; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy |
||||||
|
{ |
||||||
|
public interface IContextMenuEntry |
||||||
|
{ |
||||||
|
bool IsVisible(SharpTreeNode[] selectedNodes); |
||||||
|
bool IsEnabled(SharpTreeNode[] selectedNodes); |
||||||
|
void Execute(SharpTreeNode[] selectedNodes); |
||||||
|
} |
||||||
|
|
||||||
|
public interface IContextMenuEntryMetadata |
||||||
|
{ |
||||||
|
string Icon { get; } |
||||||
|
string Header { get; } |
||||||
|
string Category { get; } |
||||||
|
|
||||||
|
double Order { get; } |
||||||
|
} |
||||||
|
|
||||||
|
[MetadataAttribute] |
||||||
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple=false)] |
||||||
|
public class ExportContextMenuEntryAttribute : ExportAttribute, IContextMenuEntryMetadata |
||||||
|
{ |
||||||
|
public ExportContextMenuEntryAttribute() |
||||||
|
: base(typeof(IContextMenuEntry)) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public string Icon { get; set; } |
||||||
|
public string Header { get; set; } |
||||||
|
public string Category { get; set; } |
||||||
|
public double Order { get; set; } |
||||||
|
} |
||||||
|
|
||||||
|
internal class ContextMenuProvider |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Enables extensible context menu support for the specified tree view.
|
||||||
|
/// </summary>
|
||||||
|
public static void Add(SharpTreeView treeView) |
||||||
|
{ |
||||||
|
var provider = new ContextMenuProvider(treeView); |
||||||
|
treeView.ContextMenuOpening += provider.treeView_ContextMenuOpening; |
||||||
|
treeView.ContextMenuClosing -= provider.treeView_ContextMenuClosing; |
||||||
|
} |
||||||
|
|
||||||
|
readonly SharpTreeView treeView; |
||||||
|
|
||||||
|
[ImportMany(typeof(IContextMenuEntry))] |
||||||
|
Lazy<IContextMenuEntry, IContextMenuEntryMetadata>[] entries = null; |
||||||
|
|
||||||
|
private ContextMenuProvider(SharpTreeView treeView) |
||||||
|
{ |
||||||
|
this.treeView = treeView; |
||||||
|
App.CompositionContainer.ComposeParts(this); |
||||||
|
} |
||||||
|
|
||||||
|
void treeView_ContextMenuOpening(object sender, ContextMenuEventArgs e) |
||||||
|
{ |
||||||
|
SharpTreeNode[] selectedNodes = treeView.GetTopLevelSelection().ToArray(); |
||||||
|
if (selectedNodes.Length == 0) |
||||||
|
return; |
||||||
|
ContextMenu menu = new ContextMenu(); |
||||||
|
foreach (var category in entries.OrderBy(c => c.Metadata.Order).GroupBy(c => c.Metadata.Category)) { |
||||||
|
if (menu.Items.Count > 0) { |
||||||
|
menu.Items.Add(new Separator()); |
||||||
|
} |
||||||
|
foreach (var entryPair in category) { |
||||||
|
IContextMenuEntry entry = entryPair.Value; |
||||||
|
if (entry.IsVisible(selectedNodes)) { |
||||||
|
MenuItem menuItem = new MenuItem(); |
||||||
|
menuItem.Header = entryPair.Metadata.Header; |
||||||
|
if (!string.IsNullOrEmpty(entryPair.Metadata.Icon)) { |
||||||
|
menuItem.Icon = new Image { |
||||||
|
Width = 16, |
||||||
|
Height = 16, |
||||||
|
Source = Images.LoadImage(entry, entryPair.Metadata.Icon) |
||||||
|
}; |
||||||
|
} |
||||||
|
if (entryPair.Value.IsEnabled(selectedNodes)) { |
||||||
|
menuItem.Click += delegate { |
||||||
|
entry.Execute(selectedNodes); |
||||||
|
}; |
||||||
|
} |
||||||
|
menu.Items.Add(menuItem); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (menu.Items.Count > 0) |
||||||
|
treeView.ContextMenu = menu; |
||||||
|
} |
||||||
|
|
||||||
|
void treeView_ContextMenuClosing(object sender, ContextMenuEventArgs e) |
||||||
|
{ |
||||||
|
treeView.ContextMenu = null; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,72 @@ |
|||||||
|
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||||
|
// software and associated documentation files (the "Software"), to deal in the Software
|
||||||
|
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||||
|
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||||
|
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all copies or
|
||||||
|
// substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Text; |
||||||
|
using System.Runtime.InteropServices; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy |
||||||
|
{ |
||||||
|
static class NativeMethods |
||||||
|
{ |
||||||
|
public const uint WM_COPYDATA = 0x4a; |
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto)] |
||||||
|
[return: MarshalAs(UnmanagedType.Bool)] |
||||||
|
internal static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, IntPtr lParam); |
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto)] |
||||||
|
static extern int GetWindowText(IntPtr hWnd, [Out] StringBuilder title, int size); |
||||||
|
|
||||||
|
public static string GetWindowText(IntPtr hWnd, int maxLength) |
||||||
|
{ |
||||||
|
StringBuilder b = new StringBuilder(maxLength + 1); |
||||||
|
if (GetWindowText(hWnd, b, b.Capacity) != 0) |
||||||
|
return b.ToString(); |
||||||
|
else |
||||||
|
return string.Empty; |
||||||
|
} |
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto)] |
||||||
|
internal static extern IntPtr SendMessageTimeout( |
||||||
|
IntPtr hWnd, uint msg, IntPtr wParam, ref CopyDataStruct lParam, |
||||||
|
uint flags, uint timeout, out IntPtr result); |
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto)] |
||||||
|
[return: MarshalAs(UnmanagedType.Bool)] |
||||||
|
internal static extern bool SetForegroundWindow(IntPtr hWnd); |
||||||
|
} |
||||||
|
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)] |
||||||
|
delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam); |
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)] |
||||||
|
struct CopyDataStruct |
||||||
|
{ |
||||||
|
public IntPtr Padding; |
||||||
|
public int Size; |
||||||
|
public IntPtr Buffer; |
||||||
|
|
||||||
|
public CopyDataStruct(IntPtr padding, int size, IntPtr buffer) |
||||||
|
{ |
||||||
|
this.Padding = padding; |
||||||
|
this.Size = size; |
||||||
|
this.Buffer = buffer; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,57 @@ |
|||||||
|
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||||
|
// software and associated documentation files (the "Software"), to deal in the Software
|
||||||
|
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||||
|
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||||
|
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all copies or
|
||||||
|
// substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Linq; |
||||||
|
using ICSharpCode.TreeView; |
||||||
|
using Mono.Cecil; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy.TreeNodes.Analyzer |
||||||
|
{ |
||||||
|
[ExportContextMenuEntry(Header = "Analyze", Icon = "images/Search.png")] |
||||||
|
sealed class AnalyzeContextMenuEntry : IContextMenuEntry |
||||||
|
{ |
||||||
|
public bool IsVisible(SharpTreeNode[] selectedNodes) |
||||||
|
{ |
||||||
|
return selectedNodes.All(n => n is IMemberTreeNode); |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsEnabled(SharpTreeNode[] selectedNodes) |
||||||
|
{ |
||||||
|
foreach (IMemberTreeNode node in selectedNodes) { |
||||||
|
if (!(node.Member is FieldDefinition || node.Member is MethodDefinition)) |
||||||
|
return false; |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
public void Execute(SharpTreeNode[] selectedNodes) |
||||||
|
{ |
||||||
|
// TODO: figure out when equivalent nodes are already present
|
||||||
|
// and focus those instead.
|
||||||
|
foreach (IMemberTreeNode node in selectedNodes) { |
||||||
|
FieldDefinition field = node.Member as FieldDefinition; |
||||||
|
if (field != null) |
||||||
|
MainWindow.Instance.AddToAnalyzer(new AnalyzedFieldNode(field)); |
||||||
|
MethodDefinition method = node.Member as MethodDefinition; |
||||||
|
if (method != null) |
||||||
|
MainWindow.Instance.AddToAnalyzer(new AnalyzedMethodTreeNode(method)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||||
|
// software and associated documentation files (the "Software"), to deal in the Software
|
||||||
|
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||||
|
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||||
|
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in all copies or
|
||||||
|
// substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||||
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
using System; |
||||||
|
using Mono.Cecil; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy.TreeNodes |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Interface implemented by all tree nodes
|
||||||
|
/// (both in main tree view and in analyzer)
|
||||||
|
/// that represent Cecil members.
|
||||||
|
/// </summary>
|
||||||
|
public interface IMemberTreeNode |
||||||
|
{ |
||||||
|
MemberReference Member { get; } |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,168 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Text; |
||||||
|
using Mono.Cecil; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Provides XML documentation tags.
|
||||||
|
/// </summary>
|
||||||
|
sealed class XmlDocKeyProvider |
||||||
|
{ |
||||||
|
#region GetKey
|
||||||
|
public static string GetKey(MemberReference member) |
||||||
|
{ |
||||||
|
StringBuilder b = new StringBuilder(); |
||||||
|
if (member is TypeReference) { |
||||||
|
b.Append("T:"); |
||||||
|
AppendTypeName(b, (TypeDefinition)member); |
||||||
|
} else { |
||||||
|
if (member is FieldReference) |
||||||
|
b.Append("F:"); |
||||||
|
else if (member is PropertyDefinition) |
||||||
|
b.Append("P:"); |
||||||
|
else if (member is EventDefinition) |
||||||
|
b.Append("E:"); |
||||||
|
else if (member is MethodReference) |
||||||
|
b.Append("M:"); |
||||||
|
AppendTypeName(b, member.DeclaringType); |
||||||
|
b.Append('.'); |
||||||
|
b.Append(member.Name); |
||||||
|
IList<ParameterDefinition> parameters; |
||||||
|
if (member is PropertyDefinition) { |
||||||
|
parameters = ((PropertyDefinition)member).Parameters; |
||||||
|
} else if (member is MethodReference) { |
||||||
|
parameters = ((MethodReference)member).Parameters; |
||||||
|
} else { |
||||||
|
parameters = null; |
||||||
|
} |
||||||
|
if (parameters != null && parameters.Count > 0) { |
||||||
|
b.Append('('); |
||||||
|
for (int i = 0; i < parameters.Count; i++) { |
||||||
|
if (i > 0) b.Append(','); |
||||||
|
AppendTypeName(b, parameters[i].ParameterType); |
||||||
|
} |
||||||
|
b.Append(')'); |
||||||
|
} |
||||||
|
} |
||||||
|
return b.ToString(); |
||||||
|
} |
||||||
|
|
||||||
|
static void AppendTypeName(StringBuilder b, TypeReference type) |
||||||
|
{ |
||||||
|
if (type is TypeSpecification) { |
||||||
|
AppendTypeName(b, ((TypeSpecification)type).ElementType); |
||||||
|
ArrayType arrayType = type as ArrayType; |
||||||
|
if (arrayType != null) { |
||||||
|
b.Append('['); |
||||||
|
for (int i = 1; i < arrayType.Dimensions.Count; i++) { |
||||||
|
b.Append(','); |
||||||
|
} |
||||||
|
b.Append(']'); |
||||||
|
} |
||||||
|
ByReferenceType refType = type as ByReferenceType; |
||||||
|
if (refType != null) { |
||||||
|
b.Append('@'); |
||||||
|
} |
||||||
|
GenericInstanceType giType = type as GenericInstanceType; |
||||||
|
if (giType != null) { |
||||||
|
b.Append('{'); |
||||||
|
for (int i = 0; i < giType.GenericArguments.Count; i++) { |
||||||
|
if (i > 0) b.Append(','); |
||||||
|
AppendTypeName(b, giType.GenericArguments[i]); |
||||||
|
} |
||||||
|
b.Append('}'); |
||||||
|
} |
||||||
|
PointerType ptrType = type as PointerType; |
||||||
|
if (ptrType != null) { |
||||||
|
b.Append('*'); // TODO: is this correct?
|
||||||
|
} |
||||||
|
} else { |
||||||
|
GenericParameter gp = type as GenericParameter; |
||||||
|
if (gp != null) { |
||||||
|
b.Append('`'); |
||||||
|
if (gp.Owner.GenericParameterType == GenericParameterType.Method) { |
||||||
|
b.Append('`'); |
||||||
|
} |
||||||
|
b.Append(gp.Position); |
||||||
|
} else if (type.DeclaringType != null) { |
||||||
|
AppendTypeName(b, type.DeclaringType); |
||||||
|
b.Append('.'); |
||||||
|
b.Append(type.Name); |
||||||
|
} else { |
||||||
|
b.Append(type.FullName); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region FindMemberByKey
|
||||||
|
public static MemberReference FindMemberByKey(ModuleDefinition module, string key) |
||||||
|
{ |
||||||
|
if (module == null) |
||||||
|
throw new ArgumentNullException("module"); |
||||||
|
if (key == null || key.Length < 2 || key[1] != ':') |
||||||
|
return null; |
||||||
|
switch (key[0]) { |
||||||
|
case 'T': |
||||||
|
return FindType(module, key.Substring(2)); |
||||||
|
case 'F': |
||||||
|
return FindMember(module, key, type => type.Fields); |
||||||
|
case 'P': |
||||||
|
return FindMember(module, key, type => type.Properties); |
||||||
|
case 'E': |
||||||
|
return FindMember(module, key, type => type.Events); |
||||||
|
case 'M': |
||||||
|
return FindMember(module, key, type => type.Methods); |
||||||
|
default: |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static MemberReference FindMember(ModuleDefinition module, string key, Func<TypeDefinition, IEnumerable<MemberReference>> memberSelector) |
||||||
|
{ |
||||||
|
int pos = key.IndexOf('('); |
||||||
|
int dotPos; |
||||||
|
if (pos > 0) { |
||||||
|
dotPos = key.LastIndexOf('.', 0, pos); |
||||||
|
} else { |
||||||
|
dotPos = key.LastIndexOf('.'); |
||||||
|
} |
||||||
|
TypeDefinition type = FindType(module, key.Substring(2, dotPos - 2)); |
||||||
|
if (type == null) |
||||||
|
return null; |
||||||
|
foreach (MemberReference member in memberSelector(type)) { |
||||||
|
if (GetKey(member) == key) |
||||||
|
return member; |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
static TypeDefinition FindType(ModuleDefinition module, string name) |
||||||
|
{ |
||||||
|
int pos = name.LastIndexOf('.'); |
||||||
|
string ns; |
||||||
|
if (pos >= 0) { |
||||||
|
ns = name.Substring(0, pos); |
||||||
|
name = name.Substring(pos + 1); |
||||||
|
} else { |
||||||
|
ns = string.Empty; |
||||||
|
} |
||||||
|
TypeDefinition type = module.GetType(ns, name); |
||||||
|
if (type == null && ns.Length > 0) { |
||||||
|
// try if this is a nested type
|
||||||
|
type = FindType(module, ns); |
||||||
|
if (type != null) { |
||||||
|
type = type.NestedTypes.FirstOrDefault(t => t.Name == name); |
||||||
|
} |
||||||
|
} |
||||||
|
return type; |
||||||
|
} |
||||||
|
#endregion
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,52 @@ |
|||||||
|
ILSpy Command Line Arguments |
||||||
|
|
||||||
|
Command line arguments can be either options or file names. |
||||||
|
If an argument is a file name, the file will be opened as assembly and added to the current assembly list. |
||||||
|
|
||||||
|
Available options: |
||||||
|
/singleInstance If ILSpy is already running, activates the existing instance |
||||||
|
and passes command line arguments to that instance. |
||||||
|
This is the default value if /list is not used. |
||||||
|
|
||||||
|
/separate Start up a separate ILSpy instance even if it is already running. |
||||||
|
|
||||||
|
/noActivate Do not activate the existing ILSpy instance. This option has no effec |
||||||
|
if a new ILSpy instance is being started. |
||||||
|
|
||||||
|
/list:listname Specifies the name of the assembly list that is loaded initially. |
||||||
|
When this option is not specified, ILSpy loads the previously opened list. |
||||||
|
Specify "/list" (without value) to open the default list. |
||||||
|
|
||||||
|
When this option is used, ILSpy will activate an existing instance |
||||||
|
only if it uses the same list as specified. |
||||||
|
|
||||||
|
[Note: Assembly Lists are not yet implemented] |
||||||
|
|
||||||
|
/clearList Clears the assembly list before loading the specified assemblies. |
||||||
|
[Note: Assembly Lists are not yet implemented] |
||||||
|
|
||||||
|
/navigateTo:tag Navigates to the member specified by the given XML documentation tag. |
||||||
|
The member is searched for only in the assemblies specified on the command line. |
||||||
|
Example: 'ILSpy ILSpy.exe /navigateTo:T:ICSharpCode.ILSpy.CommandLineArguments' |
||||||
|
|
||||||
|
/language:name Selects the specified language. |
||||||
|
Example: 'ILSpy /language:C#' or 'ILSpy /language:IL' |
||||||
|
|
||||||
|
WM_COPYDATA (SendMessage API): |
||||||
|
ILSpy can be controlled by other programs that send a WM_COPYDATA message to its main window. |
||||||
|
The message data must be an Unicode (UTF-16) string starting with "ILSpy:\r\n". |
||||||
|
All lines except the first ("ILSpy:") in that string are handled as command-line arguments. |
||||||
|
There must be exactly one argument per line. |
||||||
|
|
||||||
|
That is, by sending this message: |
||||||
|
ILSpy: |
||||||
|
C:\Assembly.dll |
||||||
|
/navigateTo T:Type |
||||||
|
The target ILSpy instance will open C:\Assembly.dll and navigate to the specified type. |
||||||
|
|
||||||
|
ILSpy will return TRUE (1) if it handles the message, and FALSE (0) otherwise. |
||||||
|
The /separate option will be ignored; WM_COPYDATA will never start up a new instance. |
||||||
|
The /noActivate option has no effect, sending WM_COPYDATA will never activate the window. |
||||||
|
Instead, the calling process should use SetForegroundWindow(). |
||||||
|
If you use /list with WM_COPYDATA, you need to specify /singleInstance as well, otherwise |
||||||
|
ILSpy will not handle the message if it has opened a different assembly list. |
Loading…
Reference in new issue