summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs')
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs614
1 files changed, 308 insertions, 306 deletions
diff --git a/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs
index 88502cb096..a98af2bdcf 100644
--- a/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs
@@ -5,7 +5,8 @@
//
-namespace System.Reflection.Emit {
+namespace System.Reflection.Emit
+{
using System;
using System.Reflection;
using System.Security;
@@ -22,21 +23,22 @@ namespace System.Reflection.Emit {
[Serializable]
public enum PackingSize
{
- Unspecified = 0,
- Size1 = 1,
- Size2 = 2,
- Size4 = 4,
- Size8 = 8,
- Size16 = 16,
- Size32 = 32,
- Size64 = 64,
- Size128 = 128,
+ Unspecified = 0,
+ Size1 = 1,
+ Size2 = 2,
+ Size4 = 4,
+ Size8 = 8,
+ Size16 = 16,
+ Size32 = 32,
+ Size64 = 64,
+ Size128 = 128,
}
public sealed class TypeBuilder : TypeInfo
{
- public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo){
- if(typeInfo==null) return false;
+ public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo)
+ {
+ if (typeInfo == null) return false;
return IsAssignableFrom(typeInfo.AsType());
}
@@ -46,7 +48,7 @@ namespace System.Reflection.Emit {
private ConstructorInfo m_con;
private byte[] m_binaryAttribute;
private CustomAttributeBuilder m_customBuilder;
-
+
public CustAttr(ConstructorInfo con, byte[] binaryAttribute)
{
if (con == null)
@@ -83,12 +85,12 @@ namespace System.Reflection.Emit {
}
}
#endregion
-
+
#region Public Static Methods
public static MethodInfo GetMethod(Type type, MethodInfo method)
{
if (!(type is TypeBuilder) && !(type is TypeBuilderInstantiation))
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeTypeBuilder"));
+ throw new ArgumentException(SR.Argument_MustBeTypeBuilder);
// The following checks establishes invariants that more simply put require type to be generic and
// method to be a generic method definition declared on the generic type definition of type.
@@ -96,15 +98,15 @@ namespace System.Reflection.Emit {
// this function followed by MakeGenericMethod on the resulting MethodInfo to finally get G<Foo>.M<Bar>.
// We could also allow G<T>.M<Bar> to be created before G<Foo>.M<Bar> (BindGenParm followed by this method)
// if we wanted to but that just complicates things so these checks are designed to prevent that scenario.
-
+
if (method.IsGenericMethod && !method.IsGenericMethodDefinition)
- throw new ArgumentException(Environment.GetResourceString("Argument_NeedGenericMethodDefinition"), nameof(method));
-
+ throw new ArgumentException(SR.Argument_NeedGenericMethodDefinition, nameof(method));
+
if (method.DeclaringType == null || !method.DeclaringType.IsGenericTypeDefinition)
- throw new ArgumentException(Environment.GetResourceString("Argument_MethodNeedGenericDeclaringType"), nameof(method));
-
+ throw new ArgumentException(SR.Argument_MethodNeedGenericDeclaringType, nameof(method));
+
if (type.GetGenericTypeDefinition() != method.DeclaringType)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidMethodDeclaringType"), nameof(type));
+ throw new ArgumentException(SR.Argument_InvalidMethodDeclaringType, nameof(type));
Contract.EndContractBlock();
// The following converts from Type or TypeBuilder of G<T> to TypeBuilderInstantiation G<T>. These types
@@ -112,51 +114,51 @@ namespace System.Reflection.Emit {
// G<M>.M() be encoded by a typeSpec whose parent is the typeDef for G<M> and whose instantiation is also G<M>.
if (type.IsGenericTypeDefinition)
type = type.MakeGenericType(type.GetGenericArguments());
-
+
if (!(type is TypeBuilderInstantiation))
- throw new ArgumentException(Environment.GetResourceString("Argument_NeedNonGenericType"), nameof(type));
+ throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(type));
return MethodOnTypeBuilderInstantiation.GetMethod(method, type as TypeBuilderInstantiation);
}
public static ConstructorInfo GetConstructor(Type type, ConstructorInfo constructor)
- {
+ {
if (!(type is TypeBuilder) && !(type is TypeBuilderInstantiation))
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeTypeBuilder"));
+ throw new ArgumentException(SR.Argument_MustBeTypeBuilder);
if (!constructor.DeclaringType.IsGenericTypeDefinition)
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstructorNeedGenericDeclaringType"), nameof(constructor));
+ throw new ArgumentException(SR.Argument_ConstructorNeedGenericDeclaringType, nameof(constructor));
Contract.EndContractBlock();
-
+
if (!(type is TypeBuilderInstantiation))
- throw new ArgumentException(Environment.GetResourceString("Argument_NeedNonGenericType"), nameof(type));
+ throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(type));
// TypeBuilder G<T> ==> TypeBuilderInstantiation G<T>
if (type is TypeBuilder && type.IsGenericTypeDefinition)
type = type.MakeGenericType(type.GetGenericArguments());
if (type.GetGenericTypeDefinition() != constructor.DeclaringType)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidConstructorDeclaringType"), nameof(type));
+ throw new ArgumentException(SR.Argument_InvalidConstructorDeclaringType, nameof(type));
return ConstructorOnTypeBuilderInstantiation.GetConstructor(constructor, type as TypeBuilderInstantiation);
}
public static FieldInfo GetField(Type type, FieldInfo field)
{
if (!(type is TypeBuilder) && !(type is TypeBuilderInstantiation))
- throw new ArgumentException(Environment.GetResourceString("Argument_MustBeTypeBuilder"));
+ throw new ArgumentException(SR.Argument_MustBeTypeBuilder);
if (!field.DeclaringType.IsGenericTypeDefinition)
- throw new ArgumentException(Environment.GetResourceString("Argument_FieldNeedGenericDeclaringType"), nameof(field));
+ throw new ArgumentException(SR.Argument_FieldNeedGenericDeclaringType, nameof(field));
Contract.EndContractBlock();
-
+
if (!(type is TypeBuilderInstantiation))
- throw new ArgumentException(Environment.GetResourceString("Argument_NeedNonGenericType"), nameof(type));
+ throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(type));
// TypeBuilder G<T> ==> TypeBuilderInstantiation G<T>
if (type is TypeBuilder && type.IsGenericTypeDefinition)
type = type.MakeGenericType(type.GetGenericArguments());
if (type.GetGenericTypeDefinition() != field.DeclaringType)
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFieldDeclaringType"), nameof(type));
+ throw new ArgumentException(SR.Argument_InvalidFieldDeclaringType, nameof(type));
return FieldOnTypeBuilderInstantiation.GetField(field, type as TypeBuilderInstantiation);
}
@@ -168,41 +170,41 @@ namespace System.Reflection.Emit {
#region Private Static FCalls
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
private static extern void SetParentType(RuntimeModule module, int tdTypeDef, int tkParent);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
private static extern void AddInterfaceImpl(RuntimeModule module, int tdTypeDef, int tkInterface);
#endregion
#region Internal Static FCalls
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- internal static extern int DefineMethod(RuntimeModule module, int tkParent, String name, byte[] signature, int sigLength,
+ [SuppressUnmanagedCodeSecurity]
+ internal static extern int DefineMethod(RuntimeModule module, int tkParent, String name, byte[] signature, int sigLength,
MethodAttributes attributes);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
internal static extern int DefineMethodSpec(RuntimeModule module, int tkParent, byte[] signature, int sigLength);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- internal static extern int DefineField(RuntimeModule module, int tkParent, String name, byte[] signature, int sigLength,
+ [SuppressUnmanagedCodeSecurity]
+ internal static extern int DefineField(RuntimeModule module, int tkParent, String name, byte[] signature, int sigLength,
FieldAttributes attributes);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private static extern void SetMethodIL(RuntimeModule module, int tk, bool isInitLocals,
+ [SuppressUnmanagedCodeSecurity]
+ private static extern void SetMethodIL(RuntimeModule module, int tk, bool isInitLocals,
byte[] body, int bodyLength,
- byte[] LocalSig, int sigLength,
+ byte[] LocalSig, int sigLength,
int maxStackSize,
- ExceptionHandler[] exceptions, int numExceptions,
- int [] tokenFixups, int numTokenFixups);
+ ExceptionHandler[] exceptions, int numExceptions,
+ int[] tokenFixups, int numTokenFixups);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- private static extern void DefineCustomAttribute(RuntimeModule module, int tkAssociate, int tkConstructor,
+ [SuppressUnmanagedCodeSecurity]
+ private static extern void DefineCustomAttribute(RuntimeModule module, int tkAssociate, int tkConstructor,
byte[] attr, int attrLength, bool toDisk, bool updateCompilerFlags);
internal static void DefineCustomAttribute(ModuleBuilder module, int tkAssociate, int tkConstructor,
@@ -216,55 +218,55 @@ namespace System.Reflection.Emit {
Buffer.BlockCopy(attr, 0, localAttr, 0, attr.Length);
}
- DefineCustomAttribute(module.GetNativeHandle(), tkAssociate, tkConstructor,
+ DefineCustomAttribute(module.GetNativeHandle(), tkAssociate, tkConstructor,
localAttr, (localAttr != null) ? localAttr.Length : 0, toDisk, updateCompilerFlags);
}
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
internal static extern int DefineProperty(RuntimeModule module, int tkParent, String name, PropertyAttributes attributes,
byte[] signature, int sigLength);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
internal static extern int DefineEvent(RuntimeModule module, int tkParent, String name, EventAttributes attributes, int tkEventType);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- internal static extern void DefineMethodSemantics(RuntimeModule module, int tkAssociation,
+ [SuppressUnmanagedCodeSecurity]
+ internal static extern void DefineMethodSemantics(RuntimeModule module, int tkAssociation,
MethodSemanticsAttributes semantics, int tkMethod);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
internal static extern void DefineMethodImpl(RuntimeModule module, int tkType, int tkBody, int tkDecl);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
internal static extern void SetMethodImpl(RuntimeModule module, int tkMethod, MethodImplAttributes MethodImplAttributes);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
- internal static extern int SetParamInfo(RuntimeModule module, int tkMethod, int iSequence,
+ [SuppressUnmanagedCodeSecurity]
+ internal static extern int SetParamInfo(RuntimeModule module, int tkMethod, int iSequence,
ParameterAttributes iParamAttributes, String strParamName);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
internal static extern int GetTokenFromSig(RuntimeModule module, byte[] signature, int sigLength);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
internal static extern void SetFieldLayoutOffset(RuntimeModule module, int fdToken, int iOffset);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
internal static extern void SetClassLayout(RuntimeModule module, int tk, PackingSize iPackingSize, int iTypeSize);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
private static extern unsafe void SetConstantValue(RuntimeModule module, int tk, int corType, void* pValue);
-#endregion
-#region Internal\Private Static Members
+ #endregion
+ #region Internal\Private Static Members
[Pure]
internal static bool IsTypeEqual(Type t1, Type t2)
@@ -273,14 +275,14 @@ namespace System.Reflection.Emit {
if (t1 == t2)
return true;
TypeBuilder tb1 = null;
- TypeBuilder tb2 = null;
- Type runtimeType1 = null;
- Type runtimeType2 = null;
-
+ TypeBuilder tb2 = null;
+ Type runtimeType1 = null;
+ Type runtimeType2 = null;
+
// set up the runtimeType and TypeBuilder type corresponding to t1 and t2
if (t1 is TypeBuilder)
{
- tb1 =(TypeBuilder)t1;
+ tb1 = (TypeBuilder)t1;
// This will be null if it is not baked.
runtimeType1 = tb1.m_bakedRuntimeType;
}
@@ -291,7 +293,7 @@ namespace System.Reflection.Emit {
if (t2 is TypeBuilder)
{
- tb2 =(TypeBuilder)t2;
+ tb2 = (TypeBuilder)t2;
// This will be null if it is not baked.
runtimeType2 = tb2.m_bakedRuntimeType;
}
@@ -299,16 +301,16 @@ namespace System.Reflection.Emit {
{
runtimeType2 = t2;
}
-
+
// If the type builder view is eqaul then it is equal
if (tb1 != null && tb2 != null && Object.ReferenceEquals(tb1, tb2))
return true;
// if the runtimetype view is eqaul than it is equal
- if (runtimeType1 != null && runtimeType2 != null && runtimeType1 == runtimeType2)
+ if (runtimeType1 != null && runtimeType2 != null && runtimeType1 == runtimeType2)
return true;
- return false;
+ return false;
}
internal static unsafe void SetConstantValue(ModuleBuilder module, int tk, Type destType, Object value)
@@ -349,7 +351,7 @@ namespace System.Reflection.Emit {
// The constant value supplied should match either the baked enum type or its underlying type
// we don't need to compare it with the EnumBuilder itself because you can never have an object of that type
if (type != enumBldr.m_typeBuilder.m_bakedRuntimeType && type != underlyingType)
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstantDoesntMatch"));
+ throw new ArgumentException(SR.Argument_ConstantDoesntMatch);
}
else if ((typeBldr = destType as TypeBuilder) != null)
{
@@ -358,7 +360,7 @@ namespace System.Reflection.Emit {
// The constant value supplied should match either the baked enum type or its underlying type
// typeBldr.m_enumUnderlyingType is null if the user hasn't created a "value__" field on the enum
if (underlyingType == null || (type != typeBldr.UnderlyingSystemType && type != underlyingType))
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstantDoesntMatch"));
+ throw new ArgumentException(SR.Argument_ConstantDoesntMatch);
}
else // must be a runtime Enum Type
{
@@ -368,7 +370,7 @@ namespace System.Reflection.Emit {
// The constant value supplied should match either the enum itself or its underlying type
if (type != destType && type != underlyingType)
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstantDoesntMatch"));
+ throw new ArgumentException(SR.Argument_ConstantDoesntMatch);
}
type = underlyingType;
@@ -377,9 +379,9 @@ namespace System.Reflection.Emit {
{
// Note that it is non CLS compliant if destType != type. But RefEmit never guarantees CLS-Compliance.
if (!destType.IsAssignableFrom(type))
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstantDoesntMatch"));
+ throw new ArgumentException(SR.Argument_ConstantDoesntMatch);
}
-
+
CorElementType corType = RuntimeTypeHandle.GetCorElementType((RuntimeType)type);
switch (corType)
@@ -414,7 +416,7 @@ namespace System.Reflection.Emit {
}
else
{
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstantNotSupported", type.ToString()));
+ throw new ArgumentException(SR.Format(SR.Argument_ConstantNotSupported, type.ToString()));
}
break;
}
@@ -425,7 +427,7 @@ namespace System.Reflection.Emit {
{
// nullable types can hold null value.
if (!(destType.IsGenericType && destType.GetGenericTypeDefinition() == typeof(Nullable<>)))
- throw new ArgumentException(Environment.GetResourceString("Argument_ConstantNull"));
+ throw new ArgumentException(SR.Argument_ConstantNull);
}
SetConstantValue(module.GetNativeHandle(), tk, (int)CorElementType.Class, null);
@@ -436,7 +438,7 @@ namespace System.Reflection.Emit {
#region Private Data Members
private List<CustAttr> m_ca;
- private TypeToken m_tdType;
+ private TypeToken m_tdType;
private ModuleBuilder m_module;
private String m_strName;
private String m_strNameSpace;
@@ -483,8 +485,8 @@ namespace System.Reflection.Emit {
{
Contract.Requires(declMeth != null);
m_declMeth = declMeth;
- m_DeclaringType =m_declMeth.GetTypeBuilder();
- m_module =declMeth.GetModuleBuilder();
+ m_DeclaringType = m_declMeth.GetTypeBuilder();
+ m_module = declMeth.GetModuleBuilder();
InitAsGenericParam(szName, genParamPos);
}
@@ -493,7 +495,7 @@ namespace System.Reflection.Emit {
{
Contract.Requires(declType != null);
m_DeclaringType = declType;
- m_module =declType.GetModuleBuilder();
+ m_module = declType.GetModuleBuilder();
InitAsGenericParam(szName, genParamPos);
}
@@ -512,7 +514,7 @@ namespace System.Reflection.Emit {
Type[] interfaces,
ModuleBuilder module,
PackingSize iPackingSize,
- int iTypeSize,
+ int iTypeSize,
TypeBuilder enclosingType)
{
Init(name, attr, parent, interfaces, module, iPackingSize, iTypeSize, enclosingType);
@@ -525,14 +527,14 @@ namespace System.Reflection.Emit {
throw new ArgumentNullException(nameof(fullname));
if (fullname.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(fullname));
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(fullname));
if (fullname[0] == '\0')
- throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), nameof(fullname));
+ throw new ArgumentException(SR.Argument_IllegalName, nameof(fullname));
if (fullname.Length > 1023)
- throw new ArgumentException(Environment.GetResourceString("Argument_TypeNameTooLong"), nameof(fullname));
+ throw new ArgumentException(SR.Argument_TypeNameTooLong, nameof(fullname));
Contract.EndContractBlock();
int i;
@@ -547,14 +549,14 @@ namespace System.Reflection.Emit {
{
// Nested Type should have nested attribute set.
// If we are renumbering TypeAttributes' bit, we need to change the logic here.
- if (((attr & TypeAttributes.VisibilityMask) == TypeAttributes.Public) ||((attr & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic))
- throw new ArgumentException(Environment.GetResourceString("Argument_BadNestedTypeFlags"), nameof(attr));
+ if (((attr & TypeAttributes.VisibilityMask) == TypeAttributes.Public) || ((attr & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic))
+ throw new ArgumentException(SR.Argument_BadNestedTypeFlags, nameof(attr));
}
int[] interfaceTokens = null;
if (interfaces != null)
{
- for(i = 0; i < interfaces.Length; i++)
+ for (i = 0; i < interfaces.Length; i++)
{
if (interfaces[i] == null)
{
@@ -563,7 +565,7 @@ namespace System.Reflection.Emit {
}
}
interfaceTokens = new int[interfaces.Length + 1];
- for(i = 0; i < interfaces.Length; i++)
+ for (i = 0; i < interfaces.Length; i++)
{
interfaceTokens[i] = m_module.GetTypeTokenInternal(interfaces[i]).Token;
}
@@ -609,14 +611,14 @@ namespace System.Reflection.Emit {
m_iPackingSize = iPackingSize;
m_iTypeSize = iTypeSize;
- if ((m_iPackingSize != 0) ||(m_iTypeSize != 0))
+ if ((m_iPackingSize != 0) || (m_iTypeSize != 0))
SetClassLayout(GetModuleBuilder().GetNativeHandle(), m_tdType.Token, m_iPackingSize, m_iTypeSize);
m_module.AddType(FullName, this);
}
-#endregion
-#region Private Members
+ #endregion
+ #region Private Members
private FieldBuilder DefineDataHelper(String name, byte[] data, int size, FieldAttributes attributes)
{
@@ -629,10 +631,10 @@ namespace System.Reflection.Emit {
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name));
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
if (size <= 0 || size >= 0x003f0000)
- throw new ArgumentException(Environment.GetResourceString("Argument_BadSizeForData"));
+ throw new ArgumentException(SR.Argument_BadSizeForData);
Contract.EndContractBlock();
ThrowIfCreated();
@@ -653,7 +655,7 @@ namespace System.Reflection.Emit {
valueClassType.CreateType();
}
- fdBuilder = DefineField(name, valueClassType,(attributes | FieldAttributes.Static));
+ fdBuilder = DefineField(name, valueClassType, (attributes | FieldAttributes.Static));
// now we need to set the RVA
fdBuilder.SetData(data, size);
@@ -666,54 +668,54 @@ namespace System.Reflection.Emit {
if (DeclaringType == null)
{
// Not a nested class.
- if (((attr & TypeAttributes.VisibilityMask) != TypeAttributes.NotPublic) &&((attr & TypeAttributes.VisibilityMask) != TypeAttributes.Public))
+ if (((attr & TypeAttributes.VisibilityMask) != TypeAttributes.NotPublic) && ((attr & TypeAttributes.VisibilityMask) != TypeAttributes.Public))
{
- throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeAttrNestedVisibilityOnNonNestedType"));
+ throw new ArgumentException(SR.Argument_BadTypeAttrNestedVisibilityOnNonNestedType);
}
}
else
{
// Nested class.
- if (((attr & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic) ||((attr & TypeAttributes.VisibilityMask) == TypeAttributes.Public))
+ if (((attr & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic) || ((attr & TypeAttributes.VisibilityMask) == TypeAttributes.Public))
{
- throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeAttrNonNestedVisibilityNestedType"));
+ throw new ArgumentException(SR.Argument_BadTypeAttrNonNestedVisibilityNestedType);
}
}
// Verify that the layout mask is valid.
- if (((attr & TypeAttributes.LayoutMask) != TypeAttributes.AutoLayout) &&((attr & TypeAttributes.LayoutMask) != TypeAttributes.SequentialLayout) &&((attr & TypeAttributes.LayoutMask) != TypeAttributes.ExplicitLayout))
+ if (((attr & TypeAttributes.LayoutMask) != TypeAttributes.AutoLayout) && ((attr & TypeAttributes.LayoutMask) != TypeAttributes.SequentialLayout) && ((attr & TypeAttributes.LayoutMask) != TypeAttributes.ExplicitLayout))
{
- throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeAttrInvalidLayout"));
+ throw new ArgumentException(SR.Argument_BadTypeAttrInvalidLayout);
}
// Check if the user attempted to set any reserved bits.
if ((attr & TypeAttributes.ReservedMask) != 0)
{
- throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeAttrReservedBitsSet"));
+ throw new ArgumentException(SR.Argument_BadTypeAttrReservedBitsSet);
}
}
[Pure]
public bool IsCreated()
- {
+ {
return m_hasBeenCreated;
}
-
+
#endregion
#region FCalls
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
private extern static int DefineType(RuntimeModule module,
String fullname, int tkParent, TypeAttributes attributes, int tkEnclosingType, int[] interfaceTokens);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
private extern static int DefineGenericParam(RuntimeModule module,
String name, int tkParent, GenericParameterAttributes attributes, int position, int[] constraints);
[DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
- [SuppressUnmanagedCodeSecurity]
+ [SuppressUnmanagedCodeSecurity]
private static extern void TermCreateClass(RuntimeModule module, int tk, ObjectHandleOnStack type);
#endregion
@@ -721,7 +723,7 @@ namespace System.Reflection.Emit {
internal void ThrowIfCreated()
{
if (IsCreated())
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TypeHasBeenCreated"));
+ throw new InvalidOperationException(SR.InvalidOperation_TypeHasBeenCreated);
}
internal object SyncRoot
@@ -749,12 +751,12 @@ namespace System.Reflection.Emit {
{
m_genParamAttributes = genericParameterAttributes;
}
-
+
internal void SetGenParamCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
{
CustAttr ca = new CustAttr(con, binaryAttribute);
- lock(SyncRoot)
+ lock (SyncRoot)
{
SetGenParamCustomAttributeNoLock(ca);
}
@@ -764,7 +766,7 @@ namespace System.Reflection.Emit {
{
CustAttr ca = new CustAttr(customBuilder);
- lock(SyncRoot)
+ lock (SyncRoot)
{
SetGenParamCustomAttributeNoLock(ca);
}
@@ -774,7 +776,7 @@ namespace System.Reflection.Emit {
{
if (m_ca == null)
m_ca = new List<TypeBuilder.CustAttr>();
-
+
m_ca.Add(ca);
}
#endregion
@@ -782,30 +784,30 @@ namespace System.Reflection.Emit {
#region Object Overrides
public override String ToString()
{
- return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.ToString);
+ return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.ToString);
}
#endregion
#region MemberInfo Overrides
- public override Type DeclaringType
+ public override Type DeclaringType
{
get { return m_DeclaringType; }
}
- public override Type ReflectedType
+ public override Type ReflectedType
{
// Return the class that was used to obtain this field.
-
+
get { return m_DeclaringType; }
}
- public override String Name
+ public override String Name
{
get { return m_strName; }
}
- public override Module Module
+ public override Module Module
{
get { return GetModuleBuilder(); }
}
@@ -818,12 +820,12 @@ namespace System.Reflection.Emit {
#endregion
#region Type Overrides
- public override Guid GUID
+ public override Guid GUID
{
- get
+ get
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GUID;
@@ -834,27 +836,26 @@ namespace System.Reflection.Emit {
Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.InvokeMember(name, invokeAttr, binder, target, args, modifiers, culture, namedParameters);
}
- public override Assembly Assembly
+ public override Assembly Assembly
{
get { return m_module.Assembly; }
}
- public override RuntimeTypeHandle TypeHandle
+ public override RuntimeTypeHandle TypeHandle
{
-
- get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); }
+ get { throw new NotSupportedException(SR.NotSupported_DynamicModule); }
}
- public override String FullName
+ public override String FullName
{
- get
- {
+ get
+ {
if (m_strFullQualName == null)
m_strFullQualName = TypeNameBuilder.ToString(this, TypeNameBuilder.Format.FullName);
@@ -862,29 +863,29 @@ namespace System.Reflection.Emit {
}
}
- public override String Namespace
+ public override String Namespace
{
get { return m_strNameSpace; }
}
- public override String AssemblyQualifiedName
+ public override String AssemblyQualifiedName
{
- get
- {
+ get
+ {
return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.AssemblyQualifiedName);
}
}
- public override Type BaseType
+ public override Type BaseType
{
- get{ return m_typeParent; }
+ get { return m_typeParent; }
}
- protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr,Binder binder,
- CallingConventions callConvention, Type[] types,ParameterModifier[] modifiers)
+ protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder,
+ CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetConstructor(bindingAttr, binder, callConvention, types, modifiers);
@@ -893,17 +894,17 @@ namespace System.Reflection.Emit {
public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetConstructors(bindingAttr);
}
- protected override MethodInfo GetMethodImpl(String name,BindingFlags bindingAttr,Binder binder,
- CallingConventions callConvention, Type[] types,ParameterModifier[] modifiers)
+ protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder,
+ CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
if (types == null)
@@ -919,7 +920,7 @@ namespace System.Reflection.Emit {
public override MethodInfo[] GetMethods(BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetMethods(bindingAttr);
@@ -928,7 +929,7 @@ namespace System.Reflection.Emit {
public override FieldInfo GetField(String name, BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetField(name, bindingAttr);
@@ -937,18 +938,18 @@ namespace System.Reflection.Emit {
public override FieldInfo[] GetFields(BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetFields(bindingAttr);
}
- public override Type GetInterface(String name,bool ignoreCase)
+ public override Type GetInterface(String name, bool ignoreCase)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
-
+
return m_bakedRuntimeType.GetInterface(name, ignoreCase);
}
@@ -961,16 +962,16 @@ namespace System.Reflection.Emit {
if (m_typeInterfaces == null)
{
- return EmptyArray<Type>.Value;
+ return Array.Empty<Type>();
}
return m_typeInterfaces.ToArray();
}
- public override EventInfo GetEvent(String name,BindingFlags bindingAttr)
+ public override EventInfo GetEvent(String name, BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetEvent(name, bindingAttr);
@@ -979,7 +980,7 @@ namespace System.Reflection.Emit {
public override EventInfo[] GetEvents()
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetEvents();
@@ -988,13 +989,13 @@ namespace System.Reflection.Emit {
protected override PropertyInfo GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder,
Type returnType, Type[] types, ParameterModifier[] modifiers)
{
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
public override PropertyInfo[] GetProperties(BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetProperties(bindingAttr);
@@ -1003,7 +1004,7 @@ namespace System.Reflection.Emit {
public override Type[] GetNestedTypes(BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetNestedTypes(bindingAttr);
@@ -1012,16 +1013,16 @@ namespace System.Reflection.Emit {
public override Type GetNestedType(String name, BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
- return m_bakedRuntimeType.GetNestedType(name,bindingAttr);
+ return m_bakedRuntimeType.GetNestedType(name, bindingAttr);
}
public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetMember(name, type, bindingAttr);
@@ -1030,7 +1031,7 @@ namespace System.Reflection.Emit {
public override InterfaceMapping GetInterfaceMap(Type interfaceType)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetInterfaceMap(interfaceType);
@@ -1039,7 +1040,7 @@ namespace System.Reflection.Emit {
public override EventInfo[] GetEvents(BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetEvents(bindingAttr);
@@ -1048,66 +1049,68 @@ namespace System.Reflection.Emit {
public override MemberInfo[] GetMembers(BindingFlags bindingAttr)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return m_bakedRuntimeType.GetMembers(bindingAttr);
}
-
+
public override bool IsAssignableFrom(Type c)
{
if (TypeBuilder.IsTypeEqual(c, this))
return true;
-
+
Type fromRuntimeType = null;
TypeBuilder fromTypeBuilder = c as TypeBuilder;
-
+
if (fromTypeBuilder != null)
fromRuntimeType = fromTypeBuilder.m_bakedRuntimeType;
else
fromRuntimeType = c;
-
+
if (fromRuntimeType != null && fromRuntimeType is RuntimeType)
{
// fromType is baked. So if this type is not baked, it cannot be assignable to!
if (m_bakedRuntimeType == null)
return false;
-
+
// since toType is also baked, delegate to the base
return m_bakedRuntimeType.IsAssignableFrom(fromRuntimeType);
}
-
+
// So if c is not a runtimeType nor TypeBuilder. We don't know how to deal with it.
// return false then.
if (fromTypeBuilder == null)
return false;
-
+
// If fromTypeBuilder is a subclass of this class, then c can be cast to this type.
if (fromTypeBuilder.IsSubclassOf(this))
return true;
-
+
if (this.IsInterface == false)
return false;
-
+
// now is This type a base type on one of the interface impl?
Type[] interfaces = fromTypeBuilder.GetInterfaces();
- for(int i = 0; i < interfaces.Length; i++)
+ for (int i = 0; i < interfaces.Length; i++)
{
// unfortunately, IsSubclassOf does not cover the case when they are the same type.
if (TypeBuilder.IsTypeEqual(interfaces[i], this))
return true;
-
+
if (interfaces[i].IsSubclassOf(this))
return true;
}
- return false;
- }
+ return false;
+ }
protected override TypeAttributes GetAttributeFlagsImpl()
{
return m_iAttr;
}
+ public override bool IsSZArray => false;
+
protected override bool IsArrayImpl()
{
return false;
@@ -1127,14 +1130,13 @@ namespace System.Reflection.Emit {
protected override bool IsCOMObjectImpl()
{
- return((GetAttributeFlagsImpl() & TypeAttributes.Import) != 0) ? true : false;
+ return ((GetAttributeFlagsImpl() & TypeAttributes.Import) != 0) ? true : false;
}
public override Type GetElementType()
{
-
// You will never have to deal with a TypeBuilder if you are just referring to arrays.
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
}
protected override bool HasElementTypeImpl()
@@ -1165,9 +1167,9 @@ namespace System.Reflection.Emit {
if (TypeBuilder.IsTypeEqual(p, c))
return false;
- p = p.BaseType;
-
- while(p != null)
+ p = p.BaseType;
+
+ while (p != null)
{
if (TypeBuilder.IsTypeEqual(p, c))
return true;
@@ -1177,10 +1179,10 @@ namespace System.Reflection.Emit {
return false;
}
-
- public override Type UnderlyingSystemType
+
+ public override Type UnderlyingSystemType
{
- get
+ get
{
if (m_bakedRuntimeType != null)
return m_bakedRuntimeType;
@@ -1188,9 +1190,9 @@ namespace System.Reflection.Emit {
if (IsEnum)
{
if (m_enumUnderlyingType == null)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NoUnderlyingTypeOnEnum"));
-
- return m_enumUnderlyingType;
+ throw new InvalidOperationException(SR.InvalidOperation_NoUnderlyingTypeOnEnum);
+
+ return m_enumUnderlyingType;
}
else
{
@@ -1199,22 +1201,22 @@ namespace System.Reflection.Emit {
}
}
- public override Type MakePointerType()
- {
- return SymbolType.FormCompoundType("*", this, 0);
+ public override Type MakePointerType()
+ {
+ return SymbolType.FormCompoundType("*", this, 0);
}
- public override Type MakeByRefType()
+ public override Type MakeByRefType()
{
return SymbolType.FormCompoundType("&", this, 0);
}
- public override Type MakeArrayType()
+ public override Type MakeArrayType()
{
return SymbolType.FormCompoundType("[]", this, 0);
}
- public override Type MakeArrayType(int rank)
+ public override Type MakeArrayType(int rank)
{
if (rank <= 0)
throw new IndexOutOfRangeException();
@@ -1225,9 +1227,9 @@ namespace System.Reflection.Emit {
{
szrank = "*";
}
- else
+ else
{
- for(int i = 1; i < rank; i++)
+ for (int i = 1; i < rank; i++)
szrank += ",";
}
@@ -1241,7 +1243,7 @@ namespace System.Reflection.Emit {
public override Object[] GetCustomAttributes(bool inherit)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
Contract.EndContractBlock();
return CustomAttribute.GetCustomAttributes(m_bakedRuntimeType, typeof(object) as RuntimeType, inherit);
@@ -1250,7 +1252,7 @@ namespace System.Reflection.Emit {
public override Object[] GetCustomAttributes(Type attributeType, bool inherit)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
@@ -1259,7 +1261,7 @@ namespace System.Reflection.Emit {
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType));
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.GetCustomAttributes(m_bakedRuntimeType, attributeRuntimeType, inherit);
}
@@ -1267,7 +1269,7 @@ namespace System.Reflection.Emit {
public override bool IsDefined(Type attributeType, bool inherit)
{
if (!IsCreated())
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated"));
+ throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated);
if (attributeType == null)
throw new ArgumentNullException(nameof(attributeType));
@@ -1276,7 +1278,7 @@ namespace System.Reflection.Emit {
RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType;
if (attributeRuntimeType == null)
- throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"),nameof(attributeType));
+ throw new ArgumentException(SR.Arg_MustBeType, nameof(attributeType));
return CustomAttribute.IsDefined(m_bakedRuntimeType, attributeRuntimeType, inherit);
}
@@ -1284,12 +1286,12 @@ namespace System.Reflection.Emit {
#endregion
#region Public Member
-
+
#region DefineType
public override GenericParameterAttributes GenericParameterAttributes { get { return m_genParamAttributes; } }
- internal void SetInterfaces(params Type[] interfaces)
- {
+ internal void SetInterfaces(params Type[] interfaces)
+ {
ThrowIfCreated();
m_typeInterfaces = new List<Type>();
@@ -1308,8 +1310,8 @@ namespace System.Reflection.Emit {
if (names.Length == 0)
throw new ArgumentException();
Contract.EndContractBlock();
-
- for (int i = 0; i < names.Length; i ++)
+
+ for (int i = 0; i < names.Length; i++)
if (names[i] == null)
throw new ArgumentNullException(nameof(names));
@@ -1317,25 +1319,25 @@ namespace System.Reflection.Emit {
throw new InvalidOperationException();
m_inst = new GenericTypeParameterBuilder[names.Length];
- for(int i = 0; i < names.Length; i ++)
+ for (int i = 0; i < names.Length; i++)
m_inst[i] = new GenericTypeParameterBuilder(new TypeBuilder(names[i], i, this));
return m_inst;
}
-
- public override Type MakeGenericType(params Type[] typeArguments)
- {
+
+ public override Type MakeGenericType(params Type[] typeArguments)
+ {
CheckContext(typeArguments);
-
- return TypeBuilderInstantiation.MakeGenericType(this, typeArguments);
+
+ return TypeBuilderInstantiation.MakeGenericType(this, typeArguments);
}
-
+
public override Type[] GetGenericArguments() { return m_inst; }
// If a TypeBuilder is generic, it must be a generic type definition
// All instantiated generic types are TypeBuilderInstantiation.
public override bool IsGenericTypeDefinition { get { return IsGenericType; } }
- public override bool IsGenericType { get { return m_inst != null; } }
+ public override bool IsGenericType { get { return m_inst != null; } }
public override bool IsGenericParameter { get { return m_bIsGenParam; } }
public override bool IsConstructedGenericType { get { return false; } }
@@ -1347,7 +1349,7 @@ namespace System.Reflection.Emit {
#region Define Method
public void DefineMethodOverride(MethodInfo methodInfoBody, MethodInfo methodInfoDeclaration)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
DefineMethodOverrideNoLock(methodInfoBody, methodInfoDeclaration);
}
@@ -1363,13 +1365,13 @@ namespace System.Reflection.Emit {
Contract.EndContractBlock();
ThrowIfCreated();
-
+
if (!object.ReferenceEquals(methodInfoBody.DeclaringType, this))
// Loader restriction: body method has to be from this class
- throw new ArgumentException(Environment.GetResourceString("ArgumentException_BadMethodImplBody"));
-
- MethodToken tkBody;
- MethodToken tkDecl;
+ throw new ArgumentException(SR.ArgumentException_BadMethodImplBody);
+
+ MethodToken tkBody;
+ MethodToken tkDecl;
tkBody = m_module.GetMethodTokenInternal(methodInfoBody);
tkDecl = m_module.GetMethodTokenInternal(methodInfoDeclaration);
@@ -1405,21 +1407,21 @@ namespace System.Reflection.Emit {
return DefineMethod(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null);
}
-
+
public MethodBuilder DefineMethod(String name, MethodAttributes attributes, CallingConventions callingConvention,
Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
{
Contract.Ensures(Contract.Result<MethodBuilder>() != null);
- lock(SyncRoot)
+ lock (SyncRoot)
{
- return DefineMethodNoLock(name, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers,
- returnTypeOptionalCustomModifiers, parameterTypes, parameterTypeRequiredCustomModifiers,
+ return DefineMethodNoLock(name, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers,
+ returnTypeOptionalCustomModifiers, parameterTypes, parameterTypeRequiredCustomModifiers,
parameterTypeOptionalCustomModifiers);
}
}
-
+
private MethodBuilder DefineMethodNoLock(String name, MethodAttributes attributes, CallingConventions callingConvention,
Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
@@ -1428,7 +1430,7 @@ namespace System.Reflection.Emit {
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name));
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
Contract.Ensures(Contract.Result<MethodBuilder>() != null);
Contract.EndContractBlock();
@@ -1440,10 +1442,10 @@ namespace System.Reflection.Emit {
if (parameterTypes != null)
{
if (parameterTypeOptionalCustomModifiers != null && parameterTypeOptionalCustomModifiers.Length != parameterTypes.Length)
- throw new ArgumentException(Environment.GetResourceString("Argument_MismatchedArrays", nameof(parameterTypeOptionalCustomModifiers), nameof(parameterTypes)));
+ throw new ArgumentException(SR.Format(SR.Argument_MismatchedArrays, nameof(parameterTypeOptionalCustomModifiers), nameof(parameterTypes)));
if (parameterTypeRequiredCustomModifiers != null && parameterTypeRequiredCustomModifiers.Length != parameterTypes.Length)
- throw new ArgumentException(Environment.GetResourceString("Argument_MismatchedArrays", nameof(parameterTypeRequiredCustomModifiers), nameof(parameterTypes)));
+ throw new ArgumentException(SR.Format(SR.Argument_MismatchedArrays, nameof(parameterTypeRequiredCustomModifiers), nameof(parameterTypes)));
}
ThrowIfCreated();
@@ -1451,21 +1453,21 @@ namespace System.Reflection.Emit {
if (!m_isHiddenGlobalType)
{
if (((m_iAttr & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface) &&
- (attributes & MethodAttributes.Abstract) == 0 &&(attributes & MethodAttributes.Static) == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_BadAttributeOnInterfaceMethod"));
+ (attributes & MethodAttributes.Abstract) == 0 && (attributes & MethodAttributes.Static) == 0)
+ throw new ArgumentException(SR.Argument_BadAttributeOnInterfaceMethod);
}
// pass in Method attributes
MethodBuilder method = new MethodBuilder(
- name, attributes, callingConvention,
+ name, attributes, callingConvention,
returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
- parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers,
+ parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers,
m_module, this, false);
if (!m_isHiddenGlobalType)
{
//If this method is declared to be a constructor, increment our constructor count.
- if ((method.Attributes & MethodAttributes.SpecialName) != 0 && method.Name.Equals(ConstructorInfo.ConstructorName))
+ if ((method.Attributes & MethodAttributes.SpecialName) != 0 && method.Name.Equals(ConstructorInfo.ConstructorName))
{
m_constructorCount++;
}
@@ -1481,7 +1483,7 @@ namespace System.Reflection.Emit {
#region Define Constructor
public ConstructorBuilder DefineTypeInitializer()
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineTypeInitializerNoLock();
}
@@ -1504,10 +1506,10 @@ namespace System.Reflection.Emit {
{
if ((m_iAttr & TypeAttributes.Interface) == TypeAttributes.Interface)
{
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ConstructorNotAllowedOnInterface"));
+ throw new InvalidOperationException(SR.InvalidOperation_ConstructorNotAllowedOnInterface);
}
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineDefaultConstructorNoLock(attributes);
}
@@ -1533,14 +1535,14 @@ namespace System.Reflection.Emit {
genericTypeDefinition = ((TypeBuilder)genericTypeDefinition).m_bakedRuntimeType;
if (genericTypeDefinition == null)
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
+ throw new NotSupportedException(SR.NotSupported_DynamicModule);
Type inst = genericTypeDefinition.MakeGenericType(m_typeParent.GetGenericArguments());
if (inst is TypeBuilderInstantiation)
con = TypeBuilder.GetConstructor(inst, genericTypeDefinition.GetConstructor(
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null));
- else
+ else
con = inst.GetConstructor(
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
}
@@ -1551,7 +1553,7 @@ namespace System.Reflection.Emit {
}
if (con == null)
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_NoParentDefaultConstructor"));
+ throw new NotSupportedException(SR.NotSupported_NoParentDefaultConstructor);
// Define the constructor Builder
constBuilder = DefineConstructor(attributes, CallingConventions.Standard, null);
@@ -1560,7 +1562,7 @@ namespace System.Reflection.Emit {
// generate the code to call the parent's default constructor
ILGenerator il = constBuilder.GetILGenerator();
il.Emit(OpCodes.Ldarg_0);
- il.Emit(OpCodes.Call,con);
+ il.Emit(OpCodes.Call, con);
il.Emit(OpCodes.Ret);
constBuilder.m_isDefaultConstructor = true;
@@ -1572,21 +1574,21 @@ namespace System.Reflection.Emit {
return DefineConstructor(attributes, callingConvention, parameterTypes, null, null);
}
- public ConstructorBuilder DefineConstructor(MethodAttributes attributes, CallingConventions callingConvention,
+ public ConstructorBuilder DefineConstructor(MethodAttributes attributes, CallingConventions callingConvention,
Type[] parameterTypes, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers)
{
if ((m_iAttr & TypeAttributes.Interface) == TypeAttributes.Interface && (attributes & MethodAttributes.Static) != MethodAttributes.Static)
{
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ConstructorNotAllowedOnInterface"));
+ throw new InvalidOperationException(SR.InvalidOperation_ConstructorNotAllowedOnInterface);
}
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineConstructorNoLock(attributes, callingConvention, parameterTypes, requiredCustomModifiers, optionalCustomModifiers);
}
}
- private ConstructorBuilder DefineConstructorNoLock(MethodAttributes attributes, CallingConventions callingConvention,
+ private ConstructorBuilder DefineConstructorNoLock(MethodAttributes attributes, CallingConventions callingConvention,
Type[] parameterTypes, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers)
{
CheckContext(parameterTypes);
@@ -1608,8 +1610,8 @@ namespace System.Reflection.Emit {
attributes = attributes | MethodAttributes.SpecialName;
- ConstructorBuilder constBuilder =
- new ConstructorBuilder(name, attributes, callingConvention,
+ ConstructorBuilder constBuilder =
+ new ConstructorBuilder(name, attributes, callingConvention,
parameterTypes, requiredCustomModifiers, optionalCustomModifiers, m_module, this);
m_constructorCount++;
@@ -1622,7 +1624,7 @@ namespace System.Reflection.Emit {
#region Define Nested Type
public TypeBuilder DefineNestedType(String name)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineNestedTypeNoLock(name, TypeAttributes.NestedPrivate, null, null, PackingSize.Unspecified, UnspecifiedTypeSize);
}
@@ -1630,7 +1632,7 @@ namespace System.Reflection.Emit {
public TypeBuilder DefineNestedType(String name, TypeAttributes attr, Type parent, Type[] interfaces)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
// Why do we only call CheckContext here? Why don't we call it in the other overloads?
CheckContext(parent);
@@ -1642,7 +1644,7 @@ namespace System.Reflection.Emit {
public TypeBuilder DefineNestedType(String name, TypeAttributes attr, Type parent)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineNestedTypeNoLock(name, attr, parent, null, PackingSize.Unspecified, UnspecifiedTypeSize);
}
@@ -1650,7 +1652,7 @@ namespace System.Reflection.Emit {
public TypeBuilder DefineNestedType(String name, TypeAttributes attr)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineNestedTypeNoLock(name, attr, null, null, PackingSize.Unspecified, UnspecifiedTypeSize);
}
@@ -1658,7 +1660,7 @@ namespace System.Reflection.Emit {
public TypeBuilder DefineNestedType(String name, TypeAttributes attr, Type parent, int typeSize)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineNestedTypeNoLock(name, attr, parent, null, PackingSize.Unspecified, typeSize);
}
@@ -1666,7 +1668,7 @@ namespace System.Reflection.Emit {
public TypeBuilder DefineNestedType(String name, TypeAttributes attr, Type parent, PackingSize packSize)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineNestedTypeNoLock(name, attr, parent, null, packSize, UnspecifiedTypeSize);
}
@@ -1688,22 +1690,22 @@ namespace System.Reflection.Emit {
#endregion
#region Define Field
- public FieldBuilder DefineField(String fieldName, Type type, FieldAttributes attributes)
+ public FieldBuilder DefineField(String fieldName, Type type, FieldAttributes attributes)
{
return DefineField(fieldName, type, null, null, attributes);
}
- public FieldBuilder DefineField(String fieldName, Type type, Type[] requiredCustomModifiers,
- Type[] optionalCustomModifiers, FieldAttributes attributes)
+ public FieldBuilder DefineField(String fieldName, Type type, Type[] requiredCustomModifiers,
+ Type[] optionalCustomModifiers, FieldAttributes attributes)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineFieldNoLock(fieldName, type, requiredCustomModifiers, optionalCustomModifiers, attributes);
}
}
- private FieldBuilder DefineFieldNoLock(String fieldName, Type type, Type[] requiredCustomModifiers,
- Type[] optionalCustomModifiers, FieldAttributes attributes)
+ private FieldBuilder DefineFieldNoLock(String fieldName, Type type, Type[] requiredCustomModifiers,
+ Type[] optionalCustomModifiers, FieldAttributes attributes)
{
ThrowIfCreated();
CheckContext(type);
@@ -1715,7 +1717,7 @@ namespace System.Reflection.Emit {
{
// remember the underlying type for enum type
m_enumUnderlyingType = type;
- }
+ }
}
return new FieldBuilder(this, fieldName, type, requiredCustomModifiers, optionalCustomModifiers, attributes);
@@ -1723,7 +1725,7 @@ namespace System.Reflection.Emit {
public FieldBuilder DefineInitializedData(String name, byte[] data, FieldAttributes attributes)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineInitializedDataNoLock(name, data, attributes);
}
@@ -1744,7 +1746,7 @@ namespace System.Reflection.Emit {
public FieldBuilder DefineUninitializedData(String name, int size, FieldAttributes attributes)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineUninitializedDataNoLock(name, size, attributes);
}
@@ -1763,44 +1765,44 @@ namespace System.Reflection.Emit {
#region Define Properties and Events
public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes, Type returnType, Type[] parameterTypes)
{
- return DefineProperty(name, attributes, returnType, null, null, parameterTypes, null, null);
+ return DefineProperty(name, attributes, returnType, null, null, parameterTypes, null, null);
}
- public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes,
+ public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes,
CallingConventions callingConvention, Type returnType, Type[] parameterTypes)
{
- return DefineProperty(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null);
+ return DefineProperty(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null);
}
- public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes,
- Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
+ public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes,
+ Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
{
- return DefineProperty(name, attributes, (CallingConventions)0, returnType,
- returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
- parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers);
+ return DefineProperty(name, attributes, (CallingConventions)0, returnType,
+ returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
+ parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers);
}
- public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes, CallingConventions callingConvention,
- Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
+ public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes, CallingConventions callingConvention,
+ Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
- return DefinePropertyNoLock(name, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
+ return DefinePropertyNoLock(name, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers);
}
}
private PropertyBuilder DefinePropertyNoLock(String name, PropertyAttributes attributes, CallingConventions callingConvention,
- Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
+ Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
{
if (name == null)
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name));
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
Contract.EndContractBlock();
CheckContext(returnType);
@@ -1809,8 +1811,8 @@ namespace System.Reflection.Emit {
CheckContext(parameterTypeOptionalCustomModifiers);
SignatureHelper sigHelper;
- int sigLength;
- byte[] sigBytes;
+ int sigLength;
+ byte[] sigBytes;
ThrowIfCreated();
@@ -1844,7 +1846,7 @@ namespace System.Reflection.Emit {
public EventBuilder DefineEvent(String name, EventAttributes attributes, Type eventtype)
{
- lock(SyncRoot)
+ lock (SyncRoot)
{
return DefineEventNoLock(name, attributes, eventtype);
}
@@ -1855,19 +1857,19 @@ namespace System.Reflection.Emit {
if (name == null)
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name));
+ throw new ArgumentException(SR.Argument_EmptyName, nameof(name));
if (name[0] == '\0')
- throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), nameof(name));
+ throw new ArgumentException(SR.Argument_IllegalName, nameof(name));
Contract.EndContractBlock();
int tkType;
- EventToken evToken;
-
+ EventToken evToken;
+
CheckContext(eventtype);
ThrowIfCreated();
- tkType = m_module.GetTypeTokenInternal( eventtype ).Token;
+ tkType = m_module.GetTypeTokenInternal(eventtype).Token;
// Internal helpers to define property records
evToken = new EventToken(DefineEvent(
@@ -1909,7 +1911,7 @@ namespace System.Reflection.Emit {
internal void CheckContext(params Type[][] typess)
{
- m_module.CheckContext(typess);
+ m_module.CheckContext(typess);
}
internal void CheckContext(params Type[] types)
{
@@ -1927,7 +1929,7 @@ namespace System.Reflection.Emit {
m_typeInterfaces = new List<Type>();
int[] interfaceTokens = new int[m_typeInterfaces.Count];
- for(int i = 0; i < m_typeInterfaces.Count; i++)
+ for (int i = 0; i < m_typeInterfaces.Count; i++)
{
interfaceTokens[i] = m_module.GetTypeTokenInternal(m_typeInterfaces[i]).Token;
}
@@ -1976,16 +1978,16 @@ namespace System.Reflection.Emit {
// Check for global typebuilder
if (((m_tdType.Token & 0x00FFFFFF) != 0) && ((tkParent & 0x00FFFFFF) != 0))
SetParentType(m_module.GetNativeHandle(), m_tdType.Token, tkParent);
-
+
if (m_inst != null)
foreach (Type tb in m_inst)
if (tb is GenericTypeParameterBuilder)
((GenericTypeParameterBuilder)tb).m_type.CreateType();
}
- byte [] body;
+ byte[] body;
MethodAttributes methodAttrs;
-
+
if (!m_isHiddenGlobalType)
{
// create a public default constructor if this class has no constructor.
@@ -1998,7 +2000,7 @@ namespace System.Reflection.Emit {
int size = m_listMethods.Count;
- for(int i = 0; i < size; i++)
+ for (int i = 0; i < size; i++)
{
MethodBuilder meth = m_listMethods[i];
@@ -2009,19 +2011,19 @@ namespace System.Reflection.Emit {
methodAttrs = meth.Attributes;
// Any of these flags in the implemenation flags is set, we will not attach the IL method body
- if (((meth.GetMethodImplementationFlags() &(MethodImplAttributes.CodeTypeMask|MethodImplAttributes.PreserveSig|MethodImplAttributes.Unmanaged)) != MethodImplAttributes.IL) ||
- ((methodAttrs & MethodAttributes.PinvokeImpl) !=(MethodAttributes) 0))
+ if (((meth.GetMethodImplementationFlags() & (MethodImplAttributes.CodeTypeMask | MethodImplAttributes.PreserveSig | MethodImplAttributes.Unmanaged)) != MethodImplAttributes.IL) ||
+ ((methodAttrs & MethodAttributes.PinvokeImpl) != (MethodAttributes)0))
{
continue;
}
int sigLength;
byte[] localSig = meth.GetLocalSignature(out sigLength);
-
+
// Check that they haven't declared an abstract method on a non-abstract class
- if (((methodAttrs & MethodAttributes.Abstract) != 0) &&((m_iAttr & TypeAttributes.Abstract) == 0))
+ if (((methodAttrs & MethodAttributes.Abstract) != 0) && ((m_iAttr & TypeAttributes.Abstract) == 0))
{
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadTypeAttributesNotAbstract"));
+ throw new InvalidOperationException(SR.InvalidOperation_BadTypeAttributesNotAbstract);
}
body = meth.GetBody();
@@ -2036,7 +2038,7 @@ namespace System.Reflection.Emit {
//((m_iAttr & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface))
if (body != null)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadMethodBody"));
+ throw new InvalidOperationException(SR.InvalidOperation_BadMethodBody);
}
else if (body == null || body.Length == 0)
{
@@ -2051,7 +2053,7 @@ namespace System.Reflection.Emit {
if ((body == null || body.Length == 0) && !meth.m_canBeRuntimeImpl)
throw new InvalidOperationException(
- Environment.GetResourceString("InvalidOperation_BadEmptyMethodBody", meth.Name) );
+ SR.Format(SR.InvalidOperation_BadEmptyMethodBody, meth.Name));
}
int maxStack = meth.GetMaxStack();
@@ -2059,7 +2061,7 @@ namespace System.Reflection.Emit {
ExceptionHandler[] exceptions = meth.GetExceptionHandlers();
int[] tokenFixups = meth.GetTokenFixups();
- SetMethodIL(m_module.GetNativeHandle(), meth.GetToken().Token, meth.InitLocals,
+ SetMethodIL(m_module.GetNativeHandle(), meth.GetToken().Token, meth.InitLocals,
body, (body != null) ? body.Length : 0,
localSig, sigLength, maxStack,
exceptions, (exceptions != null) ? exceptions.Length : 0,
@@ -2086,7 +2088,7 @@ namespace System.Reflection.Emit {
// if this type is a nested type, we need to invalidate the cached nested runtime type on the nesting type
if (m_DeclaringType != null && m_DeclaringType.m_bakedRuntimeType != null)
{
- m_DeclaringType.m_bakedRuntimeType.InvalidateCachedNestedType();
+ m_DeclaringType.m_bakedRuntimeType.InvalidateCachedNestedType();
}
return cls;
@@ -2104,8 +2106,8 @@ namespace System.Reflection.Emit {
{
get { return m_iTypeSize; }
}
-
- public PackingSize PackingSize
+
+ public PackingSize PackingSize
{
get { return m_iPackingSize; }
}
@@ -2119,7 +2121,7 @@ namespace System.Reflection.Emit {
CheckContext(parent);
if (parent.IsInterface)
- throw new ArgumentException(Environment.GetResourceString("Argument_CannotSetParentToInterface"));
+ throw new ArgumentException(SR.Argument_CannotSetParentToInterface);
m_typeParent = parent;
}
@@ -2132,7 +2134,7 @@ namespace System.Reflection.Emit {
else
{
if ((m_iAttr & TypeAttributes.Abstract) == 0)
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadInterfaceNotAbstract"));
+ throw new InvalidOperationException(SR.InvalidOperation_BadInterfaceNotAbstract);
// there is no extends for interface class
m_typeParent = null;
@@ -2149,7 +2151,7 @@ namespace System.Reflection.Emit {
Contract.EndContractBlock();
CheckContext(interfaceType);
-
+
ThrowIfCreated();
TypeToken tkInterface = m_module.GetTypeTokenInternal(interfaceType);
@@ -2158,14 +2160,14 @@ namespace System.Reflection.Emit {
m_typeInterfaces.Add(interfaceType);
}
-public TypeToken TypeToken
+ public TypeToken TypeToken
{
- get
+ get
{
if (IsGenericParameter)
ThrowIfCreated();
- return m_tdType;
+ return m_tdType;
}
}