-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathFieldMember.cs
More file actions
97 lines (85 loc) · 3.3 KB
/
FieldMember.cs
File metadata and controls
97 lines (85 loc) · 3.3 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
89
90
91
92
93
94
95
96
97
using System.Collections.Generic;
using System.Linq;
using ArchUnitNET.Domain.Dependencies;
namespace ArchUnitNET.Domain
{
public class FieldMember : IMember, ITypeInstance<IType>
{
private readonly ITypeInstance<IType> _typeInstance;
public FieldMember(
IType declaringType,
string name,
string fullName,
Visibility visibility,
ITypeInstance<IType> typeInstance,
bool isCompilerGenerated,
bool? isStatic,
Writability writability
)
{
DeclaringType = declaringType;
Name = name;
FullName = fullName;
AssemblyQualifiedName = System.Reflection.Assembly.CreateQualifiedName(
declaringType.Assembly.FullName,
fullName
);
Visibility = visibility;
IsCompilerGenerated = isCompilerGenerated;
_typeInstance = typeInstance;
IsStatic = isStatic;
Writability = writability;
}
public Assembly Assembly => DeclaringType.Assembly;
public Namespace Namespace => DeclaringType.Namespace;
public Visibility Visibility { get; }
public IType DeclaringType { get; }
public string Name { get; }
public string FullName { get; }
public string AssemblyQualifiedName { get; }
public bool IsCompilerGenerated { get; }
public bool? IsStatic { get; }
public Writability? Writability { get; }
public bool IsGeneric => false;
public List<GenericParameter> GenericParameters => new List<GenericParameter>();
public IEnumerable<Attribute> Attributes =>
AttributeInstances.Select(instance => instance.Type);
public List<AttributeInstance> AttributeInstances { get; } = new List<AttributeInstance>();
public List<IMemberTypeDependency> MemberDependencies { get; } =
new List<IMemberTypeDependency>();
public List<IMemberTypeDependency> MemberBackwardsDependencies { get; } =
new List<IMemberTypeDependency>();
public List<ITypeDependency> Dependencies =>
MemberDependencies.Cast<ITypeDependency>().ToList();
public List<ITypeDependency> BackwardsDependencies =>
MemberBackwardsDependencies.Cast<ITypeDependency>().ToList();
public IType Type => _typeInstance.Type;
public IEnumerable<GenericArgument> GenericArguments => _typeInstance.GenericArguments;
public IEnumerable<int> ArrayDimensions => _typeInstance.ArrayDimensions;
public bool IsArray => _typeInstance.IsArray;
public override string ToString()
{
return $"{DeclaringType.FullName}{'.'}{Name}";
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (ReferenceEquals(this, obj))
{
return true;
}
return obj.GetType() == GetType() && Equals((FieldMember)obj);
}
private bool Equals(FieldMember other)
{
return FullName.Equals(other.FullName);
}
public override int GetHashCode()
{
return FullName.GetHashCode();
}
}
}