-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathFunctionPointer.cs
More file actions
88 lines (82 loc) · 3.22 KB
/
FunctionPointer.cs
File metadata and controls
88 lines (82 loc) · 3.22 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System.Collections.Generic;
using System.Linq;
using ArchUnitNET.Domain.Dependencies;
namespace ArchUnitNET.Domain
{
public class FunctionPointer : IType
{
private readonly IType _type;
public FunctionPointer(
IType type,
ITypeInstance<IType> returnTypeInstance,
List<ITypeInstance<IType>> parameterTypeInstances
)
{
_type = type;
ReturnTypeInstance = returnTypeInstance;
ParameterTypeInstances = parameterTypeInstances;
}
public Namespace Namespace => _type.Namespace;
public Assembly Assembly => _type.Assembly;
public MemberList Members => _type.Members;
public IEnumerable<IType> ImplementedInterfaces => _type.ImplementedInterfaces;
public bool IsNested => _type.IsNested;
public bool IsStub => _type.IsStub;
public bool IsGenericParameter => _type.IsGenericParameter;
public string Name => _type.Name;
public string FullName => _type.FullName;
public string AssemblyQualifiedName => _type.AssemblyQualifiedName;
public Visibility Visibility => _type.Visibility;
public bool IsGeneric => _type.IsGeneric;
public List<GenericParameter> GenericParameters => _type.GenericParameters;
public bool IsCompilerGenerated => _type.IsCompilerGenerated;
public List<ITypeDependency> Dependencies => _type.Dependencies;
public List<ITypeDependency> BackwardsDependencies => _type.BackwardsDependencies;
public IEnumerable<Attribute> Attributes => _type.Attributes;
public List<AttributeInstance> AttributeInstances => _type.AttributeInstances;
public ITypeInstance<IType> ReturnTypeInstance { get; }
public List<ITypeInstance<IType>> ParameterTypeInstances { get; }
public bool Equals(FunctionPointer other)
{
if (ReferenceEquals(null, other))
{
return false;
}
if (ReferenceEquals(this, other))
{
return true;
}
return Equals(_type, other._type)
&& Equals(ReturnTypeInstance, other.ReturnTypeInstance)
&& ParameterTypeInstances.SequenceEqual(other.ParameterTypeInstances);
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj.GetType() == GetType() && Equals((FunctionPointer)obj);
}
public override int GetHashCode()
{
unchecked
{
var hashCode = _type.GetHashCode();
hashCode =
(hashCode * 397)
^ (ReturnTypeInstance != null ? ReturnTypeInstance.GetHashCode() : 0);
hashCode = ParameterTypeInstances.Aggregate(
hashCode,
(current, typeInstance) =>
(current * 397) ^ (typeInstance != null ? typeInstance.GetHashCode() : 0)
);
return hashCode;
}
}
}
}