-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
Copy pathSRMHacks.cs
36 lines (32 loc) · 1.05 KB
/
SRMHacks.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Reflection;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using ICSharpCode.Decompiler.Metadata;
namespace ICSharpCode.Decompiler
{
public static partial class SRMExtensions
{
public static ImmutableArray<MethodImplementationHandle> GetMethodImplementations(
this MethodDefinitionHandle handle, MetadataReader reader)
{
var resultBuilder = ImmutableArray.CreateBuilder<MethodImplementationHandle>();
var typeDefinition = reader.GetTypeDefinition(reader.GetMethodDefinition(handle)
.GetDeclaringType());
foreach (var methodImplementationHandle in typeDefinition.GetMethodImplementations())
{
var methodImplementation = reader.GetMethodImplementation(methodImplementationHandle);
if (methodImplementation.MethodBody == handle)
{
resultBuilder.Add(methodImplementationHandle);
}
}
return resultBuilder.ToImmutable();
}
}
}