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.cs77
1 files changed, 37 insertions, 40 deletions
diff --git a/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs
index 5953b67173..d0e9d3483c 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,36 +24,36 @@ 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)
throw new ArgumentNullException(nameof(fieldName));
if (fieldName.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(fieldName));
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(fieldName));
if (fieldName[0] == '\0')
- throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), nameof(fieldName));
+ throw new ArgumentException(SR.Argument_IllegalName, nameof(fieldName));
if (type == null)
throw new ArgumentNullException(nameof(type));
if (type == typeof(void))
- throw new ArgumentException(Environment.GetResourceString("Argument_BadFieldType"));
+ throw new ArgumentException(SR.Argument_BadFieldType);
Contract.EndContractBlock();
m_fieldName = fieldName;
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,35 +110,35 @@ 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.
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.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.
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
- public override RuntimeFieldHandle FieldHandle
+ public override RuntimeFieldHandle FieldHandle
{
- get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); }
+ get { throw new NotSupportedException(SR.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"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
-
+
public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
{
-
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
public override bool IsDefined(Type attributeType, bool inherit)
{
-
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.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)
{