diff options
Diffstat (limited to 'src/mscorlib/src/System/Reflection')
48 files changed, 438 insertions, 439 deletions
diff --git a/src/mscorlib/src/System/Reflection/AmbiguousMatchException.cs b/src/mscorlib/src/System/Reflection/AmbiguousMatchException.cs index 36091d0296..11abf8ddda 100644 --- a/src/mscorlib/src/System/Reflection/AmbiguousMatchException.cs +++ b/src/mscorlib/src/System/Reflection/AmbiguousMatchException.cs @@ -23,7 +23,7 @@ namespace System.Reflection public sealed class AmbiguousMatchException : SystemException { public AmbiguousMatchException() - : base(Environment.GetResourceString("RFLCT.Ambiguous")) + : base(SR.RFLCT_Ambiguous) { SetErrorCode(__HResults.COR_E_AMBIGUOUSMATCH); } diff --git a/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs b/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs index 86f7f42512..82966dba60 100644 --- a/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs +++ b/src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs @@ -47,7 +47,7 @@ namespace System.Reflection byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_AssemblyLoadFromHash")); + throw new NotSupportedException(SR.NotSupported_AssemblyLoadFromHash); } // Locate an assembly by the long form of the assembly name. @@ -104,7 +104,7 @@ namespace System.Reflection if (assemblyRef != null && assemblyRef.CodeBase != null) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_AssemblyLoadCodeBase")); + throw new NotSupportedException(SR.NotSupported_AssemblyLoadCodeBase); } StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; @@ -121,7 +121,7 @@ namespace System.Reflection if (assemblyRef != null && assemblyRef.CodeBase != null) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_AssemblyLoadCodeBase")); + throw new NotSupportedException(SR.NotSupported_AssemblyLoadCodeBase); } StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; @@ -164,7 +164,7 @@ namespace System.Reflection if (PathInternal.IsPartiallyQualified(path)) { - throw new ArgumentException(Environment.GetResourceString("Argument_AbsolutePathRequired"), nameof(path)); + throw new ArgumentException(SR.Argument_AbsolutePathRequired, nameof(path)); } string normalizedPath = Path.GetFullPath(path); diff --git a/src/mscorlib/src/System/Reflection/AssemblyName.cs b/src/mscorlib/src/System/Reflection/AssemblyName.cs index 202bd07655..a1b9034391 100644 --- a/src/mscorlib/src/System/Reflection/AssemblyName.cs +++ b/src/mscorlib/src/System/Reflection/AssemblyName.cs @@ -366,7 +366,7 @@ namespace System.Reflection Contract.EndContractBlock(); if ((assemblyName.Length == 0) || (assemblyName[0] == '\0')) - throw new ArgumentException(Environment.GetResourceString("Format_StringZeroLength")); + throw new ArgumentException(SR.Format_StringZeroLength); _Name = assemblyName; nInit(); @@ -545,7 +545,7 @@ namespace System.Reflection { // Should be a rare case where the app tries to feed an invalid Unicode surrogates pair if (count == 1 || count == end - i) - throw new FormatException(Environment.GetResourceString("Arg_FormatException")); + throw new FormatException(SR.Arg_FormatException); // need to grab one more char as a Surrogate except when it's a bogus input ++count; } @@ -561,7 +561,7 @@ namespace System.Reflection // This is the only exception that built in UriParser can throw after a Uri ctor. // Should not happen unless the app tries to feed an invalid Unicode String if (numberOfBytes == 0) - throw new FormatException(Environment.GetResourceString("Arg_FormatException")); + throw new FormatException(SR.Arg_FormatException); i += (count - 1); diff --git a/src/mscorlib/src/System/Reflection/CustomAttribute.cs b/src/mscorlib/src/System/Reflection/CustomAttribute.cs index c12187d7c8..0c8271b9a9 100644 --- a/src/mscorlib/src/System/Reflection/CustomAttribute.cs +++ b/src/mscorlib/src/System/Reflection/CustomAttribute.cs @@ -268,7 +268,7 @@ namespace System.Reflection if (type.IsValueType) return CustomAttributeEncoding.Undefined; - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidKindOfTypeForCA"), nameof(type)); + throw new ArgumentException(SR.Argument_InvalidKindOfTypeForCA, nameof(type)); } private static CustomAttributeType InitCustomAttributeType(RuntimeType parameterType) { @@ -604,7 +604,7 @@ namespace System.Reflection else if (property != null) type = property.PropertyType; else - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidMemberForNamedArgument")); + throw new ArgumentException(SR.Argument_InvalidMemberForNamedArgument); m_memberInfo = memberInfo; m_value = new CustomAttributeTypedArgument(type, value); @@ -730,7 +730,7 @@ namespace System.Reflection return typeof(object); default: - throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)encodedType), nameof(encodedType)); + throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)encodedType), nameof(encodedType)); } } @@ -775,7 +775,7 @@ namespace System.Reflection unsafe { return *(double*)&val; } default: - throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)val), nameof(val)); + throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)val), nameof(val)); } } private static RuntimeType ResolveType(RuntimeModule scope, string typeName) @@ -784,7 +784,7 @@ namespace System.Reflection if (type == null) throw new InvalidOperationException( - String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Arg_CATypeResolutionFailed"), typeName)); + String.Format(CultureInfo.CurrentUICulture, SR.Arg_CATypeResolutionFailed, typeName)); return type; } @@ -1524,7 +1524,7 @@ namespace System.Reflection RuntimeModule decoratedModule, int decoratedMetadataToken, RuntimeType attributeFilterType, int attributeCtorToken, bool mustBeInheritable) { if (decoratedModule.Assembly.ReflectionOnly) - throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyCA")); + throw new InvalidOperationException(SR.Arg_ReflectionOnlyCA); Contract.EndContractBlock(); CustomAttributeRecord[] car = CustomAttributeData.GetCustomAttributeRecords(decoratedModule, decoratedMetadataToken); @@ -1580,7 +1580,7 @@ namespace System.Reflection RuntimeType attributeFilterType, bool mustBeInheritable, IList derivedAttributes, bool isDecoratedTargetSecurityTransparent) { if (decoratedModule.Assembly.ReflectionOnly) - throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyCA")); + throw new InvalidOperationException(SR.Arg_ReflectionOnlyCA); Contract.EndContractBlock(); MetadataImport scope = decoratedModule.MetadataImport; @@ -1700,8 +1700,8 @@ namespace System.Reflection if (property == null) { throw new CustomAttributeFormatException( - String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString( - isProperty ? "RFLCT.InvalidPropFail" : "RFLCT.InvalidFieldFail"), name)); + String.Format(CultureInfo.CurrentUICulture, + isProperty ? SR.RFLCT_InvalidPropFail : SR.RFLCT_InvalidFieldFail, name)); } RuntimeMethodInfo setMethod = property.GetSetMethod(true) as RuntimeMethodInfo; @@ -1731,8 +1731,8 @@ namespace System.Reflection catch (Exception e) { throw new CustomAttributeFormatException( - String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString( - isProperty ? "RFLCT.InvalidPropFail" : "RFLCT.InvalidFieldFail"), name), e); + String.Format(CultureInfo.CurrentUICulture, + isProperty ? SR.RFLCT_InvalidPropFail : SR.RFLCT_InvalidFieldFail, name), e); } #endregion } @@ -1905,7 +1905,7 @@ namespace System.Reflection if (attributeUsageAttribute != null) throw new FormatException(String.Format( - CultureInfo.CurrentUICulture, Environment.GetResourceString("Format_AttributeUsage"), attributeType)); + CultureInfo.CurrentUICulture, SR.Format_AttributeUsage, attributeType)); AttributeTargets targets; bool inherited, allowMultiple; diff --git a/src/mscorlib/src/System/Reflection/CustomAttributeFormatException.cs b/src/mscorlib/src/System/Reflection/CustomAttributeFormatException.cs index 83ef54138e..7f88e0c286 100644 --- a/src/mscorlib/src/System/Reflection/CustomAttributeFormatException.cs +++ b/src/mscorlib/src/System/Reflection/CustomAttributeFormatException.cs @@ -20,7 +20,7 @@ namespace System.Reflection public class CustomAttributeFormatException : FormatException { public CustomAttributeFormatException() - : base(Environment.GetResourceString("Arg_CustomAttributeFormatException")) + : base(SR.Arg_CustomAttributeFormatException) { SetErrorCode(__HResults.COR_E_CUSTOMATTRIBUTEFORMAT); } diff --git a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs index 2ff87a02ac..6d9cb0db2f 100644 --- a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilder.cs @@ -94,39 +94,39 @@ namespace System.Reflection.Emit #region Methods inherited from Assembly public override String[] GetManifestResourceNames() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly")); + throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } public override FileStream GetFile(String name) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly")); + throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } public override FileStream[] GetFiles(bool getResourceModules) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly")); + throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } public override Stream GetManifestResourceStream(Type type, String name) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly")); + throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } public override Stream GetManifestResourceStream(String name) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly")); + throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } public override ManifestResourceInfo GetManifestResourceInfo(String resourceName) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly")); + throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } public override String Location { get { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly")); + throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } } @@ -134,13 +134,13 @@ namespace System.Reflection.Emit { get { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly")); + throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } } public override Type[] GetExportedTypes() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicAssembly")); + throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } public override String ImageRuntimeVersion @@ -231,7 +231,7 @@ namespace System.Reflection.Emit && access != AssemblyBuilderAccess.RunAndCollect ) { - throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)access), nameof(access)); + throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)access), nameof(access)); } if (securityContextSource < SecurityContextSource.CurrentAppDomain || @@ -441,9 +441,9 @@ 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_InvalidName"), nameof(name)); + throw new ArgumentException(SR.Argument_InvalidName, nameof(name)); Contract.Ensures(Contract.Result<ModuleBuilder>() != null); Contract.EndContractBlock(); @@ -457,7 +457,7 @@ namespace System.Reflection.Emit // create the dynamic module- only one ModuleBuilder per AssemblyBuilder can be created if (m_fManifestModuleUsedAsDefinedModule == true) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NoMultiModuleAssembly")); + throw new InvalidOperationException(SR.InvalidOperation_NoMultiModuleAssembly); // Init(...) has already been called on m_manifestModuleBuilder in InitManifestModule() dynModule = m_manifestModuleBuilder; @@ -511,16 +511,16 @@ namespace System.Reflection.Emit continue; if (type.Module == null || type.Module.Assembly == null) - throw new ArgumentException(Environment.GetResourceString("Argument_TypeNotValid")); + throw new ArgumentException(SR.Argument_TypeNotValid); if (type.Module.Assembly == typeof(object).Module.Assembly) continue; if (type.Module.Assembly.ReflectionOnly && !ReflectionOnly) - throw new InvalidOperationException(Environment.GetResourceString("Arugment_EmitMixedContext1", type.AssemblyQualifiedName)); + throw new InvalidOperationException(SR.Format(SR.Arugment_EmitMixedContext1, type.AssemblyQualifiedName)); if (!type.Module.Assembly.ReflectionOnly && ReflectionOnly) - throw new InvalidOperationException(Environment.GetResourceString("Arugment_EmitMixedContext2", type.AssemblyQualifiedName)); + throw new InvalidOperationException(SR.Format(SR.Arugment_EmitMixedContext2, type.AssemblyQualifiedName)); } } @@ -742,7 +742,7 @@ 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)); Contract.EndContractBlock(); BCLDebug.Log("DYNIL", "## DYNIL LOGGING: AssemblyBuilder.GetDynamicModule( " + name + " )"); diff --git a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs index a2fb2b602c..529ba54514 100644 --- a/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs +++ b/src/mscorlib/src/System/Reflection/Emit/AssemblyBuilderData.cs @@ -120,7 +120,7 @@ namespace System.Reflection.Emit // if (enclosingType == null && m_assembly.GetType(strTypeName, false, false) != null) // { // // Cannot have two types with the same name - // throw new ArgumentException(Environment.GetResourceString("Argument_DuplicateTypeName")); + // throw new ArgumentException(SR.Argument_DuplicateTypeName); // } } diff --git a/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs index 185d2041a2..3ca9b2eb9d 100644 --- a/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/ConstructorBuilder.cs @@ -102,7 +102,7 @@ namespace System.Reflection.Emit #region MethodBase Overrides public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } [Pure] @@ -132,7 +132,7 @@ namespace System.Reflection.Emit #region ConstructorInfo Overrides public override Object Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } #endregion @@ -175,7 +175,7 @@ namespace System.Reflection.Emit public ILGenerator GetILGenerator() { if (m_isDefaultConstructor) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_DefaultConstructorILGen")); + throw new InvalidOperationException(SR.InvalidOperation_DefaultConstructorILGen); return m_methodBuilder.GetILGenerator(); } @@ -183,7 +183,7 @@ namespace System.Reflection.Emit public ILGenerator GetILGenerator(int streamSize) { if (m_isDefaultConstructor) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_DefaultConstructorILGen")); + throw new InvalidOperationException(SR.InvalidOperation_DefaultConstructorILGen); return m_methodBuilder.GetILGenerator(streamSize); } diff --git a/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs index cbc73455ed..cf5bd11de6 100644 --- a/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/CustomAttributeBuilder.cs @@ -118,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; @@ -143,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++) @@ -195,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 @@ -217,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); } } @@ -253,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 @@ -271,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); } } @@ -299,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); } } @@ -453,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); } } @@ -527,7 +526,7 @@ 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); @@ -539,7 +538,7 @@ 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)); } } diff --git a/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs b/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs index ec725acad7..b592053f9f 100644 --- a/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs +++ b/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs @@ -54,7 +54,7 @@ namespace System.Reflection.Emit RuntimeType rtType = localType as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); + throw new ArgumentException(SR.Argument_MustBeRuntimeType); localBuilder = new LocalBuilder(m_localCount, localType, m_methodBuilder); // add the localType to local signature @@ -81,7 +81,7 @@ namespace System.Reflection.Emit { RuntimeMethodInfo rtMeth = meth as RuntimeMethodInfo; if (rtMeth == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), nameof(meth)); + throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, nameof(meth)); RuntimeType declaringType = rtMeth.GetRuntimeType(); if (declaringType != null && (declaringType.IsGenericType || declaringType.IsArray)) @@ -94,7 +94,7 @@ namespace System.Reflection.Emit // rule out not allowed operations on DynamicMethods if (opcode.Equals(OpCodes.Ldtoken) || opcode.Equals(OpCodes.Ldftn) || opcode.Equals(OpCodes.Ldvirtftn)) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOpCodeOnDynamicMethod")); + throw new ArgumentException(SR.Argument_InvalidOpCodeOnDynamicMethod); } token = GetTokenFor(dynMeth); } @@ -132,7 +132,7 @@ namespace System.Reflection.Emit RuntimeConstructorInfo rtConstructor = con as RuntimeConstructorInfo; if (rtConstructor == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), nameof(con)); + throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, nameof(con)); RuntimeType declaringType = rtConstructor.GetRuntimeType(); int token; @@ -161,7 +161,7 @@ namespace System.Reflection.Emit RuntimeType rtType = type as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); + throw new ArgumentException(SR.Argument_MustBeRuntimeType); int token = GetTokenFor(rtType); EnsureCapacity(7); @@ -177,7 +177,7 @@ namespace System.Reflection.Emit RuntimeFieldInfo runtimeField = field as RuntimeFieldInfo; if (runtimeField == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeFieldInfo"), nameof(field)); + throw new ArgumentException(SR.Argument_MustBeRuntimeFieldInfo, nameof(field)); int token; if (field.DeclaringType == null) @@ -218,7 +218,7 @@ namespace System.Reflection.Emit if (optionalParameterTypes != null) if ((callingConvention & CallingConventions.VarArgs) == 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAVarArgCallingConvention")); + throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention); sig = GetMemberRefSignature(callingConvention, returnType, @@ -254,13 +254,13 @@ namespace System.Reflection.Emit throw new ArgumentNullException(nameof(methodInfo)); if (!(opcode.Equals(OpCodes.Call) || opcode.Equals(OpCodes.Callvirt) || opcode.Equals(OpCodes.Newobj))) - throw new ArgumentException(Environment.GetResourceString("Argument_NotMethodCallOpcode"), nameof(opcode)); + throw new ArgumentException(SR.Argument_NotMethodCallOpcode, nameof(opcode)); if (methodInfo.ContainsGenericParameters) - throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), nameof(methodInfo)); + throw new ArgumentException(SR.Argument_GenericsInvalid, nameof(methodInfo)); if (methodInfo.DeclaringType != null && methodInfo.DeclaringType.ContainsGenericParameters) - throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), nameof(methodInfo)); + throw new ArgumentException(SR.Argument_GenericsInvalid, nameof(methodInfo)); Contract.EndContractBlock(); int tk; @@ -328,7 +328,7 @@ namespace System.Reflection.Emit // Begins an exception filter block. Emits a branch instruction to the end of the current exception block. if (CurrExcStackCount == 0) - throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); + throw new NotSupportedException(SR.Argument_NotInExceptionBlock); __ExceptionInfo current = CurrExcStack[CurrExcStackCount - 1]; @@ -342,7 +342,7 @@ namespace System.Reflection.Emit public override void BeginCatchBlock(Type exceptionType) { if (CurrExcStackCount == 0) - throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); + throw new NotSupportedException(SR.Argument_NotInExceptionBlock); Contract.EndContractBlock(); __ExceptionInfo current = CurrExcStack[CurrExcStackCount - 1]; @@ -353,7 +353,7 @@ namespace System.Reflection.Emit { if (exceptionType != null) { - throw new ArgumentException(Environment.GetResourceString("Argument_ShouldNotSpecifyExceptionType")); + throw new ArgumentException(SR.Argument_ShouldNotSpecifyExceptionType); } this.Emit(OpCodes.Endfilter); @@ -367,7 +367,7 @@ namespace System.Reflection.Emit throw new ArgumentNullException(nameof(exceptionType)); if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); + throw new ArgumentException(SR.Argument_MustBeRuntimeType); Label endLabel = current.GetEndLabel(); this.Emit(OpCodes.Leave, endLabel); @@ -392,7 +392,7 @@ namespace System.Reflection.Emit [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. public override void UsingNamespace(String ns) { - throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod")); + throw new NotSupportedException(SR.InvalidOperation_NotAllowedInDynamicMethod); } [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. @@ -402,17 +402,17 @@ namespace System.Reflection.Emit int endLine, int endColumn) { - throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod")); + throw new NotSupportedException(SR.InvalidOperation_NotAllowedInDynamicMethod); } public override void BeginScope() { - throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod")); + throw new NotSupportedException(SR.InvalidOperation_NotAllowedInDynamicMethod); } public override void EndScope() { - throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod")); + throw new NotSupportedException(SR.InvalidOperation_NotAllowedInDynamicMethod); } private int GetMemberRefToken(MethodBase methodInfo, Type[] optionalParameterTypes) @@ -420,13 +420,13 @@ namespace System.Reflection.Emit Type[] parameterTypes; if (optionalParameterTypes != null && (methodInfo.CallingConvention & CallingConventions.VarArgs) == 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAVarArgCallingConvention")); + throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention); RuntimeMethodInfo rtMeth = methodInfo as RuntimeMethodInfo; DynamicMethod dm = methodInfo as DynamicMethod; if (rtMeth == null && dm == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), nameof(methodInfo)); + throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, nameof(methodInfo)); ParameterInfo[] paramInfo = methodInfo.GetParametersNoCopy(); if (paramInfo != null && paramInfo.Length != 0) @@ -953,7 +953,7 @@ namespace System.Reflection.Emit Type t = m.DeclaringType.GetGenericTypeDefinition(); throw new ArgumentException(String.Format( - CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_MethodDeclaringTypeGenericLcg"), m, t)); + CultureInfo.CurrentCulture, SR.Argument_MethodDeclaringTypeGenericLcg, m, t)); } } diff --git a/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs b/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs index 953b39a5ae..ef4d1ca833 100644 --- a/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs +++ b/src/mscorlib/src/System/Reflection/Emit/DynamicMethod.cs @@ -217,18 +217,18 @@ namespace System.Reflection.Emit { // only static public for method attributes if ((attributes & ~MethodAttributes.MemberAccessMask) != MethodAttributes.Static) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicMethodFlags")); + throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags); if ((attributes & MethodAttributes.MemberAccessMask) != MethodAttributes.Public) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicMethodFlags")); + throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags); Contract.EndContractBlock(); // only standard or varargs supported if (callingConvention != CallingConventions.Standard && callingConvention != CallingConventions.VarArgs) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicMethodFlags")); + throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags); // vararg is not supported at the moment if (callingConvention == CallingConventions.VarArgs) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicMethodFlags")); + throw new NotSupportedException(SR.NotSupported_DynamicMethodFlags); } // We create a transparent assembly to host DynamicMethods. Since the assembly does not have any @@ -288,10 +288,10 @@ namespace System.Reflection.Emit for (int i = 0; i < signature.Length; i++) { if (signature[i] == null) - throw new ArgumentException(Environment.GetResourceString("Arg_InvalidTypeInSignature")); + throw new ArgumentException(SR.Arg_InvalidTypeInSignature); m_parameterTypes[i] = signature[i].UnderlyingSystemType as RuntimeType; if (m_parameterTypes[i] == null || !(m_parameterTypes[i] is RuntimeType) || m_parameterTypes[i] == (RuntimeType)typeof(void)) - throw new ArgumentException(Environment.GetResourceString("Arg_InvalidTypeInSignature")); + throw new ArgumentException(SR.Arg_InvalidTypeInSignature); } } else @@ -302,7 +302,7 @@ namespace System.Reflection.Emit // check and store the return value m_returnType = (returnType == null) ? (RuntimeType)typeof(void) : returnType.UnderlyingSystemType as RuntimeType; if ((m_returnType == null) || !(m_returnType is RuntimeType) || m_returnType.IsByRef) - throw new NotSupportedException(Environment.GetResourceString("Arg_InvalidTypeInRetType")); + throw new NotSupportedException(SR.Arg_InvalidTypeInRetType); if (transparentMethod) { @@ -331,7 +331,7 @@ namespace System.Reflection.Emit { if (rtOwner.HasElementType || rtOwner.ContainsGenericParameters || rtOwner.IsGenericParameter || rtOwner.IsInterface) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidTypeForDynamicMethod")); + throw new ArgumentException(SR.Argument_InvalidTypeForDynamicMethod); m_typeOwner = rtOwner; m_module = rtOwner.GetRuntimeModule(); @@ -400,7 +400,7 @@ namespace System.Reflection.Emit else { if (m_ilGenerator == null || m_ilGenerator.ILOffset == 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadEmptyMethodBody", Name)); + throw new InvalidOperationException(SR.Format(SR.InvalidOperation_BadEmptyMethodBody, Name)); m_ilGenerator.GetCallableMethod(m_module, this); } @@ -425,7 +425,7 @@ namespace System.Reflection.Emit public override Module Module { get { return m_dynMethod.Module; } } // we cannot return a MethodHandle because we cannot track it via GC so this method is off limits - public override RuntimeMethodHandle MethodHandle { get { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod")); } } + public override RuntimeMethodHandle MethodHandle { get { throw new InvalidOperationException(SR.InvalidOperation_NotAllowedInDynamicMethod); } } public override MethodAttributes Attributes { get { return m_dynMethod.Attributes; } } @@ -465,7 +465,7 @@ namespace System.Reflection.Emit public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) { if ((CallingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_CallToVarArg")); + throw new NotSupportedException(SR.NotSupported_CallToVarArg); Contract.EndContractBlock(); // @@ -486,7 +486,7 @@ namespace System.Reflection.Emit int formalCount = sig.Arguments.Length; int actualCount = (parameters != null) ? parameters.Length : 0; if (formalCount != actualCount) - throw new TargetParameterCountException(Environment.GetResourceString("Arg_ParmCnt")); + throw new TargetParameterCountException(SR.Arg_ParmCnt); // if we are here we passed all the previous checks. Time to look at the arguments Object retValue = null; @@ -529,7 +529,7 @@ namespace System.Reflection.Emit public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, String parameterName) { if (position < 0 || position > m_parameterTypes.Length) - throw new ArgumentOutOfRangeException(Environment.GetResourceString("ArgumentOutOfRange_ParamSequence")); + throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_ParamSequence); position--; // it's 1 based. 0 is the return value if (position >= 0) @@ -631,7 +631,7 @@ namespace System.Reflection.Emit public override RuntimeMethodHandle MethodHandle { - get { throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod")); } + get { throw new InvalidOperationException(SR.InvalidOperation_NotAllowedInDynamicMethod); } } public override MethodAttributes Attributes @@ -671,7 +671,7 @@ namespace System.Reflection.Emit // If we allowed use of RTDynamicMethod, the creator of the DynamicMethod would // not be able to bound access to the DynamicMethod. Hence, we do not allow // direct use of RTDynamicMethod. - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), "this"); + throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, "this"); } public override Object[] GetCustomAttributes(Type attributeType, bool inherit) diff --git a/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs index aae90c2ed4..55aa5c5a8f 100644 --- a/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/EnumBuilder.cs @@ -199,7 +199,7 @@ 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) @@ -410,7 +410,7 @@ namespace System.Reflection.Emit { // Client should not set any bits other than the visibility bits. if ((visibility & ~TypeAttributes.VisibilityMask) != 0) - throw new ArgumentException(Environment.GetResourceString("Argument_ShouldOnlySetVisibilityFlags"), nameof(name)); + throw new ArgumentException(SR.Argument_ShouldOnlySetVisibilityFlags, nameof(name)); m_typeBuilder = new TypeBuilder(name, visibility | TypeAttributes.Sealed, typeof(System.Enum), null, module, PackingSize.Unspecified, TypeBuilder.UnspecifiedTypeSize, null); // Define the underlying field for the enum. It will be a non-static, private field with special name bit set. diff --git a/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs index ae28212732..d0e9d3483c 100644 --- a/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/FieldBuilder.cs @@ -31,16 +31,16 @@ namespace System.Reflection.Emit 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; @@ -121,7 +121,7 @@ namespace System.Reflection.Emit // 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) @@ -130,12 +130,12 @@ namespace System.Reflection.Emit // 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 { - get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); } + get { throw new NotSupportedException(SR.NotSupported_DynamicModule); } } public override FieldAttributes Attributes @@ -148,17 +148,17 @@ 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 diff --git a/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs index 4538988c28..dd5ffa92a9 100644 --- a/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs @@ -192,7 +192,7 @@ namespace System.Reflection.Emit public override Type GetGenericTypeDefinition() { throw new InvalidOperationException(); } - public override Type MakeGenericType(params Type[] typeArguments) { throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericTypeDefinition")); } + public override Type MakeGenericType(params Type[] typeArguments) { throw new InvalidOperationException(SR.Arg_NotGenericTypeDefinition); } protected override bool IsValueTypeImpl() { return false; } diff --git a/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs b/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs index fe32417b2e..4021410a33 100644 --- a/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs +++ b/src/mscorlib/src/System/Reflection/Emit/ILGenerator.cs @@ -233,7 +233,7 @@ namespace System.Reflection.Emit if (m_currExcStackCount != 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_UnclosedExceptionBlock")); + throw new ArgumentException(SR.Argument_UnclosedExceptionBlock); } if (m_length == 0) return null; @@ -261,7 +261,7 @@ namespace System.Reflection.Emit //Verify that our one-byte arg will fit into a Signed Byte. if (updateAddr < SByte.MinValue || updateAddr > SByte.MaxValue) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_IllegalOneByteBranch", m_fixupData[i].m_fixupPos, updateAddr)); + throw new NotSupportedException(SR.Format(SR.NotSupported_IllegalOneByteBranch, m_fixupData[i].m_fixupPos, updateAddr)); } //Place the one-byte arg @@ -288,7 +288,7 @@ namespace System.Reflection.Emit __ExceptionInfo[] temp; if (m_currExcStackCount != 0) { - throw new NotSupportedException(Environment.GetResourceString(ResId.Argument_UnclosedExceptionBlock)); + throw new NotSupportedException(SR.GetResourceString(ResId.Argument_UnclosedExceptionBlock)); } if (m_exceptionCount == 0) @@ -342,10 +342,10 @@ namespace System.Reflection.Emit int index = lbl.GetLabelValue(); if (index < 0 || index >= m_labelCount) - throw new ArgumentException(Environment.GetResourceString("Argument_BadLabel")); + throw new ArgumentException(SR.Argument_BadLabel); if (m_labelList[index] < 0) - throw new ArgumentException(Environment.GetResourceString("Argument_BadLabelContent")); + throw new ArgumentException(SR.Argument_BadLabelContent); return m_labelList[index]; } @@ -503,7 +503,7 @@ namespace System.Reflection.Emit if ((callingConvention & CallingConventions.VarArgs) == 0) { // Client should not supply optional parameter in default calling convention - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAVarArgCallingConvention")); + throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention); } } @@ -542,7 +542,7 @@ namespace System.Reflection.Emit throw new ArgumentNullException(nameof(methodInfo)); if (!(opcode.Equals(OpCodes.Call) || opcode.Equals(OpCodes.Callvirt) || opcode.Equals(OpCodes.Newobj))) - throw new ArgumentException(Environment.GetResourceString("Argument_NotMethodCallOpcode"), nameof(opcode)); + throw new ArgumentException(SR.Argument_NotMethodCallOpcode, nameof(opcode)); Contract.EndContractBlock(); @@ -804,7 +804,7 @@ namespace System.Reflection.Emit int tempVal = local.GetLocalIndex(); if (local.GetMethodBuilder() != m_methodBuilder) { - throw new ArgumentException(Environment.GetResourceString("Argument_UnmatchedMethodForLocal"), nameof(local)); + throw new ArgumentException(SR.Argument_UnmatchedMethodForLocal, nameof(local)); } // If the instruction is a ldloc, ldloca a stloc, morph it to the optimal form. if (opcode.Equals(OpCodes.Ldloc)) @@ -872,7 +872,7 @@ namespace System.Reflection.Emit //Handle stloc_1, ldloc_1 if (tempVal > Byte.MaxValue) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadInstructionOrIndexOutOfBound")); + throw new InvalidOperationException(SR.InvalidOperation_BadInstructionOrIndexOutOfBound); } m_ILStream[m_length++] = (byte)tempVal; } @@ -930,7 +930,7 @@ namespace System.Reflection.Emit { if (m_currExcStackCount == 0) { - throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); + throw new NotSupportedException(SR.Argument_NotInExceptionBlock); } // Pop the current exception block @@ -944,7 +944,7 @@ namespace System.Reflection.Emit if (state == __ExceptionInfo.State_Filter || state == __ExceptionInfo.State_Try) { - throw new InvalidOperationException(Environment.GetResourceString("Argument_BadExceptionCodeGen")); + throw new InvalidOperationException(SR.Argument_BadExceptionCodeGen); } if (state == __ExceptionInfo.State_Catch) @@ -975,7 +975,7 @@ namespace System.Reflection.Emit // Begins an exception filter block. Emits a branch instruction to the end of the current exception block. if (m_currExcStackCount == 0) - throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); + throw new NotSupportedException(SR.Argument_NotInExceptionBlock); __ExceptionInfo current = m_currExcStack[m_currExcStackCount - 1]; @@ -991,7 +991,7 @@ namespace System.Reflection.Emit if (m_currExcStackCount == 0) { - throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); + throw new NotSupportedException(SR.Argument_NotInExceptionBlock); } __ExceptionInfo current = m_currExcStack[m_currExcStackCount - 1]; @@ -999,7 +999,7 @@ namespace System.Reflection.Emit { if (exceptionType != null) { - throw new ArgumentException(Environment.GetResourceString("Argument_ShouldNotSpecifyExceptionType")); + throw new ArgumentException(SR.Argument_ShouldNotSpecifyExceptionType); } this.Emit(OpCodes.Endfilter); @@ -1023,7 +1023,7 @@ namespace System.Reflection.Emit { if (m_currExcStackCount == 0) { - throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); + throw new NotSupportedException(SR.Argument_NotInExceptionBlock); } __ExceptionInfo current = m_currExcStack[m_currExcStackCount - 1]; @@ -1038,7 +1038,7 @@ namespace System.Reflection.Emit { if (m_currExcStackCount == 0) { - throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock")); + throw new NotSupportedException(SR.Argument_NotInExceptionBlock); } __ExceptionInfo current = m_currExcStack[m_currExcStackCount - 1]; int state = current.GetCurrentState(); @@ -1097,12 +1097,12 @@ namespace System.Reflection.Emit //This should never happen. if (labelIndex < 0 || labelIndex >= m_labelList.Length) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidLabel")); + throw new ArgumentException(SR.Argument_InvalidLabel); } if (m_labelList[labelIndex] != -1) { - throw new ArgumentException(Environment.GetResourceString("Argument_RedefinedLabel")); + throw new ArgumentException(SR.Argument_RedefinedLabel); } m_labelList[labelIndex] = m_length; @@ -1122,13 +1122,13 @@ namespace System.Reflection.Emit if (!excType.IsSubclassOf(typeof(Exception)) && excType != typeof(Exception)) { - throw new ArgumentException(Environment.GetResourceString("Argument_NotExceptionType")); + throw new ArgumentException(SR.Argument_NotExceptionType); } Contract.EndContractBlock(); ConstructorInfo con = excType.GetConstructor(Type.EmptyTypes); if (con == null) { - throw new ArgumentException(Environment.GetResourceString("Argument_MissingDefaultConstructor")); + throw new ArgumentException(SR.Argument_MissingDefaultConstructor); } this.Emit(OpCodes.Newobj, con); this.Emit(OpCodes.Throw); @@ -1162,7 +1162,7 @@ namespace System.Reflection.Emit Object cls; if (m_methodBuilder == null) { - throw new ArgumentException(Environment.GetResourceString("InvalidOperation_BadILGeneratorUsage")); + throw new ArgumentException(SR.InvalidOperation_BadILGeneratorUsage); } MethodInfo prop = GetConsoleType().GetMethod("get_Out"); @@ -1172,13 +1172,13 @@ namespace System.Reflection.Emit cls = localBuilder.LocalType; if (cls is TypeBuilder || cls is EnumBuilder) { - throw new ArgumentException(Environment.GetResourceString("NotSupported_OutputStreamUsingTypeBuilder")); + throw new ArgumentException(SR.NotSupported_OutputStreamUsingTypeBuilder); } parameterTypes[0] = (Type)cls; MethodInfo mi = prop.ReturnType.GetMethod("WriteLine", parameterTypes); if (mi == null) { - throw new ArgumentException(Environment.GetResourceString("Argument_EmitWriteLineType"), nameof(localBuilder)); + throw new ArgumentException(SR.Argument_EmitWriteLineType, nameof(localBuilder)); } Emit(OpCodes.Callvirt, mi); @@ -1215,13 +1215,13 @@ namespace System.Reflection.Emit cls = fld.FieldType; if (cls is TypeBuilder || cls is EnumBuilder) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_OutputStreamUsingTypeBuilder")); + throw new NotSupportedException(SR.NotSupported_OutputStreamUsingTypeBuilder); } parameterTypes[0] = (Type)cls; MethodInfo mi = prop.ReturnType.GetMethod("WriteLine", parameterTypes); if (mi == null) { - throw new ArgumentException(Environment.GetResourceString("Argument_EmitWriteLineType"), nameof(fld)); + throw new ArgumentException(SR.Argument_EmitWriteLineType, nameof(fld)); } Emit(OpCodes.Callvirt, mi); } @@ -1248,7 +1248,7 @@ namespace System.Reflection.Emit if (methodBuilder.IsTypeCreated()) { // cannot change method after its containing type has been created - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TypeHasBeenCreated")); + throw new InvalidOperationException(SR.InvalidOperation_TypeHasBeenCreated); } if (localType == null) @@ -1258,7 +1258,7 @@ namespace System.Reflection.Emit if (methodBuilder.m_bIsBaked) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_MethodBaked")); + throw new InvalidOperationException(SR.InvalidOperation_MethodBaked); } // add the localType to local signature @@ -1278,7 +1278,7 @@ namespace System.Reflection.Emit throw new ArgumentNullException(nameof(usingNamespace)); if (usingNamespace.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(usingNamespace)); + throw new ArgumentException(SR.Argument_EmptyName, nameof(usingNamespace)); Contract.EndContractBlock(); int index; @@ -1477,7 +1477,7 @@ namespace System.Reflection.Emit { if (m_endFinally != -1) { - throw new ArgumentException(Environment.GetResourceString("Argument_TooManyFinallyClause")); + throw new ArgumentException(SR.Argument_TooManyFinallyClause); } else { @@ -1680,7 +1680,7 @@ namespace System.Reflection.Emit { if (sa == ScopeAction.Close && m_iOpenScopeCount <= 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_UnmatchingSymScope")); + throw new ArgumentException(SR.Argument_UnmatchingSymScope); } Contract.EndContractBlock(); diff --git a/src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs index 42165075b4..c04c3c8434 100644 --- a/src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/LocalBuilder.cs @@ -76,14 +76,14 @@ namespace System.Reflection.Emit if (methodBuilder.IsTypeCreated()) { // cannot change method after its containing type has been created - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TypeHasBeenCreated")); + throw new InvalidOperationException(SR.InvalidOperation_TypeHasBeenCreated); } // set the name and range of offset for the local if (dynMod.GetSymWriter() == null) { // cannot set local name if not debug module - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotADebugModule")); + throw new InvalidOperationException(SR.InvalidOperation_NotADebugModule); } sigHelp = SignatureHelper.GetFieldSigHelper(dynMod); diff --git a/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs index ee4c68ebf4..73882584a5 100644 --- a/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/MethodBuilder.cs @@ -84,10 +84,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 (name[0] == '\0') - throw new ArgumentException(Environment.GetResourceString("Argument_IllegalName"), nameof(name)); + throw new ArgumentException(SR.Argument_IllegalName, nameof(name)); if (mod == null) throw new ArgumentNullException(nameof(mod)); @@ -124,7 +124,7 @@ namespace System.Reflection.Emit else if ((attributes & MethodAttributes.Virtual) != 0) { // A method can't be both static and virtual - throw new ArgumentException(Environment.GetResourceString("Arg_NoStaticVirtual")); + throw new ArgumentException(SR.Arg_NoStaticVirtual); } if ((attributes & MethodAttributes.SpecialName) != MethodAttributes.SpecialName) @@ -135,7 +135,7 @@ namespace System.Reflection.Emit if ((attributes & (MethodAttributes.Abstract | MethodAttributes.Virtual)) != (MethodAttributes.Abstract | MethodAttributes.Virtual) && (attributes & MethodAttributes.Static) == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_BadAttributeOnInterfaceMethod")); + throw new ArgumentException(SR.Argument_BadAttributeOnInterfaceMethod); } } @@ -212,7 +212,7 @@ namespace System.Reflection.Emit if (m_bIsBaked) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_MethodHasBody")); + throw new InvalidOperationException(SR.InvalidOperation_MethodHasBody); } if (il.m_methodBuilder != this && il.m_methodBuilder != null) @@ -221,7 +221,7 @@ namespace System.Reflection.Emit // through MethodBuilder::GetILGenerator. // - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_BadILGeneratorUsage")); + throw new InvalidOperationException(SR.InvalidOperation_BadILGeneratorUsage); } ThrowIfShouldNotHaveBody(); @@ -229,7 +229,7 @@ namespace System.Reflection.Emit if (il.m_ScopeTree.m_iOpenScopeCount != 0) { // There are still unclosed local scope - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_OpenLocalVariableScope")); + throw new InvalidOperationException(SR.InvalidOperation_OpenLocalVariableScope); } @@ -559,7 +559,7 @@ namespace System.Reflection.Emit #region MethodBase Overrides public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } public override MethodImplAttributes GetMethodImplementationFlags() @@ -579,7 +579,7 @@ namespace System.Reflection.Emit public override RuntimeMethodHandle MethodHandle { - get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); } + get { throw new NotSupportedException(SR.NotSupported_DynamicModule); } } public override bool IsSecurityCritical @@ -616,7 +616,7 @@ namespace System.Reflection.Emit public override ParameterInfo[] GetParameters() { if (!m_bIsBaked || m_containingType == null || m_containingType.BakedRuntimeType == null) - throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_TypeNotCreated")); + throw new NotSupportedException(SR.InvalidOperation_TypeNotCreated); MethodInfo rmi = m_containingType.GetMethod(m_strName, m_parameterTypes); @@ -628,7 +628,7 @@ namespace System.Reflection.Emit get { if (!m_bIsBaked || m_containingType == null || m_containingType.BakedRuntimeType == null) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TypeNotCreated")); + throw new InvalidOperationException(SR.InvalidOperation_TypeNotCreated); MethodInfo rmi = m_containingType.GetMethod(m_strName, m_parameterTypes); @@ -640,17 +640,17 @@ 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 @@ -678,18 +678,18 @@ namespace System.Reflection.Emit throw new ArgumentNullException(nameof(names)); if (names.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Arg_EmptyArray"), nameof(names)); + throw new ArgumentException(SR.Arg_EmptyArray, nameof(names)); Contract.EndContractBlock(); if (m_inst != null) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_GenericParametersAlreadySet")); + throw new InvalidOperationException(SR.InvalidOperation_GenericParametersAlreadySet); for (int i = 0; i < names.Length; i++) if (names[i] == null) throw new ArgumentNullException(nameof(names)); if (m_tkMethod.Token != 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_MethodBuilderBaked")); + throw new InvalidOperationException(SR.InvalidOperation_MethodBuilderBaked); m_bIsGenMethDef = true; m_inst = new GenericTypeParameterBuilder[names.Length]; @@ -824,14 +824,14 @@ namespace System.Reflection.Emit public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, String strParamName) { if (position < 0) - throw new ArgumentOutOfRangeException(Environment.GetResourceString("ArgumentOutOfRange_ParamSequence")); + throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_ParamSequence); Contract.EndContractBlock(); ThrowIfGeneric(); m_containingType.ThrowIfCreated(); if (position > 0 && (m_parameterTypes == null || position > m_parameterTypes.Length)) - throw new ArgumentOutOfRangeException(Environment.GetResourceString("ArgumentOutOfRange_ParamSequence")); + throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_ParamSequence); attributes = attributes & ~ParameterAttributes.ReservedMask; return new ParameterBuilder(this, position, attributes, strParamName); @@ -890,7 +890,7 @@ namespace System.Reflection.Emit { // cannot attach method body if methodimpl is marked not marked as managed IL // - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ShouldNotHaveMethodBody")); + throw new InvalidOperationException(SR.InvalidOperation_ShouldNotHaveMethodBody); } } diff --git a/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs b/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs index ad5cc70a30..2d0a9b41dd 100644 --- a/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs +++ b/src/mscorlib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs @@ -59,7 +59,7 @@ namespace System.Reflection.Emit [Pure] public override ParameterInfo[] GetParameters() { throw new NotSupportedException(); } public override MethodImplAttributes GetMethodImplementationFlags() { return m_method.GetMethodImplementationFlags(); } - public override RuntimeMethodHandle MethodHandle { get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); } } + public override RuntimeMethodHandle MethodHandle { get { throw new NotSupportedException(SR.NotSupported_DynamicModule); } } public override MethodAttributes Attributes { get { return m_method.Attributes; } } public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) { @@ -88,7 +88,7 @@ namespace System.Reflection.Emit public override MethodInfo MakeGenericMethod(params Type[] arguments) { - throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericMethodDefinition")); + throw new InvalidOperationException(SR.Arg_NotGenericMethodDefinition); } public override bool IsGenericMethod { get { return true; } } diff --git a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs index 13ae4ee9ec..d92d8220b8 100644 --- a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilder.cs @@ -120,7 +120,7 @@ namespace System.Reflection.Emit object.ReferenceEquals(foundType.DeclaringType, enclosingType)) { // Cannot have two types with the same name - throw new ArgumentException(Environment.GetResourceString("Argument_DuplicateTypeName")); + throw new ArgumentException(SR.Argument_DuplicateTypeName); } } @@ -308,7 +308,7 @@ namespace System.Reflection.Emit // go through the slower code path, i.e. retrieve parameters and form signature helper. ParameterInfo[] parameters = con.GetParameters(); if (parameters == null) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidConstructorInfo")); + throw new ArgumentException(SR.Argument_InvalidConstructorInfo); Type[] parameterTypes = new Type[parameters.Length]; Type[][] requiredCustomModifiers = new Type[parameters.Length][]; @@ -317,7 +317,7 @@ namespace System.Reflection.Emit for (int i = 0; i < parameters.Length; i++) { if (parameters[i] == null) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidConstructorInfo")); + throw new ArgumentException(SR.Argument_InvalidConstructorInfo); parameterTypes[i] = parameters[i].ParameterType; requiredCustomModifiers[i] = parameters[i].GetRequiredCustomModifiers(); @@ -409,7 +409,7 @@ namespace System.Reflection.Emit if ((method.CallingConvention & CallingConventions.VarArgs) == 0) { // Client should not supply optional parameter in default calling convention - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAVarArgCallingConvention")); + throw new InvalidOperationException(SR.InvalidOperation_NotAVarArgCallingConvention); } } @@ -1010,16 +1010,16 @@ namespace System.Reflection.Emit Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { if (m_moduleData.m_fGlobalBeenCreated == true) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_GlobalsHaveBeenCreated")); + throw new InvalidOperationException(SR.InvalidOperation_GlobalsHaveBeenCreated); 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 ((attributes & MethodAttributes.Static) == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_GlobalFunctionHasToBeStatic")); + throw new ArgumentException(SR.Argument_GlobalFunctionHasToBeStatic); Contract.Ensures(Contract.Result<MethodBuilder>() != null); Contract.EndContractBlock(); @@ -1048,7 +1048,7 @@ namespace System.Reflection.Emit if (m_moduleData.m_fGlobalBeenCreated) { // cannot create globals twice - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotADebugModule")); + throw new InvalidOperationException(SR.InvalidOperation_NotADebugModule); } m_moduleData.m_globalTypeBuilder.CreateType(); m_moduleData.m_fGlobalBeenCreated = true; @@ -1078,7 +1078,7 @@ namespace System.Reflection.Emit // will be the signature for the Field. if (m_moduleData.m_fGlobalBeenCreated == true) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_GlobalsHaveBeenCreated")); + throw new InvalidOperationException(SR.InvalidOperation_GlobalsHaveBeenCreated); } Contract.Ensures(Contract.Result<FieldBuilder>() != null); Contract.EndContractBlock(); @@ -1105,7 +1105,7 @@ namespace System.Reflection.Emit if (m_moduleData.m_fGlobalBeenCreated == true) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_GlobalsHaveBeenCreated")); + throw new InvalidOperationException(SR.InvalidOperation_GlobalsHaveBeenCreated); } Contract.Ensures(Contract.Result<FieldBuilder>() != null); Contract.EndContractBlock(); @@ -1158,7 +1158,7 @@ namespace System.Reflection.Emit // We should also be aware of multiple dynamic modules and multiple implementation of Type!!! if (type.IsByRef) - throw new ArgumentException(Environment.GetResourceString("Argument_CannotGetTypeTokenForByRef")); + throw new ArgumentException(SR.Argument_CannotGetTypeTokenForByRef); if ((type.IsGenericType && (!type.IsGenericTypeDefinition || !getGenericDefinition)) || type.IsGenericParameter || @@ -1275,7 +1275,7 @@ namespace System.Reflection.Emit return new MethodToken(methodToken); if (method.DeclaringType == null) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotImportGlobalFromDifferentModule")); + throw new InvalidOperationException(SR.InvalidOperation_CannotImportGlobalFromDifferentModule); // method is defined in a different module tr = getGenericTypeDefinition ? GetTypeToken(method.DeclaringType).Token : GetTypeTokenInternal(method.DeclaringType).Token; @@ -1299,7 +1299,7 @@ namespace System.Reflection.Emit // We need to get the TypeRef tokens if (declaringType == null) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotImportGlobalFromDifferentModule")); + throw new InvalidOperationException(SR.InvalidOperation_CannotImportGlobalFromDifferentModule); RuntimeMethodInfo rtMeth = null; @@ -1448,10 +1448,10 @@ namespace System.Reflection.Emit throw new ArgumentNullException(nameof(methodName)); if (methodName.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(methodName)); + throw new ArgumentException(SR.Argument_EmptyName, nameof(methodName)); if (arrayClass.IsArray == false) - throw new ArgumentException(Environment.GetResourceString("Argument_HasToBeArrayClass")); + throw new ArgumentException(SR.Argument_HasToBeArrayClass); Contract.EndContractBlock(); CheckContext(returnType, arrayClass); @@ -1537,7 +1537,7 @@ namespace System.Reflection.Emit // field is defined in a different module if (field.DeclaringType == null) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotImportGlobalFromDifferentModule")); + throw new InvalidOperationException(SR.InvalidOperation_CannotImportGlobalFromDifferentModule); } tr = GetTypeTokenInternal(field.DeclaringType).Token; mr = GetMemberRef(field.ReflectedType.Module, tr, fdBuilder.GetToken().Token); @@ -1550,7 +1550,7 @@ namespace System.Reflection.Emit // We need to get the TypeRef tokens if (field.DeclaringType == null) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotImportGlobalFromDifferentModule")); + throw new InvalidOperationException(SR.InvalidOperation_CannotImportGlobalFromDifferentModule); } if (field.DeclaringType != null && field.DeclaringType.IsGenericType) @@ -1718,7 +1718,7 @@ namespace System.Reflection.Emit if (m_iSymWriter == null) { // Cannot DefineDocument when it is not a debug module - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotADebugModule")); + throw new InvalidOperationException(SR.InvalidOperation_NotADebugModule); } return m_iSymWriter.DefineDocument(url, language, languageVendor, documentType); diff --git a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs index c0af6ba7db..4f1b8eb713 100644 --- a/src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs +++ b/src/mscorlib/src/System/Reflection/Emit/ModuleBuilderData.cs @@ -46,7 +46,7 @@ namespace System.Reflection.Emit if (strExtension == null || strExtension == String.Empty) { // This is required by our loader. It cannot load module file that does not have file extension. - throw new ArgumentException(Environment.GetResourceString("Argument_NoModuleFileExtension", strFileName)); + throw new ArgumentException(SR.Format(SR.Argument_NoModuleFileExtension, strFileName)); } m_strFileName = strFileName; } diff --git a/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs index da087dcea7..6dbcba251f 100644 --- a/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/PropertyBuilder.cs @@ -44,9 +44,9 @@ 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(); m_name = name; @@ -153,27 +153,27 @@ namespace System.Reflection.Emit // Not supported functions in dynamic module. public override Object GetValue(Object obj, Object[] index) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } public override Object GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } public override void SetValue(Object obj, Object value, Object[] index) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } public override MethodInfo[] GetAccessors(bool nonPublic) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } public override MethodInfo GetGetMethod(bool nonPublic) @@ -198,7 +198,7 @@ namespace System.Reflection.Emit public override ParameterInfo[] GetIndexParameters() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); + throw new NotSupportedException(SR.NotSupported_DynamicModule); } public override Type PropertyType @@ -223,17 +223,17 @@ namespace System.Reflection.Emit 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); } public override String Name diff --git a/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs b/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs index eb5df8c8db..fd1a8e70fe 100644 --- a/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs +++ b/src/mscorlib/src/System/Reflection/Emit/SignatureHelper.cs @@ -114,7 +114,7 @@ namespace System.Reflection.Emit } else { - throw new ArgumentException(Environment.GetResourceString("Argument_UnknownUnmanagedCallConv"), nameof(unmanagedCallConv)); + throw new ArgumentException(SR.Argument_UnknownUnmanagedCallConv, nameof(unmanagedCallConv)); } sigHelp = new SignatureHelper(mod, intCall, returnType, null, null); @@ -217,7 +217,7 @@ namespace System.Reflection.Emit Init(mod, callingConvention, cGenericParameters); if (callingConvention == MdSigCallingConvention.Field) - throw new ArgumentException(Environment.GetResourceString("Argument_BadFieldSig")); + throw new ArgumentException(SR.Argument_BadFieldSig); AddOneArgTypeHelper(returnType, requiredCustomModifiers, optionalCustomModifiers); } @@ -245,7 +245,7 @@ namespace System.Reflection.Emit m_sizeLoc = NO_SIZE_IN_SIG; if (m_module == null && mod != null) - throw new ArgumentException(Environment.GetResourceString("NotSupported_MustBeModuleBuilder")); + throw new ArgumentException(SR.NotSupported_MustBeModuleBuilder); } private void Init(Module mod, MdSigCallingConvention callingConvention) @@ -302,10 +302,10 @@ namespace System.Reflection.Emit throw new ArgumentNullException(nameof(optionalCustomModifiers)); if (t.HasElementType) - throw new ArgumentException(Environment.GetResourceString("Argument_ArraysInvalid"), nameof(optionalCustomModifiers)); + throw new ArgumentException(SR.Argument_ArraysInvalid, nameof(optionalCustomModifiers)); if (t.ContainsGenericParameters) - throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), nameof(optionalCustomModifiers)); + throw new ArgumentException(SR.Argument_GenericsInvalid, nameof(optionalCustomModifiers)); AddElementType(CorElementType.CModOpt); @@ -325,10 +325,10 @@ namespace System.Reflection.Emit throw new ArgumentNullException(nameof(requiredCustomModifiers)); if (t.HasElementType) - throw new ArgumentException(Environment.GetResourceString("Argument_ArraysInvalid"), nameof(requiredCustomModifiers)); + throw new ArgumentException(SR.Argument_ArraysInvalid, nameof(requiredCustomModifiers)); if (t.ContainsGenericParameters) - throw new ArgumentException(Environment.GetResourceString("Argument_GenericsInvalid"), nameof(requiredCustomModifiers)); + throw new ArgumentException(SR.Argument_GenericsInvalid, nameof(requiredCustomModifiers)); AddElementType(CorElementType.CModReqd); @@ -510,7 +510,7 @@ namespace System.Reflection.Emit } else { - throw new ArgumentException(Environment.GetResourceString("Argument_LargeInteger")); + throw new ArgumentException(SR.Argument_LargeInteger); } } @@ -535,7 +535,7 @@ namespace System.Reflection.Emit if (rid > 0x3FFFFFF) { // token is too big to be compressed - throw new ArgumentException(Environment.GetResourceString("Argument_LargeInteger")); + throw new ArgumentException(SR.Argument_LargeInteger); } rid = (rid << 2); @@ -755,7 +755,7 @@ namespace System.Reflection.Emit temp[sigCopyIndex++] = (byte)((argCount) & 0xFF); } else - throw new ArgumentException(Environment.GetResourceString("Argument_LargeInteger")); + throw new ArgumentException(SR.Argument_LargeInteger); // copy the sig part of the sig Buffer.BlockCopy(m_signature, 2, temp, sigCopyIndex, currSigLength - 2); // mark the end of sig @@ -784,10 +784,10 @@ namespace System.Reflection.Emit public void AddArguments(Type[] arguments, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers) { if (requiredCustomModifiers != null && (arguments == null || requiredCustomModifiers.Length != arguments.Length)) - throw new ArgumentException(Environment.GetResourceString("Argument_MismatchedArrays", nameof(requiredCustomModifiers), nameof(arguments))); + throw new ArgumentException(SR.Format(SR.Argument_MismatchedArrays, nameof(requiredCustomModifiers), nameof(arguments))); if (optionalCustomModifiers != null && (arguments == null || optionalCustomModifiers.Length != arguments.Length)) - throw new ArgumentException(Environment.GetResourceString("Argument_MismatchedArrays", nameof(optionalCustomModifiers), nameof(arguments))); + throw new ArgumentException(SR.Format(SR.Argument_MismatchedArrays, nameof(optionalCustomModifiers), nameof(arguments))); if (arguments != null) { @@ -803,7 +803,7 @@ namespace System.Reflection.Emit public void AddArgument(Type argument, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers) { if (m_sigDone) - throw new ArgumentException(Environment.GetResourceString("Argument_SigIsFinalized")); + throw new ArgumentException(SR.Argument_SigIsFinalized); if (argument == null) throw new ArgumentNullException(nameof(argument)); diff --git a/src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs b/src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs index d82e271672..4c4cd15922 100644 --- a/src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs +++ b/src/mscorlib/src/System/Reflection/Emit/SymbolMethod.cs @@ -99,17 +99,17 @@ namespace System.Reflection.Emit [Pure] public override ParameterInfo[] GetParameters() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod")); + throw new NotSupportedException(SR.NotSupported_SymbolMethod); } public override MethodImplAttributes GetMethodImplementationFlags() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod")); + throw new NotSupportedException(SR.NotSupported_SymbolMethod); } public override MethodAttributes Attributes { - get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod")); } + get { throw new NotSupportedException(SR.NotSupported_SymbolMethod); } } public override CallingConventions CallingConvention @@ -119,7 +119,7 @@ namespace System.Reflection.Emit public override RuntimeMethodHandle MethodHandle { - get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod")); } + get { throw new NotSupportedException(SR.NotSupported_SymbolMethod); } } #endregion @@ -140,7 +140,7 @@ namespace System.Reflection.Emit public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod")); + throw new NotSupportedException(SR.NotSupported_SymbolMethod); } public override MethodInfo GetBaseDefinition() @@ -152,17 +152,17 @@ namespace System.Reflection.Emit #region ICustomAttributeProvider Implementation public override Object[] GetCustomAttributes(bool inherit) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod")); + throw new NotSupportedException(SR.NotSupported_SymbolMethod); } public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod")); + throw new NotSupportedException(SR.NotSupported_SymbolMethod); } public override bool IsDefined(Type attributeType, bool inherit) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_SymbolMethod")); + throw new NotSupportedException(SR.NotSupported_SymbolMethod); } #endregion diff --git a/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs b/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs index bfe9ce0fe5..16848b43dd 100644 --- a/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs +++ b/src/mscorlib/src/System/Reflection/Emit/SymbolType.cs @@ -66,7 +66,7 @@ namespace System.Reflection.Emit if (curIndex != format.Length) // ByRef has to be the last char!! - throw new ArgumentException(Environment.GetResourceString("Argument_BadSigFormat")); + throw new ArgumentException(SR.Argument_BadSigFormat); symbolType.SetElementType(baseType); return symbolType; @@ -128,7 +128,7 @@ namespace System.Reflection.Emit if (format[curIndex] != '.') { // bad format!! Throw exception - throw new ArgumentException(Environment.GetResourceString("Argument_BadSigFormat")); + throw new ArgumentException(SR.Argument_BadSigFormat); } curIndex++; @@ -158,7 +158,7 @@ namespace System.Reflection.Emit { // User specified upper bound less than lower bound, this is an error. // Throw error exception. - throw new ArgumentException(Environment.GetResourceString("Argument_BadSigFormat")); + throw new ArgumentException(SR.Argument_BadSigFormat); } } } @@ -176,7 +176,7 @@ namespace System.Reflection.Emit } else if (format[curIndex] != ']') { - throw new ArgumentException(Environment.GetResourceString("Argument_BadSigFormat")); + throw new ArgumentException(SR.Argument_BadSigFormat); } } @@ -313,7 +313,7 @@ namespace System.Reflection.Emit public override int GetArrayRank() { if (!IsArray) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_SubclassOverride")); + throw new NotSupportedException(SR.NotSupported_SubclassOverride); Contract.EndContractBlock(); return m_cRank; @@ -321,13 +321,13 @@ namespace System.Reflection.Emit public override Guid GUID { - get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); } + get { throw new NotSupportedException(SR.NotSupported_NonReflectedType); } } public override Object InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override Module Module @@ -355,7 +355,7 @@ namespace System.Reflection.Emit public override RuntimeTypeHandle TypeHandle { - get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); } + get { throw new NotSupportedException(SR.NotSupported_NonReflectedType); } } public override String Name @@ -406,94 +406,94 @@ namespace System.Reflection.Emit protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override MethodInfo[] GetMethods(BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override FieldInfo GetField(String name, BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override FieldInfo[] GetFields(BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override Type GetInterface(String name, bool ignoreCase) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override Type[] GetInterfaces() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override EventInfo GetEvent(String name, BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override EventInfo[] GetEvents() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } protected override PropertyInfo GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override PropertyInfo[] GetProperties(BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override Type[] GetNestedTypes(BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override Type GetNestedType(String name, BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override MemberInfo[] GetMembers(BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override InterfaceMapping GetInterfaceMap(Type interfaceType) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override EventInfo[] GetEvents(BindingFlags bindingAttr) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } protected override TypeAttributes GetAttributeFlagsImpl() @@ -559,17 +559,17 @@ namespace System.Reflection.Emit public override Object[] GetCustomAttributes(bool inherit) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } public override bool IsDefined(Type attributeType, bool inherit) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NonReflectedType")); + throw new NotSupportedException(SR.NotSupported_NonReflectedType); } #endregion } diff --git a/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs b/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs index b4cba17668..bfd2c96064 100644 --- a/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs +++ b/src/mscorlib/src/System/Reflection/Emit/TypeBuilder.cs @@ -90,7 +90,7 @@ namespace System.Reflection.Emit 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. @@ -100,13 +100,13 @@ namespace System.Reflection.Emit // 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 @@ -116,49 +116,49 @@ namespace System.Reflection.Emit 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); } @@ -351,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) { @@ -360,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 { @@ -370,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; @@ -379,7 +379,7 @@ 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); @@ -416,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; } @@ -427,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); @@ -527,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; @@ -550,7 +550,7 @@ 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)); + throw new ArgumentException(SR.Argument_BadNestedTypeFlags, nameof(attr)); } int[] interfaceTokens = null; @@ -631,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(); @@ -670,7 +670,7 @@ namespace System.Reflection.Emit // Not a nested class. 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 @@ -678,20 +678,20 @@ namespace System.Reflection.Emit // Nested class. 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)) { - 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); } } @@ -723,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 @@ -825,7 +825,7 @@ namespace System.Reflection.Emit get { if (!IsCreated()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_TypeNotYetCreated")); + throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); Contract.EndContractBlock(); return m_bakedRuntimeType.GUID; @@ -836,7 +836,7 @@ 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); @@ -849,7 +849,7 @@ namespace System.Reflection.Emit public override RuntimeTypeHandle TypeHandle { - get { throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule")); } + get { throw new NotSupportedException(SR.NotSupported_DynamicModule); } } public override String FullName @@ -885,7 +885,7 @@ namespace System.Reflection.Emit 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); @@ -894,7 +894,7 @@ 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); @@ -904,7 +904,7 @@ namespace System.Reflection.Emit 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) @@ -920,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); @@ -929,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); @@ -938,7 +938,7 @@ 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); @@ -947,7 +947,7 @@ namespace System.Reflection.Emit 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); @@ -971,7 +971,7 @@ namespace System.Reflection.Emit 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); @@ -980,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(); @@ -989,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); @@ -1004,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); @@ -1013,7 +1013,7 @@ 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); @@ -1022,7 +1022,7 @@ namespace System.Reflection.Emit 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); @@ -1031,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); @@ -1040,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); @@ -1049,7 +1049,7 @@ 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); @@ -1136,7 +1136,7 @@ namespace System.Reflection.Emit 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() @@ -1190,7 +1190,7 @@ namespace System.Reflection.Emit if (IsEnum) { if (m_enumUnderlyingType == null) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NoUnderlyingTypeOnEnum")); + throw new InvalidOperationException(SR.InvalidOperation_NoUnderlyingTypeOnEnum); return m_enumUnderlyingType; } @@ -1243,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); @@ -1252,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)); @@ -1261,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); } @@ -1269,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)); @@ -1278,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); } @@ -1368,7 +1368,7 @@ namespace System.Reflection.Emit if (!object.ReferenceEquals(methodInfoBody.DeclaringType, this)) // Loader restriction: body method has to be from this class - throw new ArgumentException(Environment.GetResourceString("ArgumentException_BadMethodImplBody")); + throw new ArgumentException(SR.ArgumentException_BadMethodImplBody); MethodToken tkBody; MethodToken tkDecl; @@ -1430,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(); @@ -1442,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(); @@ -1454,7 +1454,7 @@ namespace System.Reflection.Emit { if (((m_iAttr & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface) && (attributes & MethodAttributes.Abstract) == 0 && (attributes & MethodAttributes.Static) == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_BadAttributeOnInterfaceMethod")); + throw new ArgumentException(SR.Argument_BadAttributeOnInterfaceMethod); } // pass in Method attributes @@ -1506,7 +1506,7 @@ 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) @@ -1535,7 +1535,7 @@ 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()); @@ -1553,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); @@ -1579,7 +1579,7 @@ namespace System.Reflection.Emit { 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) @@ -1802,7 +1802,7 @@ 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)); Contract.EndContractBlock(); CheckContext(returnType); @@ -1857,9 +1857,9 @@ 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; @@ -2023,7 +2023,7 @@ namespace System.Reflection.Emit // Check that they haven't declared an abstract method on a non-abstract class 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(); @@ -2038,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) { @@ -2053,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(); @@ -2121,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; } @@ -2134,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; diff --git a/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs b/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs index 06d8384c10..6d46362f91 100644 --- a/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs +++ b/src/mscorlib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs @@ -221,7 +221,7 @@ namespace System.Reflection.Emit } public override MethodBase DeclaringMethod { get { return null; } } public override Type GetGenericTypeDefinition() { return m_type; } - public override Type MakeGenericType(params Type[] inst) { throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericTypeDefinition")); } + public override Type MakeGenericType(params Type[] inst) { throw new InvalidOperationException(SR.Arg_NotGenericTypeDefinition); } public override bool IsAssignableFrom(Type c) { throw new NotSupportedException(); } [Pure] diff --git a/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs b/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs index 6c9bc81323..78238c02b7 100644 --- a/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs +++ b/src/mscorlib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs @@ -72,7 +72,7 @@ namespace System.Reflection.Emit public override MethodInfo MakeGenericMethod(params Type[] typeArgs) { if (!IsGenericMethodDefinition) - throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericMethodDefinition")); + throw new InvalidOperationException(SR.Arg_NotGenericMethodDefinition); Contract.EndContractBlock(); return MethodBuilderInstantiation.MakeGenericMethod(this, typeArgs); diff --git a/src/mscorlib/src/System/Reflection/FieldInfo.CoreCLR.cs b/src/mscorlib/src/System/Reflection/FieldInfo.CoreCLR.cs index e9515b171c..bcda3418fa 100644 --- a/src/mscorlib/src/System/Reflection/FieldInfo.CoreCLR.cs +++ b/src/mscorlib/src/System/Reflection/FieldInfo.CoreCLR.cs @@ -11,14 +11,14 @@ namespace System.Reflection public static FieldInfo GetFieldFromHandle(RuntimeFieldHandle handle) { if (handle.IsNullHandle()) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle"), nameof(handle)); + throw new ArgumentException(SR.Argument_InvalidHandle, nameof(handle)); FieldInfo f = RuntimeType.GetFieldInfo(handle.GetRuntimeFieldInfo()); Type declaringType = f.DeclaringType; if (declaringType != null && declaringType.IsGenericType) throw new ArgumentException(String.Format( - CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_FieldDeclaringTypeGeneric"), + CultureInfo.CurrentCulture, SR.Argument_FieldDeclaringTypeGeneric, f.Name, declaringType.GetGenericTypeDefinition())); return f; @@ -27,7 +27,7 @@ namespace System.Reflection public static FieldInfo GetFieldFromHandle(RuntimeFieldHandle handle, RuntimeTypeHandle declaringType) { if (handle.IsNullHandle()) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle")); + throw new ArgumentException(SR.Argument_InvalidHandle); return RuntimeType.GetFieldInfo(declaringType.GetRuntimeType(), handle.GetRuntimeFieldInfo()); } diff --git a/src/mscorlib/src/System/Reflection/InvalidFilterCriteriaException.cs b/src/mscorlib/src/System/Reflection/InvalidFilterCriteriaException.cs index d3333df8e1..dc1d19b13d 100644 --- a/src/mscorlib/src/System/Reflection/InvalidFilterCriteriaException.cs +++ b/src/mscorlib/src/System/Reflection/InvalidFilterCriteriaException.cs @@ -22,7 +22,7 @@ namespace System.Reflection public class InvalidFilterCriteriaException : ApplicationException { public InvalidFilterCriteriaException() - : base(Environment.GetResourceString("Arg_InvalidFilterCriteriaException")) + : base(SR.Arg_InvalidFilterCriteriaException) { SetErrorCode(__HResults.COR_E_INVALIDFILTERCRITERIA); } diff --git a/src/mscorlib/src/System/Reflection/MdConstant.cs b/src/mscorlib/src/System/Reflection/MdConstant.cs index 43c5556ed8..8e5b65724d 100644 --- a/src/mscorlib/src/System/Reflection/MdConstant.cs +++ b/src/mscorlib/src/System/Reflection/MdConstant.cs @@ -69,7 +69,7 @@ namespace System.Reflection break; default: - throw new FormatException(Environment.GetResourceString("Arg_BadLiteralFormat")); + throw new FormatException(SR.Arg_BadLiteralFormat); #endregion } @@ -95,7 +95,7 @@ namespace System.Reflection break; default: - throw new FormatException(Environment.GetResourceString("Arg_BadLiteralFormat")); + throw new FormatException(SR.Arg_BadLiteralFormat); #endregion } @@ -158,7 +158,7 @@ namespace System.Reflection return null; default: - throw new FormatException(Environment.GetResourceString("Arg_BadLiteralFormat")); + throw new FormatException(SR.Arg_BadLiteralFormat); #endregion } } diff --git a/src/mscorlib/src/System/Reflection/MdFieldInfo.cs b/src/mscorlib/src/System/Reflection/MdFieldInfo.cs index 994cdc6879..2ec6abd713 100644 --- a/src/mscorlib/src/System/Reflection/MdFieldInfo.cs +++ b/src/mscorlib/src/System/Reflection/MdFieldInfo.cs @@ -79,7 +79,7 @@ namespace System.Reflection [Diagnostics.DebuggerHidden] public override void SetValueDirect(TypedReference obj, Object value) { - throw new FieldAccessException(Environment.GetResourceString("Acc_ReadOnly")); + throw new FieldAccessException(SR.Acc_ReadOnly); } [DebuggerStepThroughAttribute] @@ -98,7 +98,7 @@ namespace System.Reflection Object value = MdConstant.GetValue(GetRuntimeModule().MetadataImport, m_tkField, FieldType.GetTypeHandleInternal(), raw); if (value == DBNull.Value) - throw new NotSupportedException(Environment.GetResourceString("Arg_EnumLitValueNotFound")); + throw new NotSupportedException(SR.Arg_EnumLitValueNotFound); return value; } @@ -107,7 +107,7 @@ namespace System.Reflection [Diagnostics.DebuggerHidden] public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture) { - throw new FieldAccessException(Environment.GetResourceString("Acc_ReadOnly")); + throw new FieldAccessException(SR.Acc_ReadOnly); } public override Type FieldType diff --git a/src/mscorlib/src/System/Reflection/MemberInfoSerializationHolder.cs b/src/mscorlib/src/System/Reflection/MemberInfoSerializationHolder.cs index d59205d707..a487f68c1f 100644 --- a/src/mscorlib/src/System/Reflection/MemberInfoSerializationHolder.cs +++ b/src/mscorlib/src/System/Reflection/MemberInfoSerializationHolder.cs @@ -72,7 +72,7 @@ namespace System.Reflection String typeName = info.GetString("ClassName"); if (assemblyName == null || typeName == null) - throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState")); + throw new SerializationException(SR.Serialization_InsufficientState); Assembly assem = FormatterServices.LoadAssemblyFromString(assemblyName); m_reflectedType = assem.GetType(typeName, true, false) as RuntimeType; @@ -88,7 +88,7 @@ namespace System.Reflection #region ISerializable public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { - throw new NotSupportedException(Environment.GetResourceString(ResId.NotSupported_Method)); + throw new NotSupportedException(SR.GetResourceString(ResId.NotSupported_Method)); } #endregion @@ -96,7 +96,7 @@ namespace System.Reflection public virtual Object GetRealObject(StreamingContext context) { if (m_memberName == null || m_reflectedType == null || m_memberType == 0) - throw new SerializationException(Environment.GetResourceString(ResId.Serialization_InsufficientState)); + throw new SerializationException(SR.GetResourceString(ResId.Serialization_InsufficientState)); BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | @@ -110,7 +110,7 @@ namespace System.Reflection FieldInfo[] fields = m_reflectedType.GetMember(m_memberName, MemberTypes.Field, bindingFlags) as FieldInfo[]; if (fields.Length == 0) - throw new SerializationException(Environment.GetResourceString("Serialization_UnknownMember", m_memberName)); + throw new SerializationException(SR.Format(SR.Serialization_UnknownMember, m_memberName)); return fields[0]; } @@ -122,7 +122,7 @@ namespace System.Reflection EventInfo[] events = m_reflectedType.GetMember(m_memberName, MemberTypes.Event, bindingFlags) as EventInfo[]; if (events.Length == 0) - throw new SerializationException(Environment.GetResourceString("Serialization_UnknownMember", m_memberName)); + throw new SerializationException(SR.Format(SR.Serialization_UnknownMember, m_memberName)); return events[0]; } @@ -134,7 +134,7 @@ namespace System.Reflection PropertyInfo[] properties = m_reflectedType.GetMember(m_memberName, MemberTypes.Property, bindingFlags) as PropertyInfo[]; if (properties.Length == 0) - throw new SerializationException(Environment.GetResourceString("Serialization_UnknownMember", m_memberName)); + throw new SerializationException(SR.Format(SR.Serialization_UnknownMember, m_memberName)); if (properties.Length == 1) return properties[0]; @@ -156,7 +156,7 @@ namespace System.Reflection } } - throw new SerializationException(Environment.GetResourceString(ResId.Serialization_UnknownMember, m_memberName)); + throw new SerializationException(SR.Format(SR.GetResourceString(ResId.Serialization_UnknownMember), m_memberName)); } #endregion @@ -164,7 +164,7 @@ namespace System.Reflection case MemberTypes.Constructor: { if (m_signature == null) - throw new SerializationException(Environment.GetResourceString(ResId.Serialization_NullSignature)); + throw new SerializationException(SR.GetResourceString(ResId.Serialization_NullSignature)); ConstructorInfo[] constructors = m_reflectedType.GetMember(m_memberName, MemberTypes.Constructor, bindingFlags) as ConstructorInfo[]; @@ -188,7 +188,7 @@ namespace System.Reflection } } - throw new SerializationException(Environment.GetResourceString(ResId.Serialization_UnknownMember, m_memberName)); + throw new SerializationException(SR.Format(SR.GetResourceString(ResId.Serialization_UnknownMember), m_memberName)); } #endregion @@ -198,7 +198,7 @@ namespace System.Reflection MethodInfo methodInfo = null; if (m_signature == null) - throw new SerializationException(Environment.GetResourceString(ResId.Serialization_NullSignature)); + throw new SerializationException(SR.GetResourceString(ResId.Serialization_NullSignature)); Type[] genericArguments = m_info.GetValueNoThrow("GenericArguments", typeof(Type[])) as Type[]; @@ -258,7 +258,7 @@ namespace System.Reflection } if (methodInfo == null) - throw new SerializationException(Environment.GetResourceString(ResId.Serialization_UnknownMember, m_memberName)); + throw new SerializationException(SR.Format(SR.GetResourceString(ResId.Serialization_UnknownMember), m_memberName)); if (!methodInfo.IsGenericMethodDefinition) return methodInfo; @@ -274,7 +274,7 @@ namespace System.Reflection #endregion default: - throw new ArgumentException(Environment.GetResourceString("Serialization_MemberTypeNotRecognized")); + throw new ArgumentException(SR.Serialization_MemberTypeNotRecognized); } } #endregion diff --git a/src/mscorlib/src/System/Reflection/MethodBase.CoreCLR.cs b/src/mscorlib/src/System/Reflection/MethodBase.CoreCLR.cs index 384b2dd0a1..3afd396471 100644 --- a/src/mscorlib/src/System/Reflection/MethodBase.CoreCLR.cs +++ b/src/mscorlib/src/System/Reflection/MethodBase.CoreCLR.cs @@ -15,14 +15,14 @@ namespace System.Reflection public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle) { if (handle.IsNullHandle()) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle")); + throw new ArgumentException(SR.Argument_InvalidHandle); MethodBase m = RuntimeType.GetMethodBase(handle.GetMethodInfo()); Type declaringType = m.DeclaringType; if (declaringType != null && declaringType.IsGenericType) throw new ArgumentException(String.Format( - CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_MethodDeclaringTypeGeneric"), + CultureInfo.CurrentCulture, SR.Argument_MethodDeclaringTypeGeneric, m, declaringType.GetGenericTypeDefinition())); return m; @@ -31,7 +31,7 @@ namespace System.Reflection public static MethodBase GetMethodFromHandle(RuntimeMethodHandle handle, RuntimeTypeHandle declaringType) { if (handle.IsNullHandle()) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHandle")); + throw new ArgumentException(SR.Argument_InvalidHandle); return RuntimeType.GetMethodBase(declaringType.GetRuntimeType(), handle.GetMethodInfo()); } @@ -144,7 +144,7 @@ namespace System.Reflection if (p == null) p = GetParametersNoCopy(); if (p[i].DefaultValue == System.DBNull.Value) - throw new ArgumentException(Environment.GetResourceString("Arg_VarMissNull"), nameof(parameters)); + throw new ArgumentException(SR.Arg_VarMissNull, nameof(parameters)); arg = p[i].DefaultValue; } copyOfParameters[i] = argRT.CheckValue(arg, binder, culture, invokeAttr); diff --git a/src/mscorlib/src/System/Reflection/MethodBody.cs b/src/mscorlib/src/System/Reflection/MethodBody.cs index b245b5406b..275e4f86c0 100644 --- a/src/mscorlib/src/System/Reflection/MethodBody.cs +++ b/src/mscorlib/src/System/Reflection/MethodBody.cs @@ -52,7 +52,7 @@ namespace System.Reflection get { if (m_flags != ExceptionHandlingClauseOptions.Filter) - throw new InvalidOperationException(Environment.GetResourceString("Arg_EHClauseNotFilter")); + throw new InvalidOperationException(SR.Arg_EHClauseNotFilter); return m_filterOffset; } @@ -63,7 +63,7 @@ namespace System.Reflection get { if (m_flags != ExceptionHandlingClauseOptions.Clause) - throw new InvalidOperationException(Environment.GetResourceString("Arg_EHClauseNotClause")); + throw new InvalidOperationException(SR.Arg_EHClauseNotClause); Type type = null; diff --git a/src/mscorlib/src/System/Reflection/ParameterModifier.cs b/src/mscorlib/src/System/Reflection/ParameterModifier.cs index 652831c94e..70abf75ea0 100644 --- a/src/mscorlib/src/System/Reflection/ParameterModifier.cs +++ b/src/mscorlib/src/System/Reflection/ParameterModifier.cs @@ -18,7 +18,7 @@ namespace System.Reflection public ParameterModifier(int parameterCount) { if (parameterCount <= 0) - throw new ArgumentException(Environment.GetResourceString("Arg_ParmArraySize")); + throw new ArgumentException(SR.Arg_ParmArraySize); Contract.EndContractBlock(); _byRef = new bool[parameterCount]; diff --git a/src/mscorlib/src/System/Reflection/Pointer.cs b/src/mscorlib/src/System/Reflection/Pointer.cs index 91e205e3a7..600676a5ab 100644 --- a/src/mscorlib/src/System/Reflection/Pointer.cs +++ b/src/mscorlib/src/System/Reflection/Pointer.cs @@ -42,12 +42,12 @@ namespace System.Reflection if (type == null) throw new ArgumentNullException(nameof(type)); if (!type.IsPointer) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBePointer"), nameof(ptr)); + throw new ArgumentException(SR.Arg_MustBePointer, nameof(ptr)); Contract.EndContractBlock(); RuntimeType rt = type as RuntimeType; if (rt == null) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBePointer"), nameof(ptr)); + throw new ArgumentException(SR.Arg_MustBePointer, nameof(ptr)); Pointer x = new Pointer(); x._ptr = ptr; @@ -59,7 +59,7 @@ namespace System.Reflection public static unsafe void* Unbox(Object ptr) { if (!(ptr is Pointer)) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBePointer"), nameof(ptr)); + throw new ArgumentException(SR.Arg_MustBePointer, nameof(ptr)); return ((Pointer)ptr)._ptr; } diff --git a/src/mscorlib/src/System/Reflection/ReflectionTypeLoadException.cs b/src/mscorlib/src/System/Reflection/ReflectionTypeLoadException.cs index 908b79513d..4dca8de86d 100644 --- a/src/mscorlib/src/System/Reflection/ReflectionTypeLoadException.cs +++ b/src/mscorlib/src/System/Reflection/ReflectionTypeLoadException.cs @@ -30,7 +30,7 @@ namespace System.Reflection // private constructor. This is not called. private ReflectionTypeLoadException() - : base(Environment.GetResourceString("ReflectionTypeLoad_LoadFailed")) + : base(SR.ReflectionTypeLoad_LoadFailed) { SetErrorCode(__HResults.COR_E_REFLECTIONTYPELOAD); } diff --git a/src/mscorlib/src/System/Reflection/RtFieldInfo.cs b/src/mscorlib/src/System/Reflection/RtFieldInfo.cs index 856e9521ce..20d6e6392f 100644 --- a/src/mscorlib/src/System/Reflection/RtFieldInfo.cs +++ b/src/mscorlib/src/System/Reflection/RtFieldInfo.cs @@ -114,12 +114,12 @@ namespace System.Reflection { if (target == null) { - throw new TargetException(Environment.GetResourceString("RFLCT.Targ_StatFldReqTarg")); + throw new TargetException(SR.RFLCT_Targ_StatFldReqTarg); } else { throw new ArgumentException( - String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Arg_FieldDeclTarget"), + String.Format(CultureInfo.CurrentUICulture, SR.Arg_FieldDeclTarget, Name, m_declaringType, target.GetType())); } } @@ -146,10 +146,10 @@ namespace System.Reflection if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE) != 0) { if (declaringType != null && declaringType.ContainsGenericParameters) - throw new InvalidOperationException(Environment.GetResourceString("Arg_UnboundGenField")); + throw new InvalidOperationException(SR.Arg_UnboundGenField); if ((declaringType == null && Module.Assembly.ReflectionOnly) || declaringType is ReflectionOnlyType) - throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyField")); + throw new InvalidOperationException(SR.Arg_ReflectionOnlyField); throw new FieldAccessException(); } @@ -214,10 +214,10 @@ namespace System.Reflection if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE) != 0) { if (declaringType != null && DeclaringType.ContainsGenericParameters) - throw new InvalidOperationException(Environment.GetResourceString("Arg_UnboundGenField")); + throw new InvalidOperationException(SR.Arg_UnboundGenField); if ((declaringType == null && Module.Assembly.ReflectionOnly) || declaringType is ReflectionOnlyType) - throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyField")); + throw new InvalidOperationException(SR.Arg_ReflectionOnlyField); throw new FieldAccessException(); } @@ -307,7 +307,7 @@ namespace System.Reflection public override Object GetValueDirect(TypedReference obj) { if (obj.IsNull) - throw new ArgumentException(Environment.GetResourceString("Arg_TypedReference_Null")); + throw new ArgumentException(SR.Arg_TypedReference_Null); Contract.EndContractBlock(); unsafe @@ -330,7 +330,7 @@ namespace System.Reflection public override void SetValueDirect(TypedReference obj, Object value) { if (obj.IsNull) - throw new ArgumentException(Environment.GetResourceString("Arg_TypedReference_Null")); + throw new ArgumentException(SR.Arg_TypedReference_Null); Contract.EndContractBlock(); unsafe @@ -346,7 +346,7 @@ namespace System.Reflection { Type declaringType = DeclaringType; if ((declaringType == null && Module.Assembly.ReflectionOnly) || declaringType is ReflectionOnlyType) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAllowedInReflectionOnly")); + throw new InvalidOperationException(SR.InvalidOperation_NotAllowedInReflectionOnly); return new RuntimeFieldHandle(this); } } diff --git a/src/mscorlib/src/System/Reflection/RuntimeAssembly.cs b/src/mscorlib/src/System/Reflection/RuntimeAssembly.cs index 5322047484..1cca9e1d55 100644 --- a/src/mscorlib/src/System/Reflection/RuntimeAssembly.cs +++ b/src/mscorlib/src/System/Reflection/RuntimeAssembly.cs @@ -296,7 +296,7 @@ namespace System.Reflection 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(this, attributeRuntimeType); } @@ -310,7 +310,7 @@ namespace System.Reflection 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(this, attributeRuntimeType); } @@ -382,7 +382,7 @@ namespace System.Reflection if ((assemblyString.Length == 0) || (assemblyString[0] == '\0')) - throw new ArgumentException(Environment.GetResourceString("Format_StringZeroLength")); + throw new ArgumentException(SR.Format_StringZeroLength); if (forIntrospection) AppDomain.CheckReflectionOnlyLoadSupported(); @@ -715,7 +715,7 @@ namespace System.Reflection { //Console.WriteLine("Creating an unmanaged memory stream of length "+length); if (length > Int64.MaxValue) - throw new NotImplementedException(Environment.GetResourceString("NotImplemented_ResourcesLongerThan2^63")); + throw new NotImplementedException(SR.NotImplemented_ResourcesLongerThanInt64Max); return new UnmanagedMemoryStream(pbInMemoryResource, (long)length, (long)length, FileAccess.Read); } @@ -891,7 +891,7 @@ namespace System.Reflection if (retAssembly == this || (retAssembly == null && throwOnFileNotFound)) { - throw new FileNotFoundException(String.Format(culture, Environment.GetResourceString("IO.FileNotFound_FileName"), an.Name)); + throw new FileNotFoundException(String.Format(culture, SR.IO_FileNotFound_FileName, an.Name)); } return retAssembly; diff --git a/src/mscorlib/src/System/Reflection/RuntimeConstructorInfo.cs b/src/mscorlib/src/System/Reflection/RuntimeConstructorInfo.cs index 069927e739..c2601ae3bf 100644 --- a/src/mscorlib/src/System/Reflection/RuntimeConstructorInfo.cs +++ b/src/mscorlib/src/System/Reflection/RuntimeConstructorInfo.cs @@ -142,9 +142,9 @@ namespace System.Reflection if (!m_declaringType.IsInstanceOfType(target)) { if (target == null) - throw new TargetException(Environment.GetResourceString("RFLCT.Targ_StatMethReqTarg")); + throw new TargetException(SR.RFLCT_Targ_StatMethReqTarg); - throw new TargetException(Environment.GetResourceString("RFLCT.Targ_ITargMismatch")); + throw new TargetException(SR.RFLCT_Targ_ITargMismatch); } } @@ -177,7 +177,7 @@ namespace System.Reflection 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(this, attributeRuntimeType); } @@ -191,7 +191,7 @@ namespace System.Reflection 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(this, attributeRuntimeType); } @@ -277,7 +277,7 @@ namespace System.Reflection { Type declaringType = DeclaringType; if ((declaringType == null && Module.Assembly.ReflectionOnly) || declaringType is ReflectionOnlyType) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAllowedInReflectionOnly")); + throw new InvalidOperationException(SR.InvalidOperation_NotAllowedInReflectionOnly); return new RuntimeMethodHandle(this); } } @@ -306,17 +306,17 @@ namespace System.Reflection // ctor is ReflectOnly if (declaringType is ReflectionOnlyType) - throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyInvoke")); + throw new InvalidOperationException(SR.Arg_ReflectionOnlyInvoke); // ctor is declared on interface class else if (declaringType.IsInterface) throw new MemberAccessException( - String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Acc_CreateInterfaceEx"), declaringType)); + String.Format(CultureInfo.CurrentUICulture, SR.Acc_CreateInterfaceEx, declaringType)); // ctor is on an abstract class else if (declaringType.IsAbstract) throw new MemberAccessException( - String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Acc_CreateAbstEx"), declaringType)); + String.Format(CultureInfo.CurrentUICulture, SR.Acc_CreateAbstEx, declaringType)); // ctor is on a class that contains stack pointers else if (declaringType.GetRootElementType() == typeof(ArgIterator)) @@ -330,12 +330,12 @@ namespace System.Reflection else if (declaringType.ContainsGenericParameters) { throw new MemberAccessException( - String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Acc_CreateGenericEx"), declaringType)); + String.Format(CultureInfo.CurrentUICulture, SR.Acc_CreateGenericEx, declaringType)); } // ctor is declared on System.Void else if (declaringType == typeof(void)) - throw new MemberAccessException(Environment.GetResourceString("Access_Void")); + throw new MemberAccessException(SR.Access_Void); } internal void ThrowNoInvokeException() @@ -344,7 +344,7 @@ namespace System.Reflection // ctor is .cctor if ((Attributes & MethodAttributes.Static) == MethodAttributes.Static) - throw new MemberAccessException(Environment.GetResourceString("Acc_NotClassInit")); + throw new MemberAccessException(SR.Acc_NotClassInit); throw new TargetException(); } @@ -376,7 +376,7 @@ namespace System.Reflection int formalCount = sig.Arguments.Length; int actualCount = (parameters != null) ? parameters.Length : 0; if (formalCount != actualCount) - throw new TargetParameterCountException(Environment.GetResourceString("Arg_ParmCnt")); + throw new TargetParameterCountException(SR.Arg_ParmCnt); // if we are here we passed all the previous checks. Time to look at the arguments if (actualCount > 0) @@ -443,7 +443,7 @@ namespace System.Reflection int formalCount = sig.Arguments.Length; int actualCount = (parameters != null) ? parameters.Length : 0; if (formalCount != actualCount) - throw new TargetParameterCountException(Environment.GetResourceString("Arg_ParmCnt")); + throw new TargetParameterCountException(SR.Arg_ParmCnt); // We don't need to explicitly invoke the class constructor here, // JIT/NGen will insert the call to .cctor in the instance ctor. diff --git a/src/mscorlib/src/System/Reflection/RuntimeEventInfo.cs b/src/mscorlib/src/System/Reflection/RuntimeEventInfo.cs index 8d82e26a97..ba356e2ebf 100644 --- a/src/mscorlib/src/System/Reflection/RuntimeEventInfo.cs +++ b/src/mscorlib/src/System/Reflection/RuntimeEventInfo.cs @@ -75,7 +75,7 @@ namespace System.Reflection public override String ToString() { if (m_addMethod == null || m_addMethod.GetParametersNoCopy().Length == 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NoPublicAddMethod")); + throw new InvalidOperationException(SR.InvalidOperation_NoPublicAddMethod); return m_addMethod.GetParametersNoCopy()[0].ParameterType.FormatTypeName() + " " + Name; } @@ -96,7 +96,7 @@ namespace System.Reflection 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(this, attributeRuntimeType); } @@ -110,7 +110,7 @@ namespace System.Reflection 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(this, attributeRuntimeType); } diff --git a/src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs b/src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs index cc1beb74a1..cab7a4a5c4 100644 --- a/src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs +++ b/src/mscorlib/src/System/Reflection/RuntimeFieldInfo.cs @@ -93,7 +93,7 @@ namespace System.Reflection 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(this, attributeRuntimeType); } @@ -107,7 +107,7 @@ namespace System.Reflection 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(this, attributeRuntimeType); } diff --git a/src/mscorlib/src/System/Reflection/RuntimeMethodInfo.cs b/src/mscorlib/src/System/Reflection/RuntimeMethodInfo.cs index a2530e22bf..73298d3e36 100644 --- a/src/mscorlib/src/System/Reflection/RuntimeMethodInfo.cs +++ b/src/mscorlib/src/System/Reflection/RuntimeMethodInfo.cs @@ -287,7 +287,7 @@ namespace System.Reflection 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(this, attributeRuntimeType, inherit); } @@ -301,7 +301,7 @@ namespace System.Reflection 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(this, attributeRuntimeType, inherit); } @@ -404,7 +404,7 @@ namespace System.Reflection { Type declaringType = DeclaringType; if ((declaringType == null && Module.Assembly.ReflectionOnly) || declaringType is ReflectionOnlyType) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAllowedInReflectionOnly")); + throw new InvalidOperationException(SR.InvalidOperation_NotAllowedInReflectionOnly); return new RuntimeMethodHandle(this); } } @@ -437,9 +437,9 @@ namespace System.Reflection if (!m_declaringType.IsInstanceOfType(target)) { if (target == null) - throw new TargetException(Environment.GetResourceString("RFLCT.Targ_StatMethReqTarg")); + throw new TargetException(SR.RFLCT_Targ_StatMethReqTarg); else - throw new TargetException(Environment.GetResourceString("RFLCT.Targ_ITargMismatch")); + throw new TargetException(SR.RFLCT_Targ_ITargMismatch); } } } @@ -450,7 +450,7 @@ namespace System.Reflection Type declaringType = DeclaringType; if ((declaringType == null && Module.Assembly.ReflectionOnly) || declaringType is ReflectionOnlyType) { - throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyInvoke")); + throw new InvalidOperationException(SR.Arg_ReflectionOnlyInvoke); } // method is on a class that contains stack pointers else if ((InvocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_CONTAINS_STACK_POINTERS) != 0) @@ -465,7 +465,7 @@ namespace System.Reflection // method is generic or on a generic class else if (DeclaringType.ContainsGenericParameters || ContainsGenericParameters) { - throw new InvalidOperationException(Environment.GetResourceString("Arg_UnboundGenParam")); + throw new InvalidOperationException(SR.Arg_UnboundGenParam); } // method is abstract class else if (IsAbstract) @@ -475,7 +475,7 @@ namespace System.Reflection // ByRef return are not allowed in reflection else if (ReturnType.IsByRef) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_ByRefReturn")); + throw new NotSupportedException(SR.NotSupported_ByRefReturn); } throw new TargetException(); @@ -540,7 +540,7 @@ namespace System.Reflection CheckConsistency(obj); if (formalCount != actualCount) - throw new TargetParameterCountException(Environment.GetResourceString("Arg_ParmCnt")); + throw new TargetParameterCountException(SR.Arg_ParmCnt); if (actualCount != 0) return CheckArguments(parameters, binder, invokeAttr, culture, sig); @@ -642,15 +642,15 @@ namespace System.Reflection RuntimeType rtType = delegateType as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), nameof(delegateType)); + throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(delegateType)); if (!rtType.IsDelegate()) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), nameof(delegateType)); + throw new ArgumentException(SR.Arg_MustBeDelegate, nameof(delegateType)); Delegate d = Delegate.CreateDelegateInternal(rtType, this, firstArgument, bindingFlags, ref stackMark); if (d == null) { - throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth")); + throw new ArgumentException(SR.Arg_DlgtTargMeth); } return d; @@ -669,7 +669,7 @@ namespace System.Reflection if (!IsGenericMethodDefinition) throw new InvalidOperationException( - Environment.GetResourceString("Arg_NotGenericMethodDefinition", this)); + SR.Format(SR.Arg_NotGenericMethodDefinition, this)); for (int i = 0; i < methodInstantiation.Length; i++) { @@ -777,7 +777,7 @@ namespace System.Reflection Contract.EndContractBlock(); if (m_reflectedTypeCache.IsGlobal) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_GlobalMethodSerialization")); + throw new NotSupportedException(SR.NotSupported_GlobalMethodSerialization); MemberInfoSerializationHolder.GetSerializationInfo( info, diff --git a/src/mscorlib/src/System/Reflection/RuntimeModule.cs b/src/mscorlib/src/System/Reflection/RuntimeModule.cs index 2b663a8677..4e77e8f8c4 100644 --- a/src/mscorlib/src/System/Reflection/RuntimeModule.cs +++ b/src/mscorlib/src/System/Reflection/RuntimeModule.cs @@ -58,12 +58,12 @@ namespace System.Reflection { Type typeArg = genericArguments[i]; if (typeArg == null) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidGenericInstArray")); + throw new ArgumentException(SR.Argument_InvalidGenericInstArray); typeArg = typeArg.UnderlyingSystemType; if (typeArg == null) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidGenericInstArray")); + throw new ArgumentException(SR.Argument_InvalidGenericInstArray); if (!(typeArg is RuntimeType)) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidGenericInstArray")); + throw new ArgumentException(SR.Argument_InvalidGenericInstArray); typeHandleArgs[i] = typeArg.GetTypeHandleInternal(); } return typeHandleArgs; @@ -75,10 +75,10 @@ namespace System.Reflection if (!MetadataImport.IsValidToken(tk)) throw new ArgumentOutOfRangeException(nameof(metadataToken), - Environment.GetResourceString("Argument_InvalidToken", tk, this)); + SR.Format(SR.Argument_InvalidToken, tk, this)); if (!tk.IsMemberRef && !tk.IsMethodDef && !tk.IsTypeSpec && !tk.IsSignature && !tk.IsFieldDef) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidToken", tk, this), + throw new ArgumentException(SR.Format(SR.Argument_InvalidToken, tk, this), nameof(metadataToken)); ConstArray signature; @@ -101,7 +101,7 @@ namespace System.Reflection if (!MetadataImport.IsValidToken(tk)) throw new ArgumentOutOfRangeException(nameof(metadataToken), - Environment.GetResourceString("Argument_InvalidToken", tk, this)); + SR.Format(SR.Argument_InvalidToken, tk, this)); RuntimeTypeHandle[] typeArgs = ConvertToTypeHandleArray(genericTypeArguments); RuntimeTypeHandle[] methodArgs = ConvertToTypeHandleArray(genericMethodArguments); @@ -111,7 +111,7 @@ namespace System.Reflection if (!tk.IsMethodDef && !tk.IsMethodSpec) { if (!tk.IsMemberRef) - throw new ArgumentException(Environment.GetResourceString("Argument_ResolveMethod", tk, this), + throw new ArgumentException(SR.Format(SR.Argument_ResolveMethod, tk, this), nameof(metadataToken)); unsafe @@ -119,7 +119,7 @@ namespace System.Reflection ConstArray sig = MetadataImport.GetMemberRefProps(tk); if (*(MdSigCallingConvention*)sig.Signature.ToPointer() == MdSigCallingConvention.Field) - throw new ArgumentException(Environment.GetResourceString("Argument_ResolveMethod", tk, this), + throw new ArgumentException(SR.Format(SR.Argument_ResolveMethod, tk, this), nameof(metadataToken)); } } @@ -141,7 +141,7 @@ namespace System.Reflection } catch (BadImageFormatException e) { - throw new ArgumentException(Environment.GetResourceString("Argument_BadImageFormatExceptionResolve"), e); + throw new ArgumentException(SR.Argument_BadImageFormatExceptionResolve, e); } } @@ -151,7 +151,7 @@ namespace System.Reflection if (!MetadataImport.IsValidToken(tk) || !tk.IsFieldDef) throw new ArgumentOutOfRangeException(nameof(metadataToken), - String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Argument_InvalidToken", tk, this))); + String.Format(CultureInfo.CurrentUICulture, SR.Format(SR.Argument_InvalidToken, tk, this))); int tkDeclaringType; string fieldName; @@ -172,7 +172,7 @@ namespace System.Reflection } catch { - throw new ArgumentException(Environment.GetResourceString("Argument_ResolveField", tk, this), nameof(metadataToken)); + throw new ArgumentException(SR.Format(SR.Argument_ResolveField, tk, this), nameof(metadataToken)); } } @@ -182,7 +182,7 @@ namespace System.Reflection if (!MetadataImport.IsValidToken(tk)) throw new ArgumentOutOfRangeException(nameof(metadataToken), - Environment.GetResourceString("Argument_InvalidToken", tk, this)); + SR.Format(SR.Argument_InvalidToken, tk, this)); RuntimeTypeHandle[] typeArgs = ConvertToTypeHandleArray(genericTypeArguments); RuntimeTypeHandle[] methodArgs = ConvertToTypeHandleArray(genericMethodArguments); @@ -194,7 +194,7 @@ namespace System.Reflection if (!tk.IsFieldDef) { if (!tk.IsMemberRef) - throw new ArgumentException(Environment.GetResourceString("Argument_ResolveField", tk, this), + throw new ArgumentException(SR.Format(SR.Argument_ResolveField, tk, this), nameof(metadataToken)); unsafe @@ -202,7 +202,7 @@ namespace System.Reflection ConstArray sig = MetadataImport.GetMemberRefProps(tk); if (*(MdSigCallingConvention*)sig.Signature.ToPointer() != MdSigCallingConvention.Field) - throw new ArgumentException(Environment.GetResourceString("Argument_ResolveField", tk, this), + throw new ArgumentException(SR.Format(SR.Argument_ResolveField, tk, this), nameof(metadataToken)); } @@ -226,7 +226,7 @@ namespace System.Reflection } catch (BadImageFormatException e) { - throw new ArgumentException(Environment.GetResourceString("Argument_BadImageFormatExceptionResolve"), e); + throw new ArgumentException(SR.Argument_BadImageFormatExceptionResolve, e); } } @@ -235,14 +235,14 @@ namespace System.Reflection MetadataToken tk = new MetadataToken(metadataToken); if (tk.IsGlobalTypeDefToken) - throw new ArgumentException(Environment.GetResourceString("Argument_ResolveModuleType", tk), nameof(metadataToken)); + throw new ArgumentException(SR.Format(SR.Argument_ResolveModuleType, tk), nameof(metadataToken)); if (!MetadataImport.IsValidToken(tk)) throw new ArgumentOutOfRangeException(nameof(metadataToken), - Environment.GetResourceString("Argument_InvalidToken", tk, this)); + SR.Format(SR.Argument_InvalidToken, tk, this)); if (!tk.IsTypeDef && !tk.IsTypeSpec && !tk.IsTypeRef) - throw new ArgumentException(Environment.GetResourceString("Argument_ResolveType", tk, this), nameof(metadataToken)); + throw new ArgumentException(SR.Format(SR.Argument_ResolveType, tk, this), nameof(metadataToken)); RuntimeTypeHandle[] typeArgs = ConvertToTypeHandleArray(genericTypeArguments); RuntimeTypeHandle[] methodArgs = ConvertToTypeHandleArray(genericMethodArguments); @@ -252,13 +252,13 @@ namespace System.Reflection Type t = GetModuleHandleImpl().ResolveTypeHandle(metadataToken, typeArgs, methodArgs).GetRuntimeType(); if (t == null) - throw new ArgumentException(Environment.GetResourceString("Argument_ResolveType", tk, this), nameof(metadataToken)); + throw new ArgumentException(SR.Format(SR.Argument_ResolveType, tk, this), nameof(metadataToken)); return t; } catch (BadImageFormatException e) { - throw new ArgumentException(Environment.GetResourceString("Argument_BadImageFormatExceptionResolve"), e); + throw new ArgumentException(SR.Argument_BadImageFormatExceptionResolve, e); } } @@ -267,10 +267,10 @@ namespace System.Reflection MetadataToken tk = new MetadataToken(metadataToken); if (tk.IsProperty) - throw new ArgumentException(Environment.GetResourceString("InvalidOperation_PropertyInfoNotAvailable")); + throw new ArgumentException(SR.InvalidOperation_PropertyInfoNotAvailable); if (tk.IsEvent) - throw new ArgumentException(Environment.GetResourceString("InvalidOperation_EventInfoNotAvailable")); + throw new ArgumentException(SR.InvalidOperation_EventInfoNotAvailable); if (tk.IsMethodSpec || tk.IsMethodDef) return ResolveMethod(metadataToken, genericTypeArguments, genericMethodArguments); @@ -285,7 +285,7 @@ namespace System.Reflection { if (!MetadataImport.IsValidToken(tk)) throw new ArgumentOutOfRangeException(nameof(metadataToken), - Environment.GetResourceString("Argument_InvalidToken", tk, this)); + SR.Format(SR.Argument_InvalidToken, tk, this)); ConstArray sig = MetadataImport.GetMemberRefProps(tk); @@ -302,7 +302,7 @@ namespace System.Reflection } } - throw new ArgumentException(Environment.GetResourceString("Argument_ResolveMember", tk, this), + throw new ArgumentException(SR.Format(SR.Argument_ResolveMember, tk, this), nameof(metadataToken)); } @@ -311,17 +311,17 @@ namespace System.Reflection MetadataToken tk = new MetadataToken(metadataToken); if (!tk.IsString) throw new ArgumentException( - String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Argument_ResolveString"), metadataToken, ToString())); + String.Format(CultureInfo.CurrentUICulture, SR.Argument_ResolveString, metadataToken, ToString())); if (!MetadataImport.IsValidToken(tk)) throw new ArgumentOutOfRangeException(nameof(metadataToken), - String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Argument_InvalidToken", tk, this))); + String.Format(CultureInfo.CurrentUICulture, SR.Format(SR.Argument_InvalidToken, tk, this))); string str = MetadataImport.GetUserString(metadataToken); if (str == null) throw new ArgumentException( - String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Argument_ResolveString"), metadataToken, ToString())); + String.Format(CultureInfo.CurrentUICulture, SR.Argument_ResolveString, metadataToken, ToString())); return str; } @@ -420,7 +420,7 @@ namespace System.Reflection 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(this, attributeRuntimeType); } @@ -434,7 +434,7 @@ namespace System.Reflection 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(this, attributeRuntimeType); } diff --git a/src/mscorlib/src/System/Reflection/RuntimeParameterInfo.cs b/src/mscorlib/src/System/Reflection/RuntimeParameterInfo.cs index 5fb2e92088..77a56b4fe2 100644 --- a/src/mscorlib/src/System/Reflection/RuntimeParameterInfo.cs +++ b/src/mscorlib/src/System/Reflection/RuntimeParameterInfo.cs @@ -55,7 +55,7 @@ namespace System.Reflection // Not all parameters have tokens. Parameters may have no token // if they have no name and no attributes. if (cParamDefs > sigArgCount + 1 /* return type */) - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ParameterSignatureMismatch")); + throw new BadImageFormatException(SR.BadImageFormat_ParameterSignatureMismatch); for (int i = 0; i < cParamDefs; i++) { @@ -71,7 +71,7 @@ namespace System.Reflection { // more than one return parameter? if (returnParameter != null) - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ParameterSignatureMismatch")); + throw new BadImageFormatException(SR.BadImageFormat_ParameterSignatureMismatch); returnParameter = new RuntimeParameterInfo(sig, scope, tkParamDef, position, attr, member); } @@ -79,7 +79,7 @@ namespace System.Reflection { // position beyong sigArgCount? if (position >= sigArgCount) - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ParameterSignatureMismatch")); + throw new BadImageFormatException(SR.BadImageFormat_ParameterSignatureMismatch); args[position] = new RuntimeParameterInfo(sig, scope, tkParamDef, position, attr, member); } @@ -496,7 +496,7 @@ namespace System.Reflection 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(this, attributeRuntimeType); } @@ -513,7 +513,7 @@ namespace System.Reflection 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(this, attributeRuntimeType); } diff --git a/src/mscorlib/src/System/Reflection/RuntimePropertyInfo.cs b/src/mscorlib/src/System/Reflection/RuntimePropertyInfo.cs index 5726081b2a..fe4ffbf8b7 100644 --- a/src/mscorlib/src/System/Reflection/RuntimePropertyInfo.cs +++ b/src/mscorlib/src/System/Reflection/RuntimePropertyInfo.cs @@ -162,7 +162,7 @@ namespace System.Reflection 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(this, attributeRuntimeType); } @@ -176,7 +176,7 @@ namespace System.Reflection 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(this, attributeRuntimeType); } @@ -249,7 +249,7 @@ namespace System.Reflection if (defaultValue == DBNull.Value) // Arg_EnumLitValueNotFound -> "Literal value was not found." - throw new InvalidOperationException(Environment.GetResourceString("Arg_EnumLitValueNotFound")); + throw new InvalidOperationException(SR.Arg_EnumLitValueNotFound); return defaultValue; } @@ -400,7 +400,7 @@ namespace System.Reflection { MethodInfo m = GetGetMethod(true); if (m == null) - throw new ArgumentException(System.Environment.GetResourceString("Arg_GetMethNotFnd")); + throw new ArgumentException(System.SR.Arg_GetMethNotFnd); return m.Invoke(obj, invokeAttr, binder, index, null); } @@ -423,7 +423,7 @@ namespace System.Reflection MethodInfo m = GetSetMethod(true); if (m == null) - throw new ArgumentException(System.Environment.GetResourceString("Arg_SetMethNotFnd")); + throw new ArgumentException(System.SR.Arg_SetMethNotFnd); Object[] args = null; diff --git a/src/mscorlib/src/System/Reflection/TargetInvocationException.cs b/src/mscorlib/src/System/Reflection/TargetInvocationException.cs index 326b571e18..38c5b7d008 100644 --- a/src/mscorlib/src/System/Reflection/TargetInvocationException.cs +++ b/src/mscorlib/src/System/Reflection/TargetInvocationException.cs @@ -25,7 +25,7 @@ namespace System.Reflection // This exception is not creatable without specifying the // inner exception. private TargetInvocationException() - : base(Environment.GetResourceString("Arg_TargetInvocationException")) + : base(SR.Arg_TargetInvocationException) { SetErrorCode(__HResults.COR_E_TARGETINVOCATION); } @@ -37,7 +37,7 @@ namespace System.Reflection } public TargetInvocationException(System.Exception inner) - : base(Environment.GetResourceString("Arg_TargetInvocationException"), inner) + : base(SR.Arg_TargetInvocationException, inner) { SetErrorCode(__HResults.COR_E_TARGETINVOCATION); } diff --git a/src/mscorlib/src/System/Reflection/TargetParameterCountException.cs b/src/mscorlib/src/System/Reflection/TargetParameterCountException.cs index 3e2bce4b26..5e315f91ff 100644 --- a/src/mscorlib/src/System/Reflection/TargetParameterCountException.cs +++ b/src/mscorlib/src/System/Reflection/TargetParameterCountException.cs @@ -22,7 +22,7 @@ namespace System.Reflection public sealed class TargetParameterCountException : ApplicationException { public TargetParameterCountException() - : base(Environment.GetResourceString("Arg_TargetParameterCountException")) + : base(SR.Arg_TargetParameterCountException) { SetErrorCode(__HResults.COR_E_TARGETPARAMCOUNT); } |