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 FieldInfo : MemberInfo
30 // prevent external subclasses
35 public sealed override MemberTypes MemberType
37 get { return MemberTypes.Field; }
40 public abstract FieldAttributes Attributes { get; }
41 public abstract void __GetDataFromRVA(byte[] data, int offset, int length);
42 public abstract Object GetRawConstantValue();
43 internal abstract FieldSignature FieldSignature { get; }
47 get { return this.FieldSignature.FieldType; }
50 public Type[] GetOptionalCustomModifiers()
52 return this.FieldSignature.GetOptionalCustomModifiers();
55 public Type[] GetRequiredCustomModifiers()
57 return this.FieldSignature.GetRequiredCustomModifiers();
62 get { return (Attributes & FieldAttributes.Static) != 0; }
67 get { return (Attributes & FieldAttributes.Literal) != 0; }
70 public bool IsInitOnly
72 get { return (Attributes & FieldAttributes.InitOnly) != 0; }
75 public bool IsNotSerialized
77 get { return (Attributes & FieldAttributes.NotSerialized) != 0; }
80 public bool IsSpecialName
82 get { return (Attributes & FieldAttributes.SpecialName) != 0; }
87 get { return (Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Public; }
92 get { return (Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Private; }
97 get { return (Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Family; }
100 public bool IsFamilyOrAssembly
102 get { return (Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.FamORAssem; }
105 public bool IsAssembly
107 get { return (Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.Family; }
110 public bool IsFamilyAndAssembly
112 get { return (Attributes & FieldAttributes.FieldAccessMask) == FieldAttributes.FamANDAssem; }
115 public bool IsPinvokeImpl
117 get { return (Attributes & FieldAttributes.PinvokeImpl) != 0; }
120 internal abstract int ImportTo(Emit.ModuleBuilder module);
122 internal virtual FieldInfo BindTypeParameters(Type type)
124 return new GenericFieldInstance(this.DeclaringType.BindTypeParameters(type), this);