diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2017-04-13 14:17:19 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2017-04-13 14:17:19 +0900 |
commit | a56e30c8d33048216567753d9d3fefc2152af8ac (patch) | |
tree | 7e5d979695fc4a431740982eb1cfecc2898b23a5 /src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs | |
parent | 4b11dc566a5bbfa1378d6266525c281b028abcc8 (diff) | |
download | coreclr-a56e30c8d33048216567753d9d3fefc2152af8ac.tar.gz coreclr-a56e30c8d33048216567753d9d3fefc2152af8ac.tar.bz2 coreclr-a56e30c8d33048216567753d9d3fefc2152af8ac.zip |
Imported Upstream version 2.0.0.11353upstream/2.0.0.11353
Diffstat (limited to 'src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs')
-rw-r--r-- | src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs index 5d08ca08f0..cf5bd11de6 100644 --- a/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs @@ -12,18 +12,19 @@ ** ** ===========================================================*/ -namespace System.Reflection.Emit { - - - using System; - using System.Reflection; - using System.IO; - using System.Text; - using System.Runtime.InteropServices; - using System.Globalization; - using System.Diagnostics; - using System.Diagnostics.Contracts; - + + +using System; +using System.Reflection; +using System.IO; +using System.Text; +using System.Runtime.InteropServices; +using System.Globalization; +using System.Diagnostics; +using System.Diagnostics.Contracts; + +namespace System.Reflection.Emit +{ public class CustomAttributeBuilder { // public constructor to form the custom attribute with constructor and constructor @@ -31,17 +32,17 @@ namespace System.Reflection.Emit { public CustomAttributeBuilder(ConstructorInfo con, Object[] constructorArgs) { InitCustomAttributeBuilder(con, constructorArgs, - new PropertyInfo[]{}, new Object[]{}, - new FieldInfo[]{}, new Object[]{}); + new PropertyInfo[] { }, new Object[] { }, + new FieldInfo[] { }, new Object[] { }); } - + // public constructor to form the custom attribute with constructor, constructor // parameters and named properties. public CustomAttributeBuilder(ConstructorInfo con, Object[] constructorArgs, PropertyInfo[] namedProperties, Object[] propertyValues) { InitCustomAttributeBuilder(con, constructorArgs, namedProperties, - propertyValues, new FieldInfo[]{}, new Object[]{}); + propertyValues, new FieldInfo[] { }, new Object[] { }); } // public constructor to form the custom attribute with constructor and constructor @@ -49,8 +50,8 @@ namespace System.Reflection.Emit { public CustomAttributeBuilder(ConstructorInfo con, Object[] constructorArgs, FieldInfo[] namedFields, Object[] fieldValues) { - InitCustomAttributeBuilder(con, constructorArgs, new PropertyInfo[]{}, - new Object[]{}, namedFields, fieldValues); + InitCustomAttributeBuilder(con, constructorArgs, new PropertyInfo[] { }, + new Object[] { }, namedFields, fieldValues); } // public constructor to form the custom attribute with constructor and constructor @@ -117,17 +118,17 @@ namespace System.Reflection.Emit { if (fieldValues == null) throw new ArgumentNullException(nameof(fieldValues)); if (namedProperties.Length != propertyValues.Length) - throw new ArgumentException(Environment.GetResourceString("Arg_ArrayLengthsDiffer"), "namedProperties, propertyValues"); + throw new ArgumentException(SR.Arg_ArrayLengthsDiffer, "namedProperties, propertyValues"); if (namedFields.Length != fieldValues.Length) - throw new ArgumentException(Environment.GetResourceString("Arg_ArrayLengthsDiffer"), "namedFields, fieldValues"); + throw new ArgumentException(SR.Arg_ArrayLengthsDiffer, "namedFields, fieldValues"); Contract.EndContractBlock(); if ((con.Attributes & MethodAttributes.Static) == MethodAttributes.Static || (con.Attributes & MethodAttributes.MemberAccessMask) == MethodAttributes.Private) - throw new ArgumentException(Environment.GetResourceString("Argument_BadConstructor")); + throw new ArgumentException(SR.Argument_BadConstructor); if ((con.CallingConvention & CallingConventions.Standard) != CallingConventions.Standard) - throw new ArgumentException(Environment.GetResourceString("Argument_BadConstructorCallConv")); + throw new ArgumentException(SR.Argument_BadConstructorCallConv); // Cache information used elsewhere. m_con = con; @@ -142,12 +143,12 @@ namespace System.Reflection.Emit { // Since we're guaranteed a non-var calling convention, the number of arguments must equal the number of parameters. if (paramTypes.Length != constructorArgs.Length) - throw new ArgumentException(Environment.GetResourceString("Argument_BadParameterCountsForConstructor")); + throw new ArgumentException(SR.Argument_BadParameterCountsForConstructor); // Verify that the constructor has a valid signature (custom attributes only support a subset of our type system). for (i = 0; i < paramTypes.Length; i++) if (!ValidateType(paramTypes[i])) - throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeInCustomAttribute")); + throw new ArgumentException(SR.Argument_BadTypeInCustomAttribute); // Now verify that the types of the actual parameters are compatible with the types of the formal parameters. for (i = 0; i < paramTypes.Length; i++) @@ -194,11 +195,11 @@ namespace System.Reflection.Emit { // Validate property type. if (!ValidateType(propType)) - throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeInCustomAttribute")); + throw new ArgumentException(SR.Argument_BadTypeInCustomAttribute); // Property has to be writable. if (!property.CanWrite) - throw new ArgumentException(Environment.GetResourceString("Argument_NotAWritableProperty")); + throw new ArgumentException(SR.Argument_NotAWritableProperty); // Property has to be from the same class or base class as ConstructorInfo. if (property.DeclaringType != con.DeclaringType @@ -216,7 +217,7 @@ namespace System.Reflection.Emit { // type is one. if (!(property.DeclaringType is TypeBuilder) || !con.DeclaringType.IsSubclassOf(((TypeBuilder)property.DeclaringType).BakedRuntimeType)) - throw new ArgumentException(Environment.GetResourceString("Argument_BadPropertyForConstructorBuilder")); + throw new ArgumentException(SR.Argument_BadPropertyForConstructorBuilder); } } @@ -252,7 +253,7 @@ namespace System.Reflection.Emit { // Validate field type. if (!ValidateType(fldType)) - throw new ArgumentException(Environment.GetResourceString("Argument_BadTypeInCustomAttribute")); + throw new ArgumentException(SR.Argument_BadTypeInCustomAttribute); // Field has to be from the same class or base class as ConstructorInfo. if (namedField.DeclaringType != con.DeclaringType @@ -270,7 +271,7 @@ namespace System.Reflection.Emit { // type is one. if (!(namedField.DeclaringType is TypeBuilder) || !con.DeclaringType.IsSubclassOf(((TypeBuilder)namedFields[i].DeclaringType).BakedRuntimeType)) - throw new ArgumentException(Environment.GetResourceString("Argument_BadFieldForConstructorBuilder")); + throw new ArgumentException(SR.Argument_BadFieldForConstructorBuilder); } } @@ -280,7 +281,7 @@ namespace System.Reflection.Emit { { VerifyTypeAndPassedObjectType(fldType, fieldValue.GetType(), $"{nameof(fieldValues)}[{i}]"); } - + // First a byte indicating that this is a field. writer.Write((byte)CustomAttributeEncoding.Field); @@ -298,11 +299,11 @@ namespace System.Reflection.Emit { { if (type != typeof(object) && Type.GetTypeCode(passedType) != Type.GetTypeCode(type)) { - throw new ArgumentException(Environment.GetResourceString("Argument_ConstantDoesntMatch")); + throw new ArgumentException(SR.Argument_ConstantDoesntMatch); } if (passedType == typeof(IntPtr) || passedType == typeof(UIntPtr)) { - throw new ArgumentException(Environment.GetResourceString("Argument_BadParameterTypeForCAB"), paramName); + throw new ArgumentException(SR.Argument_BadParameterTypeForCAB, paramName); } } @@ -452,8 +453,7 @@ namespace System.Reflection.Emit { { String typeName = TypeNameBuilder.ToString((Type)value, TypeNameBuilder.Format.AssemblyQualifiedName); if (typeName == null) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidTypeForCA", - value.GetType())); + throw new ArgumentException(SR.Format(SR.Argument_InvalidTypeForCA, value.GetType())); EmitString(writer, typeName); } } @@ -526,8 +526,8 @@ namespace System.Reflection.Emit { // value cannot be a "System.Object" object. // If we allow this we will get into an infinite recursion if (ot == typeof(object)) - throw new ArgumentException(Environment.GetResourceString("Argument_BadParameterTypeForCAB", ot.ToString())); - + throw new ArgumentException(SR.Format(SR.Argument_BadParameterTypeForCAB, ot.ToString())); + EmitType(writer, ot); EmitValue(writer, ot, value); } @@ -537,13 +537,13 @@ namespace System.Reflection.Emit { if (value != null) typename = value.GetType().ToString(); - - throw new ArgumentException(Environment.GetResourceString("Argument_BadParameterTypeForCAB", typename)); + + throw new ArgumentException(SR.Format(SR.Argument_BadParameterTypeForCAB, typename)); } } - - + + // return the byte interpretation of the custom attribute internal void CreateCustomAttribute(ModuleBuilder mod, int tkOwner) @@ -556,12 +556,12 @@ namespace System.Reflection.Emit { //************************************************* internal void CreateCustomAttribute(ModuleBuilder mod, int tkOwner, int tkAttrib, bool toDisk) { - TypeBuilder.DefineCustomAttribute(mod, tkOwner, tkAttrib, m_blob, toDisk, + TypeBuilder.DefineCustomAttribute(mod, tkOwner, tkAttrib, m_blob, toDisk, typeof(System.Diagnostics.DebuggableAttribute) == m_con.DeclaringType); } - internal ConstructorInfo m_con; - internal Object[] m_constructorArgs; - internal byte[] m_blob; + internal ConstructorInfo m_con; + internal Object[] m_constructorArgs; + internal byte[] m_blob; } } |