summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs')
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs59
1 files changed, 28 insertions, 31 deletions
diff --git a/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs
index 5953b67173..ae28212732 100644
--- a/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs
@@ -4,14 +4,14 @@
//
-namespace System.Reflection.Emit
+namespace System.Reflection.Emit
{
using System.Runtime.InteropServices;
using System;
using CultureInfo = System.Globalization.CultureInfo;
using System.Reflection;
using System.Diagnostics.Contracts;
-
+
public sealed class FieldBuilder : FieldInfo
{
#region Private Data Members
@@ -24,7 +24,7 @@ namespace System.Reflection.Emit
#endregion
#region Constructor
- internal FieldBuilder(TypeBuilder typeBuilder, String fieldName, Type type,
+ internal FieldBuilder(TypeBuilder typeBuilder, String fieldName, Type type,
Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attributes)
{
if (fieldName == null)
@@ -47,13 +47,13 @@ namespace System.Reflection.Emit
m_typeBuilder = typeBuilder;
m_fieldType = type;
m_Attributes = attributes & ~FieldAttributes.ReservedMask;
-
+
SignatureHelper sigHelp = SignatureHelper.GetFieldSigHelper(m_typeBuilder.Module);
sigHelp.AddArgument(type, requiredCustomModifiers, optionalCustomModifiers);
int sigLength;
byte[] signature = sigHelp.InternalGetSignature(out sigLength);
-
+
m_fieldTok = TypeBuilder.DefineField(m_typeBuilder.GetModuleBuilder().GetNativeHandle(),
typeBuilder.TypeToken.Token, fieldName, signature, sigLength, m_Attributes);
@@ -74,20 +74,20 @@ namespace System.Reflection.Emit
{
get { return m_fieldTok; }
}
-
+
public override Module Module
{
get { return m_typeBuilder.Module; }
}
- public override String Name
+ public override String Name
{
- get {return m_fieldName; }
+ get { return m_fieldName; }
}
- public override Type DeclaringType
+ public override Type DeclaringType
{
- get
+ get
{
if (m_typeBuilder.m_isHiddenGlobalType == true)
return null;
@@ -95,10 +95,10 @@ namespace System.Reflection.Emit
return m_typeBuilder;
}
}
-
- public override Type ReflectedType
+
+ public override Type ReflectedType
{
- get
+ get
{
if (m_typeBuilder.m_isHiddenGlobalType == true)
return null;
@@ -110,13 +110,13 @@ namespace System.Reflection.Emit
#endregion
#region FieldInfo Overrides
- public override Type FieldType
+ public override Type FieldType
{
get { return m_fieldType; }
}
public override Object GetValue(Object obj)
- {
+ {
// NOTE!! If this is implemented, make sure that this throws
// a NotSupportedException for Save-only dynamic assemblies.
// Otherwise, it could cause the .cctor to be executed.
@@ -124,8 +124,8 @@ namespace System.Reflection.Emit
throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
}
- public override void SetValue(Object obj,Object val,BindingFlags invokeAttr,Binder binder,CultureInfo culture)
- {
+ public override void SetValue(Object obj, Object val, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
+ {
// NOTE!! If this is implemented, make sure that this throws
// a NotSupportedException for Save-only dynamic assemblies.
// Otherwise, it could cause the .cctor to be executed.
@@ -133,12 +133,12 @@ namespace System.Reflection.Emit
throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
}
- public override RuntimeFieldHandle FieldHandle
+ public override RuntimeFieldHandle FieldHandle
{
get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); }
}
- public override FieldAttributes Attributes
+ public override FieldAttributes Attributes
{
get { return m_Attributes; }
}
@@ -148,44 +148,41 @@ namespace System.Reflection.Emit
#region ICustomAttributeProvider Implementation
public override Object[] GetCustomAttributes(bool inherit)
{
-
throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
}
-
+
public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
{
-
throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
}
public override bool IsDefined(Type attributeType, bool inherit)
{
-
throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
}
#endregion
#region Public Members
- public FieldToken GetToken()
+ public FieldToken GetToken()
{
return m_tkField;
}
- public void SetOffset(int iOffset)
+ public void SetOffset(int iOffset)
{
- m_typeBuilder.ThrowIfCreated();
-
+ m_typeBuilder.ThrowIfCreated();
+
TypeBuilder.SetFieldLayoutOffset(m_typeBuilder.GetModuleBuilder().GetNativeHandle(), GetToken().Token, iOffset);
}
- public void SetConstant(Object defaultValue)
+ public void SetConstant(Object defaultValue)
{
- m_typeBuilder.ThrowIfCreated();
-
+ m_typeBuilder.ThrowIfCreated();
+
TypeBuilder.SetConstantValue(m_typeBuilder.GetModuleBuilder(), GetToken().Token, m_fieldType, defaultValue);
}
-
+
public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{