IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
ReflectionMethodBaseSymbol.cs
Go to the documentation of this file.
1using System;
2using System.Diagnostics;
3using System.Linq;
4using System.Reflection;
5using System.Threading;
6
8{
9
11 {
12
13 readonly MethodBase _underlyingMethodBase;
14
15 ParameterInfo[]? _parametersSource;
16 ReflectionParameterSymbol?[]? _parameters;
17 ReflectionParameterSymbol? _returnParameter;
18
27 base(context, module, type, underlyingMethodBase)
28 {
29 _underlyingMethodBase = underlyingMethodBase ?? throw new ArgumentNullException(nameof(underlyingMethodBase));
30 }
31
37 internal ReflectionParameterSymbol GetOrCreateParameterSymbol(ParameterInfo parameter)
38 {
39 if (parameter is null)
40 throw new ArgumentNullException(nameof(parameter));
41
42 Debug.Assert(parameter.Member == _underlyingMethodBase);
43
44 if (_parametersSource == null)
45 Interlocked.CompareExchange(ref _parametersSource, _underlyingMethodBase.GetParameters().OrderBy(i => i.Position).ToArray(), null);
46 if (_parameters == null)
47 Interlocked.CompareExchange(ref _parameters, new ReflectionParameterSymbol?[_parametersSource.Length], null);
48
49 // index of current record
50 var idx = parameter.Position;
51 Debug.Assert(idx >= -1);
52 Debug.Assert(idx < _parametersSource.Length);
53
54 // check that our list is long enough to contain the entire table
55 if (idx >= 0 && _parameters.Length < idx)
56 throw new IndexOutOfRangeException();
57
58 // if not yet created, create, allow multiple instances, but only one is eventually inserted
59 ref var rec = ref _returnParameter;
60 if (idx >= 0)
61 rec = ref _parameters[idx];
62 if (rec == null)
63 Interlocked.CompareExchange(ref rec, new ReflectionParameterSymbol(Context, this, parameter), null);
64
65 // this should never happen
66 if (rec is not ReflectionParameterSymbol sym)
67 throw new InvalidOperationException();
68
69 return sym;
70 }
71
75 internal MethodBase UnderlyingMethodBase => _underlyingMethodBase;
76
78 public MethodAttributes Attributes => _underlyingMethodBase.Attributes;
79
81 public CallingConventions CallingConvention => _underlyingMethodBase.CallingConvention;
82
84 public bool ContainsGenericParameters => _underlyingMethodBase.ContainsGenericParameters;
85
87 public bool IsAbstract => _underlyingMethodBase.IsAbstract;
88
90 public bool IsAssembly => _underlyingMethodBase.IsAssembly;
91
93 public bool IsConstructor => _underlyingMethodBase.IsConstructor;
94
96 public bool IsFamily => _underlyingMethodBase.IsFamily;
97
99 public bool IsFamilyAndAssembly => _underlyingMethodBase.IsFamilyAndAssembly;
100
102 public bool IsFamilyOrAssembly => _underlyingMethodBase.IsFamilyOrAssembly;
103
105 public bool IsFinal => _underlyingMethodBase.IsFinal;
106
108 public bool IsGenericMethod => _underlyingMethodBase.IsGenericMethod;
109
111 public bool IsGenericMethodDefinition => _underlyingMethodBase.IsGenericMethodDefinition;
112
114 public bool IsHideBySig => _underlyingMethodBase.IsHideBySig;
115
117 public bool IsPrivate => _underlyingMethodBase.IsPrivate;
118
120 public bool IsPublic => _underlyingMethodBase.IsPublic;
121
123 public bool IsStatic => _underlyingMethodBase.IsStatic;
124
126 public bool IsVirtual => _underlyingMethodBase.IsVirtual;
127
129 public bool IsSpecialName => _underlyingMethodBase.IsSpecialName;
130
132 public MethodImplAttributes MethodImplementationFlags => _underlyingMethodBase.MethodImplementationFlags;
133
136 {
137 return ResolveTypeSymbols(_underlyingMethodBase.GetGenericArguments());
138 }
139
141 public MethodImplAttributes GetMethodImplementationFlags()
142 {
143 return _underlyingMethodBase.GetMethodImplementationFlags();
144 }
145
148 {
149 return ResolveParameterSymbols(_underlyingMethodBase.GetParameters());
150 }
151
152 }
153
154}
System.Threading.Interlocked Interlocked
IKVM.Reflection.ParameterInfo ParameterInfo
IKVM.Reflection.MethodBase MethodBase
System.Runtime.InteropServices.CallingConvention CallingConvention
Definition Signature.cs:35
Obtains information about the attributes of a member and provides access to member metadata.
bool ContainsGenericParameters
Gets a value indicating whether the generic method contains unassigned generic type parameters.
bool IsConstructor
Gets a value indicating whether the method is a constructor.
bool IsPrivate
Gets a value indicating whether this member is private.
bool IsHideBySig
Gets a value indicating whether only a member of the same kind with exactly the same signature is hid...
bool IsFamilyOrAssembly
Gets a value indicating whether the potential visibility of this method or constructor is described b...
bool IsFamily
Gets a value indicating whether the visibility of this method or constructor is described by Family; ...
bool IsSpecialName
Gets a value indicating whether this method has a special name.
bool IsStatic
Gets a value indicating whether the method is static.
MethodAttributes Attributes
Gets the attributes associated with this method.
ReflectionMethodBaseSymbol(ReflectionSymbolContext context, ReflectionModuleSymbol module, ReflectionTypeSymbol? type, MethodBase underlyingMethodBase)
Initializes a new instance.
bool IsAbstract
Gets a value indicating whether the method is abstract.
bool IsPublic
Gets a value indicating whether this is a public method.
ITypeSymbol[] GetGenericArguments()
Returns an array of ITypeSymbol objects that represent the type arguments of a generic method or the ...
bool IsVirtual
Gets a value indicating whether the method is virtual.
bool IsGenericMethod
Gets a value indicating whether the method is generic.
bool IsFinal
Gets a value indicating whether this method is final.
IParameterSymbol[] GetParameters()
When overridden in a derived class, gets the parameters of the specified method or constructor.
bool IsFamilyAndAssembly
Gets a value indicating whether the visibility of this method or constructor is described by FamANDAs...
MethodImplAttributes GetMethodImplementationFlags()
When overridden in a derived class, returns the MethodImplAttributes flags.
bool IsGenericMethodDefinition
Gets a value indicating whether the method is a generic method definition.
bool IsAssembly
Gets a value indicating whether the potential visibility of this method or constructor is described b...
MethodImplAttributes MethodImplementationFlags
Gets the MethodImplAttributes flags that specify the attributes of a method implementation.
Implementation of IModuleSymbol derived from System.Reflection.
Holds references to symbols derived from System.Reflection.
ReflectionSymbolContext Context
Gets the associated ReflectionSymbolContext.
Provides information about methods and constructors.
Discovers the attributes of a parameter and provides access to parameter metadata.
Represents type declarations: class types, interface types, array types, value types,...