2
Copyright (C) 2009 Jeroen Frijters
4
This software is provided 'as-is', without any express or implied
5
warranty. In no event will the authors be held liable for any damages
6
arising from the use of this software.
8
Permission is granted to anyone to use this software for any purpose,
9
including commercial applications, and to alter it and redistribute it
10
freely, subject to the following restrictions:
12
1. The origin of this software must not be misrepresented; you must not
13
claim that you wrote the original software. If you use this software
14
in a product, an acknowledgment in the product documentation would be
15
appreciated but is not required.
16
2. Altered source versions must be plainly marked as such, and must not be
17
misrepresented as being the original software.
18
3. This notice may not be removed or altered from any source distribution.
26
namespace IKVM.Reflection
28
public abstract class MethodBase : MemberInfo
30
// prevent external subclasses
35
internal abstract MethodSignature MethodSignature { get; }
36
internal abstract int ParameterCount { get; }
37
public abstract ParameterInfo[] GetParameters();
38
public abstract MethodAttributes Attributes { get; }
39
public abstract MethodImplAttributes GetMethodImplementationFlags();
40
public abstract MethodBody GetMethodBody();
41
public abstract CallingConventions CallingConvention { get; }
42
public abstract int __MethodRVA { get; }
44
public bool IsConstructor
48
if ((this.Attributes & MethodAttributes.RTSpecialName) != 0)
50
string name = this.Name;
51
return name == ConstructorInfo.ConstructorName || name == ConstructorInfo.TypeConstructorName;
59
get { return (Attributes & MethodAttributes.Static) != 0; }
64
get { return (Attributes & MethodAttributes.Virtual) != 0; }
67
public bool IsAbstract
69
get { return (Attributes & MethodAttributes.Abstract) != 0; }
74
get { return (Attributes & MethodAttributes.Final) != 0; }
79
get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Public; }
84
get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Family; }
87
public bool IsFamilyOrAssembly
89
get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamORAssem; }
92
public bool IsAssembly
94
get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Assembly; }
97
public bool IsFamilyAndAssembly
99
get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.FamANDAssem; }
102
public bool IsPrivate
104
get { return (Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private; }
107
public bool IsSpecialName
109
get { return (Attributes & MethodAttributes.SpecialName) != 0; }
112
public bool IsHideBySig
114
get { return (Attributes & MethodAttributes.HideBySig) != 0; }
117
public MethodImplAttributes MethodImplementationFlags
119
get { return GetMethodImplementationFlags(); }
122
public virtual Type[] GetGenericArguments()
124
return Type.EmptyTypes;
127
public virtual bool IsGenericMethod
129
get { return false; }
132
public virtual bool IsGenericMethodDefinition
134
get { return false; }
137
public virtual bool ContainsGenericParameters
139
get { return IsGenericMethodDefinition; }
142
public virtual MethodBase __GetMethodOnTypeDefinition()
147
// This goes to the (uninstantiated) MethodInfo on the (uninstantiated) Type. For constructors
148
// it also has the effect of removing the ConstructorInfo wrapper and returning the underlying MethodInfo.
149
internal abstract MethodInfo GetMethodOnTypeDefinition();
151
internal abstract int ImportTo(Emit.ModuleBuilder module);
153
internal abstract MethodBase BindTypeParameters(Type type);
155
internal sealed override bool BindingFlagsMatch(BindingFlags flags)
157
return BindingFlagsMatch(IsPublic, flags, BindingFlags.Public, BindingFlags.NonPublic)
158
&& BindingFlagsMatch(IsStatic, flags, BindingFlags.Static, BindingFlags.Instance);
161
internal sealed override bool BindingFlagsMatchInherited(BindingFlags flags)
163
return (Attributes & MethodAttributes.MemberAccessMask) > MethodAttributes.Private
164
&& BindingFlagsMatch(IsPublic, flags, BindingFlags.Public, BindingFlags.NonPublic)
165
&& BindingFlagsMatch(IsStatic, flags, BindingFlags.Static | BindingFlags.FlattenHierarchy, BindingFlags.Instance);