-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathFullMethodSignature.cs
More file actions
50 lines (42 loc) · 1.27 KB
/
FullMethodSignature.cs
File metadata and controls
50 lines (42 loc) · 1.27 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Collections.Immutable;
using System.Reflection;
namespace ClassExplorer.Signatures;
internal sealed class FullMethodSignature(ITypeSignature returnType, ImmutableArray<ITypeSignature> parameters) : MemberSignature
{
internal ITypeSignature ReturnType { get; } = returnType;
internal ImmutableArray<ITypeSignature> Parameters { get; } = parameters;
public override bool IsMatch(MemberInfo subject)
{
if (subject is not MethodBase methodBase)
{
return false;
}
if (subject is ConstructorInfo ctor)
{
if (ctor.ReflectedType is null || !ReturnType.IsMatch(ctor.ReflectedType))
{
return false;
}
}
else if (subject is MethodInfo method)
{
if (!ReturnType.IsMatch(method.ReturnParameter))
{
return false;
}
}
ParameterInfo[] parameters = methodBase.GetParameters();
if (parameters.Length != Parameters.Length)
{
return false;
}
for (int i = 0; i < parameters.Length; i++)
{
if (!Parameters[i].IsMatch(parameters[i]))
{
return false;
}
}
return true;
}
}