diff options
Diffstat (limited to 'src/mscorlib/src/System/Runtime')
50 files changed, 163 insertions, 163 deletions
diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs b/src/mscorlib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs index eed21cf6fb..9e4673b624 100644 --- a/src/mscorlib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs +++ b/src/mscorlib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs @@ -973,7 +973,7 @@ namespace System.Runtime.CompilerServices { if (_invalid) { - throw new InvalidOperationException(Environment.GetResourceString("CollectionCorrupted")); + throw new InvalidOperationException(SR.InvalidOperation_CollectionCorrupted); } } diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs b/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs index abb5a8f656..dc27a65c43 100644 --- a/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs +++ b/src/mscorlib/src/System/Runtime/CompilerServices/RuntimeWrappedException.cs @@ -22,7 +22,7 @@ namespace System.Runtime.CompilerServices public sealed class RuntimeWrappedException : Exception { private RuntimeWrappedException(Object thrownObject) - : base(Environment.GetResourceString("RuntimeWrappedException")) + : base(SR.RuntimeWrappedException) { SetErrorCode(System.__HResults.COR_E_RUNTIMEWRAPPED); m_wrappedException = thrownObject; diff --git a/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionNotification.cs b/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionNotification.cs index 70b9418263..d986ea9c24 100644 --- a/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionNotification.cs +++ b/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionNotification.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. /*============================================================================= diff --git a/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionServicesCommon.cs b/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionServicesCommon.cs index 4666611278..9e87b21737 100644 --- a/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionServicesCommon.cs +++ b/src/mscorlib/src/System/Runtime/ExceptionServices/ExceptionServicesCommon.cs @@ -101,7 +101,7 @@ namespace System.Runtime.ExceptionServices { if (source == null) { - throw new ArgumentNullException(nameof(source), Environment.GetResourceString("ArgumentNull_Obj")); + throw new ArgumentNullException(nameof(source), SR.ArgumentNull_Obj); } return new ExceptionDispatchInfo(source); diff --git a/src/mscorlib/src/System/Runtime/GcSettings.cs b/src/mscorlib/src/System/Runtime/GcSettings.cs index 834307190b..993a24f986 100644 --- a/src/mscorlib/src/System/Runtime/GcSettings.cs +++ b/src/mscorlib/src/System/Runtime/GcSettings.cs @@ -50,7 +50,7 @@ namespace System.Runtime { if ((value < GCLatencyMode.Batch) || (value > GCLatencyMode.SustainedLowLatency)) { - throw new ArgumentOutOfRangeException(Environment.GetResourceString("ArgumentOutOfRange_Enum")); + throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_Enum); } Contract.EndContractBlock(); @@ -72,7 +72,7 @@ namespace System.Runtime if ((value < GCLargeObjectHeapCompactionMode.Default) || (value > GCLargeObjectHeapCompactionMode.CompactOnce)) { - throw new ArgumentOutOfRangeException(Environment.GetResourceString("ArgumentOutOfRange_Enum")); + throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_Enum); } Contract.EndContractBlock(); diff --git a/src/mscorlib/src/System/Runtime/InteropServices/COMException.cs b/src/mscorlib/src/System/Runtime/InteropServices/COMException.cs index 82a0f098a1..f8fcfb5826 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/COMException.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/COMException.cs @@ -26,7 +26,7 @@ namespace System.Runtime.InteropServices public class COMException : ExternalException { public COMException() - : base(Environment.GetResourceString("Arg_COMException")) + : base(SR.Arg_COMException) { SetErrorCode(__HResults.E_FAIL); } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/CurrencyWrapper.cs b/src/mscorlib/src/System/Runtime/InteropServices/CurrencyWrapper.cs index 51c379f369..4b436825e8 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/CurrencyWrapper.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/CurrencyWrapper.cs @@ -27,7 +27,7 @@ namespace System.Runtime.InteropServices public CurrencyWrapper(Object obj) { if (!(obj is Decimal)) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDecimal"), nameof(obj)); + throw new ArgumentException(SR.Arg_MustBeDecimal, nameof(obj)); m_WrappedObject = (Decimal)obj; } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ErrorWrapper.cs b/src/mscorlib/src/System/Runtime/InteropServices/ErrorWrapper.cs index ff96aeff61..73be2c5777 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/ErrorWrapper.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/ErrorWrapper.cs @@ -27,7 +27,7 @@ namespace System.Runtime.InteropServices public ErrorWrapper(Object errorCode) { if (!(errorCode is int)) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeInt32"), nameof(errorCode)); + throw new ArgumentException(SR.Arg_MustBeInt32, nameof(errorCode)); m_ErrorCode = (int)errorCode; } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/ExternalException.cs b/src/mscorlib/src/System/Runtime/InteropServices/ExternalException.cs index 8aea9b2a1b..323a9a666a 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/ExternalException.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/ExternalException.cs @@ -26,7 +26,7 @@ namespace System.Runtime.InteropServices public class ExternalException : SystemException { public ExternalException() - : base(Environment.GetResourceString("Arg_ExternalException")) + : base(SR.Arg_ExternalException) { SetErrorCode(__HResults.E_FAIL); } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/GCHandleCookieTable.cs b/src/mscorlib/src/System/Runtime/InteropServices/GCHandleCookieTable.cs index 304f369879..9e813d9bd9 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/GCHandleCookieTable.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/GCHandleCookieTable.cs @@ -91,7 +91,7 @@ namespace System.Runtime.InteropServices } if (cookie == GCHandleCookie.Zero) - throw new OutOfMemoryException(Environment.GetResourceString("OutOfMemory_GCHandleMDA")); + throw new OutOfMemoryException(SR.OutOfMemory_GCHandleMDA); // This handle hasn't been added to the map yet so add it. m_HandleToCookieMap.Add(handle, cookie); diff --git a/src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs b/src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs index 4cf21401fd..dcb9e24258 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/GcHandle.cs @@ -140,7 +140,7 @@ namespace System.Runtime.InteropServices ValidateHandle(); // You can only get the address of pinned handles. - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_HandleIsNotPinned")); + throw new InvalidOperationException(SR.InvalidOperation_HandleIsNotPinned); } // Get the address. diff --git a/src/mscorlib/src/System/Runtime/InteropServices/InvalidComObjectException.cs b/src/mscorlib/src/System/Runtime/InteropServices/InvalidComObjectException.cs index b7fb686a39..5e26352090 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/InvalidComObjectException.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/InvalidComObjectException.cs @@ -21,7 +21,7 @@ namespace System.Runtime.InteropServices public class InvalidComObjectException : SystemException { public InvalidComObjectException() - : base(Environment.GetResourceString("Arg_InvalidComObjectException")) + : base(SR.Arg_InvalidComObjectException) { SetErrorCode(__HResults.COR_E_INVALIDCOMOBJECT); } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs b/src/mscorlib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs index 8ce8bb2a06..6e644181ec 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs @@ -20,7 +20,7 @@ namespace System.Runtime.InteropServices public class InvalidOleVariantTypeException : SystemException { public InvalidOleVariantTypeException() - : base(Environment.GetResourceString("Arg_InvalidOleVariantTypeException")) + : base(SR.Arg_InvalidOleVariantTypeException) { SetErrorCode(__HResults.COR_E_INVALIDOLEVARIANTTYPE); } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs b/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs index 142389e29d..306d889d04 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/Marshal.cs @@ -240,9 +240,9 @@ namespace System.Runtime.InteropServices if (t == null) throw new ArgumentNullException(nameof(t)); if (!(t is RuntimeType)) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), nameof(t)); + throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(t)); if (t.IsGenericType) - throw new ArgumentException(Environment.GetResourceString("Argument_NeedNonGenericType"), nameof(t)); + throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(t)); Contract.EndContractBlock(); return SizeOfHelper(t, true); @@ -296,10 +296,10 @@ namespace System.Runtime.InteropServices FieldInfo f = t.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (f == null) - throw new ArgumentException(Environment.GetResourceString("Argument_OffsetOfFieldNotFound", t.FullName), nameof(fieldName)); + throw new ArgumentException(SR.Format(SR.Argument_OffsetOfFieldNotFound, t.FullName), nameof(fieldName)); RtFieldInfo rtField = f as RtFieldInfo; if (rtField == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeFieldInfo"), nameof(fieldName)); + throw new ArgumentException(SR.Argument_MustBeRuntimeFieldInfo, nameof(fieldName)); return OffsetOfHelper(rtField); } @@ -799,7 +799,7 @@ namespace System.Runtime.InteropServices RuntimeMethodInfo rmi = m as RuntimeMethodInfo; if (rmi == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo")); + throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo); InternalPrelink(rmi); } @@ -866,12 +866,12 @@ namespace System.Runtime.InteropServices throw new ArgumentNullException(nameof(structureType)); if (structureType.IsGenericType) - throw new ArgumentException(Environment.GetResourceString("Argument_NeedNonGenericType"), nameof(structureType)); + throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(structureType)); RuntimeType rt = structureType.UnderlyingSystemType as RuntimeType; if (rt == null) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(structureType)); + throw new ArgumentException(SR.Arg_MustBeType, nameof(structureType)); StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; @@ -925,7 +925,7 @@ namespace System.Runtime.InteropServices } if (rtModule == null) - throw new ArgumentNullException(nameof(m), Environment.GetResourceString("Argument_MustBeRuntimeModule")); + throw new ArgumentNullException(nameof(m), SR.Argument_MustBeRuntimeModule); return GetHINSTANCE(rtModule.GetNativeHandle()); } @@ -1424,7 +1424,7 @@ namespace System.Runtime.InteropServices } catch (InvalidCastException) { - throw new ArgumentException(Environment.GetResourceString("Argument_ObjNotComObject"), nameof(o)); + throw new ArgumentException(SR.Argument_ObjNotComObject, nameof(o)); } return co.ReleaseSelf(); @@ -1453,7 +1453,7 @@ namespace System.Runtime.InteropServices } catch (InvalidCastException) { - throw new ArgumentException(Environment.GetResourceString("Argument_ObjNotComObject"), nameof(o)); + throw new ArgumentException(SR.Argument_ObjNotComObject, nameof(o)); } co.FinalReleaseSelf(); @@ -1495,13 +1495,13 @@ namespace System.Runtime.InteropServices if (t == null) throw new ArgumentNullException(nameof(t)); if (!t.IsCOMObject) - throw new ArgumentException(Environment.GetResourceString("Argument_TypeNotComObject"), nameof(t)); + throw new ArgumentException(SR.Argument_TypeNotComObject, nameof(t)); if (t.IsGenericType) - throw new ArgumentException(Environment.GetResourceString("Argument_NeedNonGenericType"), nameof(t)); + throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(t)); Contract.EndContractBlock(); if (t.IsWindowsRuntimeObject) - throw new ArgumentException(Environment.GetResourceString("Argument_TypeIsWinRTType"), nameof(t)); + throw new ArgumentException(SR.Argument_TypeIsWinRTType, nameof(t)); // Check for the null case. if (o == null) @@ -1509,9 +1509,9 @@ namespace System.Runtime.InteropServices // Make sure the object is a COM object. if (!o.GetType().IsCOMObject) - throw new ArgumentException(Environment.GetResourceString("Argument_ObjNotComObject"), nameof(o)); + throw new ArgumentException(SR.Argument_ObjNotComObject, nameof(o)); if (o.GetType().IsWindowsRuntimeObject) - throw new ArgumentException(Environment.GetResourceString("Argument_ObjIsWinRTObject"), nameof(o)); + throw new ArgumentException(SR.Argument_ObjIsWinRTObject, nameof(o)); // Check to see if the type of the object is the requested type. if (o.GetType() == t) @@ -1621,9 +1621,9 @@ namespace System.Runtime.InteropServices if (type == null) throw new ArgumentNullException(nameof(type)); if (type.IsImport) - throw new ArgumentException(Environment.GetResourceString("Argument_TypeMustNotBeComImport"), nameof(type)); + throw new ArgumentException(SR.Argument_TypeMustNotBeComImport, nameof(type)); if (type.IsGenericType) - throw new ArgumentException(Environment.GetResourceString("Argument_NeedNonGenericType"), nameof(type)); + throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(type)); Contract.EndContractBlock(); IList<CustomAttributeData> cas = CustomAttributeData.GetCustomAttributes(type); @@ -1724,14 +1724,14 @@ namespace System.Runtime.InteropServices Contract.EndContractBlock(); if ((t as RuntimeType) == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), nameof(t)); + throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(t)); if (t.IsGenericType) - throw new ArgumentException(Environment.GetResourceString("Argument_NeedNonGenericType"), nameof(t)); + throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(t)); Type c = t.BaseType; if (c == null || (c != typeof(Delegate) && c != typeof(MulticastDelegate))) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), nameof(t)); + throw new ArgumentException(SR.Arg_MustBeDelegate, nameof(t)); return GetDelegateForFunctionPointerInternal(ptr, t); } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs b/src/mscorlib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs index 8240e299cb..4634ea893c 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/MarshalDirectiveException.cs @@ -21,7 +21,7 @@ namespace System.Runtime.InteropServices public class MarshalDirectiveException : SystemException { public MarshalDirectiveException() - : base(Environment.GetResourceString("Arg_MarshalDirectiveException")) + : base(SR.Arg_MarshalDirectiveException) { SetErrorCode(__HResults.COR_E_MARSHALDIRECTIVE); } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs b/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs index ad64e5e927..96bbdd7b59 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs @@ -20,7 +20,7 @@ namespace System.Runtime.InteropServices public class SafeArrayRankMismatchException : SystemException { public SafeArrayRankMismatchException() - : base(Environment.GetResourceString("Arg_SafeArrayRankMismatchException")) + : base(SR.Arg_SafeArrayRankMismatchException) { SetErrorCode(__HResults.COR_E_SAFEARRAYRANKMISMATCH); } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs b/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs index d541cf41b5..2ec2f9e80a 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs @@ -21,7 +21,7 @@ namespace System.Runtime.InteropServices public class SafeArrayTypeMismatchException : SystemException { public SafeArrayTypeMismatchException() - : base(Environment.GetResourceString("Arg_SafeArrayTypeMismatchException")) + : base(SR.Arg_SafeArrayTypeMismatchException) { SetErrorCode(__HResults.COR_E_SAFEARRAYTYPEMISMATCH); } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs b/src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs index 7fb3e4e5e8..aba25e94a3 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/SafeBuffer.cs @@ -99,13 +99,13 @@ namespace System.Runtime.InteropServices public void Initialize(ulong numBytes) { if (numBytes < 0) - throw new ArgumentOutOfRangeException(nameof(numBytes), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(numBytes), SR.ArgumentOutOfRange_NeedNonNegNum); if (IntPtr.Size == 4 && numBytes > UInt32.MaxValue) - throw new ArgumentOutOfRangeException(nameof(numBytes), Environment.GetResourceString("ArgumentOutOfRange_AddressSpace")); + throw new ArgumentOutOfRangeException(nameof(numBytes), SR.ArgumentOutOfRange_AddressSpace); Contract.EndContractBlock(); if (numBytes >= (ulong)Uninitialized) - throw new ArgumentOutOfRangeException(nameof(numBytes), Environment.GetResourceString("ArgumentOutOfRange_UIntPtrMax-1")); + throw new ArgumentOutOfRangeException(nameof(numBytes), SR.ArgumentOutOfRange_UIntPtrMax); _numBytes = (UIntPtr)numBytes; } @@ -118,16 +118,16 @@ namespace System.Runtime.InteropServices public void Initialize(uint numElements, uint sizeOfEachElement) { if (numElements < 0) - throw new ArgumentOutOfRangeException(nameof(numElements), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(numElements), SR.ArgumentOutOfRange_NeedNonNegNum); if (sizeOfEachElement < 0) - throw new ArgumentOutOfRangeException(nameof(sizeOfEachElement), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(sizeOfEachElement), SR.ArgumentOutOfRange_NeedNonNegNum); if (IntPtr.Size == 4 && numElements * sizeOfEachElement > UInt32.MaxValue) - throw new ArgumentOutOfRangeException("numBytes", Environment.GetResourceString("ArgumentOutOfRange_AddressSpace")); + throw new ArgumentOutOfRangeException("numBytes", SR.ArgumentOutOfRange_AddressSpace); Contract.EndContractBlock(); if (numElements * sizeOfEachElement >= (ulong)Uninitialized) - throw new ArgumentOutOfRangeException(nameof(numElements), Environment.GetResourceString("ArgumentOutOfRange_UIntPtrMax-1")); + throw new ArgumentOutOfRangeException(nameof(numElements), SR.ArgumentOutOfRange_UIntPtrMax); _numBytes = checked((UIntPtr)(numElements * sizeOfEachElement)); } @@ -240,13 +240,13 @@ namespace System.Runtime.InteropServices where T : struct { if (array == null) - throw new ArgumentNullException(nameof(array), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(array), SR.ArgumentNull_Buffer); if (index < 0) - throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_NeedNonNegNum); if (count < 0) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); if (array.Length - index < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); if (_numBytes == Uninitialized) @@ -311,13 +311,13 @@ namespace System.Runtime.InteropServices where T : struct { if (array == null) - throw new ArgumentNullException(nameof(array), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(array), SR.ArgumentNull_Buffer); if (index < 0) - throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_NeedNonNegNum); if (count < 0) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); if (array.Length - index < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); if (_numBytes == Uninitialized) @@ -372,13 +372,13 @@ namespace System.Runtime.InteropServices private static void NotEnoughRoom() { - throw new ArgumentException(Environment.GetResourceString("Arg_BufferTooSmall")); + throw new ArgumentException(SR.Arg_BufferTooSmall); } private static InvalidOperationException NotInitialized() { Debug.Assert(false, "Uninitialized SafeBuffer! Someone needs to call Initialize before using this instance!"); - return new InvalidOperationException(Environment.GetResourceString("InvalidOperation_MustCallInitialize")); + return new InvalidOperationException(SR.InvalidOperation_MustCallInitialize); } // FCALL limitations mean we can't have generic FCALL methods. However, we can pass diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToCollectionAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToCollectionAdapter.cs index 2d0e9a799c..350920564a 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToCollectionAdapter.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToCollectionAdapter.cs @@ -39,7 +39,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime uint size = _this.Size; if (((uint)Int32.MaxValue) < size) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingListTooLarge")); + throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } return (int)size; @@ -68,7 +68,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // ICollection expects the destination array to be single-dimensional. if (array.Rank != 1) - throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported")); + throw new ArgumentException(SR.Arg_RankMultiDimNotSupported); int destLB = array.GetLowerBound(0); @@ -88,10 +88,10 @@ namespace System.Runtime.InteropServices.WindowsRuntime // list.CopyTo(items, 0); if (srcLen > (destLen - (arrayIndex - destLB))) - throw new ArgumentException(Environment.GetResourceString("Argument_InsufficientSpaceToCopyCollection")); + throw new ArgumentException(SR.Argument_InsufficientSpaceToCopyCollection); if (arrayIndex - destLB > destLen) - throw new ArgumentException(Environment.GetResourceString("Argument_IndexOutOfArrayBounds")); + throw new ArgumentException(SR.Argument_IndexOutOfArrayBounds); // We need to verify the index as we; IBindableVector _this = JitHelpers.UnsafeCast<IBindableVector>(this); diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToListAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToListAdapter.cs index d6e50f5164..539b8020b8 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToListAdapter.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToListAdapter.cs @@ -60,7 +60,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime uint size = _this.Size; if (((uint)Int32.MaxValue) < size) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingListTooLarge")); + throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } return (int)(size - 1); @@ -109,7 +109,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime if (((uint)Int32.MaxValue) < index) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingListTooLarge")); + throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } return (int)index; @@ -137,7 +137,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime { if (((uint)Int32.MaxValue) < index) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingListTooLarge")); + throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } RemoveAtHelper(_this, index); diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs index 8fd30438ad..aa0f3ba056 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs @@ -134,7 +134,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime public char GetChar16() { if (this.Type != PropertyType.Char16) - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", this.Type, "Char16"), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Char16"), __HResults.TYPE_E_TYPEMISMATCH); Contract.EndContractBlock(); return (char)_data; } @@ -143,7 +143,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime public Boolean GetBoolean() { if (this.Type != PropertyType.Boolean) - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", this.Type, "Boolean"), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Boolean"), __HResults.TYPE_E_TYPEMISMATCH); Contract.EndContractBlock(); return (bool)_data; } @@ -166,7 +166,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime public DateTimeOffset GetDateTime() { if (this.Type != PropertyType.DateTime) - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", this.Type, "DateTime"), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "DateTime"), __HResults.TYPE_E_TYPEMISMATCH); Contract.EndContractBlock(); return (DateTimeOffset)_data; } @@ -175,7 +175,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime public TimeSpan GetTimeSpan() { if (this.Type != PropertyType.TimeSpan) - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", this.Type, "TimeSpan"), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "TimeSpan"), __HResults.TYPE_E_TYPEMISMATCH); Contract.EndContractBlock(); return (TimeSpan)_data; } @@ -184,7 +184,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime public Point GetPoint() { if (this.Type != PropertyType.Point) - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", this.Type, "Point"), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Point"), __HResults.TYPE_E_TYPEMISMATCH); Contract.EndContractBlock(); return Unbox<Point>(IReferenceFactory.s_pointType); @@ -194,7 +194,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime public Size GetSize() { if (this.Type != PropertyType.Size) - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", this.Type, "Size"), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Size"), __HResults.TYPE_E_TYPEMISMATCH); Contract.EndContractBlock(); return Unbox<Size>(IReferenceFactory.s_sizeType); @@ -204,7 +204,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime public Rect GetRect() { if (this.Type != PropertyType.Rect) - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", this.Type, "Rect"), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Rect"), __HResults.TYPE_E_TYPEMISMATCH); Contract.EndContractBlock(); return Unbox<Rect>(IReferenceFactory.s_rectType); @@ -268,7 +268,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime public char[] GetChar16Array() { if (this.Type != PropertyType.Char16Array) - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", this.Type, "Char16[]"), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Char16[]"), __HResults.TYPE_E_TYPEMISMATCH); Contract.EndContractBlock(); return (char[])_data; } @@ -277,7 +277,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime public Boolean[] GetBooleanArray() { if (this.Type != PropertyType.BooleanArray) - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", this.Type, "Boolean[]"), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Boolean[]"), __HResults.TYPE_E_TYPEMISMATCH); Contract.EndContractBlock(); return (bool[])_data; } @@ -292,7 +292,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime public Object[] GetInspectableArray() { if (this.Type != PropertyType.InspectableArray) - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", this.Type, "Inspectable[]"), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Inspectable[]"), __HResults.TYPE_E_TYPEMISMATCH); Contract.EndContractBlock(); return (Object[])_data; } @@ -307,7 +307,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime public DateTimeOffset[] GetDateTimeArray() { if (this.Type != PropertyType.DateTimeArray) - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", this.Type, "DateTimeOffset[]"), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "DateTimeOffset[]"), __HResults.TYPE_E_TYPEMISMATCH); Contract.EndContractBlock(); return (DateTimeOffset[])_data; } @@ -316,7 +316,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime public TimeSpan[] GetTimeSpanArray() { if (this.Type != PropertyType.TimeSpanArray) - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", this.Type, "TimeSpan[]"), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "TimeSpan[]"), __HResults.TYPE_E_TYPEMISMATCH); Contract.EndContractBlock(); return (TimeSpan[])_data; } @@ -325,7 +325,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime public Point[] GetPointArray() { if (this.Type != PropertyType.PointArray) - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", this.Type, "Point[]"), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Point[]"), __HResults.TYPE_E_TYPEMISMATCH); Contract.EndContractBlock(); return UnboxArray<Point>(IReferenceFactory.s_pointType); @@ -335,7 +335,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime public Size[] GetSizeArray() { if (this.Type != PropertyType.SizeArray) - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", this.Type, "Size[]"), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Size[]"), __HResults.TYPE_E_TYPEMISMATCH); Contract.EndContractBlock(); @@ -346,7 +346,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime public Rect[] GetRectArray() { if (this.Type != PropertyType.RectArray) - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", this.Type, "Rect[]"), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Rect[]"), __HResults.TYPE_E_TYPEMISMATCH); Contract.EndContractBlock(); return UnboxArray<Rect>(IReferenceFactory.s_rectType); @@ -364,7 +364,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime Array dataArray = _data as Array; if (dataArray == null) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", this.Type, typeof(T).MakeArrayType().Name), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, typeof (T).MakeArrayType().Name), __HResults.TYPE_E_TYPEMISMATCH); } // Array types are 1024 larger than their equivilent scalar counterpart @@ -382,7 +382,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime } catch (InvalidCastException elementCastException) { - Exception e = new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueArrayCoersion", this.Type, typeof(T).MakeArrayType().Name, i, elementCastException.Message), elementCastException); + Exception e = new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueArrayCoersion, this.Type, typeof (T).MakeArrayType().Name, i, elementCastException.Message), elementCastException); e.SetErrorCode(elementCastException._HResult); throw e; } @@ -408,7 +408,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // should not attempt coersion, even if the underlying value is technically convertable if (!IsCoercable(type, value) && type != PropertyType.Inspectable) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", type, typeof(T).Name), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, type, typeof (T).Name), __HResults.TYPE_E_TYPEMISMATCH); } try @@ -438,15 +438,15 @@ namespace System.Runtime.InteropServices.WindowsRuntime } catch (FormatException) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", type, typeof(T).Name), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, type, typeof (T).Name), __HResults.TYPE_E_TYPEMISMATCH); } catch (InvalidCastException) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", type, typeof(T).Name), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, type, typeof (T).Name), __HResults.TYPE_E_TYPEMISMATCH); } catch (OverflowException) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueCoersion", type, value, typeof(T).Name), __HResults.DISP_E_OVERFLOW); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueCoersion, type, value, typeof (T).Name), __HResults.DISP_E_OVERFLOW); } // If the property type is IInspectable, and we have a nested IPropertyValue, then we need @@ -497,7 +497,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime } // Otherwise, this is an invalid coersion - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", type, typeof(T).Name), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, type, typeof (T).Name), __HResults.TYPE_E_TYPEMISMATCH); } private static bool IsCoercable(PropertyType type, object data) @@ -539,7 +539,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime if (_data.GetType() != expectedBoxedType) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", _data.GetType(), expectedBoxedType.Name), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, _data.GetType(), expectedBoxedType.Name), __HResults.TYPE_E_TYPEMISMATCH); } T unboxed = new T(); @@ -563,7 +563,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime Array dataArray = _data as Array; if (dataArray == null || _data.GetType().GetElementType() != expectedArrayElementType) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_WinRTIPropertyValueElement", _data.GetType(), expectedArrayElementType.MakeArrayType().Name), __HResults.TYPE_E_TYPEMISMATCH); + throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, _data.GetType(), expectedArrayElementType.MakeArrayType().Name), __HResults.TYPE_E_TYPEMISMATCH); } T[] converted = new T[dataArray.Length]; diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs index 0e9140f41b..4549a407e0 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs @@ -102,7 +102,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime if (!found) { - Exception e = new KeyNotFoundException(Environment.GetResourceString("Arg_KeyNotFound")); + Exception e = new KeyNotFoundException(SR.Arg_KeyNotFound); e.SetErrorCode(__HResults.E_BOUNDS); throw e; } @@ -205,8 +205,8 @@ namespace System.Runtime.InteropServices.WindowsRuntime { get { - if (_current < _start) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumNotStarted)); - if (_current > _end) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumEnded)); + if (_current < _start) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumNotStarted)); + if (_current > _end) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumEnded)); return new CLRIKeyValuePairImpl<TKey, TValue>(ref _array[_current]); } } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs index fe1ecff161..63565a39b8 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs @@ -107,19 +107,19 @@ namespace System.Runtime.InteropServices.WindowsRuntime MethodInfo accessor = getValue ? m_property.GetGetMethod(true) : m_property.GetSetMethod(true); if (accessor == null) - throw new ArgumentException(System.Environment.GetResourceString(getValue ? "Arg_GetMethNotFnd" : "Arg_SetMethNotFnd")); + throw new ArgumentException(getValue ? SR.Arg_GetMethNotFnd : SR.Arg_SetMethNotFnd); if (!accessor.IsPublic) throw new MethodAccessException( String.Format( CultureInfo.CurrentCulture, - Environment.GetResourceString("Arg_MethodAccessException_WithMethodName"), + SR.Arg_MethodAccessException_WithMethodName, accessor.ToString(), accessor.DeclaringType.FullName)); RuntimeMethodInfo rtMethod = accessor as RuntimeMethodInfo; if (rtMethod == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo")); + throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo); // We can safely skip access check because this is only used in full trust scenarios. // And we have already verified that the property accessor is public. diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryKeyCollection.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryKeyCollection.cs index 9f33b2f946..2a34aba717 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryKeyCollection.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryKeyCollection.cs @@ -30,9 +30,9 @@ namespace System.Runtime.InteropServices.WindowsRuntime if (index < 0) throw new ArgumentOutOfRangeException(nameof(index)); if (array.Length <= index && this.Count > 0) - throw new ArgumentException(Environment.GetResourceString("Arg_IndexOutOfRangeException")); + throw new ArgumentException(SR.Arg_IndexOutOfRangeException); if (array.Length - index < dictionary.Count) - throw new ArgumentException(Environment.GetResourceString("Argument_InsufficientSpaceToCopyCollection")); + throw new ArgumentException(SR.Argument_InsufficientSpaceToCopyCollection); int i = index; foreach (KeyValuePair<TKey, TValue> mapping in dictionary) @@ -53,12 +53,12 @@ namespace System.Runtime.InteropServices.WindowsRuntime void ICollection<TKey>.Add(TKey item) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_KeyCollectionSet")); + throw new NotSupportedException(SR.NotSupported_KeyCollectionSet); } void ICollection<TKey>.Clear() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_KeyCollectionSet")); + throw new NotSupportedException(SR.NotSupported_KeyCollectionSet); } public bool Contains(TKey item) @@ -68,7 +68,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime bool ICollection<TKey>.Remove(TKey item) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_KeyCollectionSet")); + throw new NotSupportedException(SR.NotSupported_KeyCollectionSet); } IEnumerator IEnumerable.GetEnumerator() diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryToMapAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryToMapAdapter.cs index b1a4042419..bb54d49b60 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryToMapAdapter.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryToMapAdapter.cs @@ -41,7 +41,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime if (!keyFound) { - Exception e = new KeyNotFoundException(Environment.GetResourceString("Arg_KeyNotFound")); + Exception e = new KeyNotFoundException(SR.Arg_KeyNotFound); e.SetErrorCode(__HResults.E_BOUNDS); throw e; } @@ -96,7 +96,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime if (!removed) { - Exception e = new KeyNotFoundException(Environment.GetResourceString("Arg_KeyNotFound")); + Exception e = new KeyNotFoundException(SR.Arg_KeyNotFound); e.SetErrorCode(__HResults.E_BOUNDS); throw e; } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs index d599d24aa3..083b0ffcb1 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs @@ -34,9 +34,9 @@ namespace System.Runtime.InteropServices.WindowsRuntime if (index < 0) throw new ArgumentOutOfRangeException(nameof(index)); if (array.Length <= index && this.Count > 0) - throw new ArgumentException(Environment.GetResourceString("Arg_IndexOutOfRangeException")); + throw new ArgumentException(SR.Arg_IndexOutOfRangeException); if (array.Length - index < dictionary.Count) - throw new ArgumentException(Environment.GetResourceString("Argument_InsufficientSpaceToCopyCollection")); + throw new ArgumentException(SR.Argument_InsufficientSpaceToCopyCollection); int i = index; foreach (KeyValuePair<TKey, TValue> mapping in dictionary) @@ -57,12 +57,12 @@ namespace System.Runtime.InteropServices.WindowsRuntime void ICollection<TValue>.Add(TValue item) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_ValueCollectionSet")); + throw new NotSupportedException(SR.NotSupported_ValueCollectionSet); } void ICollection<TValue>.Clear() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_ValueCollectionSet")); + throw new NotSupportedException(SR.NotSupported_ValueCollectionSet); } public bool Contains(TValue item) @@ -76,7 +76,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime bool ICollection<TValue>.Remove(TValue item) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_ValueCollectionSet")); + throw new NotSupportedException(SR.NotSupported_ValueCollectionSet); } IEnumerator IEnumerable.GetEnumerator() diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs index 03b17d9261..974da48a42 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs @@ -28,7 +28,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // static check at construction time if (!typeof(Delegate).IsAssignableFrom(typeof(T))) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EventTokenTableRequiresDelegate", typeof(T))); + throw new InvalidOperationException(SR.Format(SR.InvalidOperation_EventTokenTableRequiresDelegate, typeof (T))); } } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs index 55f8a1e862..e06364dcae 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs @@ -114,7 +114,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime catch (Exception ex) { if (__HResults.E_BOUNDS == ex._HResult) - throw new KeyNotFoundException(Environment.GetResourceString("Arg_KeyNotFound")); + throw new KeyNotFoundException(SR.Arg_KeyNotFound); throw; } } @@ -145,9 +145,9 @@ namespace System.Runtime.InteropServices.WindowsRuntime if (index < 0) throw new ArgumentOutOfRangeException(nameof(index)); if (array.Length <= index && this.Count > 0) - throw new ArgumentException(Environment.GetResourceString("Arg_IndexOutOfRangeException")); + throw new ArgumentException(SR.Arg_IndexOutOfRangeException); if (array.Length - index < dictionary.Count) - throw new ArgumentException(Environment.GetResourceString("Argument_InsufficientSpaceToCopyCollection")); + throw new ArgumentException(SR.Argument_InsufficientSpaceToCopyCollection); int i = index; foreach (KeyValuePair<TKey, TValue> mapping in dictionary) @@ -242,9 +242,9 @@ namespace System.Runtime.InteropServices.WindowsRuntime if (index < 0) throw new ArgumentOutOfRangeException(nameof(index)); if (array.Length <= index && this.Count > 0) - throw new ArgumentException(Environment.GetResourceString("Arg_IndexOutOfRangeException")); + throw new ArgumentException(SR.Arg_IndexOutOfRangeException); if (array.Length - index < dictionary.Count) - throw new ArgumentException(Environment.GetResourceString("Argument_InsufficientSpaceToCopyCollection")); + throw new ArgumentException(SR.Argument_InsufficientSpaceToCopyCollection); int i = index; foreach (KeyValuePair<TKey, TValue> mapping in dictionary) diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyDictionaryToIMapViewAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyDictionaryToIMapViewAdapter.cs index 2fac36b23f..73daf876cd 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyDictionaryToIMapViewAdapter.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyDictionaryToIMapViewAdapter.cs @@ -40,7 +40,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime if (!keyFound) { - Exception e = new KeyNotFoundException(Environment.GetResourceString("Arg_KeyNotFound")); + Exception e = new KeyNotFoundException(SR.Arg_KeyNotFound); e.SetErrorCode(__HResults.E_BOUNDS); throw e; } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyListToIVectorViewAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyListToIVectorViewAdapter.cs index b902ded9c0..5dce7dfc8d 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyListToIVectorViewAdapter.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyListToIVectorViewAdapter.cs @@ -126,7 +126,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // that Size > Int32.MaxValue: if (((uint)Int32.MaxValue) <= index || index >= (uint)listCapacity) { - Exception e = new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_IndexLargerThanMaxValue")); + Exception e = new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_IndexLargerThanMaxValue); e.SetErrorCode(__HResults.E_BOUNDS); throw e; } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorAdapter.cs index 6010eec6c8..5f12322ea8 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorAdapter.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorAdapter.cs @@ -146,7 +146,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime IList _this = JitHelpers.UnsafeCast<IList>(this); if (_this.Count == 0) { - Exception e = new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotRemoveLastFromEmptyCollection")); + Exception e = new InvalidOperationException(SR.InvalidOperation_CannotRemoveLastFromEmptyCollection); e.SetErrorCode(__HResults.E_BOUNDS); throw e; } @@ -170,7 +170,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // that Size > Int32.MaxValue: if (((uint)Int32.MaxValue) <= index || index >= (uint)listCapacity) { - Exception e = new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_IndexLargerThanMaxValue")); + Exception e = new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_IndexLargerThanMaxValue); e.SetErrorCode(__HResults.E_BOUNDS); throw e; } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorViewAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorViewAdapter.cs index 0503b726dd..fc02bedfa6 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorViewAdapter.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorViewAdapter.cs @@ -38,7 +38,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // that Size > Int32.MaxValue: if (((uint)Int32.MaxValue) <= index || index >= (uint)listCapacity) { - Exception e = new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_IndexLargerThanMaxValue")); + Exception e = new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_IndexLargerThanMaxValue); e.SetErrorCode(__HResults.E_BOUNDS); throw e; } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToVectorAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToVectorAdapter.cs index 8373885284..87330e2559 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToVectorAdapter.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ListToVectorAdapter.cs @@ -155,7 +155,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime IList<T> _this = JitHelpers.UnsafeCast<IList<T>>(this); if (_this.Count == 0) { - Exception e = new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotRemoveLastFromEmptyCollection")); + Exception e = new InvalidOperationException(SR.InvalidOperation_CannotRemoveLastFromEmptyCollection); e.SetErrorCode(__HResults.E_BOUNDS); throw e; } @@ -201,7 +201,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // that Size > Int32.MaxValue: if (((uint)Int32.MaxValue) <= index || index >= (uint)listCapacity) { - Exception e = new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_IndexLargerThanMaxValue")); + Exception e = new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_IndexLargerThanMaxValue); e.SetErrorCode(__HResults.E_BOUNDS); throw e; } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ManagedActivationFactory.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ManagedActivationFactory.cs index cace2047d9..12b13ac79b 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ManagedActivationFactory.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/ManagedActivationFactory.cs @@ -41,7 +41,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // Check whether the type is "exported to WinRT", i.e. it is declared in a managed .winmd and is decorated // with at least one ActivatableAttribute or StaticAttribute. if (!(type is RuntimeType) || !type.IsExportedToWindowsRuntime) - throw new ArgumentException(Environment.GetResourceString("Argument_TypeNotActivatableViaWindowsRuntime", type), nameof(type)); + throw new ArgumentException(SR.Format(SR.Argument_TypeNotActivatableViaWindowsRuntime, type), nameof(type)); m_type = type; } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToCollectionAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToCollectionAdapter.cs index f11260eb4a..6b6c1719c3 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToCollectionAdapter.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToCollectionAdapter.cs @@ -46,7 +46,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime if (((uint)Int32.MaxValue) < size) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingDictionaryTooLarge")); + throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingDictionaryTooLarge); } return (int)size; @@ -58,7 +58,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime if (((uint)Int32.MaxValue) < size) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingListTooLarge")); + throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } return (int)size; @@ -140,10 +140,10 @@ namespace System.Runtime.InteropServices.WindowsRuntime throw new ArgumentOutOfRangeException(nameof(arrayIndex)); if (array.Length <= arrayIndex && Count<K, V>() > 0) - throw new ArgumentException(Environment.GetResourceString("Argument_IndexOutOfArrayBounds")); + throw new ArgumentException(SR.Argument_IndexOutOfArrayBounds); if (array.Length - arrayIndex < Count<K, V>()) - throw new ArgumentException(Environment.GetResourceString("Argument_InsufficientSpaceToCopyCollection")); + throw new ArgumentException(SR.Argument_InsufficientSpaceToCopyCollection); Contract.EndContractBlock(); @@ -175,7 +175,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime if (((uint)Int32.MaxValue) < index) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingListTooLarge")); + throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } VectorToListAdapter.RemoveAtHelper<KeyValuePair<K, V>>(_this_vector, index); diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToDictionaryAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToDictionaryAdapter.cs index a8a13c6912..224a266b07 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToDictionaryAdapter.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapToDictionaryAdapter.cs @@ -88,7 +88,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime throw new ArgumentNullException(nameof(key)); if (ContainsKey<K, V>(key)) - throw new ArgumentException(Environment.GetResourceString("Argument_AddingDuplicate")); + throw new ArgumentException(SR.Argument_AddingDuplicate); Contract.EndContractBlock(); @@ -158,7 +158,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime catch (Exception ex) { if (__HResults.E_BOUNDS == ex._HResult) - throw new KeyNotFoundException(Environment.GetResourceString("Arg_KeyNotFound")); + throw new KeyNotFoundException(SR.Arg_KeyNotFound); throw; } } diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapViewToReadOnlyCollectionAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapViewToReadOnlyCollectionAdapter.cs index a3715da0b0..5d509549d3 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapViewToReadOnlyCollectionAdapter.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/MapViewToReadOnlyCollectionAdapter.cs @@ -46,7 +46,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime if (((uint)Int32.MaxValue) < size) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingDictionaryTooLarge")); + throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingDictionaryTooLarge); } return (int)size; @@ -58,7 +58,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime if (((uint)Int32.MaxValue) < size) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingListTooLarge")); + throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } return (int)size; diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToCollectionAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToCollectionAdapter.cs index 898f1a68a0..3065b83c30 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToCollectionAdapter.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToCollectionAdapter.cs @@ -38,7 +38,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime uint size = _this.Size; if (((uint)Int32.MaxValue) < size) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingListTooLarge")); + throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } return (int)size; @@ -83,10 +83,10 @@ namespace System.Runtime.InteropServices.WindowsRuntime throw new ArgumentOutOfRangeException(nameof(arrayIndex)); if (array.Length <= arrayIndex && Count<T>() > 0) - throw new ArgumentException(Environment.GetResourceString("Argument_IndexOutOfArrayBounds")); + throw new ArgumentException(SR.Argument_IndexOutOfArrayBounds); if (array.Length - arrayIndex < Count<T>()) - throw new ArgumentException(Environment.GetResourceString("Argument_InsufficientSpaceToCopyCollection")); + throw new ArgumentException(SR.Argument_InsufficientSpaceToCopyCollection); Contract.EndContractBlock(); @@ -111,7 +111,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime if (((uint)Int32.MaxValue) < index) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingListTooLarge")); + throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } VectorToListAdapter.RemoveAtHelper<T>(_this, index); diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToListAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToListAdapter.cs index 3e3324864d..56e62a25e7 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToListAdapter.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToListAdapter.cs @@ -63,7 +63,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime if (((uint)Int32.MaxValue) < index) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingListTooLarge")); + throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } return (int)index; diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorViewToReadOnlyCollectionAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorViewToReadOnlyCollectionAdapter.cs index 6b7785d2dc..84c12f8a5c 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorViewToReadOnlyCollectionAdapter.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/VectorViewToReadOnlyCollectionAdapter.cs @@ -38,7 +38,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime uint size = _this.Size; if (((uint)Int32.MaxValue) < size) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingListTooLarge")); + throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } return (int)size; diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs index 00dad37a2a..0b7ba10d62 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs @@ -1054,13 +1054,13 @@ namespace System.Runtime.InteropServices.WindowsRuntime string message = innerException.Message; if (message == null && messageResource != null) { - message = Environment.GetResourceString(messageResource); + message = SR.GetResourceString(messageResource); } e = new Exception(message, innerException); } else { - string message = (messageResource != null ? Environment.GetResourceString(messageResource) : null); + string message = (messageResource != null ? SR.GetResourceString(messageResource): null); e = new Exception(message); } @@ -1234,7 +1234,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime public static IntPtr StringToHString(String s) { if (!Environment.IsWinRTSupported) - throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_WinRT")); + throw new PlatformNotSupportedException(SR.PlatformNotSupported_WinRT); if (s == null) throw new ArgumentNullException(nameof(s)); @@ -1252,7 +1252,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime { if (!Environment.IsWinRTSupported) { - throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_WinRT")); + throw new PlatformNotSupportedException(SR.PlatformNotSupported_WinRT); } return HStringToString(ptr); @@ -1261,7 +1261,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime public static void FreeHString(IntPtr ptr) { if (!Environment.IsWinRTSupported) - throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_WinRT")); + throw new PlatformNotSupportedException(SR.PlatformNotSupported_WinRT); if (ptr != IntPtr.Zero) { diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs index b772a2252b..0f28d3b080 100644 --- a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs +++ b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs @@ -42,7 +42,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime { if (String.IsNullOrEmpty(assemblyFile)) { // DesignerNamespaceResolve event returned null or empty file name - that is not allowed - throw new ArgumentException(Environment.GetResourceString("Arg_EmptyOrNullString"), "DesignerNamespaceResolveEventArgs.ResolvedAssemblyFiles"); + throw new ArgumentException(SR.Arg_EmptyOrNullString, "DesignerNamespaceResolveEventArgs.ResolvedAssemblyFiles"); } retAssemblyFiles[retIndex] = assemblyFile; retIndex++; diff --git a/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs b/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs index 3f21425a2a..0da47739ff 100644 --- a/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs +++ b/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs @@ -93,7 +93,7 @@ namespace System.Runtime.Loader if (PathInternal.IsPartiallyQualified(assemblyPath)) { - throw new ArgumentException(Environment.GetResourceString("Argument_AbsolutePathRequired"), nameof(assemblyPath)); + throw new ArgumentException(SR.Argument_AbsolutePathRequired, nameof(assemblyPath)); } RuntimeAssembly loadedAssembly = null; @@ -110,12 +110,12 @@ namespace System.Runtime.Loader if (PathInternal.IsPartiallyQualified(nativeImagePath)) { - throw new ArgumentException(Environment.GetResourceString("Argument_AbsolutePathRequired"), nameof(nativeImagePath)); + throw new ArgumentException(SR.Argument_AbsolutePathRequired, nameof(nativeImagePath)); } if (assemblyPath != null && PathInternal.IsPartiallyQualified(assemblyPath)) { - throw new ArgumentException(Environment.GetResourceString("Argument_AbsolutePathRequired"), nameof(assemblyPath)); + throw new ArgumentException(SR.Argument_AbsolutePathRequired, nameof(assemblyPath)); } // Basic validation has succeeded - lets try to load the NI image. @@ -139,7 +139,7 @@ namespace System.Runtime.Loader if (assembly.Length <= 0) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_BadILFormat")); + throw new BadImageFormatException(SR.BadImageFormat_BadILFormat); } int iAssemblyStreamLength = (int)assembly.Length; @@ -236,7 +236,7 @@ namespace System.Runtime.Loader // The simple names should match at the very least if (String.IsNullOrEmpty(loadedSimpleName) || (!requestedSimpleName.Equals(loadedSimpleName, StringComparison.InvariantCultureIgnoreCase))) - throw new InvalidOperationException(Environment.GetResourceString("Argument_CustomAssemblyLoadContextRequestedNameMismatch")); + throw new InvalidOperationException(SR.Argument_CustomAssemblyLoadContextRequestedNameMismatch); return assembly; } @@ -269,7 +269,7 @@ namespace System.Runtime.Loader // throw an exception if we do not find any assembly. if (assembly == null) { - throw new FileNotFoundException(Environment.GetResourceString("IO.FileLoad"), simpleName); + throw new FileNotFoundException(SR.IO_FileLoad, simpleName); } return assembly; @@ -297,11 +297,11 @@ namespace System.Runtime.Loader } if (unmanagedDllPath.Length == 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyPath"), nameof(unmanagedDllPath)); + throw new ArgumentException(SR.Argument_EmptyPath, nameof(unmanagedDllPath)); } if (PathInternal.IsPartiallyQualified(unmanagedDllPath)) { - throw new ArgumentException(Environment.GetResourceString("Argument_AbsolutePathRequired"), nameof(unmanagedDllPath)); + throw new ArgumentException(SR.Argument_AbsolutePathRequired, nameof(unmanagedDllPath)); } return InternalLoadUnmanagedDllFromPath(unmanagedDllPath); diff --git a/src/mscorlib/src/System/Runtime/MemoryFailPoint.cs b/src/mscorlib/src/System/Runtime/MemoryFailPoint.cs index 2785942712..f9f87bc928 100644 --- a/src/mscorlib/src/System/Runtime/MemoryFailPoint.cs +++ b/src/mscorlib/src/System/Runtime/MemoryFailPoint.cs @@ -155,7 +155,7 @@ namespace System.Runtime public MemoryFailPoint(int sizeInMegabytes) { if (sizeInMegabytes <= 0) - throw new ArgumentOutOfRangeException(nameof(sizeInMegabytes), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(sizeInMegabytes), SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); #if !FEATURE_PAL // Remove this when CheckForAvailableMemory is able to provide legitimate estimates @@ -170,7 +170,7 @@ namespace System.Runtime // heap, and to check both the normal & large object heaps. ulong segmentSize = (ulong)(Math.Ceiling((double)size / GCSegmentSize) * GCSegmentSize); if (segmentSize >= TopOfMemory) - throw new InsufficientMemoryException(Environment.GetResourceString("InsufficientMemory_MemFailPoint_TooBig")); + throw new InsufficientMemoryException(SR.InsufficientMemory_MemFailPoint_TooBig); ulong requestedSizeRounded = (ulong)(Math.Ceiling((double)sizeInMegabytes / MemoryCheckGranularity) * MemoryCheckGranularity); //re-convert into bytes @@ -266,7 +266,7 @@ namespace System.Runtime // state. if (needPageFile || needAddressSpace) { - InsufficientMemoryException e = new InsufficientMemoryException(Environment.GetResourceString("InsufficientMemory_MemFailPoint")); + InsufficientMemoryException e = new InsufficientMemoryException(SR.InsufficientMemory_MemFailPoint); #if _DEBUG e.Data["MemFailPointState"] = new MemoryFailPointState(sizeInMegabytes, segmentSize, needPageFile, needAddressSpace, needContiguousVASpace, @@ -278,7 +278,7 @@ namespace System.Runtime if (needContiguousVASpace) { - InsufficientMemoryException e = new InsufficientMemoryException(Environment.GetResourceString("InsufficientMemory_MemFailPoint_VAFrag")); + InsufficientMemoryException e = new InsufficientMemoryException(SR.InsufficientMemory_MemFailPoint_VAFrag); #if _DEBUG e.Data["MemFailPointState"] = new MemoryFailPointState(sizeInMegabytes, segmentSize, needPageFile, needAddressSpace, needContiguousVASpace, @@ -349,7 +349,7 @@ namespace System.Runtime LastTimeCheckingAddressSpace = Environment.TickCount; if (freeSpaceAfterGCHeap < size && shouldThrow) - throw new InsufficientMemoryException(Environment.GetResourceString("InsufficientMemory_MemFailPoint_VAFrag")); + throw new InsufficientMemoryException(SR.InsufficientMemory_MemFailPoint_VAFrag); return freeSpaceAfterGCHeap >= size; } diff --git a/src/mscorlib/src/System/Runtime/RuntimeImports.cs b/src/mscorlib/src/System/Runtime/RuntimeImports.cs index 17a2602cd4..16d41d3951 100644 --- a/src/mscorlib/src/System/Runtime/RuntimeImports.cs +++ b/src/mscorlib/src/System/Runtime/RuntimeImports.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. diff --git a/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs b/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs index 0db38b6545..5f07c3a5ce 100644 --- a/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs +++ b/src/mscorlib/src/System/Runtime/Serialization/FormatterServices.cs @@ -48,7 +48,7 @@ namespace System.Runtime.Serialization if (!(type is RuntimeType)) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidType", type.ToString())); + throw new SerializationException(SR.Format(SR.Serialization_InvalidType, type.ToString())); } return nativeGetUninitializedObject((RuntimeType)type); diff --git a/src/mscorlib/src/System/Runtime/Serialization/SerializationAttributes.cs b/src/mscorlib/src/System/Runtime/Serialization/SerializationAttributes.cs index 435ca279e4..be9f4aefee 100644 --- a/src/mscorlib/src/System/Runtime/Serialization/SerializationAttributes.cs +++ b/src/mscorlib/src/System/Runtime/Serialization/SerializationAttributes.cs @@ -32,7 +32,7 @@ namespace System.Runtime.Serialization set { if (value < 1) - throw new ArgumentException(Environment.GetResourceString("Serialization_OptionalFieldVersionValue")); + throw new ArgumentException(SR.Serialization_OptionalFieldVersionValue); Contract.EndContractBlock(); versionAdded = value; } diff --git a/src/mscorlib/src/System/Runtime/Serialization/SerializationException.cs b/src/mscorlib/src/System/Runtime/Serialization/SerializationException.cs index 65db0e930a..7f2d2755bc 100644 --- a/src/mscorlib/src/System/Runtime/Serialization/SerializationException.cs +++ b/src/mscorlib/src/System/Runtime/Serialization/SerializationException.cs @@ -21,7 +21,7 @@ namespace System.Runtime.Serialization [Serializable] public class SerializationException : SystemException { - private static String _nullMessage = Environment.GetResourceString("Arg_SerializationException"); + private static String _nullMessage = SR.Arg_SerializationException; // Creates a new SerializationException with its message // string set to a default message. diff --git a/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs b/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs index d024361985..7fc3ce27d9 100644 --- a/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs +++ b/src/mscorlib/src/System/Runtime/Serialization/SerializationInfo.cs @@ -331,7 +331,7 @@ namespace System.Runtime.Serialization if (m_nameToIndex.ContainsKey(name)) { BCLDebug.Trace("SER", "[SerializationInfo.AddValue]Tried to add ", name, " twice to the SI."); - throw new SerializationException(Environment.GetResourceString("Serialization_SameNameTwice")); + throw new SerializationException(SR.Serialization_SameNameTwice); } m_nameToIndex.Add(name, m_currMember); @@ -415,7 +415,7 @@ namespace System.Runtime.Serialization int index = FindElement(name); if (index == -1) { - throw new SerializationException(Environment.GetResourceString("Serialization_NotFound", name)); + throw new SerializationException(SR.Format(SR.Serialization_NotFound, name)); } Debug.Assert(index < m_data.Length, "[SerializationInfo.GetElement]index<m_data.Length"); @@ -458,7 +458,7 @@ namespace System.Runtime.Serialization RuntimeType rt = type as RuntimeType; if (rt == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); + throw new ArgumentException(SR.Argument_MustBeRuntimeType); Type foundType; Object value; diff --git a/src/mscorlib/src/System/Runtime/Serialization/SerializationInfoEnumerator.cs b/src/mscorlib/src/System/Runtime/Serialization/SerializationInfoEnumerator.cs index b7857dece2..615b128f2a 100644 --- a/src/mscorlib/src/System/Runtime/Serialization/SerializationInfoEnumerator.cs +++ b/src/mscorlib/src/System/Runtime/Serialization/SerializationInfoEnumerator.cs @@ -116,7 +116,7 @@ namespace System.Runtime.Serialization { if (m_current == false) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); + throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen); } return (Object)(new SerializationEntry(m_members[m_currItem], m_data[m_currItem], m_types[m_currItem])); } @@ -128,7 +128,7 @@ namespace System.Runtime.Serialization { if (m_current == false) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); + throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen); } return (new SerializationEntry(m_members[m_currItem], m_data[m_currItem], m_types[m_currItem])); } @@ -146,7 +146,7 @@ namespace System.Runtime.Serialization { if (m_current == false) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); + throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen); } return m_members[m_currItem]; } @@ -157,7 +157,7 @@ namespace System.Runtime.Serialization { if (m_current == false) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); + throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen); } return m_data[m_currItem]; } @@ -168,7 +168,7 @@ namespace System.Runtime.Serialization { if (m_current == false) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); + throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen); } return m_types[m_currItem]; } |