16 changed files with 1090 additions and 291 deletions
After Width: | Height: | Size: 689 B |
@ -0,0 +1,33 @@ |
|||||||
|
<AddIn name = "ILSpyAddIn" |
||||||
|
author = "Daniel Grunwald" |
||||||
|
copyright = "prj:///doc/copyright.txt" |
||||||
|
description = "Can open ILSpy on a selected class or member." |
||||||
|
addInManagerHidden = "preinstalled"> |
||||||
|
|
||||||
|
<Manifest> |
||||||
|
<Identity name="ICSharpCode.ILSpyAddIn" /> |
||||||
|
</Manifest> |
||||||
|
|
||||||
|
<Runtime> |
||||||
|
<Import assembly = "ILSpyAddIn.dll"/> |
||||||
|
</Runtime> |
||||||
|
|
||||||
|
<!-- Text editor context menu --> |
||||||
|
|
||||||
|
<Path name = "/SharpDevelop/ViewContent/DefaultTextEditor/ClassMemberContextMenu"> |
||||||
|
<MenuItem id="ILSpy" icon="ILSpy" type="Item" label="${res:ILSpyAddIn.OpenILSpyCommand}" class="ICSharpCode.ILSpyAddIn.TextEditorContextMenuCommand"/> |
||||||
|
</Path> |
||||||
|
|
||||||
|
<Path name = "/SharpDevelop/ViewContent/DefaultTextEditor/ClassBookmarkContextMenu"> |
||||||
|
<MenuItem id="ILSpy" icon="ILSpy" type="Item" label="${res:ILSpyAddIn.OpenILSpyCommand}" class="ICSharpCode.ILSpyAddIn.TextEditorContextMenuCommand"/> |
||||||
|
</Path> |
||||||
|
|
||||||
|
<Path name = "/SharpDevelop/Pads/ClassBrowser/MemberContextMenu"> |
||||||
|
<MenuItem id="ILSpy" icon="ILSpy" type="Item" label="${res:ILSpyAddIn.OpenILSpyCommand}" class="ICSharpCode.ILSpyAddIn.TextEditorContextMenuCommand"/> |
||||||
|
</Path> |
||||||
|
|
||||||
|
<Path name = "/SharpDevelop/Pads/ClassBrowser/ClassContextMenu"> |
||||||
|
<MenuItem id="ILSpy" icon="ILSpy" type="Item" label="${res:ILSpyAddIn.OpenILSpyCommand}" class="ICSharpCode.ILSpyAddIn.TextEditorContextMenuCommand"/> |
||||||
|
</Path> |
||||||
|
|
||||||
|
</AddIn> |
@ -0,0 +1,85 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||||
|
<PropertyGroup> |
||||||
|
<ProjectGuid>{8AA421C8-D7AF-4957-9F43-5135328ACB24}</ProjectGuid> |
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||||
|
<OutputType>Library</OutputType> |
||||||
|
<RootNamespace>ICSharpCode.ILSpyAddIn</RootNamespace> |
||||||
|
<AssemblyName>ILSpyAddIn</AssemblyName> |
||||||
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder> |
||||||
|
<OutputPath>..\..\..\..\AddIns\Misc\ILSpyAddIn\</OutputPath> |
||||||
|
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||||
|
<NoStdLib>False</NoStdLib> |
||||||
|
<WarningLevel>4</WarningLevel> |
||||||
|
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||||
|
<TargetFrameworkProfile> |
||||||
|
</TargetFrameworkProfile> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||||
|
<DebugSymbols>true</DebugSymbols> |
||||||
|
<DebugType>Full</DebugType> |
||||||
|
<Optimize>False</Optimize> |
||||||
|
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||||
|
<DebugSymbols>False</DebugSymbols> |
||||||
|
<DebugType>None</DebugType> |
||||||
|
<Optimize>True</Optimize> |
||||||
|
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||||
|
<DefineConstants>TRACE</DefineConstants> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> |
||||||
|
<RegisterForComInterop>False</RegisterForComInterop> |
||||||
|
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||||
|
<BaseAddress>4194304</BaseAddress> |
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget> |
||||||
|
<FileAlignment>4096</FileAlignment> |
||||||
|
</PropertyGroup> |
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||||
|
<ItemGroup> |
||||||
|
<Reference Include="System" /> |
||||||
|
<Reference Include="System.Core"> |
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||||
|
</Reference> |
||||||
|
<Reference Include="System.Drawing" /> |
||||||
|
<Reference Include="System.Windows.Forms" /> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<Compile Include="..\..\..\Main\GlobalAssemblyInfo.cs"> |
||||||
|
<Link>Properties\GlobalAssemblyInfo.cs</Link> |
||||||
|
</Compile> |
||||||
|
<Compile Include="ILSpyController.cs" /> |
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" /> |
||||||
|
<Compile Include="SetILSpyPathDialog.cs" /> |
||||||
|
<Compile Include="SetILSpyPathDialog.Designer.cs"> |
||||||
|
<DependentUpon>SetILSpyPathDialog.cs</DependentUpon> |
||||||
|
</Compile> |
||||||
|
<Compile Include="TextEditorContextMenuCommand.cs" /> |
||||||
|
<None Include="ILSpyAddIn.addin"> |
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||||
|
</None> |
||||||
|
<EmbeddedResource Include="SetILSpyPathDialog.resx"> |
||||||
|
<DependentUpon>SetILSpyPathDialog.cs</DependentUpon> |
||||||
|
</EmbeddedResource> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<ProjectReference Include="..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
||||||
|
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
||||||
|
<Name>ICSharpCode.SharpDevelop</Name> |
||||||
|
<Private>False</Private> |
||||||
|
</ProjectReference> |
||||||
|
<ProjectReference Include="..\..\..\Main\Core\Project\ICSharpCode.Core.csproj"> |
||||||
|
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project> |
||||||
|
<Name>ICSharpCode.Core</Name> |
||||||
|
<Private>False</Private> |
||||||
|
</ProjectReference> |
||||||
|
<ProjectReference Include="..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj"> |
||||||
|
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project> |
||||||
|
<Name>ICSharpCode.SharpDevelop.Dom</Name> |
||||||
|
<Private>False</Private> |
||||||
|
</ProjectReference> |
||||||
|
</ItemGroup> |
||||||
|
</Project> |
@ -0,0 +1,168 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Diagnostics; |
||||||
|
using System.IO; |
||||||
|
using System.Text; |
||||||
|
using System.Windows.Forms; |
||||||
|
using ICSharpCode.Core; |
||||||
|
using ICSharpCode.SharpDevelop.Dom; |
||||||
|
using ICSharpCode.SharpDevelop.Gui; |
||||||
|
using ICSharpCode.SharpDevelop.Project; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpyAddIn |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Controls .NET ILSpy.
|
||||||
|
/// </summary>
|
||||||
|
public static class ILSpyController |
||||||
|
{ |
||||||
|
public static void TryGoTo(AbstractEntity entity) |
||||||
|
{ |
||||||
|
if (entity == null) |
||||||
|
throw new ArgumentNullException("entity"); |
||||||
|
|
||||||
|
while ((entity is IMember) && ((IMember)entity).GenericMember is AbstractEntity) |
||||||
|
entity = (AbstractEntity)((IMember)entity).GenericMember; |
||||||
|
|
||||||
|
// Try to find the assembly which contains the resolved type
|
||||||
|
IProjectContent pc = entity.ProjectContent; |
||||||
|
ReflectionProjectContent rpc = pc as ReflectionProjectContent; |
||||||
|
string assemblyLocation = null; |
||||||
|
if (rpc != null) { |
||||||
|
// prefer GAC assemblies over reference assemblies:
|
||||||
|
assemblyLocation = FindAssemblyInNetGac(new DomAssemblyName(rpc.AssemblyFullName)); |
||||||
|
if (string.IsNullOrEmpty(assemblyLocation)) { |
||||||
|
// use file only if assembly isn't in GAC:
|
||||||
|
assemblyLocation = rpc.AssemblyLocation; |
||||||
|
} |
||||||
|
} else { |
||||||
|
IProject project = pc.Project as IProject; |
||||||
|
if (project != null) { |
||||||
|
assemblyLocation = project.OutputAssemblyFullPath; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(assemblyLocation)) { |
||||||
|
MessageService.ShowWarning("ILSpy AddIn: Could not determine the assembly location for " + entity.FullyQualifiedName + "."); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
string ilspyPath = GetILSpyExeFullPathInteractive(); |
||||||
|
if (string.IsNullOrEmpty(ilspyPath)) |
||||||
|
return; |
||||||
|
|
||||||
|
string commandLine = "/singleInstance \"" + assemblyLocation + "\" \"/navigateTo:" + entity.DocumentationTag + "\""; |
||||||
|
LoggingService.Debug(ilspyPath + " " + commandLine); |
||||||
|
Process.Start(ilspyPath, commandLine); |
||||||
|
} |
||||||
|
|
||||||
|
#region Find ILSpy
|
||||||
|
internal const string ILSpyExePathPropertyName = "ILSpyAddIn.ILSpyExePath"; |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the full path of ILSpy.exe, asking the user for it if it
|
||||||
|
/// has not been set.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="owner">The owner for the path selection dialog, if it is needed.</param>
|
||||||
|
/// <returns>The full path of ILSpy.exe, or <c>null</c> if the path was unknown and the user cancelled the path selection dialog.</returns>
|
||||||
|
internal static string GetILSpyExeFullPathInteractive() |
||||||
|
{ |
||||||
|
string path = PropertyService.Get(ILSpyExePathPropertyName); |
||||||
|
string askReason = null; |
||||||
|
|
||||||
|
if (String.IsNullOrEmpty(path)) { |
||||||
|
askReason = ResourceService.GetString("ILSpyAddIn.ILSpyPathNotSet"); |
||||||
|
} else if (!File.Exists(path)) { |
||||||
|
askReason = ResourceService.GetString("ILSpyAddIn.ILSpyDoesNotExist"); |
||||||
|
} |
||||||
|
|
||||||
|
if (askReason != null) { |
||||||
|
using(SetILSpyPathDialog dialog = new SetILSpyPathDialog(path, askReason)) { |
||||||
|
|
||||||
|
if (dialog.ShowDialog(WorkbenchSingleton.MainWin32Window) != DialogResult.OK || !File.Exists(dialog.SelectedFile)) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
path = dialog.SelectedFile; |
||||||
|
PropertyService.Set(ILSpyExePathPropertyName, path); |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return path; |
||||||
|
} |
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region FindAssemblyInGac
|
||||||
|
// This region is based on code from Mono.Cecil:
|
||||||
|
|
||||||
|
// Author:
|
||||||
|
// Jb Evain (jbevain@gmail.com)
|
||||||
|
//
|
||||||
|
// Copyright (c) 2008 - 2010 Jb Evain
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
|
||||||
|
static readonly string[] gac_paths = { GacInterop.GacRootPathV2, GacInterop.GacRootPathV4 }; |
||||||
|
static readonly string[] gacs = { "GAC_MSIL", "GAC_32", "GAC" }; |
||||||
|
static readonly string[] prefixes = { string.Empty, "v4.0_" }; |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the file name for an assembly stored in the GAC.
|
||||||
|
/// </summary>
|
||||||
|
public static string FindAssemblyInNetGac (DomAssemblyName reference) |
||||||
|
{ |
||||||
|
// without public key, it can't be in the GAC
|
||||||
|
if (reference.PublicKeyToken == null) |
||||||
|
return null; |
||||||
|
|
||||||
|
for (int i = 0; i < 2; i++) { |
||||||
|
for (int j = 0; j < gacs.Length; j++) { |
||||||
|
var gac = Path.Combine (gac_paths [i], gacs [j]); |
||||||
|
var file = GetAssemblyFile (reference, prefixes [i], gac); |
||||||
|
if (File.Exists (file)) |
||||||
|
return file; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
static string GetAssemblyFile (DomAssemblyName reference, string prefix, string gac) |
||||||
|
{ |
||||||
|
var gac_folder = new StringBuilder () |
||||||
|
.Append (prefix) |
||||||
|
.Append (reference.Version) |
||||||
|
.Append ("__"); |
||||||
|
|
||||||
|
gac_folder.Append (reference.PublicKeyToken); |
||||||
|
|
||||||
|
return Path.Combine ( |
||||||
|
Path.Combine ( |
||||||
|
Path.Combine (gac, reference.ShortName), gac_folder.ToString ()), |
||||||
|
reference.ShortName + ".dll"); |
||||||
|
} |
||||||
|
#endregion
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System.Reflection; |
||||||
|
|
||||||
|
// Information about this assembly is defined by the following
|
||||||
|
// attributes.
|
||||||
|
//
|
||||||
|
// change them to the information which is associated with the assembly
|
||||||
|
// you compile.
|
||||||
|
|
||||||
|
[assembly: AssemblyTitle("Reflector AddIn")] |
||||||
|
[assembly: AssemblyDescription("Reflector AddIn for SharpDevelop")] |
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
[assembly: AssemblyConfiguration("Debug")] |
||||||
|
#else
|
||||||
|
[assembly: AssemblyConfiguration("Release")] |
||||||
|
#endif
|
||||||
|
|
||||||
|
[assembly: AssemblyTrademark("")] |
||||||
|
[assembly: AssemblyCulture("")] |
||||||
|
|
||||||
|
[assembly: System.CLSCompliant(true)] |
@ -0,0 +1,166 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpyAddIn |
||||||
|
{ |
||||||
|
partial class SetILSpyPathDialog |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Designer variable used to keep track of non-visual components.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null; |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disposes resources used by the form.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing) |
||||||
|
{ |
||||||
|
if (disposing) { |
||||||
|
if (components != null) { |
||||||
|
components.Dispose(); |
||||||
|
} |
||||||
|
} |
||||||
|
base.Dispose(disposing); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This method is required for Windows Forms designer support.
|
||||||
|
/// Do not change the method contents inside the source code editor. The Forms designer might
|
||||||
|
/// not be able to load this method if it was changed manually.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent() |
||||||
|
{ |
||||||
|
System.Windows.Forms.Button pshOK; |
||||||
|
System.Windows.Forms.Button pshCancel; |
||||||
|
System.Windows.Forms.Label txtILSpyExplanation; |
||||||
|
System.Windows.Forms.GroupBox grpPath; |
||||||
|
System.Windows.Forms.Button pshBrowse; |
||||||
|
this.slePath = new System.Windows.Forms.TextBox(); |
||||||
|
this.linkILSpy = new System.Windows.Forms.LinkLabel(); |
||||||
|
this.txtReason = new System.Windows.Forms.Label(); |
||||||
|
pshOK = new System.Windows.Forms.Button(); |
||||||
|
pshCancel = new System.Windows.Forms.Button(); |
||||||
|
txtILSpyExplanation = new System.Windows.Forms.Label(); |
||||||
|
grpPath = new System.Windows.Forms.GroupBox(); |
||||||
|
pshBrowse = new System.Windows.Forms.Button(); |
||||||
|
grpPath.SuspendLayout(); |
||||||
|
this.SuspendLayout(); |
||||||
|
//
|
||||||
|
// pshOK
|
||||||
|
//
|
||||||
|
pshOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); |
||||||
|
pshOK.DialogResult = System.Windows.Forms.DialogResult.OK; |
||||||
|
pshOK.Location = new System.Drawing.Point(272, 187); |
||||||
|
pshOK.Name = "pshOK"; |
||||||
|
pshOK.Size = new System.Drawing.Size(75, 23); |
||||||
|
pshOK.TabIndex = 0; |
||||||
|
pshOK.Text = "${res:Global.OKButtonText}"; |
||||||
|
pshOK.UseVisualStyleBackColor = true; |
||||||
|
//
|
||||||
|
// pshCancel
|
||||||
|
//
|
||||||
|
pshCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); |
||||||
|
pshCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; |
||||||
|
pshCancel.Location = new System.Drawing.Point(353, 187); |
||||||
|
pshCancel.Name = "pshCancel"; |
||||||
|
pshCancel.Size = new System.Drawing.Size(75, 23); |
||||||
|
pshCancel.TabIndex = 1; |
||||||
|
pshCancel.Text = "${res:Global.CancelButtonText}"; |
||||||
|
pshCancel.UseVisualStyleBackColor = true; |
||||||
|
//
|
||||||
|
// txtILSpyExplanation
|
||||||
|
//
|
||||||
|
txtILSpyExplanation.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) |
||||||
|
| System.Windows.Forms.AnchorStyles.Right))); |
||||||
|
txtILSpyExplanation.Location = new System.Drawing.Point(12, 45); |
||||||
|
txtILSpyExplanation.Name = "txtILSpyExplanation"; |
||||||
|
txtILSpyExplanation.Size = new System.Drawing.Size(416, 46); |
||||||
|
txtILSpyExplanation.TabIndex = 3; |
||||||
|
txtILSpyExplanation.Text = "${res:ILSpyAddIn.SetILSpyPathDialog.ILSpyInfo}"; |
||||||
|
//
|
||||||
|
// grpPath
|
||||||
|
//
|
||||||
|
grpPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) |
||||||
|
| System.Windows.Forms.AnchorStyles.Right))); |
||||||
|
grpPath.Controls.Add(pshBrowse); |
||||||
|
grpPath.Controls.Add(this.slePath); |
||||||
|
grpPath.Location = new System.Drawing.Point(12, 127); |
||||||
|
grpPath.Name = "grpPath"; |
||||||
|
grpPath.Size = new System.Drawing.Size(416, 51); |
||||||
|
grpPath.TabIndex = 5; |
||||||
|
grpPath.TabStop = false; |
||||||
|
grpPath.Text = "${res:ILSpyAddIn.SetILSpyPathDialog.PathToILSpyExe}"; |
||||||
|
//
|
||||||
|
// pshBrowse
|
||||||
|
//
|
||||||
|
pshBrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); |
||||||
|
pshBrowse.Location = new System.Drawing.Point(303, 17); |
||||||
|
pshBrowse.Name = "pshBrowse"; |
||||||
|
pshBrowse.Size = new System.Drawing.Size(107, 23); |
||||||
|
pshBrowse.TabIndex = 1; |
||||||
|
pshBrowse.Text = "${res:Global.BrowseButtonText}"; |
||||||
|
pshBrowse.UseVisualStyleBackColor = true; |
||||||
|
pshBrowse.Click += new System.EventHandler(this.PshBrowseClick); |
||||||
|
//
|
||||||
|
// slePath
|
||||||
|
//
|
||||||
|
this.slePath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) |
||||||
|
| System.Windows.Forms.AnchorStyles.Right))); |
||||||
|
this.slePath.Location = new System.Drawing.Point(6, 19); |
||||||
|
this.slePath.Name = "slePath"; |
||||||
|
this.slePath.Size = new System.Drawing.Size(291, 20); |
||||||
|
this.slePath.TabIndex = 0; |
||||||
|
//
|
||||||
|
// linkILSpy
|
||||||
|
//
|
||||||
|
this.linkILSpy.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) |
||||||
|
| System.Windows.Forms.AnchorStyles.Right))); |
||||||
|
this.linkILSpy.Location = new System.Drawing.Point(12, 91); |
||||||
|
this.linkILSpy.Name = "linkILSpy"; |
||||||
|
this.linkILSpy.Size = new System.Drawing.Size(416, 23); |
||||||
|
this.linkILSpy.TabIndex = 4; |
||||||
|
this.linkILSpy.TabStop = true; |
||||||
|
this.linkILSpy.Text = "http://www.ilspy.net/"; |
||||||
|
this.linkILSpy.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkILSpyLinkClicked); |
||||||
|
//
|
||||||
|
// txtReason
|
||||||
|
//
|
||||||
|
this.txtReason.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) |
||||||
|
| System.Windows.Forms.AnchorStyles.Right))); |
||||||
|
this.txtReason.Location = new System.Drawing.Point(12, 9); |
||||||
|
this.txtReason.Name = "txtReason"; |
||||||
|
this.txtReason.Size = new System.Drawing.Size(416, 36); |
||||||
|
this.txtReason.TabIndex = 2; |
||||||
|
//
|
||||||
|
// SetILSpyPathDialog
|
||||||
|
//
|
||||||
|
this.AcceptButton = pshOK; |
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); |
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
||||||
|
this.CancelButton = pshCancel; |
||||||
|
this.ClientSize = new System.Drawing.Size(440, 222); |
||||||
|
this.Controls.Add(grpPath); |
||||||
|
this.Controls.Add(this.linkILSpy); |
||||||
|
this.Controls.Add(txtILSpyExplanation); |
||||||
|
this.Controls.Add(this.txtReason); |
||||||
|
this.Controls.Add(pshCancel); |
||||||
|
this.Controls.Add(pshOK); |
||||||
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; |
||||||
|
this.MaximizeBox = false; |
||||||
|
this.MinimizeBox = false; |
||||||
|
this.Name = "SetILSpyPathDialog"; |
||||||
|
this.ShowIcon = false; |
||||||
|
this.ShowInTaskbar = false; |
||||||
|
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; |
||||||
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; |
||||||
|
this.Text = "${res:ILSpyAddIn.SetILSpyPathDialogTitle}"; |
||||||
|
grpPath.ResumeLayout(false); |
||||||
|
grpPath.PerformLayout(); |
||||||
|
this.ResumeLayout(false); |
||||||
|
} |
||||||
|
private System.Windows.Forms.LinkLabel linkILSpy; |
||||||
|
private System.Windows.Forms.TextBox slePath; |
||||||
|
private System.Windows.Forms.Label txtReason; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,73 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Drawing; |
||||||
|
using System.Windows.Forms; |
||||||
|
|
||||||
|
using ICSharpCode.Core; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpyAddIn |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Asks the user for the path to ILSpy.exe.
|
||||||
|
/// </summary>
|
||||||
|
internal partial class SetILSpyPathDialog : Form |
||||||
|
{ |
||||||
|
public SetILSpyPathDialog(string oldPath, string reason) |
||||||
|
{ |
||||||
|
//
|
||||||
|
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||||
|
//
|
||||||
|
InitializeComponent(); |
||||||
|
|
||||||
|
Translate(this); |
||||||
|
|
||||||
|
this.txtReason.Text = reason; |
||||||
|
if (!String.IsNullOrEmpty(oldPath)) { |
||||||
|
this.slePath.Text = oldPath; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private static void Translate(Control container) { |
||||||
|
container.Text = StringParser.Parse(container.Text); |
||||||
|
foreach (Control c in container.Controls) { |
||||||
|
Translate(c); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void LinkILSpyLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) |
||||||
|
{ |
||||||
|
try { |
||||||
|
using(System.Diagnostics.Process.Start(linkILSpy.Text)) { |
||||||
|
} |
||||||
|
} catch (Exception ex) { |
||||||
|
MessageService.ShowError(ex.Message); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void PshBrowseClick(object sender, EventArgs e) |
||||||
|
{ |
||||||
|
using(OpenFileDialog dialog = new OpenFileDialog()) { |
||||||
|
|
||||||
|
dialog.Title = this.Text; |
||||||
|
dialog.DefaultExt = "exe"; |
||||||
|
dialog.RestoreDirectory = true; |
||||||
|
dialog.Filter = "ILSpy.exe|ILSpy.exe"; |
||||||
|
|
||||||
|
if (!String.IsNullOrEmpty(this.slePath.Text)) { |
||||||
|
dialog.FileName = this.slePath.Text; |
||||||
|
} |
||||||
|
|
||||||
|
if (dialog.ShowDialog(this) == DialogResult.OK) { |
||||||
|
this.slePath.Text = dialog.FileName; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public string SelectedFile { |
||||||
|
get { return this.slePath.Text; } |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,135 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<root> |
||||||
|
<!-- |
||||||
|
Microsoft ResX Schema |
||||||
|
|
||||||
|
Version 2.0 |
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format |
||||||
|
that is mostly human readable. The generation and parsing of the |
||||||
|
various data types are done through the TypeConverter classes |
||||||
|
associated with the data types. |
||||||
|
|
||||||
|
Example: |
||||||
|
|
||||||
|
... ado.net/XML headers & schema ... |
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader> |
||||||
|
<resheader name="version">2.0</resheader> |
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value> |
||||||
|
</data> |
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
||||||
|
<comment>This is a comment</comment> |
||||||
|
</data> |
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple |
||||||
|
name/value pairs. |
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a |
||||||
|
type or mimetype. Type corresponds to a .NET class that support |
||||||
|
text/value conversion through the TypeConverter architecture. |
||||||
|
Classes that don't support this are serialized and stored with the |
||||||
|
mimetype set. |
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the |
||||||
|
ResXResourceReader how to depersist the object. This is currently not |
||||||
|
extensible. For a given mimetype the value must be set accordingly: |
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format |
||||||
|
that the ResXResourceWriter will generate, however the reader can |
||||||
|
read any of the formats listed below. |
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64 |
||||||
|
value : The object must be serialized with |
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
||||||
|
: and then encoded with base64 encoding. |
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64 |
||||||
|
value : The object must be serialized with |
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
||||||
|
: and then encoded with base64 encoding. |
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64 |
||||||
|
value : The object must be serialized into a byte array |
||||||
|
: using a System.ComponentModel.TypeConverter |
||||||
|
: and then encoded with base64 encoding. |
||||||
|
--> |
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |
||||||
|
<xsd:element name="root" msdata:IsDataSet="true"> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:choice maxOccurs="unbounded"> |
||||||
|
<xsd:element name="metadata"> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:sequence> |
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
||||||
|
</xsd:sequence> |
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" /> |
||||||
|
<xsd:attribute name="type" type="xsd:string" /> |
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" /> |
||||||
|
<xsd:attribute ref="xml:space" /> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
<xsd:element name="assembly"> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:attribute name="alias" type="xsd:string" /> |
||||||
|
<xsd:attribute name="name" type="xsd:string" /> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
<xsd:element name="data"> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:sequence> |
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
||||||
|
</xsd:sequence> |
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
||||||
|
<xsd:attribute ref="xml:space" /> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
<xsd:element name="resheader"> |
||||||
|
<xsd:complexType> |
||||||
|
<xsd:sequence> |
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||||
|
</xsd:sequence> |
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" /> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
</xsd:choice> |
||||||
|
</xsd:complexType> |
||||||
|
</xsd:element> |
||||||
|
</xsd:schema> |
||||||
|
<resheader name="resmimetype"> |
||||||
|
<value>text/microsoft-resx</value> |
||||||
|
</resheader> |
||||||
|
<resheader name="version"> |
||||||
|
<value>2.0</value> |
||||||
|
</resheader> |
||||||
|
<resheader name="reader"> |
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||||
|
</resheader> |
||||||
|
<resheader name="writer"> |
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||||
|
</resheader> |
||||||
|
<metadata name="pshOK.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> |
||||||
|
<value>False</value> |
||||||
|
</metadata> |
||||||
|
<metadata name="pshCancel.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> |
||||||
|
<value>False</value> |
||||||
|
</metadata> |
||||||
|
<metadata name="txtILSpyExplanation.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> |
||||||
|
<value>False</value> |
||||||
|
</metadata> |
||||||
|
<metadata name="grpPath.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> |
||||||
|
<value>False</value> |
||||||
|
</metadata> |
||||||
|
<metadata name="pshBrowse.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> |
||||||
|
<value>False</value> |
||||||
|
</metadata> |
||||||
|
</root> |
@ -0,0 +1,63 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.Core; |
||||||
|
using ICSharpCode.SharpDevelop.Bookmarks; |
||||||
|
using ICSharpCode.SharpDevelop.Dom; |
||||||
|
using ICSharpCode.SharpDevelop.Gui.ClassBrowser; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpyAddIn |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Implements a menu command to position .NET ILSpy on a class
|
||||||
|
/// or class member.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class TextEditorContextMenuCommand : AbstractMenuCommand |
||||||
|
{ |
||||||
|
public override void Run() |
||||||
|
{ |
||||||
|
IClass c; |
||||||
|
IMember m; |
||||||
|
|
||||||
|
MemberNode mn = this.Owner as MemberNode; |
||||||
|
if (mn != null) { |
||||||
|
m = mn.Member; |
||||||
|
c = m.DeclaringType; |
||||||
|
} else { |
||||||
|
ClassNode cn = this.Owner as ClassNode; |
||||||
|
if (cn != null) { |
||||||
|
c = cn.Class; |
||||||
|
m = null; |
||||||
|
} else { |
||||||
|
ClassMemberBookmark cmbm = this.Owner as ClassMemberBookmark; |
||||||
|
if (cmbm != null) { |
||||||
|
m = cmbm.Member; |
||||||
|
c = m.DeclaringType; |
||||||
|
} else { |
||||||
|
ClassBookmark cbm = this.Owner as ClassBookmark; |
||||||
|
if (cbm != null) { |
||||||
|
c = cbm.Class; |
||||||
|
m = null; |
||||||
|
} else { |
||||||
|
MessageService.ShowWarning("ILSpy AddIn: Could not determine the class for the selected element. Owner: " + ((this.Owner == null) ? "<null>" : this.Owner.ToString())); |
||||||
|
return; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (c == null) { |
||||||
|
MessageService.ShowWarning("ILSpy AddIn: Could not determine the class for the selected element (known owner). Owner: " + this.Owner.ToString()); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
AbstractEntity entity = m as AbstractEntity; |
||||||
|
if (entity == null) |
||||||
|
entity = c as AbstractEntity; |
||||||
|
if (entity != null) { |
||||||
|
ILSpyController.TryGoTo(entity); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Binary file not shown.
Loading…
Reference in new issue