Browse Source

Merge pull request #1872 from cshung/dev/andrewau/ready-to-run

Introducing ILSpy.ReadyToRun
pull/1894/head
Siegfried Pammer 6 years ago committed by GitHub
parent
commit
d8e42d9255
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 43
      ICSharpCode.Decompiler/Metadata/AssemblyReferences.cs
  2. 71
      ILSpy.ReadyToRun/ILSpy.ReadyToRun.csproj
  3. 33
      ILSpy.ReadyToRun/Properties/AssemblyInfo.cs
  4. 187
      ILSpy.ReadyToRun/ReadyToRunLanguage.cs
  5. 10
      ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml
  6. 82
      ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs
  7. 58
      ILSpy.ReadyToRun/ReadyToRunOptions.cs
  8. 6
      ILSpy.sln
  9. 15
      ILSpy/LoadedAssembly.cs
  10. 2
      ILSpy/LoadedAssemblyExtensions.cs
  11. 2
      ILSpy/README.txt
  12. 2
      ILSpy/TextView/Asm-Mode.xshd
  13. 3
      NuGet.config
  14. 2
      README.md
  15. 2
      doc/license.txt

43
ICSharpCode.Decompiler/Metadata/AssemblyReferences.cs

@ -17,14 +17,12 @@ @@ -17,14 +17,12 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Security.Cryptography;
using System.Text;
using ICSharpCode.Decompiler.Util;
namespace ICSharpCode.Decompiler.Metadata
{
@ -167,38 +165,51 @@ namespace ICSharpCode.Decompiler.Metadata @@ -167,38 +165,51 @@ namespace ICSharpCode.Decompiler.Metadata
{
static readonly SHA1 sha1 = SHA1.Create();
public PEFile Module { get; }
public AssemblyReferenceHandle Handle { get; }
readonly System.Reflection.Metadata.AssemblyReference entry;
System.Reflection.Metadata.AssemblyReference This() => Module.Metadata.GetAssemblyReference(Handle);
public MetadataReader Metadata { get; }
public AssemblyReferenceHandle Handle { get; }
public bool IsWindowsRuntime => (This().Flags & AssemblyFlags.WindowsRuntime) != 0;
public bool IsRetargetable => (This().Flags & AssemblyFlags.Retargetable) != 0;
public bool IsWindowsRuntime => (entry.Flags & AssemblyFlags.WindowsRuntime) != 0;
public bool IsRetargetable => (entry.Flags & AssemblyFlags.Retargetable) != 0;
public string Name => Module.Metadata.GetString(This().Name);
public string FullName => This().GetFullAssemblyName(Module.Metadata);
public Version Version => This().Version;
public string Culture => Module.Metadata.GetString(This().Culture);
public string Name => Metadata.GetString(entry.Name);
public string FullName => entry.GetFullAssemblyName(Metadata);
public Version Version => entry.Version;
public string Culture => Metadata.GetString(entry.Culture);
byte[] IAssemblyReference.PublicKeyToken => GetPublicKeyToken();
public byte[] GetPublicKeyToken()
{
var inst = This();
if (inst.PublicKeyOrToken.IsNil)
if (entry.PublicKeyOrToken.IsNil)
return null;
var bytes = Module.Metadata.GetBlobBytes(inst.PublicKeyOrToken);
if ((inst.Flags & AssemblyFlags.PublicKey) != 0) {
var bytes = Metadata.GetBlobBytes(entry.PublicKeyOrToken);
if ((entry.Flags & AssemblyFlags.PublicKey) != 0) {
return sha1.ComputeHash(bytes).Skip(12).ToArray();
}
return bytes;
}
public AssemblyReference(MetadataReader metadata, AssemblyReferenceHandle handle)
{
if (metadata == null)
throw new ArgumentNullException(nameof(metadata));
if (handle.IsNil)
throw new ArgumentNullException(nameof(handle));
Metadata = metadata;
Handle = handle;
entry = metadata.GetAssemblyReference(handle);
}
public AssemblyReference(PEFile module, AssemblyReferenceHandle handle)
{
Module = module ?? throw new ArgumentNullException(nameof(module));
if (module == null)
throw new ArgumentNullException(nameof(module));
if (handle.IsNil)
throw new ArgumentNullException(nameof(handle));
Metadata = module.Metadata;
Handle = handle;
entry = Metadata.GetAssemblyReference(handle);
}
public override string ToString()

71
ILSpy.ReadyToRun/ILSpy.ReadyToRun.csproj

@ -0,0 +1,71 @@ @@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<AssemblyName>ILSpy.ReadyToRun.Plugin</AssemblyName>
<LangVersion>7.2</LangVersion>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<EnableDefaultItems>false</EnableDefaultItems>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup>
<OutputPath>..\ILSpy\bin\$(Configuration)\</OutputPath>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ICSharpCode.Decompiler\ICSharpCode.Decompiler.csproj">
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\ILSpy\ILSpy.csproj">
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\SharpTreeView\ICSharpCode.TreeView.csproj">
<Private>False</Private>
</ProjectReference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System.Xaml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="ReadyToRunLanguage.cs" />
<Compile Include="ReadyToRunOptionPage.xaml.cs">
<DependentUpon>ReadyToRunOptionPage.xaml</DependentUpon>
</Compile>
<Compile Include="ReadyToRunOptions.cs" />
</ItemGroup>
<ItemGroup>
<Page Include="ReadyToRunOptionPage.xaml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Iced" Version="1.4.0" />
<PackageReference Include="ILCompiler.Reflection.ReadyToRun" Version="1.0.2-alpha" />
</ItemGroup>
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />
<Target Name="RemoveTransitiveProjectReferences" AfterTargets="IncludeTransitiveProjectReferences">
<ItemGroup>
<ProjectReference Remove="@(_TransitiveProjectReferences)" />
</ItemGroup>
</Target>
</Project>

33
ILSpy.ReadyToRun/Properties/AssemblyInfo.cs

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
#region Using directives
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
#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.ReadyToRun.Plugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ILSpy.ReadyToRun.Plugin")]
[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)]
[assembly: InternalsVisibleTo("ILSpy.ReadyToRun.Tests")]
// 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")]

187
ILSpy.ReadyToRun/ReadyToRunLanguage.cs

@ -0,0 +1,187 @@ @@ -0,0 +1,187 @@
// Copyright (c) 2018 Siegfried Pammer
//
// 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.Reflection.Metadata;
using System.Reflection.PortableExecutable;
using System.Runtime.CompilerServices;
using Iced.Intel;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.Solution;
using ICSharpCode.Decompiler.TypeSystem;
using ILCompiler.Reflection.ReadyToRun;
namespace ICSharpCode.ILSpy.ReadyToRun
{
[Export(typeof(Language))]
internal class ReadyToRunLanguage : Language
{
private static readonly ConditionalWeakTable<PEFile, R2RReaderCacheEntry> r2rReaders = new ConditionalWeakTable<PEFile, R2RReaderCacheEntry>();
public override string Name => "ReadyToRun";
public override string FileExtension {
get { return ".asm"; }
}
public override ProjectId DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
{
PEFile module = assembly.GetPEFileOrNull();
R2RReaderCacheEntry r2rReaderCacheEntry = GetReader(assembly, module);
if (r2rReaderCacheEntry.r2rReader == null) {
WriteCommentLine(output, r2rReaderCacheEntry.failureReason);
} else {
R2RReader reader = r2rReaderCacheEntry.r2rReader;
WriteCommentLine(output, "TODO - display ready to run information");
// TODO: display other header information
foreach (var method in reader.R2RMethods) {
WriteCommentLine(output, method.SignatureString);
}
}
return base.DecompileAssembly(assembly, output, options);
}
public override void DecompileMethod(IMethod method, ITextOutput output, DecompilationOptions options)
{
PEFile module = method.ParentModule.PEFile;
R2RReaderCacheEntry r2rReaderCacheEntry = GetReader(module.GetLoadedAssembly(), module);
if (r2rReaderCacheEntry.r2rReader == null) {
WriteCommentLine(output, r2rReaderCacheEntry.failureReason);
} else {
R2RReader reader = r2rReaderCacheEntry.r2rReader;
int bitness = -1;
if (reader.Machine == Machine.Amd64) {
bitness = 64;
} else {
Debug.Assert(reader.Machine == Machine.I386);
bitness = 32;
}
foreach (var m in reader.R2RMethods) {
if (m.MethodHandle == method.MetadataToken) {
// TODO: Indexing
foreach (RuntimeFunction runtimeFunction in m.RuntimeFunctions) {
WriteCommentLine(output, m.SignatureString);
byte[] code = new byte[runtimeFunction.Size];
for (int i = 0; i < runtimeFunction.Size; i++) {
code[i] = reader.Image[reader.GetOffset(runtimeFunction.StartAddress) + i];
}
Disassemble(output, code, bitness, (ulong)runtimeFunction.StartAddress);
output.WriteLine();
}
}
}
}
}
public override void WriteCommentLine(ITextOutput output, string comment)
{
output.WriteLine("; " + comment);
}
private void Disassemble(ITextOutput output, byte[] codeBytes, int bitness, ulong address)
{
// TODO: Decorate the disassembly with Unwind, GC and debug info
var codeReader = new ByteArrayCodeReader(codeBytes);
var decoder = Decoder.Create(bitness, codeReader);
decoder.IP = address;
ulong endRip = decoder.IP + (uint)codeBytes.Length;
var instructions = new InstructionList();
while (decoder.IP < endRip) {
decoder.Decode(out instructions.AllocUninitializedElement());
}
string disassemblyFormat = ReadyToRunOptions.GetDisassemblyFormat(null);
Formatter formatter = null;
if (disassemblyFormat.Equals(ReadyToRunOptions.intel)) {
formatter = new NasmFormatter();
} else {
Debug.Assert(disassemblyFormat.Equals(ReadyToRunOptions.gas));
formatter = new GasFormatter();
}
formatter.Options.DigitSeparator = "`";
formatter.Options.FirstOperandCharIndex = 10;
var tempOutput = new StringBuilderFormatterOutput();
foreach (var instr in instructions) {
formatter.Format(instr, tempOutput);
output.Write(instr.IP.ToString("X16"));
output.Write(" ");
int instrLen = instr.ByteLength;
int byteBaseIndex = (int)(instr.IP - address);
for (int i = 0; i < instrLen; i++)
output.Write(codeBytes[byteBaseIndex + i].ToString("X2"));
int missingBytes = 10 - instrLen;
for (int i = 0; i < missingBytes; i++)
output.Write(" ");
output.Write(" ");
output.WriteLine(tempOutput.ToStringAndReset());
}
}
private R2RReaderCacheEntry GetReader(LoadedAssembly assembly, PEFile module)
{
R2RReaderCacheEntry result;
lock (r2rReaders) {
if (!r2rReaders.TryGetValue(module, out result)) {
result = new R2RReaderCacheEntry();
try {
// TODO: avoid eager parsing
result.r2rReader = new R2RReader(new R2RAssemblyResolver(assembly), module.Metadata, module.Reader, module.FileName);
if (result.r2rReader.Machine != Machine.Amd64 && result.r2rReader.Machine != Machine.I386) {
result.failureReason = $"Architecture {result.r2rReader.Machine} is not currently supported.";
result.r2rReader = null;
}
} catch (BadImageFormatException e) {
result.failureReason = e.Message;
}
r2rReaders.Add(module, result);
}
}
return result;
}
private class R2RAssemblyResolver : ILCompiler.Reflection.ReadyToRun.IAssemblyResolver
{
private LoadedAssembly loadedAssembly;
public R2RAssemblyResolver(LoadedAssembly loadedAssembly)
{
this.loadedAssembly = loadedAssembly;
}
public bool Naked => false;
public bool SignatureBinary => false;
public bool InlineSignatureBinary => false;
public MetadataReader FindAssembly(MetadataReader metadataReader, AssemblyReferenceHandle assemblyReferenceHandle, string parentFile)
{
LoadedAssembly loadedAssembly = this.loadedAssembly.LookupReferencedAssembly(new Decompiler.Metadata.AssemblyReference(metadataReader, assemblyReferenceHandle));
return loadedAssembly?.GetPEFileOrNull()?.Metadata;
}
}
private class R2RReaderCacheEntry
{
public R2RReader r2rReader;
public string failureReason;
}
}
}

10
ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
<UserControl x:Class="ICSharpCode.ILSpy.ReadyToRun.ReadyToRunOptionPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock>Disassembly Format</TextBlock>
<ComboBox ItemsSource="{Binding DisassemblyFormats}" SelectedItem="{Binding DisassemblyFormat}"/>
</StackPanel>
</StackPanel>
</UserControl>

82
ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs

@ -0,0 +1,82 @@ @@ -0,0 +1,82 @@
// Copyright (c) 2018 Siegfried Pammer
//
// 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.ComponentModel;
using System.Windows.Controls;
using System.Xml.Linq;
using ICSharpCode.ILSpy.Options;
namespace ICSharpCode.ILSpy.ReadyToRun
{
[ExportOptionPage(Title = "ReadyToRun", Order = 0)]
partial class ReadyToRunOptionPage : UserControl, IOptionPage
{
public ReadyToRunOptionPage()
{
InitializeComponent();
}
public void Load(ILSpySettings settings)
{
Options s = new Options();
s.DisassemblyFormat = ReadyToRunOptions.GetDisassemblyFormat(settings);
this.DataContext = s;
}
public void LoadDefaults()
{
this.DataContext = new Options();
}
public void Save(XElement root)
{
Options s = (Options)this.DataContext;
ReadyToRunOptions.SetDisassemblyFormat(root, s.DisassemblyFormat);
}
}
internal class Options : INotifyPropertyChanged
{
public string[] DisassemblyFormats {
get {
return ReadyToRunOptions.disassemblyFormats;
}
}
private string disassemblyFormat;
public string DisassemblyFormat {
get { return disassemblyFormat; }
set {
if (disassemblyFormat != value) {
disassemblyFormat = value;
OnPropertyChanged(nameof(DisassemblyFormat));
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}

58
ILSpy.ReadyToRun/ReadyToRunOptions.cs

@ -0,0 +1,58 @@ @@ -0,0 +1,58 @@
// Copyright (c) 2018 Siegfried Pammer
//
// 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.Xml.Linq;
namespace ICSharpCode.ILSpy.ReadyToRun
{
internal class ReadyToRunOptions
{
private static readonly XNamespace ns = "http://www.ilspy.net/ready-to-run";
internal static string intel = "Intel";
internal static string gas = "AT & T";
internal static string[] disassemblyFormats = new string[] { intel, gas };
public static string GetDisassemblyFormat(ILSpySettings settings)
{
if (settings == null) {
settings = ILSpySettings.Load();
}
XElement e = settings[ns + "ReadyToRunOptions"];
XAttribute a = e.Attribute("DisassemblyFormat");
if (a == null) {
return ReadyToRunOptions.intel;
} else {
return (string)a;
}
}
public static void SetDisassemblyFormat(XElement root, string disassemblyFormat)
{
XElement section = new XElement(ns + "ReadyToRunOptions");
section.SetAttributeValue("DisassemblyFormat", disassemblyFormat);
XElement existingElement = root.Element(ns + "ReadyToRunOptions");
if (existingElement != null) {
existingElement.ReplaceWith(section);
} else {
root.Add(section);
}
}
}
}

6
ILSpy.sln

@ -33,6 +33,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.Decompiler.PdbP @@ -33,6 +33,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.Decompiler.PdbP
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILSpy.Tests", "ILSpy.Tests\ILSpy.Tests.csproj", "{B51C6636-B8D1-4200-9869-08F2689DE6C2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ILSpy.ReadyToRun", "ILSpy.ReadyToRun\ILSpy.ReadyToRun.csproj", "{0313F581-C63B-43BB-AA9B-07615DABD8A3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -79,6 +81,10 @@ Global @@ -79,6 +81,10 @@ Global
{B51C6636-B8D1-4200-9869-08F2689DE6C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B51C6636-B8D1-4200-9869-08F2689DE6C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B51C6636-B8D1-4200-9869-08F2689DE6C2}.Release|Any CPU.Build.0 = Release|Any CPU
{0313F581-C63B-43BB-AA9B-07615DABD8A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0313F581-C63B-43BB-AA9B-07615DABD8A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0313F581-C63B-43BB-AA9B-07615DABD8A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0313F581-C63B-43BB-AA9B-07615DABD8A3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

15
ILSpy/LoadedAssembly.cs

@ -55,6 +55,7 @@ namespace ICSharpCode.ILSpy @@ -55,6 +55,7 @@ namespace ICSharpCode.ILSpy
this.assemblyTask = Task.Factory.StartNew(LoadAssembly, stream); // requires that this.fileName is set
this.shortName = Path.GetFileNameWithoutExtension(fileName);
this.resolver = new MyAssemblyResolver(this);
}
/// <summary>
@ -223,9 +224,11 @@ namespace ICSharpCode.ILSpy @@ -223,9 +224,11 @@ namespace ICSharpCode.ILSpy
}
}
readonly MyAssemblyResolver resolver;
public IAssemblyResolver GetAssemblyResolver()
{
return new MyAssemblyResolver(this);
return resolver;
}
/// <summary>
@ -266,7 +269,8 @@ namespace ICSharpCode.ILSpy @@ -266,7 +269,8 @@ namespace ICSharpCode.ILSpy
}
}
static Dictionary<string, LoadedAssembly> loadingAssemblies = new Dictionary<string, LoadedAssembly>();
static readonly Dictionary<string, LoadedAssembly> loadingAssemblies = new Dictionary<string, LoadedAssembly>();
MyUniversalResolver universalResolver;
LoadedAssembly LookupReferencedAssemblyInternal(Decompiler.Metadata.IAssemblyReference fullName, bool isWinRT)
{
@ -286,8 +290,11 @@ namespace ICSharpCode.ILSpy @@ -286,8 +290,11 @@ namespace ICSharpCode.ILSpy
}
}
var resolver = new MyUniversalResolver(this);
file = resolver.FindAssemblyFile(fullName);
if (universalResolver == null) {
universalResolver = new MyUniversalResolver(this);
}
file = universalResolver.FindAssemblyFile(fullName);
foreach (LoadedAssembly loaded in assemblyList.GetAssemblies()) {
if (loaded.FileName.Equals(file, StringComparison.OrdinalIgnoreCase)) {

2
ILSpy/LoadedAssemblyExtensions.cs

@ -45,7 +45,7 @@ namespace ICSharpCode.ILSpy @@ -45,7 +45,7 @@ namespace ICSharpCode.ILSpy
return GetLoadedAssembly(file).GetTypeSystemOrNull();
}
static LoadedAssembly GetLoadedAssembly(PEFile file)
public static LoadedAssembly GetLoadedAssembly(this PEFile file)
{
if (file == null)
throw new ArgumentNullException(nameof(file));

2
ILSpy/README.txt

@ -13,5 +13,7 @@ Included open-source libraries: @@ -13,5 +13,7 @@ Included open-source libraries:
SharpTreeView: LGPL
ILSpy.BamlDecompiler: MIT License
CommandLineUtils: Apache License 2.0 (part of ICSharpCode.Decompiler.Console)
ILCompiler.Reflection.ReadyToRun: MIT License (part of ILSpy.ReadyToRun)
Iced: MIT License (part of ILSpy.ReadyToRun)
Current and past contributors: https://github.com/icsharpcode/ILSpy/graphs/contributors

2
ILSpy/TextView/Asm-Mode.xshd

@ -1190,7 +1190,7 @@ @@ -1190,7 +1190,7 @@
<Begin>;</Begin>
</Span>
<Rule color="NumberLiteral">
\b0[xX][0-9a-fA-F]+ # hex number
\b(0[xXhH])?[0-9a-fA-F_`]+[h]? # hex number
|
( \b\d+(\.[0-9]+)? #number with optional floating point
| \.[0-9]+ #or just starting with floating point

3
NuGet.config

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
<packageSources>
<add key="Nuget Official" value="https://api.nuget.org/v3/index.json" />
<add key="ILSpy" value="https://ci.appveyor.com/nuget/ilspy-masterfeed" />
<add key="DotNet MyGet" value="https://dotnet.myget.org/F/symreader-converter/api/v3/index.json" />
<add key="DotNet MyGet" value="https://dotnet.myget.org/F/symreader-converter/api/v3/index.json" />
<add key="cshung_public_development" value="https://pkgs.dev.azure.com/cshung/public/_packaging/development/nuget/v3/index.json" />
</packageSources>
</configuration>

2
README.md

@ -43,6 +43,8 @@ Included open-source libraries: @@ -43,6 +43,8 @@ Included open-source libraries:
* SharpTreeView: LGPL
* ILSpy.BamlDecompiler: MIT license
* CommandLineUtils: Apache License 2.0 (part of ICSharpCode.Decompiler.Console)
* ILCompiler.Reflection.ReadyToRun: MIT License (part of ILSpy.ReadyToRun)
* Iced: MIT License (part of ILSpy.ReadyToRun)
How to build
------------

2
doc/license.txt

@ -1,5 +1,7 @@ @@ -1,5 +1,7 @@
The following MIT license applies to ILSpy, NRefactory and ICSharpCode.Decompiler.
Mono.Cecil also uses the MIT license (Copyright JB Evain).
ILCompiler.Reflection.ReadyToRun also uses the MIT license (Copyright Microsoft).
Iced also uses the MIT license (Copyright 0xd4d).
AvalonEdit and SharpTreeView use LGPL, which can be found in the LGPL.txt file.
ILSpy.BamlDecompiler uses the MS-PL, which can be found in the MS-PL.txt file.

Loading…
Cancel
Save