mirror of https://github.com/icsharpcode/ILSpy.git
110 changed files with 2190 additions and 981 deletions
@ -0,0 +1,117 @@ |
|||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness |
||||||
|
{ |
||||||
|
class StringConcat |
||||||
|
{ |
||||||
|
private class C |
||||||
|
{ |
||||||
|
int i; |
||||||
|
|
||||||
|
public C(int i) |
||||||
|
{ |
||||||
|
Console.WriteLine(" new C(" + i + ")"); |
||||||
|
this.i = i; |
||||||
|
} |
||||||
|
|
||||||
|
public override string ToString() |
||||||
|
{ |
||||||
|
Console.WriteLine(" C(" + i + ").ToString()"); |
||||||
|
return (i++).ToString(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private struct S |
||||||
|
{ |
||||||
|
int i; |
||||||
|
|
||||||
|
public S(int i) |
||||||
|
{ |
||||||
|
Console.WriteLine(" new C(" + i + ")"); |
||||||
|
this.i = i; |
||||||
|
} |
||||||
|
|
||||||
|
public override string ToString() |
||||||
|
{ |
||||||
|
Console.WriteLine(" S(" + i + ").ToString()"); |
||||||
|
return (i++).ToString(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static string Space() |
||||||
|
{ |
||||||
|
Console.WriteLine(" Space()"); |
||||||
|
return " "; |
||||||
|
} |
||||||
|
|
||||||
|
static void TestClass() |
||||||
|
{ |
||||||
|
Console.WriteLine("string + C:"); |
||||||
|
Console.WriteLine(Space() + new C(1)); |
||||||
|
|
||||||
|
Console.WriteLine("C + string:"); |
||||||
|
Console.WriteLine(new C(2) + Space()); |
||||||
|
|
||||||
|
Console.WriteLine("C + string + C:"); |
||||||
|
Console.WriteLine(new C(3) + Space() + new C(4)); |
||||||
|
|
||||||
|
Console.WriteLine("string + C + C:"); |
||||||
|
Console.WriteLine(Space() + new C(5) + new C(6)); |
||||||
|
|
||||||
|
Console.WriteLine("string.Concat(C, string, C):"); |
||||||
|
Console.WriteLine(string.Concat(new C(10), Space(), new C(11))); |
||||||
|
|
||||||
|
Console.WriteLine("string.Concat(string.Concat(C, string), C):"); |
||||||
|
Console.WriteLine(string.Concat(string.Concat(new C(15), Space()), new C(16))); |
||||||
|
|
||||||
|
Console.WriteLine("string.Concat(C, string.Concat(string, C)):"); |
||||||
|
Console.WriteLine(string.Concat(new C(20), string.Concat(Space(), new C(21)))); |
||||||
|
|
||||||
|
Console.WriteLine("string.Concat(C, string) + C:"); |
||||||
|
Console.WriteLine(string.Concat(new C(30), Space()) + new C(31)); |
||||||
|
} |
||||||
|
|
||||||
|
static void TestStruct() |
||||||
|
{ |
||||||
|
Console.WriteLine("string + S:"); |
||||||
|
Console.WriteLine(Space() + new S(1)); |
||||||
|
|
||||||
|
Console.WriteLine("S + string:"); |
||||||
|
Console.WriteLine(new S(2) + Space()); |
||||||
|
|
||||||
|
Console.WriteLine("S + string + S:"); |
||||||
|
Console.WriteLine(new S(3) + Space() + new S(4)); |
||||||
|
|
||||||
|
Console.WriteLine("string + S + S:"); |
||||||
|
Console.WriteLine(Space() + new S(5) + new S(6)); |
||||||
|
|
||||||
|
Console.WriteLine("string.Concat(S, string, S):"); |
||||||
|
Console.WriteLine(string.Concat(new S(10), Space(), new S(11))); |
||||||
|
|
||||||
|
Console.WriteLine("string.Concat(string.Concat(S, string), S):"); |
||||||
|
Console.WriteLine(string.Concat(string.Concat(new S(15), Space()), new S(16))); |
||||||
|
|
||||||
|
Console.WriteLine("string.Concat(S, string.Concat(string, S)):"); |
||||||
|
Console.WriteLine(string.Concat(new S(20), string.Concat(Space(), new S(21)))); |
||||||
|
|
||||||
|
Console.WriteLine("string.Concat(S, string) + S:"); |
||||||
|
Console.WriteLine(string.Concat(new S(30), Space()) + new S(31)); |
||||||
|
} |
||||||
|
|
||||||
|
static void TestStructMutation() |
||||||
|
{ |
||||||
|
Console.WriteLine("TestStructMutation:"); |
||||||
|
S s = new S(0); |
||||||
|
Console.WriteLine(Space() + s); |
||||||
|
Console.WriteLine(Space() + s.ToString()); |
||||||
|
Console.WriteLine(s); |
||||||
|
} |
||||||
|
|
||||||
|
static void Main() |
||||||
|
{ |
||||||
|
TestClass(); |
||||||
|
TestStruct(); |
||||||
|
TestStructMutation(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
using System; |
||||||
|
using System.Runtime.CompilerServices; |
||||||
|
|
||||||
|
[assembly: Extension] |
||||||
|
|
||||||
|
namespace ICSharpCode.Decompiler.Tests.TestCases.Ugly |
||||||
|
{ |
||||||
|
[Extension] |
||||||
|
internal static class NoExtensionMethods |
||||||
|
{ |
||||||
|
[Extension] |
||||||
|
internal static Func<T> AsFunc<T>(T value) where T : class |
||||||
|
{ |
||||||
|
return new Func<T>(value, __ldftn(Return)); |
||||||
|
} |
||||||
|
|
||||||
|
[Extension] |
||||||
|
private static T Return<T>(T value) |
||||||
|
{ |
||||||
|
return value; |
||||||
|
} |
||||||
|
|
||||||
|
internal static Func<int, int> ExtensionMethodAsStaticFunc() |
||||||
|
{ |
||||||
|
return Return; |
||||||
|
} |
||||||
|
|
||||||
|
internal static Func<object> ExtensionMethodBoundToNull() |
||||||
|
{ |
||||||
|
return new Func<object>(null, __ldftn(Return)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.Decompiler.Tests.TestCases.Ugly |
||||||
|
{ |
||||||
|
internal static class NoExtensionMethods |
||||||
|
{ |
||||||
|
internal static Func<T> AsFunc<T>(this T value) where T : class |
||||||
|
{ |
||||||
|
return new Func<T>(value.Return); |
||||||
|
} |
||||||
|
|
||||||
|
private static T Return<T>(this T value) |
||||||
|
{ |
||||||
|
return value; |
||||||
|
} |
||||||
|
|
||||||
|
internal static Func<int, int> ExtensionMethodAsStaticFunc() |
||||||
|
{ |
||||||
|
return Return; |
||||||
|
} |
||||||
|
|
||||||
|
internal static Func<object> ExtensionMethodBoundToNull() |
||||||
|
{ |
||||||
|
return ((object)null).Return; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,93 @@ |
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Metadata version: v4.0.30319 |
||||||
|
.assembly extern mscorlib |
||||||
|
{ |
||||||
|
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. |
||||||
|
.ver 4:0:0:0 |
||||||
|
} |
||||||
|
.assembly NoExtensionMethods |
||||||
|
{ |
||||||
|
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) |
||||||
|
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) |
||||||
|
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx |
||||||
|
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. |
||||||
|
|
||||||
|
// --- The following custom attribute is added automatically, do not uncomment ------- |
||||||
|
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 02 00 00 00 00 00 ) |
||||||
|
|
||||||
|
.permissionset reqmin |
||||||
|
= {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} |
||||||
|
.hash algorithm 0x00008004 |
||||||
|
.ver 0:0:0:0 |
||||||
|
} |
||||||
|
.module NoExtensionMethods.dll |
||||||
|
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) |
||||||
|
.imagebase 0x10000000 |
||||||
|
.file alignment 0x00000200 |
||||||
|
.stackreserve 0x00100000 |
||||||
|
.subsystem 0x0003 // WINDOWS_CUI |
||||||
|
.corflags 0x00000001 // ILONLY |
||||||
|
|
||||||
|
|
||||||
|
// =============== CLASS MEMBERS DECLARATION =================== |
||||||
|
|
||||||
|
.class private abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoExtensionMethods |
||||||
|
extends [mscorlib]System.Object |
||||||
|
{ |
||||||
|
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) |
||||||
|
.method assembly hidebysig static class [mscorlib]System.Func`1<!!T> |
||||||
|
AsFunc<class T>(!!T 'value') cil managed |
||||||
|
{ |
||||||
|
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) |
||||||
|
// Code size 18 (0x12) |
||||||
|
.maxstack 8 |
||||||
|
IL_0000: ldarg.0 |
||||||
|
IL_0001: box !!T |
||||||
|
IL_0006: ldftn !!0 ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoExtensionMethods::Return<!!0>(!!0) |
||||||
|
IL_000c: newobj instance void class [mscorlib]System.Func`1<!!T>::.ctor(object, |
||||||
|
native int) |
||||||
|
IL_0011: ret |
||||||
|
} // end of method NoExtensionMethods::AsFunc |
||||||
|
|
||||||
|
.method private hidebysig static !!T Return<T>(!!T 'value') cil managed |
||||||
|
{ |
||||||
|
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) |
||||||
|
// Code size 2 (0x2) |
||||||
|
.maxstack 8 |
||||||
|
IL_0000: ldarg.0 |
||||||
|
IL_0001: ret |
||||||
|
} // end of method NoExtensionMethods::Return |
||||||
|
|
||||||
|
.method assembly hidebysig static class [mscorlib]System.Func`2<int32,int32> |
||||||
|
ExtensionMethodAsStaticFunc() cil managed |
||||||
|
{ |
||||||
|
// Code size 13 (0xd) |
||||||
|
.maxstack 8 |
||||||
|
IL_0000: ldnull |
||||||
|
IL_0001: ldftn !!0 ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoExtensionMethods::Return<int32>(!!0) |
||||||
|
IL_0007: newobj instance void class [mscorlib]System.Func`2<int32,int32>::.ctor(object, |
||||||
|
native int) |
||||||
|
IL_000c: ret |
||||||
|
} // end of method NoExtensionMethods::ExtensionMethodAsStaticFunc |
||||||
|
|
||||||
|
.method assembly hidebysig static class [mscorlib]System.Func`1<object> |
||||||
|
ExtensionMethodBoundToNull() cil managed |
||||||
|
{ |
||||||
|
// Code size 13 (0xd) |
||||||
|
.maxstack 8 |
||||||
|
IL_0000: ldnull |
||||||
|
IL_0001: ldftn !!0 ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoExtensionMethods::Return<object>(!!0) |
||||||
|
IL_0007: newobj instance void class [mscorlib]System.Func`1<object>::.ctor(object, |
||||||
|
native int) |
||||||
|
IL_000c: ret |
||||||
|
} // end of method NoExtensionMethods::ExtensionMethodBoundToNull |
||||||
|
|
||||||
|
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoExtensionMethods |
||||||
|
|
||||||
|
|
||||||
|
// ============================================================= |
||||||
|
|
||||||
|
// *********** DISASSEMBLY COMPLETE *********************** |
@ -0,0 +1,117 @@ |
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Metadata version: v4.0.30319 |
||||||
|
.assembly extern mscorlib |
||||||
|
{ |
||||||
|
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. |
||||||
|
.ver 4:0:0:0 |
||||||
|
} |
||||||
|
.assembly NoExtensionMethods |
||||||
|
{ |
||||||
|
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) |
||||||
|
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) |
||||||
|
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx |
||||||
|
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. |
||||||
|
|
||||||
|
// --- The following custom attribute is added automatically, do not uncomment ------- |
||||||
|
// .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(valuetype [mscorlib]System.Diagnostics.DebuggableAttribute/DebuggingModes) = ( 01 00 07 01 00 00 00 00 ) |
||||||
|
|
||||||
|
.permissionset reqmin |
||||||
|
= {[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'SkipVerification' = bool(true)}} |
||||||
|
.hash algorithm 0x00008004 |
||||||
|
.ver 0:0:0:0 |
||||||
|
} |
||||||
|
.module NoExtensionMethods.dll |
||||||
|
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) |
||||||
|
.imagebase 0x10000000 |
||||||
|
.file alignment 0x00000200 |
||||||
|
.stackreserve 0x00100000 |
||||||
|
.subsystem 0x0003 // WINDOWS_CUI |
||||||
|
.corflags 0x00000001 // ILONLY |
||||||
|
|
||||||
|
|
||||||
|
// =============== CLASS MEMBERS DECLARATION =================== |
||||||
|
|
||||||
|
.class private abstract auto ansi sealed beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoExtensionMethods |
||||||
|
extends [mscorlib]System.Object |
||||||
|
{ |
||||||
|
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) |
||||||
|
.method assembly hidebysig static class [mscorlib]System.Func`1<!!T> |
||||||
|
AsFunc<class T>(!!T 'value') cil managed |
||||||
|
{ |
||||||
|
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) |
||||||
|
// Code size 23 (0x17) |
||||||
|
.maxstack 2 |
||||||
|
.locals init (class [mscorlib]System.Func`1<!!T> V_0) |
||||||
|
IL_0000: nop |
||||||
|
IL_0001: ldarg.0 |
||||||
|
IL_0002: box !!T |
||||||
|
IL_0007: ldftn !!0 ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoExtensionMethods::Return<!!0>(!!0) |
||||||
|
IL_000d: newobj instance void class [mscorlib]System.Func`1<!!T>::.ctor(object, |
||||||
|
native int) |
||||||
|
IL_0012: stloc.0 |
||||||
|
IL_0013: br.s IL_0015 |
||||||
|
|
||||||
|
IL_0015: ldloc.0 |
||||||
|
IL_0016: ret |
||||||
|
} // end of method NoExtensionMethods::AsFunc |
||||||
|
|
||||||
|
.method private hidebysig static !!T Return<T>(!!T 'value') cil managed |
||||||
|
{ |
||||||
|
.custom instance void [mscorlib]System.Runtime.CompilerServices.ExtensionAttribute::.ctor() = ( 01 00 00 00 ) |
||||||
|
// Code size 7 (0x7) |
||||||
|
.maxstack 1 |
||||||
|
.locals init (!!T V_0) |
||||||
|
IL_0000: nop |
||||||
|
IL_0001: ldarg.0 |
||||||
|
IL_0002: stloc.0 |
||||||
|
IL_0003: br.s IL_0005 |
||||||
|
|
||||||
|
IL_0005: ldloc.0 |
||||||
|
IL_0006: ret |
||||||
|
} // end of method NoExtensionMethods::Return |
||||||
|
|
||||||
|
.method assembly hidebysig static class [mscorlib]System.Func`2<int32,int32> |
||||||
|
ExtensionMethodAsStaticFunc() cil managed |
||||||
|
{ |
||||||
|
// Code size 18 (0x12) |
||||||
|
.maxstack 2 |
||||||
|
.locals init (class [mscorlib]System.Func`2<int32,int32> V_0) |
||||||
|
IL_0000: nop |
||||||
|
IL_0001: ldnull |
||||||
|
IL_0002: ldftn !!0 ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoExtensionMethods::Return<int32>(!!0) |
||||||
|
IL_0008: newobj instance void class [mscorlib]System.Func`2<int32,int32>::.ctor(object, |
||||||
|
native int) |
||||||
|
IL_000d: stloc.0 |
||||||
|
IL_000e: br.s IL_0010 |
||||||
|
|
||||||
|
IL_0010: ldloc.0 |
||||||
|
IL_0011: ret |
||||||
|
} // end of method NoExtensionMethods::ExtensionMethodAsStaticFunc |
||||||
|
|
||||||
|
.method assembly hidebysig static class [mscorlib]System.Func`1<object> |
||||||
|
ExtensionMethodBoundToNull() cil managed |
||||||
|
{ |
||||||
|
// Code size 18 (0x12) |
||||||
|
.maxstack 2 |
||||||
|
.locals init (class [mscorlib]System.Func`1<object> V_0) |
||||||
|
IL_0000: nop |
||||||
|
IL_0001: ldnull |
||||||
|
IL_0002: ldftn !!0 ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoExtensionMethods::Return<object>(!!0) |
||||||
|
IL_0008: newobj instance void class [mscorlib]System.Func`1<object>::.ctor(object, |
||||||
|
native int) |
||||||
|
IL_000d: stloc.0 |
||||||
|
IL_000e: br.s IL_0010 |
||||||
|
|
||||||
|
IL_0010: ldloc.0 |
||||||
|
IL_0011: ret |
||||||
|
} // end of method NoExtensionMethods::ExtensionMethodBoundToNull |
||||||
|
|
||||||
|
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Ugly.NoExtensionMethods |
||||||
|
|
||||||
|
|
||||||
|
// ============================================================= |
||||||
|
|
||||||
|
// *********** DISASSEMBLY COMPLETE *********************** |
@ -0,0 +1,57 @@ |
|||||||
|
// 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.Collections.Generic; |
||||||
|
using System.Linq; |
||||||
|
using System.Text; |
||||||
|
using ICSharpCode.Decompiler.IL.Transforms; |
||||||
|
using ICSharpCode.Decompiler.TypeSystem; |
||||||
|
|
||||||
|
namespace ICSharpCode.Decompiler.IL |
||||||
|
{ |
||||||
|
class IntroduceRefReadOnlyModifierOnLocals : IILTransform |
||||||
|
{ |
||||||
|
public void Run(ILFunction function, ILTransformContext context) |
||||||
|
{ |
||||||
|
foreach (var variable in function.Variables) { |
||||||
|
if (variable.Type.Kind != TypeKind.ByReference || variable.Kind == VariableKind.Parameter) |
||||||
|
continue; |
||||||
|
// ref readonly
|
||||||
|
if (IsUsedAsRefReadonly(variable)) { |
||||||
|
variable.IsRefReadOnly = true; |
||||||
|
continue; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Infer ref readonly type from usage:
|
||||||
|
/// An ILVariable should be marked as readonly,
|
||||||
|
/// if it's a "by-ref-like" type and the initialized value is known to be readonly.
|
||||||
|
/// </summary>
|
||||||
|
bool IsUsedAsRefReadonly(ILVariable variable) |
||||||
|
{ |
||||||
|
foreach (var store in variable.StoreInstructions.OfType<StLoc>()) { |
||||||
|
if (ILInlining.IsReadonlyReference(store.Value)) |
||||||
|
return true; |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,3 @@ |
|||||||
|
Test cases for various types of projects as well as corresponding test plans are located in a separate repository. |
||||||
|
|
||||||
|
[https://github.com/icsharpcode/ILSpy-Addin-tests](https://github.com/icsharpcode/ILSpy-Addin-tests) |
@ -0,0 +1,52 @@ |
|||||||
|
// 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.Linq; |
||||||
|
using ICSharpCode.ILSpy.Properties; |
||||||
|
using ICSharpCode.ILSpy.TextView; |
||||||
|
using ICSharpCode.ILSpy.TreeNodes; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy.Commands |
||||||
|
{ |
||||||
|
// [ExportContextMenuEntry(Header = nameof(Resources.DecompileToNewPanel), Icon = "images/Search", Category = nameof(Resources.Analyze), Order = 90)]
|
||||||
|
internal sealed class DecompileInNewViewCommand : IContextMenuEntry |
||||||
|
{ |
||||||
|
public bool IsVisible(TextViewContext context) |
||||||
|
{ |
||||||
|
if (context.SelectedTreeNodes == null) |
||||||
|
return false; |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsEnabled(TextViewContext context) |
||||||
|
{ |
||||||
|
if (context.SelectedTreeNodes == null) |
||||||
|
return false; |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
public async void Execute(TextViewContext context) |
||||||
|
{ |
||||||
|
var dtv = new DecompilerTextView(); |
||||||
|
var nodes = context.SelectedTreeNodes.Cast<ILSpyTreeNode>().ToArray(); |
||||||
|
var title = string.Join(", ", nodes.Select(x => x.ToString())); |
||||||
|
MainWindow.Instance.ShowInNewPane(title, dtv, PanePosition.Document); |
||||||
|
await dtv.DecompileAsync(MainWindow.Instance.CurrentLanguage, nodes, new DecompilationOptions()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,76 +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.Windows; |
|
||||||
using System.Windows.Controls; |
|
||||||
using System.Windows.Input; |
|
||||||
|
|
||||||
namespace ICSharpCode.ILSpy.Controls |
|
||||||
{ |
|
||||||
class DockedPane : Control |
|
||||||
{ |
|
||||||
static DockedPane() |
|
||||||
{ |
|
||||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(DockedPane), new FrameworkPropertyMetadata(typeof(DockedPane))); |
|
||||||
} |
|
||||||
|
|
||||||
public static readonly DependencyProperty TitleProperty = |
|
||||||
DependencyProperty.Register("Title", typeof(string), typeof(DockedPane)); |
|
||||||
|
|
||||||
public string Title { |
|
||||||
get { return (string)GetValue(TitleProperty); } |
|
||||||
set { SetValue(TitleProperty, value); } |
|
||||||
} |
|
||||||
|
|
||||||
public static readonly DependencyProperty ContentProperty = |
|
||||||
DependencyProperty.Register("Content", typeof(object), typeof(DockedPane)); |
|
||||||
|
|
||||||
public object Content { |
|
||||||
get { return GetValue(ContentProperty); } |
|
||||||
set { SetValue(ContentProperty, value); } |
|
||||||
} |
|
||||||
|
|
||||||
public override void OnApplyTemplate() |
|
||||||
{ |
|
||||||
base.OnApplyTemplate(); |
|
||||||
Button closeButton = (Button)this.Template.FindName("PART_Close", this); |
|
||||||
if (closeButton != null) { |
|
||||||
closeButton.Click += closeButton_Click; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
void closeButton_Click(object sender, RoutedEventArgs e) |
|
||||||
{ |
|
||||||
if (CloseButtonClicked != null) |
|
||||||
CloseButtonClicked(this, e); |
|
||||||
} |
|
||||||
|
|
||||||
public event EventHandler CloseButtonClicked; |
|
||||||
|
|
||||||
protected override void OnKeyDown(KeyEventArgs e) |
|
||||||
{ |
|
||||||
base.OnKeyDown(e); |
|
||||||
if (e.Key == Key.F4 && e.KeyboardDevice.Modifiers == ModifierKeys.Control || e.Key == Key.Escape) { |
|
||||||
if (CloseButtonClicked != null) |
|
||||||
CloseButtonClicked(this, e); |
|
||||||
e.Handled = true; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,50 @@ |
|||||||
|
using System; |
||||||
|
using System.IO; |
||||||
|
using System.Linq; |
||||||
|
using System.Xml; |
||||||
|
using System.Xml.Linq; |
||||||
|
using Xceed.Wpf.AvalonDock.Layout.Serialization; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy.Docking |
||||||
|
{ |
||||||
|
public class DockLayoutSettings |
||||||
|
{ |
||||||
|
private string rawSettings; |
||||||
|
|
||||||
|
public bool Valid => rawSettings != null; |
||||||
|
|
||||||
|
public DockLayoutSettings(XElement element) |
||||||
|
{ |
||||||
|
if ((element != null) && element.HasElements) { |
||||||
|
rawSettings = element.Elements().FirstOrDefault()?.ToString(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public XElement SaveAsXml() |
||||||
|
{ |
||||||
|
try { |
||||||
|
return XElement.Parse(rawSettings); |
||||||
|
} catch (Exception) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void Deserialize(XmlLayoutSerializer serializer) |
||||||
|
{ |
||||||
|
if (!Valid) |
||||||
|
return; |
||||||
|
|
||||||
|
using (StringReader reader = new StringReader(rawSettings)) { |
||||||
|
serializer.Deserialize(reader); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void Serialize(XmlLayoutSerializer serializer) |
||||||
|
{ |
||||||
|
using (StringWriter fs = new StringWriter()) { |
||||||
|
serializer.Serialize(fs); |
||||||
|
rawSettings = fs.ToString(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
using System.Windows; |
||||||
|
using System.Windows.Controls; |
||||||
|
using Xceed.Wpf.AvalonDock.Layout; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy.Docking |
||||||
|
{ |
||||||
|
public static class DockingHelper |
||||||
|
{ |
||||||
|
public static void DockHorizontal(LayoutContent layoutContent, ILayoutElement paneRelativeTo, GridLength dockHeight, bool dockBefore = false) |
||||||
|
{ |
||||||
|
if (paneRelativeTo is ILayoutDocumentPane parentDocumentPane) { |
||||||
|
var parentDocumentGroup = paneRelativeTo.FindParent<LayoutDocumentPaneGroup>(); |
||||||
|
if (parentDocumentGroup == null) { |
||||||
|
var grandParent = parentDocumentPane.Parent as ILayoutContainer; |
||||||
|
parentDocumentGroup = new LayoutDocumentPaneGroup() { Orientation = System.Windows.Controls.Orientation.Vertical }; |
||||||
|
grandParent.ReplaceChild(paneRelativeTo, parentDocumentGroup); |
||||||
|
parentDocumentGroup.Children.Add(parentDocumentPane); |
||||||
|
} |
||||||
|
parentDocumentGroup.Orientation = System.Windows.Controls.Orientation.Vertical; |
||||||
|
int indexOfParentPane = parentDocumentGroup.IndexOfChild(parentDocumentPane); |
||||||
|
var layoutDocumentPane = new LayoutDocumentPane(layoutContent) { DockHeight = dockHeight }; |
||||||
|
parentDocumentGroup.InsertChildAt(dockBefore ? indexOfParentPane : indexOfParentPane + 1, layoutDocumentPane); |
||||||
|
layoutContent.IsActive = true; |
||||||
|
layoutContent.Root.CollectGarbage(); |
||||||
|
Application.Current.MainWindow.Dispatcher.Invoke(() => { |
||||||
|
|
||||||
|
layoutDocumentPane.DockHeight = dockHeight; |
||||||
|
}, System.Windows.Threading.DispatcherPriority.Loaded); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,9 @@ |
|||||||
|
namespace ICSharpCode.ILSpy |
||||||
|
{ |
||||||
|
public enum PanePosition |
||||||
|
{ |
||||||
|
Top, |
||||||
|
Bottom, |
||||||
|
Document |
||||||
|
} |
||||||
|
} |
@ -1,20 +1,10 @@ |
|||||||
<!-- This file was generated by the AiToXaml tool.--> |
<!-- This file was generated by the AiToXaml tool.--> |
||||||
<!-- Tool Version: 14.0.22307.0 --> |
<!-- Tool Version: 14.0.22307.0 --> |
||||||
<Viewbox Width="16" Height="16" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> |
<DrawingGroup xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> |
||||||
<Rectangle Width="16" Height="16"> |
|
||||||
<Rectangle.Fill> |
|
||||||
<DrawingBrush> |
|
||||||
<DrawingBrush.Drawing> |
|
||||||
<DrawingGroup> |
|
||||||
<DrawingGroup.Children> |
<DrawingGroup.Children> |
||||||
<GeometryDrawing Brush="#00FFFFFF" Geometry="F1M16,16L0,16 0,0 16,0z" /> |
<GeometryDrawing Brush="#00FFFFFF" Geometry="F1M16,16L0,16 0,0 16,0z" /> |
||||||
<GeometryDrawing Brush="#FFF6F6F6" Geometry="F1M0.9999,-0.000199999999999534L0.9999,13.0008 5.0009,13.0008 5.0009,15.9998 15.9999,15.9998 15.9999,7.3788 11.6209,3.0008 10.6049,3.0008 7.6179,-0.000199999999999534z" /> |
<GeometryDrawing Brush="#FFF6F6F6" Geometry="F1M0.9999,-0.000199999999999534L0.9999,13.0008 5.0009,13.0008 5.0009,15.9998 15.9999,15.9998 15.9999,7.3788 11.6209,3.0008 10.6049,3.0008 7.6179,-0.000199999999999534z" /> |
||||||
<GeometryDrawing Brush="#FF424242" Geometry="F1M14,14L7,14 7,5 10,5 10,9 14,9z M6,11L3,11 3,2 6.798,2 8.81,4 6,4z M11,5.207L13.793,8 11,8z M11.207,4L10.19,4 7.202,1 2,1 2,12 6,12 6,15 15,15 15,7.793z" /> |
<GeometryDrawing Brush="#FF424242" Geometry="F1M14,14L7,14 7,5 10,5 10,9 14,9z M6,11L3,11 3,2 6.798,2 8.81,4 6,4z M11,5.207L13.793,8 11,8z M11.207,4L10.19,4 7.202,1 2,1 2,12 6,12 6,15 15,15 15,7.793z" /> |
||||||
<GeometryDrawing Brush="#FFF0EFF1" Geometry="F1M14,14L7,14 7,5 10,5 10,9 14,9z M6,11L3,11 3,2 6.798,2 8.81,4 6,4z M11,5.207L13.793,8 11,8z" /> |
<GeometryDrawing Brush="#FFF0EFF1" Geometry="F1M14,14L7,14 7,5 10,5 10,9 14,9z M6,11L3,11 3,2 6.798,2 8.81,4 6,4z M11,5.207L13.793,8 11,8z" /> |
||||||
</DrawingGroup.Children> |
</DrawingGroup.Children> |
||||||
</DrawingGroup> |
</DrawingGroup> |
||||||
</DrawingBrush.Drawing> |
|
||||||
</DrawingBrush> |
|
||||||
</Rectangle.Fill> |
|
||||||
</Rectangle> |
|
||||||
</Viewbox> |
|
||||||
|
@ -0,0 +1,122 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Concurrent; |
||||||
|
using System.Text.RegularExpressions; |
||||||
|
using System.Threading; |
||||||
|
using System.Windows.Media; |
||||||
|
using ICSharpCode.Decompiler.Metadata; |
||||||
|
using ICSharpCode.Decompiler.TypeSystem; |
||||||
|
using ICSharpCode.ILSpy.TreeNodes; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy.Search |
||||||
|
{ |
||||||
|
abstract class AbstractEntitySearchStrategy : AbstractSearchStrategy |
||||||
|
{ |
||||||
|
protected readonly Language language; |
||||||
|
protected readonly ApiVisibility apiVisibility; |
||||||
|
|
||||||
|
protected AbstractEntitySearchStrategy(Language language, ApiVisibility apiVisibility, IProducerConsumerCollection<SearchResult> resultQueue, params string[] terms) |
||||||
|
: base(resultQueue, terms) |
||||||
|
{ |
||||||
|
this.language = language; |
||||||
|
this.apiVisibility = apiVisibility; |
||||||
|
} |
||||||
|
|
||||||
|
protected bool CheckVisibility(IEntity entity) |
||||||
|
{ |
||||||
|
if (apiVisibility == ApiVisibility.All) |
||||||
|
return true; |
||||||
|
|
||||||
|
do { |
||||||
|
if (apiVisibility == ApiVisibility.PublicOnly) { |
||||||
|
if (!(entity.Accessibility == Accessibility.Public || |
||||||
|
entity.Accessibility == Accessibility.Protected || |
||||||
|
entity.Accessibility == Accessibility.ProtectedOrInternal)) |
||||||
|
return false; |
||||||
|
} else if (apiVisibility == ApiVisibility.PublicAndInternal) { |
||||||
|
if (!language.ShowMember(entity)) |
||||||
|
return false; |
||||||
|
} |
||||||
|
entity = entity.DeclaringTypeDefinition; |
||||||
|
} |
||||||
|
while (entity != null); |
||||||
|
|
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
protected void OnFoundResult(IEntity entity) |
||||||
|
{ |
||||||
|
var result = ResultFromEntity(entity); |
||||||
|
OnFoundResult(result); |
||||||
|
} |
||||||
|
|
||||||
|
SearchResult ResultFromEntity(IEntity item) |
||||||
|
{ |
||||||
|
var declaringType = item.DeclaringTypeDefinition; |
||||||
|
return new MemberSearchResult { |
||||||
|
Member = item, |
||||||
|
Fitness = CalculateFitness(item), |
||||||
|
Name = GetLanguageSpecificName(item), |
||||||
|
Location = declaringType != null ? language.TypeToString(declaringType, includeNamespace: true) : item.Namespace, |
||||||
|
Assembly = item.ParentModule.FullAssemblyName, |
||||||
|
ToolTip = item.ParentModule.PEFile?.FileName |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
float CalculateFitness(IEntity member) |
||||||
|
{ |
||||||
|
string text = member.Name; |
||||||
|
|
||||||
|
// Probably compiler generated types without meaningful names, show them last
|
||||||
|
if (text.StartsWith("<")) { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
// Constructors always have the same name in IL:
|
||||||
|
// Use type name instead
|
||||||
|
if (text == ".cctor" || text == ".ctor") { |
||||||
|
text = member.DeclaringType.Name; |
||||||
|
} |
||||||
|
|
||||||
|
// Ignore generic arguments, it not possible to search based on them either
|
||||||
|
text = ReflectionHelper.SplitTypeParameterCountFromReflectionName(text); |
||||||
|
|
||||||
|
return 1.0f / text.Length; |
||||||
|
} |
||||||
|
|
||||||
|
string GetLanguageSpecificName(IEntity member) |
||||||
|
{ |
||||||
|
switch (member) { |
||||||
|
case ITypeDefinition t: |
||||||
|
return language.TypeToString(t, false); |
||||||
|
case IField f: |
||||||
|
return language.FieldToString(f, true, false, false); |
||||||
|
case IProperty p: |
||||||
|
return language.PropertyToString(p, true, false, false); |
||||||
|
case IMethod m: |
||||||
|
return language.MethodToString(m, true, false, false); |
||||||
|
case IEvent e: |
||||||
|
return language.EventToString(e, true, false, false); |
||||||
|
default: |
||||||
|
throw new NotSupportedException(member?.GetType() + " not supported!"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static internal ImageSource GetIcon(IEntity member) |
||||||
|
{ |
||||||
|
switch (member) { |
||||||
|
case ITypeDefinition t: |
||||||
|
return TypeTreeNode.GetIcon(t); |
||||||
|
case IField f: |
||||||
|
return FieldTreeNode.GetIcon(f); |
||||||
|
case IProperty p: |
||||||
|
return PropertyTreeNode.GetIcon(p); |
||||||
|
case IMethod m: |
||||||
|
return MethodTreeNode.GetIcon(m); |
||||||
|
case IEvent e: |
||||||
|
return EventTreeNode.GetIcon(e); |
||||||
|
default: |
||||||
|
throw new NotSupportedException(member?.GetType() + " not supported!"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,111 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Concurrent; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.IO; |
||||||
|
using System.Reflection; |
||||||
|
using System.Reflection.Metadata; |
||||||
|
using System.Threading; |
||||||
|
using System.Windows.Media; |
||||||
|
using System.Windows.Media.Imaging; |
||||||
|
using ICSharpCode.Decompiler.Metadata; |
||||||
|
using ICSharpCode.Decompiler.TypeSystem; |
||||||
|
using ICSharpCode.Decompiler.Util; |
||||||
|
using ICSharpCode.ILSpy.TreeNodes; |
||||||
|
using ICSharpCode.TreeView; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy.Search |
||||||
|
{ |
||||||
|
class AssemblySearchStrategy : AbstractSearchStrategy |
||||||
|
{ |
||||||
|
readonly AssemblySearchKind searchKind; |
||||||
|
|
||||||
|
public AssemblySearchStrategy(string term, IProducerConsumerCollection<SearchResult> resultQueue, AssemblySearchKind searchKind) |
||||||
|
: this(resultQueue, new[] { term }, searchKind) |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
public AssemblySearchStrategy(IProducerConsumerCollection<SearchResult> resultQueue, string[] terms, AssemblySearchKind searchKind) |
||||||
|
: base(resultQueue, terms) |
||||||
|
{ |
||||||
|
this.searchKind = searchKind; |
||||||
|
} |
||||||
|
|
||||||
|
public override void Search(PEFile module, CancellationToken cancellationToken) |
||||||
|
{ |
||||||
|
cancellationToken.ThrowIfCancellationRequested(); |
||||||
|
|
||||||
|
if (searchKind == AssemblySearchKind.NameOrFileName) { |
||||||
|
string localName = GetNameToMatch(module, AssemblySearchKind.Name); |
||||||
|
string fileName = Path.GetFileName(GetNameToMatch(module, AssemblySearchKind.FilePath)); |
||||||
|
if (IsMatch(localName) || IsMatch(fileName)) |
||||||
|
OnFoundResult(module); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
string name = GetNameToMatch(module, searchKind); |
||||||
|
if (IsMatch(name)) |
||||||
|
OnFoundResult(module); |
||||||
|
} |
||||||
|
|
||||||
|
string GetNameToMatch(PEFile module, AssemblySearchKind kind) |
||||||
|
{ |
||||||
|
switch (kind) { |
||||||
|
case AssemblySearchKind.FullName: |
||||||
|
return module.FullName; |
||||||
|
case AssemblySearchKind.Name: |
||||||
|
return module.Name; |
||||||
|
case AssemblySearchKind.FilePath: |
||||||
|
return module.FileName; |
||||||
|
} |
||||||
|
|
||||||
|
if (!module.IsAssembly) |
||||||
|
return null; |
||||||
|
|
||||||
|
var metadata = module.Metadata; |
||||||
|
var definition = module.Metadata.GetAssemblyDefinition(); |
||||||
|
|
||||||
|
switch (kind) { |
||||||
|
case AssemblySearchKind.Culture: |
||||||
|
if (definition.Culture.IsNil) |
||||||
|
return "neutral"; |
||||||
|
return metadata.GetString(definition.Culture); |
||||||
|
case AssemblySearchKind.Version: |
||||||
|
return definition.Version.ToString(); |
||||||
|
case AssemblySearchKind.PublicKey: |
||||||
|
return module.Metadata.GetPublicKeyToken(); |
||||||
|
case AssemblySearchKind.HashAlgorithm: |
||||||
|
return definition.HashAlgorithm.ToString(); |
||||||
|
case AssemblySearchKind.Flags: |
||||||
|
return definition.Flags.ToString(); |
||||||
|
} |
||||||
|
|
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
void OnFoundResult(PEFile module) |
||||||
|
{ |
||||||
|
var result = new AssemblySearchResult { |
||||||
|
Module = module, |
||||||
|
Fitness = 1.0f / module.Name.Length, |
||||||
|
Name = module.Name, |
||||||
|
Location = module.FileName, |
||||||
|
Assembly = module.FullName, |
||||||
|
ToolTip = module.FileName, |
||||||
|
}; |
||||||
|
OnFoundResult(result); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
enum AssemblySearchKind |
||||||
|
{ |
||||||
|
NameOrFileName, |
||||||
|
Name, |
||||||
|
FullName, |
||||||
|
FilePath, |
||||||
|
Culture, |
||||||
|
Version, |
||||||
|
PublicKey, |
||||||
|
HashAlgorithm, |
||||||
|
Flags |
||||||
|
} |
||||||
|
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue