@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
// This code is distributed under the MS-PL (for details please see \doc\MS-PL.txt)
|
||||
|
||||
using System; |
||||
using System.Linq; |
||||
|
||||
namespace ILSpy.BamlDecompiler |
||||
{ |
||||
public static class Extensions |
||||
{ |
||||
public static string TrimEnd(this string target, Func<char, bool> predicate) |
||||
{ |
||||
if (target == null) |
||||
throw new ArgumentNullException("target"); |
||||
|
||||
while (predicate(target.LastOrDefault())) |
||||
target = target.Remove(target.Length - 1); |
||||
|
||||
return target; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team
|
||||
// This code is distributed under the MS-PL (for details please see \doc\MS-PL.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Text; |
||||
using System.Xml; |
||||
|
||||
namespace Ricciolo.StylesExplorer.MarkupReflection |
||||
{ |
||||
class XmlBamlSimpleProperty : XmlBamlNode |
||||
{ |
||||
public string NamespaceName { get; private set; } |
||||
public string LocalName { get; private set; } |
||||
public string Value { get; private set; } |
||||
|
||||
public XmlBamlSimpleProperty(string namespaceName, string localName, string value) |
||||
{ |
||||
if (string.IsNullOrWhiteSpace(namespaceName)) |
||||
throw new ArgumentException("namespaceName"); |
||||
if (string.IsNullOrWhiteSpace(localName)) |
||||
throw new ArgumentException("localName"); |
||||
if (value == null) |
||||
throw new ArgumentNullException("value"); |
||||
this.NamespaceName = namespaceName; |
||||
this.LocalName = localName; |
||||
this.Value = value; |
||||
} |
||||
|
||||
public override XmlNodeType NodeType { |
||||
get { return XmlNodeType.Attribute; } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
<Window x:Class="ILSpy.BamlDecompiler.Tests.Cases.Simple" Title="ILSpy.BamlDecompiler.Tests.Cases" Height="300" Width="300" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
||||
<Grid /> |
||||
</Window> |
||||
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
// 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.Text; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Data; |
||||
using System.Windows.Documents; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
|
||||
namespace ILSpy.BamlDecompiler.Tests.Cases |
||||
{ |
||||
/// <summary>
|
||||
/// Interaction logic for Simple.xaml
|
||||
/// </summary>
|
||||
public partial class Simple : Window |
||||
{ |
||||
public Simple() |
||||
{ |
||||
InitializeComponent(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"></ResourceDictionary> |
||||
@ -0,0 +1,112 @@
@@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build"> |
||||
<PropertyGroup> |
||||
<ProjectGuid>{1169E6D1-1899-43D4-A500-07CE4235B388}</ProjectGuid> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ILSpy.BamlDecompiler.Tests</RootNamespace> |
||||
<AssemblyName>ILSpy.BamlDecompiler.Tests</AssemblyName> |
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> |
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Platform)' == 'x86' "> |
||||
<PlatformTarget>x86</PlatformTarget> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<FileAlignment>4096</FileAlignment> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<OutputPath>..\bin\Debug\</OutputPath> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<Optimize>False</Optimize> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<OutputPath>..\bin\Release\</OutputPath> |
||||
<DebugSymbols>false</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<Optimize>True</Optimize> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="DiffLib"> |
||||
<HintPath>..\..\packages\DiffLib.1.0.0.55\lib\net35-Client\DiffLib.dll</HintPath> |
||||
</Reference> |
||||
<Reference Include="nunit.framework"> |
||||
<HintPath>..\..\ICSharpCode.Decompiler\Tests\nunit.framework.dll</HintPath> |
||||
</Reference> |
||||
<Reference Include="PresentationCore" /> |
||||
<Reference Include="PresentationCore"> |
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="PresentationFramework" /> |
||||
<Reference Include="PresentationFramework"> |
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Core"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Xaml"> |
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="System.Xml.Linq"> |
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework> |
||||
</Reference> |
||||
<Reference Include="WindowsBase" /> |
||||
<Reference Include="WindowsBase"> |
||||
<RequiredTargetFramework>3.0</RequiredTargetFramework> |
||||
</Reference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="Cases\Simple.xaml.cs"> |
||||
<DependentUpon>Simple.xaml</DependentUpon> |
||||
<SubType>Code</SubType> |
||||
</Compile> |
||||
<Compile Include="Properties\AssemblyInfo.cs" /> |
||||
<Compile Include="TestRunner.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\..\ICSharpCode.Decompiler\Tests\ICSharpCode.Decompiler.Tests.csproj"> |
||||
<Project>{FEC0DA52-C4A6-4710-BE36-B484A20C5E22}</Project> |
||||
<Name>ICSharpCode.Decompiler.Tests</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\ILSpy\ILSpy.csproj"> |
||||
<Project>{1E85EFF9-E370-4683-83E4-8A3D063FF791}</Project> |
||||
<Name>ILSpy</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\Mono.Cecil\Mono.Cecil.csproj"> |
||||
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project> |
||||
<Name>Mono.Cecil</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\SharpTreeView\ICSharpCode.TreeView.csproj"> |
||||
<Project>{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}</Project> |
||||
<Name>ICSharpCode.TreeView</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\ILSpy.BamlDecompiler.csproj"> |
||||
<Project>{A6BAD2BA-76BA-461C-8B6D-418607591247}</Project> |
||||
<Name>ILSpy.BamlDecompiler</Name> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Folder Include="Cases" /> |
||||
<Folder Include="Properties" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Page Include="Cases\Simple.xaml"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</Page> |
||||
<Page Include="Cases\SimpleDictionary.xaml" /> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
</Project> |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
#region Using directives
|
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
#endregion
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("ILSpy.BamlDecompiler.Tests")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyCompany("")] |
||||
[assembly: AssemblyProduct("ILSpy.BamlDecompiler.Tests")] |
||||
[assembly: AssemblyCopyright("Copyright 2011")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
||||
|
||||
// This sets the default COM visibility of types in the assembly to invisible.
|
||||
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
|
||||
[assembly: ComVisible(false)] |
||||
|
||||
// The assembly version has following format :
|
||||
//
|
||||
// Major.Minor.Build.Revision
|
||||
//
|
||||
// You can specify all the values or you can use the default the Revision and
|
||||
// Build Numbers by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.*")] |
||||
@ -0,0 +1,73 @@
@@ -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.Collections; |
||||
using System.Diagnostics; |
||||
using System.IO; |
||||
using System.Linq; |
||||
using System.Resources; |
||||
using System.Xml.Linq; |
||||
using ICSharpCode.Decompiler.Tests.Helpers; |
||||
using ICSharpCode.ILSpy; |
||||
using Mono.Cecil; |
||||
using NUnit.Framework; |
||||
using Ricciolo.StylesExplorer.MarkupReflection; |
||||
|
||||
namespace ILSpy.BamlDecompiler.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class TestRunner |
||||
{ |
||||
[Test] |
||||
public void Simple() |
||||
{ |
||||
RunTest("cases/simple"); |
||||
} |
||||
|
||||
[Test] |
||||
public void SimpleDictionary() |
||||
{ |
||||
RunTest("cases/simpledictionary"); |
||||
} |
||||
|
||||
void RunTest(string name) |
||||
{ |
||||
string asmPath = typeof(TestRunner).Assembly.Location; |
||||
var assembly = AssemblyDefinition.ReadAssembly(asmPath); |
||||
Resource res = assembly.MainModule.Resources.First(); |
||||
Stream bamlStream = LoadBaml(res, name + ".baml"); |
||||
Assert.IsNotNull(bamlStream); |
||||
XDocument document = BamlResourceEntryNode.LoadIntoDocument(new DefaultAssemblyResolver(), assembly, bamlStream); |
||||
string path = Path.Combine("..\\..\\Tests", name + ".xaml"); |
||||
|
||||
CodeAssert.AreEqual(document.ToString(), File.ReadAllText(path)); |
||||
} |
||||
|
||||
Stream LoadBaml(Resource res, string name) |
||||
{ |
||||
EmbeddedResource er = res as EmbeddedResource; |
||||
if (er != null) { |
||||
Stream s = er.GetResourceStream(); |
||||
s.Position = 0; |
||||
ResourceReader reader; |
||||
try { |
||||
reader = new ResourceReader(s); |
||||
} |
||||
catch (ArgumentException) { |
||||
return null; |
||||
} |
||||
foreach (DictionaryEntry entry in reader.Cast<DictionaryEntry>().OrderBy(e => e.Key.ToString())) { |
||||
if (entry.Key.ToString() == name) { |
||||
if (entry.Value is Stream) |
||||
return (Stream)entry.Value; |
||||
if (entry.Value is byte[]) |
||||
return new MemoryStream((byte[])entry.Value); |
||||
} |
||||
} |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
@ -1,178 +0,0 @@
@@ -1,178 +0,0 @@
|
||||
// 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.Diagnostics; |
||||
using System.Linq; |
||||
using System.Threading.Tasks; |
||||
using System.Windows.Input; |
||||
using ICSharpCode.ILSpy.TextView; |
||||
using ICSharpCode.ILSpy.TreeNodes; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportMainMenuCommand(Menu = "_File", Header = "E_xit", MenuOrder = 99999, MenuCategory = "Exit")] |
||||
sealed class ExitCommand : SimpleCommand |
||||
{ |
||||
public override void Execute(object parameter) |
||||
{ |
||||
MainWindow.Instance.Close(); |
||||
} |
||||
} |
||||
|
||||
[ExportToolbarCommand(ToolTip = "Back", ToolbarIcon = "Images/Back.png", ToolbarCategory = "Navigation", ToolbarOrder = 0)] |
||||
sealed class BrowseBackCommand : CommandWrapper { |
||||
public BrowseBackCommand() : base(NavigationCommands.BrowseBack) {} |
||||
} |
||||
|
||||
[ExportToolbarCommand(ToolTip = "Forward", ToolbarIcon = "Images/Forward.png", ToolbarCategory = "Navigation", ToolbarOrder = 1)] |
||||
sealed class BrowseForwardCommand : CommandWrapper { |
||||
public BrowseForwardCommand() : base(NavigationCommands.BrowseForward) {} |
||||
} |
||||
|
||||
[ExportToolbarCommand(ToolTip = "Open", ToolbarIcon = "Images/Open.png", ToolbarCategory = "Open", ToolbarOrder = 0)] |
||||
[ExportMainMenuCommand(Menu = "_File", MenuIcon = "Images/Open.png", MenuCategory = "Open", MenuOrder = 0)] |
||||
sealed class OpenCommand : CommandWrapper { |
||||
public OpenCommand() : base(ApplicationCommands.Open) {} |
||||
} |
||||
|
||||
[ExportMainMenuCommand(Menu = "_File", Header = "Open from _GAC", MenuCategory = "Open", MenuOrder = 1)] |
||||
sealed class OpenFromGacCommand : SimpleCommand |
||||
{ |
||||
public override void Execute(object parameter) |
||||
{ |
||||
OpenFromGacDialog dlg = new OpenFromGacDialog(); |
||||
dlg.Owner = MainWindow.Instance; |
||||
if (dlg.ShowDialog() == true) { |
||||
MainWindow.Instance.OpenFiles(dlg.SelectedFileNames); |
||||
} |
||||
} |
||||
} |
||||
|
||||
[ExportToolbarCommand(ToolTip = "Reload all assemblies", ToolbarIcon = "Images/Refresh.png", ToolbarCategory = "Open", ToolbarOrder = 2)] |
||||
[ExportMainMenuCommand(Menu = "_File", Header = "Reload", MenuIcon = "Images/Refresh.png", MenuCategory = "Open", MenuOrder = 2)] |
||||
sealed class RefreshCommand : CommandWrapper { |
||||
public RefreshCommand() : base(NavigationCommands.Refresh) {} |
||||
} |
||||
|
||||
[ExportMainMenuCommand(Menu = "_File", Header = "_Save Code...", MenuIcon = "Images/SaveFile.png", MenuCategory = "Save", MenuOrder = 0)] |
||||
sealed class SaveCommand : CommandWrapper |
||||
{ |
||||
public SaveCommand() : base(ApplicationCommands.Save) {} |
||||
} |
||||
|
||||
#if DEBUG
|
||||
[ExportMainMenuCommand(Menu = "_File", Header = "DEBUG -- Decompile All", MenuCategory = "Open", MenuOrder = 2.5)] |
||||
sealed class DecompileAllCommand : SimpleCommand |
||||
{ |
||||
public override bool CanExecute(object parameter) |
||||
{ |
||||
return System.IO.Directory.Exists("c:\\temp\\decompiled"); |
||||
} |
||||
|
||||
public override void Execute(object parameter) |
||||
{ |
||||
MainWindow.Instance.TextView.RunWithCancellation( |
||||
ct => Task<AvalonEditTextOutput>.Factory.StartNew( |
||||
() => { |
||||
AvalonEditTextOutput output = new AvalonEditTextOutput(); |
||||
Parallel.ForEach( |
||||
MainWindow.Instance.CurrentAssemblyList.GetAssemblies(), |
||||
new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount, CancellationToken = ct }, |
||||
delegate (LoadedAssembly asm) { |
||||
if (!asm.HasLoadError) { |
||||
Stopwatch w = Stopwatch.StartNew(); |
||||
Exception exception = null; |
||||
using (var writer = new System.IO.StreamWriter("c:\\temp\\decompiled\\" + asm.ShortName + ".cs")) { |
||||
try { |
||||
new CSharpLanguage().DecompileAssembly( |
||||
asm, new Decompiler.PlainTextOutput(writer), |
||||
new DecompilationOptions { FullDecompilation = true, CancellationToken = ct }); |
||||
} catch (Exception ex) { |
||||
writer.WriteLine(ex.ToString()); |
||||
exception = ex; |
||||
} |
||||
} |
||||
lock (output) { |
||||
output.Write(asm.ShortName + " - " + w.Elapsed); |
||||
if (exception != null) { |
||||
output.Write(" - "); |
||||
output.Write(exception.GetType().Name); |
||||
} |
||||
output.WriteLine(); |
||||
} |
||||
} |
||||
}); |
||||
return output; |
||||
} |
||||
), |
||||
task => MainWindow.Instance.TextView.ShowText(task.Result)); |
||||
} |
||||
} |
||||
#endif
|
||||
|
||||
class CommandWrapper : ICommand |
||||
{ |
||||
ICommand wrappedCommand; |
||||
|
||||
public CommandWrapper(ICommand wrappedCommand) |
||||
{ |
||||
this.wrappedCommand = wrappedCommand; |
||||
} |
||||
|
||||
public static ICommand Unwrap(ICommand command) |
||||
{ |
||||
CommandWrapper w = command as CommandWrapper; |
||||
if (w != null) |
||||
return w.wrappedCommand; |
||||
else |
||||
return command; |
||||
} |
||||
|
||||
public event EventHandler CanExecuteChanged { |
||||
add { wrappedCommand.CanExecuteChanged += value; } |
||||
remove { wrappedCommand.CanExecuteChanged -= value; } |
||||
} |
||||
|
||||
public void Execute(object parameter) |
||||
{ |
||||
wrappedCommand.Execute(parameter); |
||||
} |
||||
|
||||
public bool CanExecute(object parameter) |
||||
{ |
||||
return wrappedCommand.CanExecute(parameter); |
||||
} |
||||
} |
||||
|
||||
public abstract class SimpleCommand : ICommand |
||||
{ |
||||
public event EventHandler CanExecuteChanged { |
||||
add { CommandManager.RequerySuggested += value; } |
||||
remove { CommandManager.RequerySuggested -= value; } |
||||
} |
||||
|
||||
public abstract void Execute(object parameter); |
||||
|
||||
public virtual bool CanExecute(object parameter) |
||||
{ |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// 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.Windows.Input; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportToolbarCommand(ToolTip = "Back", ToolbarIcon = "Images/Back.png", ToolbarCategory = "Navigation", ToolbarOrder = 0)] |
||||
sealed class BrowseBackCommand : CommandWrapper |
||||
{ |
||||
public BrowseBackCommand() |
||||
: base(NavigationCommands.BrowseBack) |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// 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.Windows.Input; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportToolbarCommand(ToolTip = "Forward", ToolbarIcon = "Images/Forward.png", ToolbarCategory = "Navigation", ToolbarOrder = 1)] |
||||
sealed class BrowseForwardCommand : CommandWrapper |
||||
{ |
||||
public BrowseForwardCommand() |
||||
: base(NavigationCommands.BrowseForward) |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,58 @@
@@ -0,0 +1,58 @@
|
||||
// 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.Windows.Input; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
class CommandWrapper : ICommand |
||||
{ |
||||
private ICommand wrappedCommand; |
||||
|
||||
public CommandWrapper(ICommand wrappedCommand) |
||||
{ |
||||
this.wrappedCommand = wrappedCommand; |
||||
} |
||||
|
||||
public static ICommand Unwrap(ICommand command) |
||||
{ |
||||
CommandWrapper w = command as CommandWrapper; |
||||
if (w != null) |
||||
return w.wrappedCommand; |
||||
else |
||||
return command; |
||||
} |
||||
|
||||
public event EventHandler CanExecuteChanged |
||||
{ |
||||
add { wrappedCommand.CanExecuteChanged += value; } |
||||
remove { wrappedCommand.CanExecuteChanged -= value; } |
||||
} |
||||
|
||||
public void Execute(object parameter) |
||||
{ |
||||
wrappedCommand.Execute(parameter); |
||||
} |
||||
|
||||
public bool CanExecute(object parameter) |
||||
{ |
||||
return wrappedCommand.CanExecute(parameter); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
// 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.
|
||||
|
||||
#if DEBUG
|
||||
|
||||
using System; |
||||
using System.Diagnostics; |
||||
using System.Threading.Tasks; |
||||
using ICSharpCode.ILSpy.TextView; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportMainMenuCommand(Menu = "_File", Header = "DEBUG -- Decompile All", MenuCategory = "Open", MenuOrder = 2.5)] |
||||
sealed class DecompileAllCommand : SimpleCommand |
||||
{ |
||||
public override bool CanExecute(object parameter) |
||||
{ |
||||
return System.IO.Directory.Exists("c:\\temp\\decompiled"); |
||||
} |
||||
|
||||
public override void Execute(object parameter) |
||||
{ |
||||
MainWindow.Instance.TextView.RunWithCancellation(ct => Task<AvalonEditTextOutput>.Factory.StartNew(() => { |
||||
AvalonEditTextOutput output = new AvalonEditTextOutput(); |
||||
Parallel.ForEach(MainWindow.Instance.CurrentAssemblyList.GetAssemblies(), new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount, CancellationToken = ct }, delegate(LoadedAssembly asm) { |
||||
if (!asm.HasLoadError) { |
||||
Stopwatch w = Stopwatch.StartNew(); |
||||
Exception exception = null; |
||||
using (var writer = new System.IO.StreamWriter("c:\\temp\\decompiled\\" + asm.ShortName + ".cs")) { |
||||
try { |
||||
new CSharpLanguage().DecompileAssembly(asm, new Decompiler.PlainTextOutput(writer), new DecompilationOptions { FullDecompilation = true, CancellationToken = ct }); |
||||
} |
||||
catch (Exception ex) { |
||||
writer.WriteLine(ex.ToString()); |
||||
exception = ex; |
||||
} |
||||
} |
||||
lock (output) { |
||||
output.Write(asm.ShortName + " - " + w.Elapsed); |
||||
if (exception != null) { |
||||
output.Write(" - "); |
||||
output.Write(exception.GetType().Name); |
||||
} |
||||
output.WriteLine(); |
||||
} |
||||
} |
||||
}); |
||||
return output; |
||||
}), task => MainWindow.Instance.TextView.ShowText(task.Result)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
#endif
|
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportMainMenuCommand(Menu = "_File", Header = "E_xit", MenuOrder = 99999, MenuCategory = "Exit")] |
||||
sealed class ExitCommand : SimpleCommand |
||||
{ |
||||
public override void Execute(object parameter) |
||||
{ |
||||
MainWindow.Instance.Close(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,33 @@
@@ -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 System.Windows.Input; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportToolbarCommand(ToolTip = "Open", ToolbarIcon = "Images/Open.png", ToolbarCategory = "Open", ToolbarOrder = 0)] |
||||
[ExportMainMenuCommand(Menu = "_File", MenuIcon = "Images/Open.png", MenuCategory = "Open", MenuOrder = 0)] |
||||
sealed class OpenCommand : CommandWrapper |
||||
{ |
||||
public OpenCommand() |
||||
: base(ApplicationCommands.Open) |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportMainMenuCommand(Menu = "_File", Header = "Open from _GAC", MenuCategory = "Open", MenuOrder = 1)] |
||||
sealed class OpenFromGacCommand : SimpleCommand |
||||
{ |
||||
public override void Execute(object parameter) |
||||
{ |
||||
OpenFromGacDialog dlg = new OpenFromGacDialog(); |
||||
dlg.Owner = MainWindow.Instance; |
||||
if (dlg.ShowDialog() == true) |
||||
MainWindow.Instance.OpenFiles(dlg.SelectedFileNames); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,33 @@
@@ -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 System.Windows.Input; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportToolbarCommand(ToolTip = "Reload all assemblies", ToolbarIcon = "Images/Refresh.png", ToolbarCategory = "Open", ToolbarOrder = 2)] |
||||
[ExportMainMenuCommand(Menu = "_File", Header = "Reload", MenuIcon = "Images/Refresh.png", MenuCategory = "Open", MenuOrder = 2)] |
||||
sealed class RefreshCommand : CommandWrapper |
||||
{ |
||||
public RefreshCommand() |
||||
: base(NavigationCommands.Refresh) |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// 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.Windows.Input; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportMainMenuCommand(Menu = "_File", Header = "_Save Code...", MenuIcon = "Images/SaveFile.png", MenuCategory = "Save", MenuOrder = 0)] |
||||
sealed class SaveCommand : CommandWrapper |
||||
{ |
||||
public SaveCommand() |
||||
: base(ApplicationCommands.Save) |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
[ExportMainMenuCommand(Menu = "_View", Header = "_Analyzer", MenuCategory = "ShowPane", MenuOrder = 100)] |
||||
sealed class ShowAnalyzerCommand : SimpleCommand |
||||
{ |
||||
public override void Execute(object parameter) |
||||
{ |
||||
AnalyzerTreeView.Instance.Show(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
// 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.Windows.Input; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
public abstract class SimpleCommand : ICommand |
||||
{ |
||||
public event EventHandler CanExecuteChanged |
||||
{ |
||||
add { CommandManager.RequerySuggested += value; } |
||||
remove { CommandManager.RequerySuggested -= value; } |
||||
} |
||||
|
||||
public abstract void Execute(object parameter); |
||||
|
||||
public virtual bool CanExecute(object parameter) |
||||
{ |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
public interface IPane |
||||
{ |
||||
void Closed(); |
||||
} |
||||
} |
||||
|
Before Width: | Height: | Size: 575 B After Width: | Height: | Size: 584 B |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 352 B After Width: | Height: | Size: 351 B |
|
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 440 B |
@ -0,0 +1,60 @@
@@ -0,0 +1,60 @@
|
||||
// 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.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using System.ComponentModel.Composition.Hosting; |
||||
using System.Linq; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
public static class Languages |
||||
{ |
||||
private static ReadOnlyCollection<Language> allLanguages; |
||||
|
||||
/// <summary>
|
||||
/// A list of all languages.
|
||||
/// </summary>
|
||||
public static ReadOnlyCollection<Language> AllLanguages |
||||
{ |
||||
get { return allLanguages; } |
||||
} |
||||
|
||||
internal static void Initialize(CompositionContainer composition) |
||||
{ |
||||
List<Language> languages = new List<Language>(); |
||||
languages.AddRange(composition.GetExportedValues<Language>()); |
||||
languages.Add(new ILLanguage(true)); |
||||
#if DEBUG
|
||||
languages.AddRange(ILAstLanguage.GetDebugLanguages()); |
||||
languages.AddRange(CSharpLanguage.GetDebugLanguages()); |
||||
#endif
|
||||
allLanguages = languages.AsReadOnly(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets a language using its name.
|
||||
/// If the language is not found, C# is returned instead.
|
||||
/// </summary>
|
||||
public static Language GetLanguage(string name) |
||||
{ |
||||
return AllLanguages.FirstOrDefault(l => l.Name == name) ?? AllLanguages.First(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,104 @@
@@ -0,0 +1,104 @@
|
||||
// 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.Decompiler; |
||||
using ICSharpCode.TreeView; |
||||
using Mono.Cecil; |
||||
|
||||
namespace ICSharpCode.ILSpy.TreeNodes |
||||
{ |
||||
sealed class BaseTypesEntryNode : ILSpyTreeNode, IMemberTreeNode |
||||
{ |
||||
private TypeReference tr; |
||||
private TypeDefinition def; |
||||
private bool isInterface; |
||||
|
||||
public BaseTypesEntryNode(TypeReference tr, bool isInterface) |
||||
{ |
||||
if (tr == null) |
||||
throw new ArgumentNullException("tr"); |
||||
this.tr = tr; |
||||
this.def = tr.Resolve(); |
||||
this.isInterface = isInterface; |
||||
this.LazyLoading = true; |
||||
} |
||||
|
||||
public override bool ShowExpander |
||||
{ |
||||
get { return def != null && (def.BaseType != null || def.HasInterfaces); } |
||||
} |
||||
|
||||
public override object Text |
||||
{ |
||||
get { return this.Language.TypeToString(tr, true); } |
||||
} |
||||
|
||||
public override object Icon |
||||
{ |
||||
get |
||||
{ |
||||
if (def != null) |
||||
return TypeTreeNode.GetIcon(def); |
||||
else |
||||
return isInterface ? Images.Interface : Images.Class; |
||||
} |
||||
} |
||||
|
||||
protected override void LoadChildren() |
||||
{ |
||||
if (def != null) |
||||
BaseTypesTreeNode.AddBaseTypes(this.Children, def); |
||||
} |
||||
|
||||
public override void ActivateItem(System.Windows.RoutedEventArgs e) |
||||
{ |
||||
// on item activation, try to resolve once again (maybe the user loaded the assembly in the meantime)
|
||||
if (def == null) { |
||||
def = tr.Resolve(); |
||||
if (def != null) |
||||
this.LazyLoading = true; |
||||
// re-load children
|
||||
} |
||||
e.Handled = ActivateItem(this, def); |
||||
} |
||||
|
||||
internal static bool ActivateItem(SharpTreeNode node, TypeDefinition def) |
||||
{ |
||||
if (def != null) { |
||||
var assemblyListNode = node.Ancestors().OfType<AssemblyListTreeNode>().FirstOrDefault(); |
||||
if (assemblyListNode != null) { |
||||
assemblyListNode.Select(assemblyListNode.FindTypeNode(def)); |
||||
return true; |
||||
} |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options) |
||||
{ |
||||
language.WriteCommentLine(output, language.TypeToString(tr, true)); |
||||
} |
||||
|
||||
MemberReference IMemberTreeNode.Member |
||||
{ |
||||
get { return tr; } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,111 @@
@@ -0,0 +1,111 @@
|
||||
// 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.Collections.Generic; |
||||
using System.Threading; |
||||
using ICSharpCode.Decompiler; |
||||
using Mono.Cecil; |
||||
|
||||
namespace ICSharpCode.ILSpy.TreeNodes |
||||
{ |
||||
class DerivedTypesEntryNode : ILSpyTreeNode, IMemberTreeNode |
||||
{ |
||||
private TypeDefinition type; |
||||
private AssemblyDefinition[] assemblies; |
||||
private ThreadingSupport threading; |
||||
|
||||
public DerivedTypesEntryNode(TypeDefinition type, AssemblyDefinition[] assemblies) |
||||
{ |
||||
this.type = type; |
||||
this.assemblies = assemblies; |
||||
this.LazyLoading = true; |
||||
threading = new ThreadingSupport(); |
||||
} |
||||
|
||||
public override bool ShowExpander |
||||
{ |
||||
get { return !type.IsSealed && base.ShowExpander; } |
||||
} |
||||
|
||||
public override object Text |
||||
{ |
||||
get { return this.Language.TypeToString(type, true); } |
||||
} |
||||
|
||||
public override object Icon |
||||
{ |
||||
get { return TypeTreeNode.GetIcon(type); } |
||||
} |
||||
|
||||
public override FilterResult Filter(FilterSettings settings) |
||||
{ |
||||
if (!settings.ShowInternalApi && !IsPublicAPI) |
||||
return FilterResult.Hidden; |
||||
if (settings.SearchTermMatches(type.Name)) { |
||||
if (type.IsNested && !settings.Language.ShowMember(type)) |
||||
return FilterResult.Hidden; |
||||
else |
||||
return FilterResult.Match; |
||||
} else |
||||
return FilterResult.Recurse; |
||||
} |
||||
|
||||
public bool IsPublicAPI |
||||
{ |
||||
get |
||||
{ |
||||
switch (type.Attributes & TypeAttributes.VisibilityMask) { |
||||
case TypeAttributes.Public: |
||||
case TypeAttributes.NestedPublic: |
||||
case TypeAttributes.NestedFamily: |
||||
case TypeAttributes.NestedFamORAssem: |
||||
return true; |
||||
default: |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
protected override void LoadChildren() |
||||
{ |
||||
threading.LoadChildren(this, FetchChildren); |
||||
} |
||||
|
||||
IEnumerable<ILSpyTreeNode> FetchChildren(CancellationToken ct) |
||||
{ |
||||
// FetchChildren() runs on the main thread; but the enumerator will be consumed on a background thread
|
||||
return DerivedTypesTreeNode.FindDerivedTypes(type, assemblies, ct); |
||||
} |
||||
|
||||
public override void ActivateItem(System.Windows.RoutedEventArgs e) |
||||
{ |
||||
e.Handled = BaseTypesEntryNode.ActivateItem(this, type); |
||||
} |
||||
|
||||
public override void Decompile(Language language, ITextOutput output, DecompilationOptions options) |
||||
{ |
||||
language.WriteCommentLine(output, language.TypeToString(type, true)); |
||||
} |
||||
|
||||
MemberReference IMemberTreeNode.Member |
||||
{ |
||||
get { return type; } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
// 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.
|
||||
|
||||
namespace ICSharpCode.ILSpy.TreeNodes |
||||
{ |
||||
public enum FilterResult |
||||
{ |
||||
/// <summary>
|
||||
/// Hides the node.
|
||||
/// </summary>
|
||||
Hidden, |
||||
/// <summary>
|
||||
/// Shows the node (and resets the search term for child nodes).
|
||||
/// </summary>
|
||||
Match, |
||||
/// <summary>
|
||||
/// Hides the node only if all children are hidden (and resets the search term for child nodes).
|
||||
/// </summary>
|
||||
MatchAndRecurse, |
||||
/// <summary>
|
||||
/// Hides the node only if all children are hidden (doesn't reset the search term for child nodes).
|
||||
/// </summary>
|
||||
Recurse |
||||
} |
||||
} |
||||