@@ -14,37 +14,42 @@ namespace ArchUnitNET.Domain
1414{
1515 public class GenericParameter : IType
1616 {
17- private readonly string _declarerFullName ;
1817 internal readonly IEnumerable < ITypeInstance < IType > > TypeInstanceConstraints ;
1918
2019 public GenericParameter (
21- string declarerFullName ,
20+ ITypeInstance < IType > declaringTypeInstance ,
21+ [ CanBeNull ] MethodMemberInstance declaringMethodInstance ,
22+ string fullName ,
2223 string name ,
2324 GenericParameterVariance variance ,
2425 IEnumerable < ITypeInstance < IType > > typeConstraints ,
2526 bool hasReferenceTypeConstraint ,
2627 bool hasNotNullableValueTypeConstraint ,
2728 bool hasDefaultConstructorConstraint ,
28- bool isCompilerGenerated ,
29- bool declarerIsMethod
29+ bool isCompilerGenerated
3030 )
3131 {
32- _declarerFullName = declarerFullName ;
32+ DeclaringTypeInstance = declaringTypeInstance ;
33+ DeclaringMethodInstance = declaringMethodInstance ;
34+ FullName = fullName ;
3335 Name = name ;
3436 Variance = variance ;
3537 TypeInstanceConstraints = typeConstraints ;
3638 HasReferenceTypeConstraint = hasReferenceTypeConstraint ;
3739 HasNotNullableValueTypeConstraint = hasNotNullableValueTypeConstraint ;
3840 HasDefaultConstructorConstraint = hasDefaultConstructorConstraint ;
3941 IsCompilerGenerated = isCompilerGenerated ;
40- DeclarerIsMethod = declarerIsMethod ;
4142 }
4243
43- public IType DeclaringType { get ; private set ; }
44+ public ITypeInstance < IType > DeclaringTypeInstance { get ; }
45+ public IType DeclaringType => DeclaringTypeInstance . Type ;
4446
4547 [ CanBeNull ]
46- public IMember DeclaringMethod { get ; private set ; }
47- public bool DeclarerIsMethod { get ; }
48+ public MethodMemberInstance DeclaringMethodInstance { get ; }
49+
50+ [ CanBeNull ]
51+ public IMember DeclaringMethod => DeclaringMethodInstance ? . Member ;
52+ public bool DeclarerIsMethod => DeclaringMethodInstance != null ;
4853 public GenericParameterVariance Variance { get ; }
4954 public IEnumerable < IType > TypeConstraints =>
5055 TypeInstanceConstraints . Select ( instance => instance . Type ) ;
@@ -59,7 +64,12 @@ bool declarerIsMethod
5964 || TypeConstraints . Any ( ) ;
6065
6166 public string Name { get ; }
62- public string FullName => _declarerFullName + "+<" + Name + ">" ;
67+ public string FullName { get ; }
68+ public string AssemblyQualifiedName =>
69+ System . Reflection . Assembly . CreateQualifiedName (
70+ DeclaringType . Assembly . FullName ,
71+ FullName
72+ ) ;
6373 public bool IsCompilerGenerated { get ; }
6474 public IEnumerable < Attribute > Attributes =>
6575 AttributeInstances . Select ( instance => instance . Type ) ;
@@ -79,27 +89,6 @@ bool declarerIsMethod
7989 public bool IsNested => true ;
8090 public bool IsStub => true ;
8191
82- internal void AssignDeclarer ( IMember declaringMethod )
83- {
84- if ( ! declaringMethod . FullName . Equals ( _declarerFullName ) )
85- {
86- throw new InvalidOperationException ( "Full name of declaring member doesn't match." ) ;
87- }
88-
89- DeclaringType = declaringMethod . DeclaringType ;
90- DeclaringMethod = declaringMethod ;
91- }
92-
93- internal void AssignDeclarer ( IType declaringType )
94- {
95- if ( ! declaringType . FullName . Equals ( _declarerFullName ) )
96- {
97- throw new InvalidOperationException ( "Full name of declaring type doesn't match." ) ;
98- }
99-
100- DeclaringType = declaringType ;
101- }
102-
10392 public bool Equals ( GenericParameter other )
10493 {
10594 if ( ReferenceEquals ( null , other ) )
0 commit comments