blob: 6785771358fcae2f1b7872253614732bfdad6fc0 (
plain)
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
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Reflection.Runtime.General;
using System.Reflection.Runtime.MethodInfos;
using System.Reflection.Runtime.TypeInfos;
using System.Reflection.Runtime.CustomAttributes;
using Internal.Reflection.Tracing;
using Internal.Metadata.NativeFormat;
namespace System.Reflection.Runtime.TypeInfos.NativeFormat
{
internal abstract partial class NativeFormatRuntimeGenericParameterTypeInfo : RuntimeGenericParameterTypeInfo
{
protected NativeFormatRuntimeGenericParameterTypeInfo(MetadataReader reader, GenericParameterHandle genericParameterHandle, GenericParameter genericParameter)
: base(genericParameter.Number)
{
Reader = reader;
GenericParameterHandle = genericParameterHandle;
_genericParameter = genericParameter;
}
public sealed override IEnumerable<CustomAttributeData> CustomAttributes
{
get
{
#if ENABLE_REFLECTION_TRACE
if (ReflectionTrace.Enabled)
ReflectionTrace.TypeInfo_CustomAttributes(this);
#endif
return RuntimeCustomAttributeData.GetCustomAttributes(Reader, _genericParameter.CustomAttributes);
}
}
public sealed override GenericParameterAttributes GenericParameterAttributes
{
get
{
return _genericParameter.Flags;
}
}
public sealed override int MetadataToken
{
get
{
throw new InvalidOperationException(SR.NoMetadataTokenAvailable);
}
}
protected sealed override int InternalGetHashCode()
{
return GenericParameterHandle.GetHashCode();
}
protected GenericParameterHandle GenericParameterHandle { get; }
protected MetadataReader Reader { get; }
public sealed override string InternalGetNameIfAvailable(ref Type rootCauseForFailure)
{
if (_genericParameter.Name.IsNull(Reader))
return string.Empty;
return _genericParameter.Name.GetString(Reader);
}
protected sealed override QTypeDefRefOrSpec[] Constraints
{
get
{
MetadataReader reader = Reader;
LowLevelList<QTypeDefRefOrSpec> constraints = new LowLevelList<QTypeDefRefOrSpec>();
foreach (Handle constraintHandle in _genericParameter.Constraints)
{
constraints.Add(new QTypeDefRefOrSpec(reader, constraintHandle));
}
return constraints.ToArray();
}
}
private readonly GenericParameter _genericParameter;
}
}
|