From cdff8b0babe5d82737058ccdae8b14d8ae90160d Mon Sep 17 00:00:00 2001 From: Alex Perovich Date: Wed, 22 Mar 2017 00:02:47 -0500 Subject: [PATCH] Switch coreclr corelib to use resx (#10372) * Revert "Revert "Switch coreclr corelib to use resx (#10268)"" * Add resources.target override This fixes the GenerateResource task running on the arm emulator runs. * Fix run.sh to have a working Tools-Override --- Tools-Override/resources.targets | 76 + run.sh | 2 +- src/mscorlib/Common/System/SR.cs | 197 + src/mscorlib/Resources/Strings.resx | 4902 ++++++++++++++++++++ src/mscorlib/System.Private.CoreLib.csproj | 14 +- src/mscorlib/shared/System/IO/Error.cs | 2 +- .../CompilerServices/TupleElementNamesAttribute.cs | 2 +- src/mscorlib/shared/System/StringSplitOptions.cs | 2 +- src/mscorlib/shared/System/TupleExtensions.cs | 4 +- src/mscorlib/src/Debug.cs | 2 +- .../Windows/kernel32/Interop.Globalization.cs | 2 +- src/mscorlib/src/Microsoft/Win32/Registry.cs | 2 +- src/mscorlib/src/Microsoft/Win32/RegistryKey.cs | 20 +- src/mscorlib/src/Microsoft/Win32/Win32Native.cs | 4 +- src/mscorlib/src/SR.cs | 1020 ---- src/mscorlib/src/System.Private.CoreLib.txt | 1970 -------- src/mscorlib/src/System/Activator.cs | 12 +- src/mscorlib/src/System/AggregateException.cs | 16 +- src/mscorlib/src/System/AppContext/AppContext.cs | 4 +- src/mscorlib/src/System/AppDomain.cs | 36 +- src/mscorlib/src/System/AppDomainSetup.cs | 4 +- .../src/System/AppDomainUnloadedException.cs | 2 +- src/mscorlib/src/System/ArgIterator.cs | 2 +- .../src/System/ArgumentOutOfRangeException.cs | 4 +- src/mscorlib/src/System/Attribute.cs | 32 +- src/mscorlib/src/System/BadImageFormatException.cs | 6 +- src/mscorlib/src/System/Boolean.cs | 8 +- src/mscorlib/src/System/Buffer.cs | 6 +- src/mscorlib/src/System/Byte.cs | 8 +- src/mscorlib/src/System/Char.cs | 28 +- src/mscorlib/src/System/Collections/ArrayList.cs | 40 +- src/mscorlib/src/System/Collections/Comparer.cs | 2 +- .../src/System/Collections/CompatibleComparer.cs | 2 +- .../Collections/Concurrent/ConcurrentQueue.cs | 4 +- .../Collections/Concurrent/ConcurrentStack.cs | 2 +- .../Collections/EmptyReadOnlyDictionaryInternal.cs | 36 +- .../System/Collections/Generic/ArraySortHelper.cs | 16 +- .../System/Collections/Generic/EqualityComparer.cs | 6 +- src/mscorlib/src/System/Collections/Hashtable.cs | 68 +- .../System/Collections/ListDictionaryInternal.cs | 40 +- src/mscorlib/src/System/CurrentTimeZone.cs | 2 +- src/mscorlib/src/System/DBNull.cs | 30 +- src/mscorlib/src/System/DateTime.cs | 104 +- src/mscorlib/src/System/DateTimeOffset.cs | 24 +- src/mscorlib/src/System/Decimal.cs | 46 +- src/mscorlib/src/System/DefaultBinder.cs | 26 +- src/mscorlib/src/System/Delegate.cs | 54 +- .../src/System/DelegateSerializationHolder.cs | 8 +- src/mscorlib/src/System/Diagnostics/Assert.cs | 2 +- .../src/System/Diagnostics/Contracts/Contracts.cs | 4 +- .../System/Diagnostics/Contracts/ContractsBCL.cs | 12 +- .../System/Diagnostics/Eventing/EventCounter.cs | 2 +- .../Diagnostics/Eventing/EventSource_CoreCLR.cs | 4 +- .../Eventing/TraceLogging/PropertyValue.cs | 2 +- src/mscorlib/src/System/Diagnostics/LogSwitch.cs | 2 +- src/mscorlib/src/System/Diagnostics/Stacktrace.cs | 14 +- src/mscorlib/src/System/Diagnostics/log.cs | 2 +- src/mscorlib/src/System/DllNotFoundException.cs | 2 +- src/mscorlib/src/System/Double.cs | 6 +- src/mscorlib/src/System/Enum.cs | 87 +- src/mscorlib/src/System/Environment.cs | 246 +- src/mscorlib/src/System/Exception.cs | 8 +- src/mscorlib/src/System/GC.cs | 26 +- .../src/System/Globalization/CompareInfo.Unix.cs | 2 +- .../src/System/Globalization/DateTimeFormat.cs | 16 +- .../src/System/Globalization/DateTimeParse.cs | 8 +- .../src/System/Globalization/DigitShapes.cs | 2 +- .../src/System/Globalization/EncodingTable.Unix.cs | 4 +- .../src/System/Globalization/EncodingTable.cs | 4 +- .../src/System/Globalization/SortVersion.cs | 2 +- .../src/System/Globalization/TimeSpanFormat.cs | 20 +- .../src/System/Globalization/TimeSpanParse.cs | 12 +- src/mscorlib/src/System/Guid.cs | 28 +- src/mscorlib/src/System/IO/BinaryReader.cs | 30 +- src/mscorlib/src/System/IO/BinaryWriter.cs | 4 +- src/mscorlib/src/System/IO/Directory.cs | 6 +- .../src/System/IO/DirectoryNotFoundException.cs | 2 +- .../src/System/IO/DriveNotFoundException.cs | 2 +- src/mscorlib/src/System/IO/EndOfStreamException.cs | 2 +- src/mscorlib/src/System/IO/File.cs | 4 +- src/mscorlib/src/System/IO/FileLoadException.cs | 4 +- .../src/System/IO/FileNotFoundException.cs | 6 +- src/mscorlib/src/System/IO/IOException.cs | 2 +- src/mscorlib/src/System/IO/MemoryStream.cs | 72 +- src/mscorlib/src/System/IO/PathTooLongException.cs | 2 +- src/mscorlib/src/System/IO/Stream.cs | 20 +- .../src/System/IO/StreamHelpers.CopyValidation.cs | 10 +- src/mscorlib/src/System/IO/StreamReader.cs | 34 +- src/mscorlib/src/System/IO/TextReader.cs | 32 +- .../src/System/IO/UnmanagedMemoryAccessor.cs | 80 +- .../src/System/IO/UnmanagedMemoryStream.cs | 94 +- .../src/System/IO/UnmanagedMemoryStreamWrapper.cs | 16 +- src/mscorlib/src/System/IO/__Error.cs | 46 +- src/mscorlib/src/System/Int16.cs | 10 +- src/mscorlib/src/System/Int32.cs | 4 +- src/mscorlib/src/System/Int64.cs | 4 +- src/mscorlib/src/System/IntPtr.cs | 2 +- src/mscorlib/src/System/Math.cs | 20 +- src/mscorlib/src/System/MathF.cs | 8 +- src/mscorlib/src/System/MissingFieldException.cs | 6 +- src/mscorlib/src/System/MissingMemberException.cs | 6 +- src/mscorlib/src/System/MissingMethodException.cs | 6 +- src/mscorlib/src/System/MulticastDelegate.cs | 10 +- src/mscorlib/src/System/Number.cs | 30 +- src/mscorlib/src/System/Object.cs | 2 +- src/mscorlib/src/System/OleAutBinder.cs | 2 +- src/mscorlib/src/System/OperatingSystem.cs | 4 +- .../src/System/OperationCanceledException.cs | 2 +- src/mscorlib/src/System/Random.cs | 4 +- .../System/Reflection/AmbiguousMatchException.cs | 2 +- .../src/System/Reflection/Assembly.CoreCLR.cs | 8 +- src/mscorlib/src/System/Reflection/AssemblyName.cs | 6 +- .../src/System/Reflection/CustomAttribute.cs | 24 +- .../Reflection/CustomAttributeFormatException.cs | 2 +- .../src/System/Reflection/Emit/AssemblyBuilder.cs | 34 +- .../System/Reflection/Emit/AssemblyBuilderData.cs | 2 +- .../System/Reflection/Emit/ConstructorBuilder.cs | 8 +- .../Reflection/Emit/CustomAttributeBuilder.cs | 33 +- .../System/Reflection/Emit/DynamicILGenerator.cs | 42 +- .../src/System/Reflection/Emit/DynamicMethod.cs | 30 +- .../src/System/Reflection/Emit/EnumBuilder.cs | 4 +- .../src/System/Reflection/Emit/FieldBuilder.cs | 18 +- .../Reflection/Emit/GenericTypeParameterBuilder.cs | 2 +- .../src/System/Reflection/Emit/ILGenerator.cs | 60 +- .../src/System/Reflection/Emit/LocalBuilder.cs | 4 +- .../src/System/Reflection/Emit/MethodBuilder.cs | 40 +- .../Reflection/Emit/MethodBuilderInstantiation.cs | 4 +- .../src/System/Reflection/Emit/ModuleBuilder.cs | 36 +- .../System/Reflection/Emit/ModuleBuilderData.cs | 2 +- .../src/System/Reflection/Emit/PropertyBuilder.cs | 22 +- .../src/System/Reflection/Emit/SignatureHelper.cs | 26 +- .../src/System/Reflection/Emit/SymbolMethod.cs | 16 +- .../src/System/Reflection/Emit/SymbolType.cs | 58 +- .../src/System/Reflection/Emit/TypeBuilder.cs | 148 +- .../Reflection/Emit/TypeBuilderInstantiation.cs | 2 +- .../Emit/XXXOnTypeBuilderInstantiation.cs | 2 +- .../src/System/Reflection/FieldInfo.CoreCLR.cs | 6 +- .../Reflection/InvalidFilterCriteriaException.cs | 2 +- src/mscorlib/src/System/Reflection/MdConstant.cs | 6 +- src/mscorlib/src/System/Reflection/MdFieldInfo.cs | 6 +- .../Reflection/MemberInfoSerializationHolder.cs | 24 +- .../src/System/Reflection/MethodBase.CoreCLR.cs | 8 +- src/mscorlib/src/System/Reflection/MethodBody.cs | 4 +- .../src/System/Reflection/ParameterModifier.cs | 2 +- src/mscorlib/src/System/Reflection/Pointer.cs | 6 +- .../Reflection/ReflectionTypeLoadException.cs | 2 +- src/mscorlib/src/System/Reflection/RtFieldInfo.cs | 18 +- .../src/System/Reflection/RuntimeAssembly.cs | 10 +- .../System/Reflection/RuntimeConstructorInfo.cs | 26 +- .../src/System/Reflection/RuntimeEventInfo.cs | 6 +- .../src/System/Reflection/RuntimeFieldInfo.cs | 4 +- .../src/System/Reflection/RuntimeMethodInfo.cs | 28 +- .../src/System/Reflection/RuntimeModule.cs | 58 +- .../src/System/Reflection/RuntimeParameterInfo.cs | 10 +- .../src/System/Reflection/RuntimePropertyInfo.cs | 10 +- .../System/Reflection/TargetInvocationException.cs | 4 +- .../Reflection/TargetParameterCountException.cs | 2 +- .../System/Resources/FileBasedResourceGroveler.cs | 4 +- .../Resources/LooselyLinkedResourceReference.cs | 6 +- .../Resources/ManifestBasedResourceGroveler.cs | 14 +- .../Resources/MissingManifestResourceException.cs | 2 +- .../Resources/MissingSatelliteAssemblyException.cs | 2 +- .../Resources/NeutralResourcesLanguageAttribute.cs | 2 +- .../src/System/Resources/ResourceManager.cs | 16 +- .../src/System/Resources/ResourceReader.cs | 118 +- src/mscorlib/src/System/Resources/ResourceSet.cs | 12 +- .../src/System/Resources/RuntimeResourceSet.cs | 6 +- src/mscorlib/src/System/RtType.cs | 135 +- .../CompilerServices/ConditionalWeakTable.cs | 2 +- .../CompilerServices/RuntimeWrappedException.cs | 2 +- .../ExceptionServices/ExceptionNotification.cs | 2 +- .../ExceptionServices/ExceptionServicesCommon.cs | 2 +- src/mscorlib/src/System/Runtime/GcSettings.cs | 4 +- .../System/Runtime/InteropServices/COMException.cs | 2 +- .../Runtime/InteropServices/CurrencyWrapper.cs | 2 +- .../System/Runtime/InteropServices/ErrorWrapper.cs | 2 +- .../Runtime/InteropServices/ExternalException.cs | 2 +- .../Runtime/InteropServices/GCHandleCookieTable.cs | 2 +- .../src/System/Runtime/InteropServices/GcHandle.cs | 2 +- .../InteropServices/InvalidComObjectException.cs | 2 +- .../InvalidOleVariantTypeException.cs | 2 +- .../src/System/Runtime/InteropServices/Marshal.cs | 40 +- .../InteropServices/MarshalDirectiveException.cs | 2 +- .../SafeArrayRankMismatchException.cs | 2 +- .../SafeArrayTypeMismatchException.cs | 2 +- .../System/Runtime/InteropServices/SafeBuffer.cs | 34 +- .../BindableVectorToCollectionAdapter.cs | 8 +- .../WindowsRuntime/BindableVectorToListAdapter.cs | 6 +- .../WindowsRuntime/CLRIPropertyValueImpl.cs | 48 +- .../WindowsRuntime/ConstantSplittableMap.cs | 6 +- .../WindowsRuntime/CustomPropertyImpl.cs | 6 +- .../WindowsRuntime/DictionaryKeyCollection.cs | 10 +- .../WindowsRuntime/DictionaryToMapAdapter.cs | 4 +- .../WindowsRuntime/DictionaryValueCollection.cs | 10 +- .../WindowsRuntime/EventRegistrationTokenTable.cs | 2 +- .../IMapViewToIReadOnlyDictionaryAdapter.cs | 10 +- .../IReadOnlyDictionaryToIMapViewAdapter.cs | 2 +- .../IReadOnlyListToIVectorViewAdapter.cs | 2 +- .../WindowsRuntime/ListToBindableVectorAdapter.cs | 4 +- .../ListToBindableVectorViewAdapter.cs | 2 +- .../WindowsRuntime/ListToVectorAdapter.cs | 4 +- .../WindowsRuntime/ManagedActivationFactory.cs | 2 +- .../WindowsRuntime/MapToCollectionAdapter.cs | 10 +- .../WindowsRuntime/MapToDictionaryAdapter.cs | 4 +- .../MapViewToReadOnlyCollectionAdapter.cs | 4 +- .../WindowsRuntime/VectorToCollectionAdapter.cs | 8 +- .../WindowsRuntime/VectorToListAdapter.cs | 2 +- .../VectorViewToReadOnlyCollectionAdapter.cs | 2 +- .../WindowsRuntime/WindowsRuntimeMarshal.cs | 10 +- .../WindowsRuntime/WindowsRuntimeMetadata.cs | 2 +- .../System/Runtime/Loader/AssemblyLoadContext.cs | 16 +- src/mscorlib/src/System/Runtime/MemoryFailPoint.cs | 10 +- src/mscorlib/src/System/Runtime/RuntimeImports.cs | 2 +- .../Runtime/Serialization/FormatterServices.cs | 2 +- .../Serialization/SerializationAttributes.cs | 2 +- .../Serialization/SerializationException.cs | 2 +- .../Runtime/Serialization/SerializationInfo.cs | 6 +- .../Serialization/SerializationInfoEnumerator.cs | 10 +- src/mscorlib/src/System/RuntimeHandles.cs | 34 +- src/mscorlib/src/System/SByte.cs | 10 +- src/mscorlib/src/System/Security/Util/URLString.cs | 2 +- .../src/System/Security/VerificationException.cs | 2 +- src/mscorlib/src/System/Single.cs | 6 +- src/mscorlib/src/System/String.Comparison.cs | 38 +- src/mscorlib/src/System/String.Manipulation.cs | 38 +- src/mscorlib/src/System/String.Searching.cs | 26 +- src/mscorlib/src/System/String.cs | 42 +- src/mscorlib/src/System/StringComparer.cs | 4 +- src/mscorlib/src/System/StubHelpers.cs | 26 +- src/mscorlib/src/System/Text/ASCIIEncoding.cs | 14 +- src/mscorlib/src/System/Text/Decoder.cs | 28 +- .../src/System/Text/DecoderExceptionFallback.cs | 5 +- src/mscorlib/src/System/Text/DecoderFallback.cs | 15 +- src/mscorlib/src/System/Text/DecoderNLS.cs | 38 +- .../src/System/Text/DecoderReplacementFallback.cs | 2 +- src/mscorlib/src/System/Text/Encoder.cs | 28 +- .../src/System/Text/EncoderBestFitFallback.cs | 6 +- .../src/System/Text/EncoderExceptionFallback.cs | 20 +- src/mscorlib/src/System/Text/EncoderFallback.cs | 3 +- src/mscorlib/src/System/Text/EncoderNLS.cs | 38 +- .../src/System/Text/EncoderReplacementFallback.cs | 8 +- src/mscorlib/src/System/Text/Encoding.cs | 77 +- src/mscorlib/src/System/Text/EncodingForwarder.cs | 58 +- src/mscorlib/src/System/Text/Latin1Encoding.cs | 8 +- src/mscorlib/src/System/Text/Normalization.Unix.cs | 10 +- .../src/System/Text/Normalization.Windows.cs | 6 +- src/mscorlib/src/System/Text/StringBuilder.cs | 124 +- src/mscorlib/src/System/Text/UTF32Encoding.cs | 19 +- src/mscorlib/src/System/Text/UTF7Encoding.cs | 8 +- src/mscorlib/src/System/Text/UTF8Encoding.cs | 16 +- src/mscorlib/src/System/Text/UnicodeEncoding.cs | 22 +- .../System/Threading/AbandonedMutexException.cs | 4 +- .../src/System/Threading/CancellationToken.cs | 4 +- .../System/Threading/CancellationTokenSource.cs | 4 +- .../src/System/Threading/EventWaitHandle.cs | 26 +- .../src/System/Threading/ExecutionContext.cs | 14 +- .../src/System/Threading/LazyInitializer.cs | 6 +- .../src/System/Threading/ManualResetEventSlim.cs | 6 +- src/mscorlib/src/System/Threading/Monitor.cs | 4 +- src/mscorlib/src/System/Threading/Mutex.cs | 18 +- src/mscorlib/src/System/Threading/Overlapped.cs | 4 +- src/mscorlib/src/System/Threading/Semaphore.cs | 32 +- .../src/System/Threading/SemaphoreFullException.cs | 2 +- src/mscorlib/src/System/Threading/SemaphoreSlim.cs | 4 +- src/mscorlib/src/System/Threading/SpinWait.cs | 8 +- .../Threading/SynchronizationLockException.cs | 2 +- .../Threading/Tasks/TaskCanceledException.cs | 4 +- .../System/Threading/Tasks/TaskExceptionHolder.cs | 4 +- .../src/System/Threading/Tasks/TaskFactory.cs | 18 +- .../src/System/Threading/Tasks/TaskScheduler.cs | 10 +- .../Threading/Tasks/TaskSchedulerException.cs | 4 +- src/mscorlib/src/System/Threading/Tasks/future.cs | 2 +- src/mscorlib/src/System/Threading/Thread.cs | 12 +- src/mscorlib/src/System/Threading/ThreadLocal.cs | 16 +- src/mscorlib/src/System/Threading/ThreadPool.cs | 20 +- .../src/System/Threading/ThreadStartException.cs | 4 +- .../src/System/Threading/ThreadStateException.cs | 2 +- src/mscorlib/src/System/Threading/Timer.cs | 34 +- src/mscorlib/src/System/Threading/WaitHandle.cs | 38 +- .../Threading/WaitHandleCannotBeOpenedException.cs | 2 +- src/mscorlib/src/System/ThrowHelper.cs | 18 +- src/mscorlib/src/System/TimeSpan.cs | 30 +- .../src/System/TimeZoneInfo.AdjustmentRule.cs | 18 +- .../src/System/TimeZoneInfo.StringSerializer.cs | 62 +- .../src/System/TimeZoneInfo.TransitionTime.cs | 14 +- src/mscorlib/src/System/TimeZoneInfo.Unix.cs | 20 +- src/mscorlib/src/System/TimeZoneInfo.Win32.cs | 8 +- src/mscorlib/src/System/TimeZoneInfo.cs | 32 +- src/mscorlib/src/System/Tuple.cs | 18 +- src/mscorlib/src/System/TypeLoadException.cs | 8 +- src/mscorlib/src/System/TypeNameParser.cs | 12 +- src/mscorlib/src/System/TypeUnloadedException.cs | 2 +- src/mscorlib/src/System/TypedReference.cs | 14 +- src/mscorlib/src/System/UInt16.cs | 8 +- src/mscorlib/src/System/UInt32.cs | 4 +- src/mscorlib/src/System/UInt64.cs | 4 +- src/mscorlib/src/System/UIntPtr.cs | 2 +- .../src/System/UnitySerializationHolder.cs | 8 +- src/mscorlib/src/System/ValueTuple.cs | 4 +- src/mscorlib/src/System/Variant.cs | 8 +- src/mscorlib/src/System/Version.cs | 34 +- 301 files changed, 7439 insertions(+), 5502 deletions(-) create mode 100644 Tools-Override/resources.targets create mode 100644 src/mscorlib/Common/System/SR.cs create mode 100644 src/mscorlib/Resources/Strings.resx delete mode 100644 src/mscorlib/src/SR.cs delete mode 100644 src/mscorlib/src/System.Private.CoreLib.txt diff --git a/Tools-Override/resources.targets b/Tools-Override/resources.targets new file mode 100644 index 0000000..82ce179 --- /dev/null +++ b/Tools-Override/resources.targets @@ -0,0 +1,76 @@ + + + + + + CurrentRuntime + CurrentArchitecture + + + + $(MSBuildProjectDirectory)/Resources/ + $(ResourcesSourceOutputDirectory)/Strings.resx + $(IntermediateOutputPath)SR.cs + $(IntermediateOutputPath)SR.vb + $(DefineConstants);DEBUGRESOURCES + + + + + GenerateResourcesSource; + $(CompileDependsOn); + + + + + + + + + + + + + + + + + + + + + + true + FxResources.$(AssemblyName).SR.resources + + + + + + + + + + true + Resources/Common/SR.cs + + + + + + + true + Resources/Common/SR.vb + + + + + + + diff --git a/run.sh b/run.sh index 9f23901..2612c86 100755 --- a/run.sh +++ b/run.sh @@ -6,7 +6,7 @@ echo "Running init-tools.sh" $working_tree_root/init-tools.sh # Always copy over the Tools-Override -cp $__scriptpath/Tools-Override/* $__scriptpath/Tools > /dev/null +cp $working_tree_root/Tools-Override/* $working_tree_root/Tools > /dev/null toolRuntime=$working_tree_root/Tools dotnet=$toolRuntime/dotnetcli/dotnet diff --git a/src/mscorlib/Common/System/SR.cs b/src/mscorlib/Common/System/SR.cs new file mode 100644 index 0000000..29f3970 --- /dev/null +++ b/src/mscorlib/Common/System/SR.cs @@ -0,0 +1,197 @@ +// 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. + +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Threading; + +namespace System +{ + internal static partial class SR + { + private static ResourceManager ResourceManager + { + get; + set; + } + + // This method is used to decide if we need to append the exception message parameters to the message when calling SR.Format. + // by default it returns false. + [MethodImpl(MethodImplOptions.NoInlining)] + private static bool UsingResourceKeys() + { + return false; + } + + // Needed for debugger integration + internal static string GetResourceString(string resourceKey) + { + return GetResourceString(resourceKey, String.Empty); + } + + internal static string GetResourceString(string resourceKey, string defaultString) + { + string resourceString = null; + try { resourceString = InternalGetResourceString(resourceKey); } + catch (MissingManifestResourceException) { } + + if (defaultString != null && resourceKey.Equals(resourceString, StringComparison.Ordinal)) + { + return defaultString; + } + + return resourceString; + } + + private static object _lock = new object(); + private static List _currentlyLoading; + private static int _infinitelyRecursingCount; + private static bool _resourceManagerInited = false; + + private static string InternalGetResourceString(string key) + { + if (key == null || key.Length == 0) + { + Debug.Assert(false, "SR::GetResourceString with null or empty key. Bug in caller, or weird recursive loading problem?"); + return key; + } + + // We have a somewhat common potential for infinite + // loops with mscorlib's ResourceManager. If "potentially dangerous" + // code throws an exception, we will get into an infinite loop + // inside the ResourceManager and this "potentially dangerous" code. + // Potentially dangerous code includes the IO package, CultureInfo, + // parts of the loader, some parts of Reflection, Security (including + // custom user-written permissions that may parse an XML file at + // class load time), assembly load event handlers, etc. Essentially, + // this is not a bounded set of code, and we need to fix the problem. + // Fortunately, this is limited to mscorlib's error lookups and is NOT + // a general problem for all user code using the ResourceManager. + + // The solution is to make sure only one thread at a time can call + // GetResourceString. Also, since resource lookups can be + // reentrant, if the same thread comes into GetResourceString + // twice looking for the exact same resource name before + // returning, we're going into an infinite loop and we should + // return a bogus string. + + bool lockTaken = false; + try + { + Monitor.Enter(_lock, ref lockTaken); + + // Are we recursively looking up the same resource? Note - our backout code will set + // the ResourceHelper's currentlyLoading stack to null if an exception occurs. + if (_currentlyLoading != null && _currentlyLoading.Count > 0 && _currentlyLoading.LastIndexOf(key) != -1) + { + // We can start infinitely recursing for one resource lookup, + // then during our failure reporting, start infinitely recursing again. + // avoid that. + if (_infinitelyRecursingCount > 0) + { + return key; + } + _infinitelyRecursingCount++; + + // Note: our infrastructure for reporting this exception will again cause resource lookup. + // This is the most direct way of dealing with that problem. + string message = $"Infinite recursion during resource lookup within {System.CoreLib.Name}. This may be a bug in {System.CoreLib.Name}, or potentially in certain extensibility points such as assembly resolve events or CultureInfo names. Resource name: {key}"; + Assert.Fail("[Recursive resource lookup bug]", message, Assert.COR_E_FAILFAST, System.Diagnostics.StackTrace.TraceFormat.NoResourceLookup); + Environment.FailFast(message); + } + if (_currentlyLoading == null) + _currentlyLoading = new List(); + + // Call class constructors preemptively, so that we cannot get into an infinite + // loop constructing a TypeInitializationException. If this were omitted, + // we could get the Infinite recursion assert above by failing type initialization + // between the Push and Pop calls below. + if (!_resourceManagerInited) + { + RuntimeHelpers.RunClassConstructor(typeof(ResourceManager).TypeHandle); + RuntimeHelpers.RunClassConstructor(typeof(ResourceReader).TypeHandle); + RuntimeHelpers.RunClassConstructor(typeof(RuntimeResourceSet).TypeHandle); + RuntimeHelpers.RunClassConstructor(typeof(BinaryReader).TypeHandle); + _resourceManagerInited = true; + } + + _currentlyLoading.Add(key); // Push + + if (ResourceManager == null) + { + ResourceManager = new ResourceManager(SR.ResourceType); + } + string s = ResourceManager.GetString(key, null); + _currentlyLoading.RemoveAt(_currentlyLoading.Count - 1); // Pop + + Debug.Assert(s != null, "Managed resource string lookup failed. Was your resource name misspelled? Did you rebuild mscorlib after adding a resource to resources.txt? Debug this w/ cordbg and bug whoever owns the code that called SR.GetResourceString. Resource name was: \"" + key + "\""); + return s ?? key; + } + catch + { + if (lockTaken) + { + // Backout code - throw away potentially corrupt state + ResourceManager = null; + _currentlyLoading = null; + } + throw; + } + finally + { + if (lockTaken) + { + Monitor.Exit(_lock); + } + } + } + + internal static string Format(string resourceFormat, params object[] args) + { + if (args != null) + { + if (UsingResourceKeys()) + { + return resourceFormat + String.Join(", ", args); + } + + return String.Format(resourceFormat, args); + } + + return resourceFormat; + } + + internal static string Format(string resourceFormat, object p1) + { + if (UsingResourceKeys()) + { + return String.Join(", ", resourceFormat, p1); + } + + return String.Format(resourceFormat, p1); + } + + internal static string Format(string resourceFormat, object p1, object p2) + { + if (UsingResourceKeys()) + { + return String.Join(", ", resourceFormat, p1, p2); + } + + return String.Format(resourceFormat, p1, p2); + } + + internal static string Format(string resourceFormat, object p1, object p2, object p3) + { + if (UsingResourceKeys()) + { + return String.Join(", ", resourceFormat, p1, p2, p3); + } + return String.Format(resourceFormat, p1, p2, p3); + } + } +} diff --git a/src/mscorlib/Resources/Strings.resx b/src/mscorlib/Resources/Strings.resx new file mode 100644 index 0000000..c9f8a63 --- /dev/null +++ b/src/mscorlib/Resources/Strings.resx @@ -0,0 +1,4902 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Cannot create an abstract class. + + + Cannot create an instance of {0} because it is an abstract class. + + + Cannot dynamically create an instance of ArgIterator. + + + Cannot create a type for which Type.ContainsGenericParameters is true. + + + Cannot create an instance of {0} because Type.ContainsGenericParameters is true. + + + Cannot create an instance of an interface. + + + Cannot create an instance of {0} because it is an interface. + + + Cannot dynamically create an instance of System.Void. + + + Type initializer was not callable. + + + Cannot set a constant field. + + + SkipVerification permission is needed to modify an image-based (RVA) static field. + + + Cannot create an instance of void. + + + One or more errors occurred. + + + An element of innerExceptions was null. + + + The serialization stream contains no inner exceptions. + + + {0}{1}---> (Inner Exception #{2}) {3}{4}{5} + + + All code + + + Allocated from: + + + The ApplicationBase must be set before retrieving this property. + + + Binding model is already locked for the AppDomain and cannot be reset. + + + ApplicationName must be set before the DynamicBase can be set. + + + ApplicationDirectory + + + Cannot access member. + + + Attempted to read or write protected memory. This is often an indication that other memory is corrupt. + + + Ambiguous match found. + + + Attempted to access an unloaded AppDomain. + + + Error in the application. + + + Value does not fall within the expected range. + + + Specified argument was out of the range of valid values. + + + Overflow or underflow in the arithmetic operation. + + + Array lengths must be the same. + + + Destination array is not long enough to copy all the items in the collection. Check array index and length. + + + Attempted to access an element as a type incompatible with the array. + + + Array must not be of length zero. + + + The manifest module of the assembly cannot be null. + + + Read an invalid decimal value from the buffer. + + + Format of the executable (.exe) or library (.dll) is invalid. + + + Encountered an invalid type for a default value. + + + Only supported array types for CopyTo on BitArrays are Boolean[], Int32[] and Byte[]. + + + Unable to sort because the IComparer.Compare() method returns inconsistent results. Either a value does not compare equal to itself, or one value repeatedly compared to another value yields different results. IComparer: '{0}'. + + + Not enough space available in the buffer. + + + TimeSpan does not accept floating point Not-a-Number values. + + + String cannot contain a minus sign if the base is not 10. + + + The usage of IKeyComparer and IHashCodeProvider/IComparer interfaces cannot be mixed; use one or the other. + + + Attempt to unload the AppDomain failed. + + + Failed to resolve type from string "{0}" which was embedded in custom attribute blob. + + + Must specify property Set or Get or method call for a COM Object. + + + Error HRESULT E_FAIL has been returned from a call to a COM component. + + + Only one of the following binding flags can be set: BindingFlags.SetProperty, BindingFlags.PutDispProperty, BindingFlags.PutRefDispProperty. + + + Attempted to marshal an object across a context boundary. + + + The file of the custom culture {0} is corrupt. Try to unregister this culture. + + + Cannot specify both CreateInstance and another access type. + + + Error occurred during a cryptographic operation. + + + Binary format of the specified custom attribute was invalid. + + + A datatype misalignment was detected in a load or store instruction. + + + Combination of arguments to the DateTime constructor is out of the legal range. + + + Decimal byte array constructor requires an array of length four containing valid decimal bytes. + + + FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of "\\\\.\\" in the path. + + + Attempted to access a path that is not on the disk. + + + Attempted to divide by zero. + + + Delegate to an instance method cannot have null 'this'. + + + Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type. + + + Delegates must be of the same type. + + + One machine may not have remote administration enabled, or both machines may not be running the remote registry service. + + + Dll was not found. + + + Attempted to access a drive that is not available. + + + Duplicate objects in argument. + + + This ExceptionHandlingClause is not a clause. + + + This ExceptionHandlingClause is not a filter. + + + Array may not be empty. + + + Collection must not be empty. + + + Array may not be empty or null. + + + String may not be empty or null. + + + Attempted to read past the end of the stream. + + + Entry point was not found. + + + Object must be the same type as the enum. The type passed in was '{0}'; the enum type was '{1}'. + + + Must set at least one flag. + + + Enum underlying type and the object must be same type or object. Type passed in was '{0}'; the enum underlying type was '{1}'. + + + Illegal enum value: {0}. + + + Literal value was not found. + + + All enums must have an underlying value__ field. + + + Must set exactly one flag. + + + Enum underlying type and the object must be same type or object must be a String. Type passed in was '{0}'; the enum underlying type was '{1}'. + + + Requested value '{0}' was not found. + + + Internal error in the runtime. + + + External component has thrown an exception. + + + Attempted to access a field that is not accessible by the caller. + + + Field '{0}' defined on type '{1}' is not a field on the target object which is of type '{2}'. + + + The target file "{0}" is a directory, not a file. + + + No arguments can be provided to Get a field value. + + + Cannot specify both GetField and SetProperty. + + + Only the field value can be specified to set a field value. + + + Cannot specify both Get and Set on a field. + + + Cannot specify Set on a Field and Invoke on a method. + + + Cannot specify both SetField and GetProperty. + + + One of the identified items was in an invalid format. + + + Method must be called on a Type for which Type.IsGenericParameter is false. + + + Property Get method was not found. + + + Byte array for GUID must be exactly {0} bytes long. + + + Handle does not support asynchronous operations. The parameters to the FileStream constructor may need to be changed to indicate that the handle was opened synchronously (that is, it was not opened for overlapped I/O). + + + Handle does not support synchronous operations. The parameters to the FileStream constructor may need to be changed to indicate that the handle was opened asynchronously (that is, it was opened explicitly for overlapped I/O). + + + The number style AllowHexSpecifier is not supported on floating point data types. + + + Hashtable's capacity overflowed and went negative. Check load factor, capacity and the current size of the table. + + + The type library importer encountered an error during type verification. Try importing without class members. + + + All indexes must be of type Int32. + + + Index was outside the bounds of the array. + + + Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space. + + + Specified access entry is invalid because it is unrestricted. The global flags should be specified instead. + + + The ANSI string passed in could not be converted from the default ANSI code page to Unicode. + + + Invalid Base. + + + Specified cast is not valid. + + + Attempt has been made to use a COM object that does not have a backing class factory. + + + The ConsoleColor enum value was not defined on that enum. Please use a defined color from the enum. + + + Invalid File or Directory attributes value. + + + Specified file extension was not a valid extension. + + + Specified file name was invalid. + + + Specified filter criteria was invalid. + + + Invalid handle. + + + With the AllowHexSpecifier bit set in the enum bit field, the only other valid bits that can be combined into the enum value must be a subset of those in HexNumber. + + + The NeutralResourcesLanguageAttribute on the assembly "{0}" specifies an invalid culture name: "{1}". + + + The NeutralResourcesLanguageAttribute specifies an invalid or unrecognized ultimate resource fallback location: "{0}". + + + Specified OLE variant was invalid. + + + Operation is not valid due to the current state of the object. + + + Satellite contract version attribute on the assembly '{0}' specifies an invalid version: {1}. + + + Search pattern cannot contain ".." to move up directories and can be contained only internally in file/directory names, as in "a..b". + + + The return Type contains some invalid type (i.e. null, ByRef) + + + The signature Type array contains some invalid type (i.e. null, void) + + + The UTF8 string passed in could not be converted to Unicode. + + + InvokeMember can be used only for COM objects. + + + I/O error occurred. + + + The given key was not present in the dictionary. + + + Destination array was not long enough. Check the destination index, length, and the array's lower bounds. + + + Source array was not long enough. Check the source index, length, and the array's lower bounds. + + + Source string was not long enough. Check sourceIndex and count. + + + The arrays' lower bounds must be identical. + + + AsAny cannot be used on return types, ByRef parameters, ArrayWithOffset, or parameters passed from unmanaged to managed. + + + Marshaling directives are invalid. + + + The Module object containing the member cannot be null. + + + Attempt to access the method failed. + + + Attempt by security transparent method '{0}' to access security critical method '{1}' failed. + + + Attempt to access the method "{0}" on type "{1}" failed. + + + The AppDomainSetup must specify the activation arguments for this call. + + + Attempted to access a non-existing field. + + + Unable to find manifest resource. + + + Attempted to access a missing member. + + + Attempted to access a missing method. + + + Attempted to add multiple callbacks to a delegate that does not support multicast. + + + At least one type argument is not a runtime type. + + + Object must be of type Boolean. + + + Object must be of type Byte. + + + Object must be of type Char. + + + Object must be of type DateTime. + + + Object must be of type DateTimeOffset. + + + Object must be of type Decimal. + + + Type must derive from Delegate. + + + Object must be of type Double. + + + Object must be a root directory ("C:\\") or a drive letter ("C"). + + + Type provided must be an Enum. + + + The value passed in must be an enum base or an underlying type for an enum, such as an Int32. + + + Object must be of type GUID. + + + Type must be an IdentityReference, such as NTAccount or SecurityIdentifier. + + + Object must be of type Int16. + + + Object must be of type Int32. + + + Object must be of type Int64. + + + Type passed must be an interface. + + + Type must be a Pointer. + + + Object must be an array of primitives. + + + Object must be of type SByte. + + + Object must be of type Single. + + + Method must be a static method. + + + Object must be of type String. + + + The pointer passed in as a String must not be in the bottom 64K of the process's address space. + + + Object must be of type TimeSpan. + + + Argument must be true. + + + Type must be a type provided by the runtime. + + + Object must be of type UInt16. + + + Object must be of type UInt32. + + + Object must be of type UInt64. + + + Object must be of type Version. + + + Must specify valid information for parsing in the string. + + + Named parameter value must not be null. + + + Named parameter array cannot be bigger than argument array. + + + No PInvoke conversion exists for value passed to Object-typed parameter. + + + Array was not a one-dimensional array. + + + Array was not a two-dimensional array. + + + Array was not a three-dimensional array. + + + Must provide at least one rank. + + + Argument count must not be negative. + + + Must specify binding flags describing the invoke operation required (BindingFlags.InvokeMethod CreateInstance GetField SetField GetProperty SetProperty). + + + No parameterless constructor defined for this object. + + + Specified type library importer callback was invalid because it did not support the ITypeLibImporterNotifySink interface. + + + Specified TypeInfo was invalid because it did not support the ITypeInfo interface. + + + Specified TypeLib was invalid because it did not support the ITypeLib interface. + + + The lower bound of target array must be zero. + + + Method cannot be both static and virtual. + + + Number encountered was not a finite quantity. + + + Interface not found. + + + {0} is not a GenericMethodDefinition. MakeGenericMethod may only be called on a method for which MethodBase.IsGenericMethodDefinition is true. + + + Method may only be called on a Type for which Type.IsGenericParameter is true. + + + {0} is not a GenericTypeDefinition. MakeGenericType may only be called on a type for which Type.IsGenericTypeDefinition is true. + + + The method or operation is not implemented. + + + Specified method is not supported. + + + Arrays indexes must be set to an object instance. + + + Object reference not set to an instance of an object. + + + Object type cannot be converted to target type. + + + Object of type '{0}' cannot be converted to type '{1}'. + + + Not a legal OleAut date. + + + OleAut date did not convert to a DateTime correctly. + + + Arithmetic operation resulted in an overflow. + + + The MemberInfo object defining the parameter cannot be null. + + + The Module object containing the parameter cannot be null. + + + Parameter name: {0} + + + Must specify one or more parameters. + + + Parameter count mismatch. + + + Second path fragment must not be a drive or UNC name. + + + Paths that begin with \\\\?\\GlobalRoot are internal to the kernel and should not be opened by managed applications. + + + The path is not of a legal form. + + + The UNC path should be of the form \\\\server\\share. + + + Path must not be a drive. + + + Operation is not supported on this platform. + + + SecureString is only supported on Windows 2000 SP3 and higher platforms. + + + Cannot widen from source type to target type either because the source type is a not a primitive type or the conversion cannot be accomplished. + + + Could not find the specified property. + + + Cannot specify both Get and Set on a property. + + + Cannot specify Set on a property and Invoke on a method. + + + Attempted to operate on an array with the incorrect number of dimensions. + + + Indices length does not match the array rank. + + + Only single dimensional arrays are supported for the requested action. + + + Number of lengths and lowerBounds must match. + + + It is illegal to reflect on the custom attributes of a Type loaded via ReflectionOnlyGetType (see Assembly.ReflectionOnly) -- use CustomAttributeData instead. + + + It is illegal to get or set the value on a field on a Type loaded via ReflectionOnlyGetType. + + + It is illegal to invoke a method on a Type loaded via ReflectionOnlyGetType. + + + The specified RegistryValueKind is an invalid value. + + + RegistryKey.GetValue does not allow a String that has a length greater than Int32.MaxValue. + + + Registry key name must start with a valid base key name. + + + Cannot delete a registry hive's subtree. + + + No remote connection to '{0}' while trying to read the registry. + + + The specified registry key does not exist. + + + Registry HKEY was out of the legal range. + + + Registry key names should not be greater than 255 characters. + + + RegistryKey.SetValue does not support arrays of type '{0}'. Only Byte[] and String[] are supported. + + + The type of the value object did not match the specified RegistryValueKind or the object could not be properly converted. + + + RegistryKey.SetValue does not allow a String[] that contains a null String reference. + + + Cannot delete a subkey tree because the subkey does not exist. + + + No value exists with that name. + + + Registry value names should not be greater than 16,383 characters. + + + Cannot remove the specified item because it was not found in the specified Collection. + + + Type parameter must refer to a subclass of ResourceSet. + + + The ResourceReader class does not know how to read this version of .resources files. Expected version: {0} This file: {1} + + + The specified resource name "{0}" does not exist in the resource file. + + + ReaderWriterLock.RestoreLock was called without releasing all locks acquired since the call to ReleaseLock. + + + Specified array was not of the expected rank. + + + Specified array was not of the expected type. + + + Security error. + + + Serialization error. + + + Property set method not found. + + + Operation caused a stack overflow. + + + Unicode surrogate characters must be written out as pairs together in the same call, not individually. Consider passing in a character array instead. + + + Object synchronization method was called from an unsynchronized block of code. + + + System error. + + + Exception has been thrown by the target of an invocation. + + + Number of parameters specified does not match the expected number. + + + Thread failed to start. + + + Thread was in an invalid state for the operation being executed. + + + The operation has timed out. + + + Attempt to access the type failed. + + + The TypedReference must be initialized. + + + Failure has occurred while loading a type. + + + A null or zero length string does not represent a valid Type. + + + TypedReferences cannot be redefined as primitives. + + + Type had been unloaded. + + + Attempted to perform an unauthorized operation. + + + Late bound operations cannot be performed on fields with types for which Type.ContainsGenericParameters is true. + + + Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true. + + + Unknown TypeCode value. + + + Missing parameter does not have a default value. + + + Version string portion was too short or too long. + + + Attempted to make an early bound call on a COM dispatch-only interface. + + + IAsyncResult object did not come from the corresponding async method on this type. + + + The value "{0}" is not of type "{1}" and cannot be used in this generic collection. + + + Absolute path information is required. + + + An item with the same key has already been added. + + + Item has already been added. Key in dictionary: '{0}' Key being added: '{1}' + + + An item with the same key has already been added. Key: {0} + + + The elements of the AdjustmentRule array must not contain ambiguous time periods that extend beyond the DateStart or DateEnd properties of the element. + + + The elements of the AdjustmentRule array must not contain invalid time periods that extend beyond the DateStart or DateEnd properties of the element. + + + The AdjustmentRule array cannot contain null elements. + + + The elements of the AdjustmentRule array must be in chronological order and must not overlap. + + + The elements of the AdjustmentRule array must not contain Daylight Saving Time periods that overlap adjacent elements in such a way as to cause invalid or ambiguous time periods. + + + The elements of the AdjustmentRule array must not contain Daylight Saving Time periods that overlap the DateStart or DateEnd properties in such a way as to cause invalid or ambiguous time periods. + + + The object already has a CCW associated with it. + + + 'handle' has already been bound to the thread pool, or was not opened for asynchronous I/O. + + + Specified capacity must not be less than the current capacity. + + + Specified slot number was invalid. + + + An ApplicationTrust must have an application identity before it can be persisted. + + + Argument cannot be zero. + + + Interface maps for generic interfaces on arrays cannot be retrieved. + + + Array or pointer types are not valid. + + + The input array length must not exceed Int32.MaxValue / {0}. Otherwise BitArray.Length would exceed Int32.MaxValue. + + + Assembly was already fully trusted. + + + Assembly was not fully trusted. + + + Assembly must not be a Windows Runtime assembly. + + + Attribute names must be unique. + + + Interface method must be abstract and virtual. + + + Bad '{0}' while generating unmanaged resource information. + + + Bad default value. + + + Cannot have private or static constructor. + + + Constructor must have standard calling convention. + + + Bad current local variable for setting symbol information. + + + Incorrect code generation for exception block. + + + Field must be on the same type of the given ConstructorInfo. + + + Field signatures do not have return types. + + + Bad field type in defining field. + + + Format specifier was invalid. + + + A BadImageFormatException has been thrown while parsing the signature. This is likely due to lack of a generic context. Ensure genericTypeArguments and genericMethodArguments are provided and contain enough context. + + + Bad label in ILGenerator. + + + Bad label content in ILGenerator. + + + Visibility of interfaces must be one of the following: NestedAssembly, NestedFamANDAssem, NestedFamily, NestedFamORAssem, NestedPrivate or NestedPublic. + + + Invalid ObjRef provided to '{0}'. + + + Parameter count does not match passed in argument value count. + + + Cannot emit a CustomAttribute with argument of type {0}. + + + Passed in argument value at index {0} does not match the parameter type. + + + Cannot have a persistable module in a transient assembly. + + + PInvoke methods must be static and native and cannot be abstract. + + + PInvoke methods cannot exist on interfaces. + + + Property must be on the same type of the given ConstructorInfo. + + + Unknown value for the ResourceScope: {0} Too many resource type bits may be set. + + + Unknown value for the ResourceScope: {0} Too many resource visibility bits may be set. + + + Incorrect signature format. + + + Data size must be > 1 and < 0x3f0000 + + + Bad type attributes. A type cannot be both abstract and final. + + + Bad type attributes. Invalid layout attribute specified. + + + Bad type attributes. Nested visibility flag set on a non-nested type. + + + Bad type attributes. Non-nested visibility flag set on a nested type. + + + Bad type attributes. Reserved bits set on the type. + + + An invalid type was used as a custom attribute constructor argument, field or property. + + + Cannot use function evaluation to create a TypedReference object. + + + Cannot get TypeToken for a ByRef type. + + + Abstract methods cannot be prepared. + + + Cannot set parent to an interface. + + + Cannot evaluate a security function. + + + {0} is not a supported code page. + + + CompareOption.Ordinal cannot be used with other options. + + + The DateTimeStyles value RoundtripKind cannot be used with the values AssumeLocal, AssumeUniversal or AdjustToUniversal. + + + The DateTimeStyles values AssumeLocal and AssumeUniversal cannot be used together. + + + Constant does not match the defined type. + + + {0} is not a supported constant type. + + + Null is not a valid constant value for this type. + + + The specified constructor must be declared on a generic type definition. + + + Conversion buffer overflow. + + + The conversion could not be completed because the supplied DateTime did not have the Kind property set correctly. For example, when the Kind property is DateTimeKind.Local, the source time zone must be TimeZoneInfo.Local. + + + Cannot find the method on the object instance. + + + Cannot evaluate a VarArgs function. + + + Culture IETF Name {0} is not a recognized IETF name. + + + Culture '{0}' is a neutral culture. It cannot be used in formatting and parsing and therefore cannot be set as the thread's current culture. + + + {0} is an invalid culture identifier. + + + Culture ID {0} (0x{0:X4}) is a neutral culture; a region cannot be created from it. + + + Culture is not supported. + + + Resolved assembly's simple name should be the same as of the requested assembly. + + + Customized cultures cannot be passed by LCID, only by name. + + + Cannot find cvtres.exe + + + Parameters 'members' and 'data' must have the same length. + + + The binary data must result in a DateTime with ticks between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. + + + The supplied DateTime must have the Year, Month, and Day properties set to 1. The time cannot be specified more precisely than whole milliseconds. + + + The supplied DateTime includes a TimeOfDay setting. This is not supported. + + + The supplied DateTime represents an invalid time. For example, when the clock is adjusted forward, any time in the period that is skipped is invalid. + + + The supplied DateTime is not in an ambiguous time range. + + + The supplied DateTime must have the Kind property set to DateTimeKind.Unspecified. + + + The supplied DateTime must have the Kind property set to DateTimeKind.Unspecified or DateTimeKind.Utc. + + + The DateTimeStyles value 'NoCurrentDateDefault' is not allowed when parsing DateTimeOffset. + + + The supplied DateTimeOffset is not in an ambiguous time range. + + + Destination is too short. + + + Duplicate file names. + + + Duplicate dynamic module name within an assembly. + + + Tried to add NamedPermissionSet with non-unique name. + + + Duplicate resource name within an assembly. + + + Duplicate type name within an assembly. + + + EmitWriteLine does not support this field or local type. + + + ApplicationId cannot have an empty string for the name. + + + Decimal separator cannot be the empty string. + + + Empty file name is not legal. + + + Empty name is not legal. + + + Empty path name is not legal. + + + StrongName cannot have an empty string for the assembly name. + + + Waithandle array may not be empty. + + + Must complete Convert() operation or call Encoder.Reset() before calling GetBytes() or GetByteCount(). Encoder '{0}' fallback '{1}'. + + + The output byte buffer is too small to contain the encoded data, encoding '{0}' fallback '{1}'. + + + The output char buffer is too small to contain the decoded characters, encoding '{0}' fallback '{1}'. + + + '{0}' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. + + + The underlying type of enum argument must be Int32 or Int16. + + + The argument type, '{0}', is not the same as the enum type '{1}'. + + + Cannot change fallback when buffer is not empty. Previous Convert() call left data in the fallback buffer. + + + Cannot resolve field {0} because the declaring type of the field handle {1} is generic. Explicitly provide the declaring type to GetFieldFromHandle. + + + The specified field must be declared on a generic type definition. + + + One or more flags are not supported. + + + FrameworkName is invalid. + + + FrameworkName version component is missing. + + + FrameworkName cannot have less than two components or more than three components. + + + GenericArguments[{0}], '{1}', on '{2}' violates the constraint of type '{3}'. + + + The number of generic arguments provided doesn't equal the arity of the generic type definition. + + + Generic types are not valid. + + + Global members must be static. + + + Cannot pass a GCHandle across AppDomains. + + + Must be an array type. + + + Left to right characters may not be mixed with right to left characters in IDN labels. + + + IDN labels must be between 1 and 63 characters long. + + + IDN names must be between 1 and {0} characters long. + + + Invalid IDN encoded string. + + + Label contains character '{0}' not allowed with UseStd3AsciiRules + + + Decoded string is not a valid IDN name. + + + The application base specified is not valid. + + + Application identity does not have same number of components as manifest paths. + + + Application identity does not match identities in manifests. + + + Environment variable name cannot contain equal character. + + + Illegal name. + + + Illegal security permission zone specified. + + + At least one object must implement IComparable. + + + Improper types in collection. + + + The specified index is out of bounds of the specified array. + + + The specified space is not sufficient to copy the elements from this Collection. + + + 'this' type cannot be an interface itself. + + + No flags can be set. + + + Append access can be requested only in write-only mode. + + + Invalid identity: no deployment or application identity specified. + + + Type of argument is not compatible with the generic comparer. + + + Length of the array must be {0}. + + + Target array type is not compatible with the type of items in the collection. + + + Assembly names may not begin with whitespace or contain the characters '/', or '\\' or ':'. + + + Not a valid calendar for the given culture. + + + Invalid Unicode code point found at index {0}. + + + String contains invalid Unicode code points. + + + Unable to translate bytes {0} at index {1} from specified code page to Unicode. + + + Unable to translate Unicode character \\u{0:X4} at index {1} to specified code page. + + + The specified constructor must be declared on the generic type definition of the specified type. + + + The ConstructorInfo object is not valid. + + + Culture name '{0}' is not supported. + + + Invalid DateTimeKind value. + + + An undefined DateTimeStyles value is being used. + + + The DigitSubstitution property must be of a valid member of the DigitShapes enumeration. Valid entries include Context, NativeNational or None. + + + Invalid directory, '{0}'. + + + Invalid directory on URL. + + + Invalid element name '{0}'. + + + Invalid element tag '{0}'. + + + Invalid element text '{0}'. + + + Invalid element value '{0}'. + + + The Enum type should contain one and only one instance field. + + + The value '{0}' is not valid for this usage of the type {1}. + + + The specified field must be declared on the generic type definition of the specified type. + + + The FieldInfo object is not valid. + + + Combining FileMode: {0} with FileAccess: {1} is invalid. + + + Combining FileMode: {0} with FileSystemRights: {1} is invalid. + + + Combining FileMode: {0} with FileSystemRights: {1} is invalid. FileMode.Truncate is valid only when used with FileSystemRights.Write. + + + Value of flags is invalid. + + + The generic type parameter was not valid + + + The given generic instantiation was invalid. + + + Generic arguments must be provided for each generic parameter and each generic argument must be a RuntimeType. + + + Every element in the value array should be between one and nine, except for the last element, which can be zero. + + + The handle is invalid. + + + Improperly formatted hex string. + + + Found a high surrogate char without a following low surrogate at index: {0}. The input may not be in this encoding, or may not contain valid Unicode (UTF-16) characters. + + + The specified ID parameter '{0}' is not supported. + + + Key was invalid. + + + '{0}' is not a valid KeyStore name. + + + This type cannot be represented as a custom attribute. + + + Invalid Label. + + + Found a low surrogate char without a preceding high surrogate at index: {0}. The input may not be in this encoding, or may not contain valid Unicode (UTF-16) characters. + + + The MarshalByRefObject is not valid. + + + The member must be either a field or a property. + + + The specified method must be declared on the generic type definition of the specified type. + + + Invalid name. + + + The NativeDigits array must contain exactly ten members. + + + Each member of the NativeDigits array must be a single text element (one or more UTF16 code points) with a Unicode Nd (Number, Decimal Digit) property indicating it is a digit. + + + The region name {0} should not correspond to neutral culture; a specific culture name is required. + + + Invalid or unsupported normalization form. + + + MemberData contains an invalid number of members. + + + An undefined NumberStyles value is being used. + + + Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection. + + + Ldtoken, Ldftn and Ldvirtftn OpCodes cannot target DynamicMethods. + + + The ParameterInfo object is not valid. + + + Invalid type for ParameterInfo member in Attribute class. + + + Illegal characters in path. + + + Invalid permission state. + + + The REG_TZI_FORMAT structure is corrupt. + + + Region name '{0}' is not supported. + + + The specified RegistryKeyPermissionCheck value is invalid. + + + The specified RegistryOptions value is invalid. + + + The specified RegistryView value is invalid. + + + The given culture name '{0}' cannot be used to locate a resource file. Resource filenames must consist of only letters, numbers, hyphens or underscores. + + + Offset and length were greater than the size of the SafeBuffer. + + + The SafeHandle is invalid. + + + Invalid seek origin. + + + The specified serialized string '{0}' is not supported. + + + Invalid site. + + + The directory specified, '{0}', is not a subdirectory of '{1}'. + + + An undefined TimeSpanStyles value is being used. + + + Token {0:x} is not valid in the scope of module {1}. + + + The type of arguments passed into generic comparer methods is invalid. + + + Cannot build type parameter for custom attribute with a type that does not support the AssemblyQualifiedName property. The type instance supplied was of type '{0}'. + + + Invalid type owner for DynamicMethod. + + + The name of the type is invalid. + + + Token {0:x} is not a valid Type token. + + + Cannot use type '{0}'. Only value types without pointers or references are supported. + + + Invalid Unity type. + + + Invalid URL. + + + Value was invalid. + + + Invalid Xml. + + + Invalid Xml - can only parse elements of version one. + + + Invalid XML. Missing required tag <{0}> for type '{1}'. + + + Invalid XML. Missing required attribute '{0}'. + + + The specified item does not exist in this KeyedCollection. + + + Integer or token was too large to be encoded. + + + Environment variable name cannot contain 1024 or more characters. + + + Environment variable name or value is too long. + + + The specified manifest file does not exist. + + + Cannot supply both a MemberInfo and an Array to indicate the parent of a value type. + + + Cannot resolve method {0} because the declaring type of the method handle {1} is generic. Explicitly provide the declaring type to GetMethodFromHandle. + + + Method '{0}' has a generic declaring type '{1}'. Explicitly provide the declaring type to GetTokenFor. + + + The specified method cannot be dynamic or global and must be declared on a generic type definition. + + + Method has been already defined. + + + '{0}' cannot be greater than {1}. + + + Two arrays, {0} and {1}, must be of the same size. + + + was missing default constructor. + + + The specified module has already been loaded. + + + Argument must be initialized to false + + + The MemberInfo must be an interface method. + + + Assembly must be a runtime Assembly object. + + + FieldInfo must be a runtime FieldInfo object. + + + MethodInfo must be a runtime MethodInfo object. + + + Module must be a runtime Module object. + + + ParameterInfo must be a runtime ParameterInfo object. + + + The object must be a runtime Reflection object. + + + Type must be a runtime Type object. + + + String is too long or has invalid contents. + + + 'type' must contain a TypeBuilder as a generic argument. + + + Type passed in must be derived from System.Attribute or System.Attribute itself. + + + The specified structure must be blittable or have layout information. + + + When supplying a FieldInfo for fixing up a nested type, a valid ID for that containing object must also be supplied. + + + When supplying the ID of a containing object, the FieldInfo that identifies the current field within that object must also be supplied. + + + The name '{0}' contains characters that are not valid for a Culture or Region. + + + The name '{0}' is too long to be a Culture or Region name, which is limited to {1} characters. + + + 'overlapped' has already been freed. + + + 'overlapped' was not allocated by this ThreadPoolBoundHandle instance. + + + Native resource has already been defined. + + + Method must represent a generic method definition on a generic type definition. + + + The specified object must not be an instance of a generic type. + + + The specified Type must not be a generic type definition. + + + The specified Type must be a struct containing no references. + + + The type '{0}' may not be used as a type argument. + + + Element does not specify a class. + + + The domain manager specified by the host could not be instantiated. + + + No Era was supplied. + + + Main entry point not defined. + + + Module file name '{0}' must have file extension. + + + Only LPArray or SafeArray has nested unmanaged marshal. + + + Either obj or ctx must be null. + + + There is no region associated with the Invariant Culture (Culture ID: 0x7F). + + + Please select a specific culture, such as zh-CN, zh-HK, zh-TW, zh-MO, zh-SG. + + + The type does not inherit from CodeGroup + + + Not a custom marshal. + + + The type does not implement IMembershipCondition + + + 'elem' was not a permission element. + + + The type does not implement IPermission + + + The UnmanagedType passed to DefineUnmanagedMarshal is not a simple type. None of the following values may be used: UnmanagedType.ByValTStr, UnmanagedType.SafeArray, UnmanagedType.ByValArray, UnmanagedType.LPArray, UnmanagedType.CustomMarshaler. + + + Type must be a TransparentProxy + + + Not a writable property. + + + There are not enough bytes remaining in the accessor to read at this position. + + + There are not enough bytes remaining in the accessor to write at this position. + + + The type or method has {1} generic parameter(s), but {0} generic argument(s) were provided. A generic argument must be provided for each generic parameter. + + + Does not extend Exception. + + + Not currently in an exception block. + + + The argument passed in was not from the same ModuleBuilder. + + + The specified opcode cannot be passed to EmitCall. + + + Argument passed in is not serializable. + + + The filename must not include a path specification. + + + The object has no underlying COM data associated with it. + + + Uninitialized Strings cannot be created. + + + Unmanaged marshal does not have ElementCount. + + + Name can be neither null nor empty. + + + A null StrongName was found in the full trust assembly list. + + + The object's type must not be a Windows Runtime type. + + + The object's type must be __ComObject or derived from __ComObject. + + + Offset and capacity were greater than the size of the view. + + + Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection. + + + The UTC Offset of the local dateTime parameter does not match the offset argument. + + + Field passed in is not a marshaled member of the type '{0}'. + + + Offset must be within plus or minus 14 hours. + + + Offset must be specified in whole minutes. + + + The UTC Offset for Utc DateTime instances must be 0. + + + Culture name {0} or {1} is not supported. + + + Only mscorlib's assembly is valid. + + + The DateStart property must come before the DateEnd property. + + + Path cannot be the empty string or all whitespace. + + + The given path's format is not supported. + + + URI formats are not supported. + + + The requested policy file does not exist. + + + 'preAllocated' is already in use. + + + Recursive fallback not allowed for character \\u{0:X4}. + + + Recursive fallback not allowed for bytes {0}. + + + Label multiply defined. + + + UrlMembershipCondition requires an absolute URL. + + + Token {0:x} is not a valid FieldInfo token in the scope of module {1}. + + + Type handle '{0}' and field handle with declaring type '{1}' are incompatible. Get RuntimeFieldHandle and declaring RuntimeTypeHandle off the same FieldInfo. + + + Token {0:x} is not a valid MemberInfo token in the scope of module {1}. + + + Token {0:x} is not a valid MethodBase token in the scope of module {1}. + + + Type handle '{0}' and method handle with declaring type '{1}' are incompatible. Get RuntimeMethodHandle and declaring RuntimeTypeHandle off the same MethodBase. + + + Token {0} resolves to the special module type representing this module. + + + Token {0:x} is not a valid string token in the scope of module {1}. + + + Token {0:x} is not a valid Type token in the scope of module {1}. + + + Resource type in the ResourceScope enum is going from a more restrictive resource type to a more general one. From: "{0}" To: "{1}" + + + The result is out of the supported range for this calendar. The result should be between {0} (Gregorian date) and {1} (Gregorian date), inclusive. + + + The date is out of the supported range for the Islamic calendar. The date should be greater than July 18th, 622 AD (Gregorian date). + + + The specified seek offset '{0}' would result in a negative Stream position. + + + The initial count for the semaphore must be greater than or equal to zero and less than the maximum count. + + + Should not specify exception type for catch clause for filter block. + + + Should only set visibility flags when creating EnumBuilder. + + + Completed signature cannot be modified. + + + Stream was not readable. + + + Stream was not writable. + + + The first char in the string is the null character. + + + String cannot be of zero length. + + + The structure must not be a value class. + + + The TimeSpan parameter cannot be specified more precisely than whole minutes. + + + The tzfile does not begin with the magic characters 'TZif'. Please verify that the file is not corrupt. + + + The TZif data structure is corrupt. + + + fromInclusive must be less than or equal to toExclusive. + + + Exception blocks may have at most one finally clause. + + + The DaylightTransitionStart property must not equal the DaylightTransitionEnd property. + + + Type does not contain the given method. + + + Field in TypedReferences cannot be static or init only. + + + The type must not be a Windows Runtime type. + + + The type must be creatable from COM. + + + The specified type must be visible from COM. + + + The type must not be imported from COM. + + + Type name was too long. The fully qualified type name must be less than 1,024 characters. + + + Type '{0}' does not have an activation factory because it is not activatable by Windows Runtime. + + + The type must be __ComObject or be derived from __ComObject. + + + The Type object is not valid. + + + Unable to generate permission set; input XML may be malformed. + + + Unexpected error while parsing the specified manifest. + + + The IL Generator cannot be used while there are unclosed exceptions. + + + + Supplied MemberInfo does not match the expected type. + + + Unexpected TypeKind when marshaling Windows.Foundation.TypeName. + + + Unknown unmanaged calling convention for function signature. + + + The UnmanagedMemoryAccessor capacity and offset would wrap around the high end of the address space. + + + Local passed in does not belong to this ILGenerator. + + + Non-matching symbol scope. + + + Unrecognized LOADER_OPTIMIZATION property value. Supported values may include "SingleDomain", "MultiDomain", "MultiDomainHost", and "NotSpecified". + + + Identity permissions cannot be unrestricted. + + + The UTC time represented when the offset is applied must be between year 0 and 10,000. + + + The unmanaged Version information is too large to persist. + + + The name can be no more than {0} characters in length. + + + Cannot marshal type '{0}' to Windows Runtime. Only 'System.RuntimeType' is supported. + + + '{0}' element required. + + + Operation on type '{0}' attempted with target of incorrect type. + + + MethodOverride's body must be from this type. + + + The buffer is not associated with this pool and may not be returned to it. + + + The binary form of an ACE object is invalid. + + + The binary form of an ACL object is invalid. + + + The SDDL form of a security descriptor object is invalid. + + + The runtime does not support a version of "{0}" less than {1}. + + + Implementations of all the NLS functions must be provided. + + + Object is not a array with the same number of elements as the array to compare it to. + + + Argument must be of type {0}. + + + The last element of an eight element tuple must be a Tuple. + + + The tuple contains an element of type {0} which does not implement the IComparable interface. + + + Argument must be of type {0}. + + + The last element of an eight element ValueTuple must be a ValueTuple. + + + The application trust cannot be null. + + + Array cannot be null. + + + At least one element in the specified array was null. + + + Found a null value within an array. + + + Assembly cannot be null. + + + AssemblyName cannot be null. + + + AssemblyName.Name cannot be null or an empty string. + + + Buffer cannot be null. + + + Cannot have a null child. + + + Collection cannot be null. + + + CriticalHandle cannot be null. + + + CultureInfo cannot be null. + + + Dictionary cannot be null. + + + File name cannot be null. + + + Value cannot be null. + + + Object Graph cannot be null. + + + GUID cannot be null. + + + Key cannot be null. + + + Member at position {0} was null. + + + Object cannot be null. + + + Path cannot be null. + + + SafeHandle cannot be null. + + + Stream cannot be null. + + + String reference not set to an instance of a String. + + + Type cannot be null. + + + Type in TypedReference cannot be null. + + + The type parameter cannot be null when scoping the resource's visibility to Private or Assembly. + + + The waitHandles parameter cannot be null. + + + Parameter '{0}' cannot be null. + + + Actual value was {0}. + + + The number of bytes cannot exceed the virtual address space on a 32 bit machine. + + + Value to add was out of range. + + + Number was less than the array's lower bound in the first dimension. + + + Higher indices will exceed Int32.MaxValue because of large lower bound and/or length. + + + The length of the array must be between {0} and {1}, inclusive. + + + The length of the array must be a multiple of {0}. + + + Insertion index was out of range. Must be non-negative and less than or equal to size. + + + Destination array is not long enough to copy all the required data. Check array length and offset. + + + Hour, Minute, and Second parameters describe an un-representable DateTime. + + + Year, Month, and Day parameters describe an un-representable DateTime. + + + Console.Beep's frequency must be between {0} and {1}. + + + Larger than collection size. + + + The number of bytes requested does not fit into BinaryReader's internal buffer. + + + Argument must be between {0} and {1}. + + + Specified time is not supported in this calendar. It should be between {0} (Gregorian date) and {1} (Gregorian date), inclusive. + + + Capacity exceeds maximum capacity. + + + The value must be greater than or equal to zero and less than the console's buffer size in that dimension. + + + The console buffer size must not be less than the current size and position of the console window, nor greater than or equal to Int16.MaxValue. + + + Console key values must be between 0 and 255. + + + The console title is too long. + + + The new console window size would force the console buffer size to be too large. + + + The window position must be set such that the current window size fits within the console's buffer, and the numbers must not be negative. + + + The value must be less than the console's current maximum window size of {0} in that dimension. Note that this value depends on screen resolution and the console font. + + + Count must be positive and count must refer to a location within the string/array/collection. + + + The cursor size is invalid. It must be a percentage between 1 and 100. + + + The added or subtracted value results in an un-representable DateTime. + + + Months value must be between +/-120000. + + + Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. + + + Years value must be between +/-10000. + + + Day must be between 1 and {0} for month {1}. + + + The DayOfWeek enumeration must be in the range 0 through 6. + + + The Day parameter must be in the range 1 through 31. + + + Decimal can only round to between 0 and 28 digits of precision. + + + Decimal's scale value must be between 0 and 28, inclusive. + + + endIndex cannot be greater than startIndex. + + + Enum value was out of legal range. + + + Time value was out of era range. + + + Specified file length was too large for the file system. + + + Not a valid Win32 FileTime. + + + Value must be positive. + + + Too many characters. The resulting number of bytes is larger than what can be returned as an int. + + + Too many bytes. The resulting number of chars is larger than what can be returned as an int. + + + Load factor needs to be between 0.1 and 1.0. + + + Arrays larger than 2GB are not supported. + + + Index was out of range. Must be non-negative and less than the size of the collection. + + + Index and count must refer to a location within the string. + + + Index and count must refer to a location within the buffer. + + + This collection cannot work with indices larger than Int32.MaxValue - 1 (0x7FFFFFFF - 1). + + + Index and length must refer to a location within the string. + + + The specified index is outside the current index range of this collection. + + + Index was out of range. Must be non-negative and less than the length of the string. + + + Era value was not valid. + + + A valid high surrogate character is between 0xd800 and 0xdbff, inclusive. + + + A valid low surrogate character is between 0xdc00 and 0xdfff, inclusive. + + + The specified threshold for creating dictionary is out of range. + + + User-defined ACEs must not have a well-known ACE type. + + + A valid UTF32 value is between 0x000000 and 0x10ffff, inclusive, and should not include surrogate codepoint values (0x00d800 ~ 0x00dfff). + + + The specified length exceeds maximum capacity of SecureString. + + + The length cannot be greater than the capacity. + + + The specified length exceeds the maximum value of {0}. + + + Argument must be less than or equal to 2^31 - 1 milliseconds. + + + Index must be within the bounds of the List. + + + The total number of parameters must not exceed {0}. + + + The number of String parameters must not exceed {0}. + + + Month must be between one and twelve. + + + The Month parameter must be in the range 1 through 12. + + + Value must be non-negative and less than or equal to Int32.MaxValue. + + + '{0}' must be non-negative. + + + '{0}' must be greater than zero. + + + Non-negative number required. + + + Number must be either non-negative and less than or equal to Int32.MaxValue or -1. + + + Positive number required. + + + The ID parameter must be in the range {0} through {1}. + + + Capacity must be positive. + + + Count cannot be less than zero. + + + Length cannot be less than zero. + + + Length must be non-negative. + + + objectID cannot be less than or equal to zero. + + + Offset and length must refer to a position in the string. + + + Either offset did not refer to a position in the string, or there is an insufficient length of destination character array. + + + The specified parameter index is not in range. + + + Pointer startIndex and length do not refer to a valid string. + + + Period must be less than 2^32-2. + + + The position may not be greater or equal to the capacity of the accessor. + + + Queue grow factor must be between {0} and {1}. + + + Valid values are between {0} and {1}, inclusive. + + + Rounding digits must be between 0 and 15, inclusive. + + + capacity was less than the current size. + + + MaxCapacity must be one or greater. + + + StartIndex cannot be less than zero. + + + startIndex cannot be larger than length of string. + + + startIndex must be less than length of string. + + + Stream length must be non-negative and less than 2^31 - 1 - origin. + + + Time-out interval must be less than 2^32-2. + + + The length of the buffer must be less than the maximum UIntPtr value for your platform. + + + UnmanagedMemoryStream length must be non-negative and less than 2^63 - 1 - baseAddress. + + + The UnmanagedMemoryStream capacity would wrap around the high end of the address space. + + + The TimeSpan parameter must be within plus or minus 14.0 hours. + + + The sum of the BaseUtcOffset and DaylightDelta properties must within plus or minus 14.0 hours. + + + Version's parameters must be greater than or equal to zero. + + + The Week parameter must be in the range 1 through 5. + + + Year must be between 1 and 9999. + + + Function does not accept floating point Not-a-Number values. + + + Source array type cannot be assigned to destination array type. + + + Array.ConstrainedCopy will only work on array types that are provably compatible, without any form of boxing, unboxing, widening, or casting of each array element. Change the array types (i.e., copy a Derived[] to a Base[]), or use a mitigation strategy in the CER for Array.Copy's less powerful reliability contract, such as cloning the array or throwing away the potentially corrupt destination array. + + + Type '{0}' was loaded in the ReflectionOnly context but the AssemblyBuilder was not created as AssemblyBuilderAccess.ReflectionOnly. + + + Type '{0}' was not loaded in the ReflectionOnly context but the AssemblyBuilder was created as AssemblyBuilderAccess.ReflectionOnly. + + + Assertion failed. + + + Assertion failed: {0} + + + Assumption failed. + + + Assumption failed: {0} + + + The builder was not properly initialized. + + + The awaitable or awaiter was not properly initialized. + + + Bad IL format. + + + Corrupt .resources file. The specified type doesn't exist. + + + Corrupt .resources file. String length must be non-negative. + + + The parameters and the signature of the method don't match. + + + Corrupt .resources file. The specified data length '{0}' is not a valid position in the stream. + + + Corrupt .resources file. A resource name extends past the end of the stream. + + + Corrupt .resources file. The resource name for name index {0} extends past the end of the stream. + + + Corrupt .resources file. Invalid offset '{0}' into data section. + + + Corrupt .resources file. Unable to read resources from this file because of invalid header information. Try regenerating the .resources file. + + + Corrupt .resources file. The resource index '{0}' is outside the valid range. + + + Corrupt .resources file. String for name index '{0}' extends past the end of the file. + + + Corrupt .resources file. Invalid offset '{0}' into name section. + + + Corrupt .resources file. Resource name extends past the end of the file. + + + The type serialized in the .resources file was not the same type that the .resources file said it contained. Expected '{0}' but read '{1}'. + + + Corrupt .resources file. The specified position '{0}' is not a valid position in the stream. + + + Corrupt .resources file. The specified type doesn't match the available data in the stream. + + + No tokens were supplied. + + + The CancellationTokenSource associated with this CancellationToken has been disposed. + + + The CancellationTokenSource has been disposed. + + + The SyncRoot property may not be used for the synchronization of concurrent collections. + + + The array is multidimensional, or the type parameter for the set cannot be cast automatically to the type of the destination array. + + + The index is equal to or greater than the length of the array, or the number of elements in the dictionary is greater than the available space from index to the end of the destination array. + + + The capacity argument must be greater than or equal to zero. + + + The concurrencyLevel argument must be positive. + + + The index argument is less than zero. + + + TKey is a reference type and item.Key is null. + + + The key already existed in the dictionary. + + + The source argument contains duplicate keys. + + + The key was of an incorrect type for this dictionary. + + + The value was of an incorrect type for this dictionary. + + + The count argument must be greater than or equal to zero. + + + The sum of the startIndex and count arguments must be less than or equal to the collection's Count. + + + The startIndex argument must be greater than or equal to zero. + + + The serialization stream contains no elements. + + + Invalid attempt made to decrement the event's count below zero. + + + The increment operation would cause the CurrentCount to overflow. + + + The event is already signaled and cannot be incremented. + + + FlushFinalBlock() method was called twice on a CryptoStream. It can only be called once. + + + Error 0x{0} from the operating system security framework: '{1}'. + + + Error 0x{0} from the operating system security framework. + + + Hash key cannot be changed after the first write to the stream. + + + Hash must be finalized before the hash value is retrieved. + + + Input buffer contains insufficient data. + + + Specified block size is not valid for this algorithm. + + + Specified cipher mode is not valid for this algorithm. + + + Length of the DSA signature was not 40 bytes. + + + {0} is an invalid handle. + + + Specified initialization vector (IV) does not match the block size for this algorithm. + + + Specified key is not a valid size for this algorithm. + + + Object identifier (OID) is unknown. + + + Error occurred while decoding OAEP padding. + + + Salt is not at least eight bytes. + + + The Initialization vector should have the same length as the algorithm block size in bytes. + + + Padding is invalid and cannot be removed. + + + Length of the data to encrypt is invalid. + + + '{0}' is not a known hash algorithm. + + + The certificate export operation failed. + + + Invalid content type. + + + Error occurred while parsing the '{0}' policy level. The default policy level was used instead. + + + Error '{1}' occurred while parsing the '{0}' policy level. The default policy level was used instead. + + + Barrier finishing phase {1}. + + + ConcurrentBag stealing in TryPeek. + + + ConcurrentBag stealing in TryTake. + + + ConcurrentDictionary acquiring all locks on {0} bucket(s). + + + Pop from ConcurrentStack spun {0} time(s). + + + Push to ConcurrentStack spun {0} time(s). + + + Task {1} entering fork/join {2}. + + + Beginning ParallelInvoke {2} from Task {1} for {4} actions. + + + Ending ParallelInvoke {2}. + + + Task {1} leaving fork/join {2}. + + + Beginning {3} loop {2} from Task {1}. + + + Ending loop {2} after {3} iterations. + + + SpinLock beginning to spin. + + + Next spin will yield. + + + Task {2} completed. + + + Task {2} scheduled to TaskScheduler {0}. + + + Task {2} executing. + + + Beginning wait ({3}) on Task {2}. + + + Ending wait on Task {2}. + + + Abstract event source must not declare event methods ({0} with ID {1}). + + + Abstract event source must not declare {0} nested type. + + + Getting out of bounds during scalar addition. + + + Event attribute placed on method {0} which does not return 'void'. + + + Channel {0} does not match event channel value {1}. + + + Data descriptors are out of range. + + + Multiple definitions for string "{0}". + + + The type of {0} is not expected in {1}. + + + The provider has already been registered with the operating system. + + + Channel {0} has a value of {1} which is outside the legal range (16-254). + + + Event {0} has ID {1} which is already in use. + + + Event {0} (with ID {1}) has a non-default opcode but not a task. + + + Event method {0} (with ID {1}) is an explicit interface method implementation. Re-write method as implicit implementation. + + + Event {0} (with ID {1}) has a name that is not the concatenation of its task name and opcode. + + + Event name {0} used more than once. If you wish to overload a method, the overloaded method should have a NonEvent attribute. + + + Event {0} was called with {1} argument(s), but it is defined with {2} parameter(s). + + + An instance of EventSource with Guid {0} already exists. + + + Event {0} specifies an Admin channel {1}. It must specify a Message property. + + + Keyword {0} has a value of {1} which is outside the legal range (0-0x0000080000000000). + + + Opcode {0} has a value of {1} which is outside the legal range (11-238). + + + Task {0} has a value of {1} which is outside the legal range (1-65535). + + + Incorrectly-authored TypeInfo - a type should be serialized as one field or as one group + + + Invalid command value. + + + Can't specify both etw event format flags. + + + Keywords {0} and {1} are defined with the same value ({2}). + + + Value {0} for keyword {1} needs to be a power of 2. + + + Creating an EventListener inside a EventListener callback. + + + Listener not found. + + + An error occurred when writing to a listener. + + + Attempt to define more than the maximum limit of 8 channels for a provider. + + + Event {0} is givien event ID {1} but {2} was passed to WriteEvent. + + + The Guid of an EventSource must be non zero. + + + The name of an EventSource must not be null. + + + Event IDs must be positive integers. + + + No Free Buffers available from the operating system (e.g. event rate too fast). + + + The API supports only anonymous types or types decorated with the EventDataAttribute. Non-compliant type: {0} dataType. + + + EventSource expects the first parameter of the Event method to be of type Guid and to be named "relatedActivityId" when calling WriteEventWithRelatedActivityId. + + + Arrays of Binary are not supported. + + + Arrays of Nil are not supported. + + + Arrays of null-terminated string are not supported. + + + Enumerables of custom-serialized data are not supported + + + Enum type {0} underlying type {1} is not supported for serialization. + + + Nested arrays/enumerables are not supported. + + + Null passed as a event argument. + + + Opcodes {0} and {1} are defined with the same value ({2}). + + + The payload for a single event is too large. + + + Period character ('.') is illegal in an ETW provider name ({0}). + + + Pins are out of range. + + + Recursive type definition is not supported. + + + Keywords values larger than 0x0000100000000000 are reserved for system use + + + Opcode values less than 11 are reserved for system use. + + + Bit position in AllKeywords ({0}) must equal the command argument named "EtwSessionKeyword" ({1}). + + + An event with stop suffix must follow a corresponding event with a start suffix. + + + Tasks {0} and {1} are defined with the same value ({2}). + + + Event {0} (with ID {1}) has the same task/opcode pair as event {2} (with ID {3}). + + + Too many arguments. + + + Too many fields in structure. + + + EventSource({0}, {1}) + + + Event source types must be sealed or abstract. + + + Event source types must derive from EventSource. + + + Use of undefined channel value {0} for event {1}. + + + Use of undefined keyword value {0} for event {1}. + + + Use of undefined opcode value {0} for event {1}. + + + Unsupported type {0} in event source. + + + Event {0} specifies an illegal or unsupported formatting message ("{1}"). + + + The parameters to the Event method do not match the parameters to the WriteEvent method. This may cause the event to be displayed incorrectly. + + + --- End of inner exception stack trace --- + + + --- End of stack trace from previous location where exception was thrown --- + + + Exception of type '{0}' was thrown. + + + An exception was not handled in an AsyncLocal<T> notification callback. + + + Undo operation on a component context threw an exception + + + Attribute cannot have multiple definitions. + + + Unable to retrieve security descriptor for this frame. + + + InitOnly (aka ReadOnly) fields can only be initialized in the type/instance constructor. + + + Could not resolve assembly '{0}'. + + + File operation not permitted. Access to path '{0}' is denied. + + + Duplicate AttributeUsageAttribute found on attribute type {0}. + + + Too many bytes in what should have been a 7 bit encoded Int32. + + + Invalid digits for the specified base. + + + The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. + + + Invalid length for a Base-64 char array or string. + + + String was not recognized as a valid Boolean. + + + Could not determine the order of year, month, and date from '{0}'. + + + String was not recognized as a valid DateTime. + + + The DateTime represented by the string is not supported in calendar {0}. + + + String was not recognized as a valid DateTime because the day of week was incorrect. + + + Format specifier was invalid. + + + Cannot find a matching quote character for the character '{0}'. + + + String was not recognized as a valid TimeSpan. + + + The DateTime represented by the string is out of range. + + + Input string was either empty or contained only whitespace. + + + Additional non-parsable characters are at the end of the string. + + + Expected {0xdddddddd, etc}. + + + Could not find a brace, or the length between the previous token and the brace was zero (i.e., '0x,'etc.). + + + Could not find a comma, or the length between the previous token and the comma was zero (i.e., '0x,'etc.). + + + Dashes are in the wrong position for GUID parsing. + + + Could not find the ending brace. + + + Expected hex 0x in '{0}'. + + + Guid string should only contain hexadecimal characters. + + + Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). + + + Unrecognized Guid format. + + + Index (zero based) must be greater than or equal to zero and less than the size of the argument list. + + + Format String can be only "G", "g", "X", "x", "F", "f", "D" or "d". + + + Format String can be only "D", "d", "N", "n", "P", "p", "B", "b", "X" or "x". + + + Input string was not in a correct format. + + + There must be at least a partial date with a year present in the input. + + + String must be exactly one character long. + + + Could not find any recognizable digits. + + + The time zone offset must be within plus or minus 14 hours. + + + DateTime pattern '{0}' appears more than once with different values. + + + String cannot have zero length. + + + The String being parsed cannot contain two TimeZone specifiers. + + + The string was not recognized as a valid DateTime. There is an unknown word starting at index {0}. + + + The UTC representation of the date falls outside the year range 1-9999. + + + GAC + + + Unicode + + + Unicode (UTF-32) + + + Unicode (UTF-32 Big-Endian) + + + Unicode (Big-Endian) + + + US-ASCII + + + Western European (ISO) + + + Unicode (UTF-7) + + + Unicode (UTF-8) + + + Hash - {0} = {1} + + + The demanded resources were: + + + Attempted to perform an operation that was forbidden by the CLR host. + + + The protected resources (only available with full trust) were: + + + Array does not have that many dimensions. + + + Probable I/O race condition detected while copying memory. The I/O package is not thread safe by default. In multithreaded applications, a stream must be accessed in a thread-safe way, such as a thread-safe wrapper returned by TextReader's or TextWriter's Synchronized methods. This also applies to classes like StreamWriter and StreamReader. + + + Unmanaged memory stream position was beyond the capacity of the stream. + + + Insufficient available memory to meet the expected demands of an operation at this time. Please try again later. + + + Insufficient memory to meet the expected demands of an operation, and this system is likely to never satisfy this request. If this is a 32 bit system, consider booting in 3 GB mode. + + + Insufficient available memory to meet the expected demands of an operation at this time, possibly due to virtual address space fragmentation. Please try again later. + + + Type mismatch between source and destination types. + + + Cannot marshal: Encountered unmappable character. + + + Null object cannot be converted to a value type. + + + Object cannot be coerced to the original type of the ByRef VARIANT it was obtained from. + + + Object cannot be cast to DBNull. + + + At least one element in the source array could not be cast down to the destination array type. + + + Object cannot be cast to Empty. + + + Object cannot be cast from DBNull to other types. + + + Invalid cast from '{0}' to '{1}'. + + + Object must implement IConvertible. + + + OleAut reported a type mismatch. + + + Object cannot be stored in an array of this type. + + + Object in an IPropertyValue is of type '{0}' which cannot be convereted to a '{1}' due to array element '{2}': {3}. + + + Object in an IPropertyValue is of type '{0}' with value '{1}', which cannot be converted to a '{2}'. + + + Object in an IPropertyValue is of type '{0}', which cannot be converted to a '{1}'. + + + The activation arguments and application trust for the AppDomain must correspond to the same application identity. + + + Attempted to add properties to a frozen context. + + + An anonymous identity cannot perform an impersonation. + + + Failed to set the specified COM apartment state. + + + The API '{0}' cannot be used on the current platform. See http://go.microsoft.com/fwlink/?LinkId=248273 for more information. + + + This API requires the ApplicationBase to be specified explicitly in the AppDomainSetup parameter. + + + Assembly has been loaded as ReflectionOnly. This API requires an assembly capable of execution. + + + Assembly '{0}' has been saved. + + + Cannot perform CAS Asserts in Security Transparent methods + + + AsyncFlowControl objects can be used to restore flow only on a Context that had its flow suppressed. + + + The stream is currently in use by a previous operation on the stream. + + + Method '{0}' does not have a method body. + + + ILGenerator usage is invalid. + + + MSIL instruction is invalid or index is out of bounds. + + + Interface must be declared abstract. + + + Method '{0}' cannot have a method body. + + + Unable to add resource to transient module or transient assembly. + + + Unable to make a reference to a transient module from a non-transient module. + + + Type must be declared abstract if any of its methods are abstract. + + + The method cannot be called twice on the same instance. + + + Unable to alter assembly information. + + + Only newly captured contexts can be copied + + + + Unable to import a global method or field from a different module. + + + Must override both HostExecutionContextManager.SetHostExecutionContext and HostExecutionContextManager.Revert. + + + Removal is an invalid operation for Stack or Queue. + + + Cannot remove the last element from an empty collection. + + + Cannot restore context flow when it is not suppressed. + + + Context flow is already suppressed. + + + AsyncFlowControl object can be used only once to call Undo(). + + + AsyncFlowControl object must be used on the thread where it was created. + + + Undo operation must be performed on the thread where the corresponding context was Set. + + + Applications may not prevent control-break from terminating their process. + + + Instances of abstract classes cannot be created. + + + Instances of function pointers cannot be created. + + + Cannot save a transient assembly. + + + The Claim '{0}' was not able to be removed. It is either not part of this Identity or it is a claim that is owned by the Principal that contains this Identity. For example, the Principal will own the claim when creating a GenericPrincipal with roles. The roles will be exposed through the Identity that is passed in the constructor, but not actually owned by the Identity. Similar logic exists for a RolePrincipal. + + + The collection backing this Dictionary contains too many elements. + + + The collection backing this List contains too many elements. + + + A prior operation on this collection was interrupted by an exception. Collection's state is no longer trusted. + + + Computer name could not be obtained. + + + Cannot see if a key has been pressed when either application does not have a console or when console input has been redirected from a file. Try Console.In.Peek. + + + Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read. + + + Interface cannot have constructors. + + + Context is already frozen. + + + SecurityTransparent and SecurityCritical attributes cannot be applied to the assembly scope at the same time. + + + Internal Error in DateTime and Calendar operations. + + + Debugger unable to launch. + + + The method body of the default constructor cannot be changed. + + + Unable to access ILGenerator on a constructor created with DefineDefaultConstructor. + + + Another property by this name already exists. + + + Queue empty. + + + Stack empty. + + + EndInvoke can only be called once for each asynchronous operation. + + + EndRead can only be called once for each asynchronous operation. + + + EndWrite can only be called once for each asynchronous operation. + + + Entry method is not defined in the same assembly. + + + Enumeration already finished. + + + Collection was modified; enumeration operation may not execute. + + + Enumeration has not started. Call MoveNext. + + + Enumeration has either not started or has already finished. + + + This API does not support EventInfo tokens. + + + Type '{0}' is not a delegate type. EventTokenTable may only be used with delegate types. + + + Thread.ExceptionState cannot access an ExceptionState from a different AppDomain. + + + The generic parameters are already defined on this MethodBuilder. + + + OSVersion's call to GetVersionEx failed. + + + Type definition of the global function has been completed. + + + Handle is not initialized. + + + Handle is not pinned. + + + Hashtable insert failed. Load factor too high. The most common cause is multiple threads writing to the Hashtable simultaneously. + + + The security state of an AppDomain was modified by an AppDomainManager configured with the NoSecurityChanges flag. + + + Failed to compare two elements in the array. + + + Invalid internal state. + + + COM register function must have a System.Type parameter and a void return type. + + + COM unregister function must have a System.Type parameter and a void return type. + + + Metadata operation failed. + + + This method is not supported by the current object. + + + Type definition of the method is complete. + + + The signature of the MethodBuilder can no longer be modified because an operation on the MethodBuilder caused the methodDef token to be created. For example, a call to SetCustomAttribute requires the methodDef token to emit the CustomAttribute token. + + + Method already has a body. + + + The IAsyncResult object provided does not match this delegate. + + + This access control list is not in canonical form and therefore cannot be modified. + + + Unable to modify a read-only NumberFormatInfo object. + + + Module '{0}' has been saved. + + + Type '{0}' has more than one COM registration function. + + + Type '{0}' has more than one COM unregistration function. + + + This operation must take place on the same thread on which the object was created. + + + You must call Initialize on this object instance before using it. + + + Object must be locked for read or write. + + + Object must be locked for read. + + + Must revert the privilege prior to attempting this operation. + + + NativeOverlapped cannot be reused for multiple operations. + + + Assembly does not have a code base. + + + Assembly does not have an assembly name. In order to be registered for use by COM, an assembly must have a valid assembly name. + + + You cannot have more than one dynamic module in each dynamic assembly in this version of the runtime. + + + COM register function must be static. + + + COM unregister function must be static. + + + Cannot add the event handler since no public add method exists for the event. + + + Cannot remove the event handler since no public remove method exists for the event. + + + The object does not contain a security descriptor. + + + Not a debug ModuleBuilder. + + + The requested operation is invalid for DynamicMethod. + + + The requested operation is invalid in the ReflectionOnly context. + + + Calling convention must be VarArgs. + + + You can only define a dynamic assembly on the current AppDomain. + + + This operation is only valid on generic types. + + + Cannot apply a context that has been marshaled across AppDomains, that was not acquired through a Capture operation or that has already been the argument to a Set call. + + + Adding or removing event handlers dynamically is not supported on WinRT events. + + + This API is not available when the concurrent GC is enabled. + + + Underlying type information on enumeration is not specified. + + + Nullable object must have a value. + + + The underlying array is null. + + + Cannot call Set on a null context + + + The requested operation is invalid when called on a null ModuleHandle. + + + Adding ACEs with Object Flags and Object GUIDs is only valid for directory-object ACLs. + + + Local variable scope was not properly closed. + + + Cannot pack a packed Overlapped again. + + + Primary interop assemblies must be strongly named. + + + This API does not support PropertyInfo tokens. + + + Instance is read-only. + + + Registry key has subkeys and recursive removes are not supported by this method. + + + '{0}': ResourceSet derived classes must provide a constructor that takes a String file name and a constructor that takes a Stream. + + + Resource '{0}' was not a Stream - call GetObject instead. + + + Resource '{0}' was not a String - call GetObject instead. + + + Resource was of type '{0}' instead of String - call GetObject instead. + + + The resource writer has already been closed and cannot be edited. + + + An additional permission should not be supplied for setting loader information. + + + SetData cannot be used to set the value for '{0}'. + + + SetData can only be used to set the value of a given name once. + + + Volume labels can only be set for writable local volumes. + + + Method body should not exist. + + + LocalDataStoreSlot storage has been freed. + + + A strong name key pair is required to emit a strong-named dynamic assembly. + + + The Undo operation encountered a context that is different from what was applied in the corresponding Set operation. The possible cause is that a context was Set on the thread and not reverted(undone). + + + Use CompressedStack.(Capture/Run) or ExecutionContext.(Capture/Run) APIs instead. + + + The thread was created with a ThreadStart delegate that does not accept a parameter. + + + Timeouts are not supported on this stream. + + + The given type cannot be boxed. + + + Unable to change after type has been created. + + + Type has not been created. + + + This range in the underlying list is invalid. A possible cause is that elements were removed. + + + Unexpected error when calling an operating system function. The returned error code is 0x{0:x}. + + + Unknown enum type. + + + UserDomainName native call failed. + + + Cannot wait on a transparent proxy. + + + This API is not available when AppDomain Resource Monitoring is not turned on. + + + This property has already been set and cannot be modified. + + + Either the IAsyncResult object did not come from the corresponding async method on this type, or the End method was called multiple times with the same IAsyncResult. + + + Either the IAsyncResult object did not come from the corresponding async method on this type, or EndRead was called multiple times with the same IAsyncResult. + + + Either the IAsyncResult object did not come from the corresponding async method on this type, or EndWrite was called multiple times with the same IAsyncResult. + + + Actor cannot be set so that circular directed graph will exist chaining the subjects together. + + + Common Language Runtime detected an invalid program. + + + The time zone ID '{0}' was found on the local computer, but the file at '{1}' was corrupt. + + + The time zone ID '{0}' was found on the local computer, but the registry information was corrupt. + + + The Local time zone was found on the local computer, but the data was corrupt. + + + Julian dates in POSIX strings are unsupported. + + + There are no ttinfo structures in the tzfile. At least one ttinfo structure is required in order to construct a TimeZoneInfo object. + + + '{0}' is not a valid POSIX-TZ-environment-variable MDate rule. A valid rule has the format 'Mm.w.d'. + + + Invariant failed. + + + Invariant failed: {0} + + + Could not find the drive '{0}'. The drive might not be ready or might not be mapped. + + + Unable to read beyond the end of the stream. + + + Could not load the specified file. + + + File name: '{0}' + + + Unable to find the specified file. + + + Could not find file '{0}'. + + + Cannot create "{0}" because a file or directory with the same name already exists. + + + BindHandle for ThreadPool failed on this handle. + + + The specified directory '{0}' cannot be created. + + + The file '{0}' already exists. + + + The OS handle's position is not what FileStream expected. Do not use a handle simultaneously in one FileStream and in Win32 code or another FileStream. This may cause data loss. + + + The file is too long. This operation is currently limited to supporting files less than 2 gigabytes in size. + + + IO operation will not work. Most likely the file will become too long or the handle was not opened to support synchronous IO operations. + + + Unable to expand length of this stream beyond its capacity. + + + BinaryReader encountered an invalid string length of {0} characters. + + + There is no console. + + + <Path discovery permission to the specified directory was denied.> + + + Unable seek backward to overwrite data that previously existed in a file opened in Append mode. + + + An attempt was made to move the position before the beginning of the stream. + + + Unable to truncate data that previously existed in a file opened in Append mode. + + + The process cannot access the file '{0}' because it is being used by another process. + + + The process cannot access the file because it is being used by another process. + + + Source and destination path must be different. + + + Source and destination path must have identical roots. Move will not work across volumes. + + + Stream was too long. + + + Could not find a part of the path. + + + Could not find a part of the path '{0}'. + + + The specified file name or path is too long, or a component of the specified path is too long. + + + A StreamWriter was not closed and all buffered data within that StreamWriter was not flushed to the underlying stream. (This was detected when the StreamWriter was finalized with data in its buffer.) A portion of the data was lost. Consider one of calling Close(), Flush(), setting the StreamWriter's AutoFlush property to true, or allocating the StreamWriter with a "using" statement. Stream type: {0}\r\nFile name: {1}\r\nAllocated from:\r\n {2} + + + callstack information is not captured by default for performance reasons. Please enable captureAllocatedCallStack config switch for streamWriterBufferedDataLost MDA (refer to MSDN MDA documentation for how to do this). + + + [Unknown] + + + The lazily-initialized type does not have a public, parameterless constructor. + + + The Value cannot be null. + + + The info argument is null. + + + The mode argument specifies an invalid value. + + + The valueSelector argument is null. + + + ValueFactory returned null. + + + Value is not created. + + + ValueFactory attempted to access the Value property of this instance. + + + Context Policies: + + + Relative path must be a string that contains the substring, "..", or does not contain a root directory. + + + Name: + + + There are no context policies. + + + {0} of .NET Framework assemblies is not supported in AppX. + + + The spinCount argument must be in the range 0 to {0}, inclusive. + + + There are too many threads currently waiting on the event. A maximum of {0} waiting threads are supported. + + + The event has been disposed. + + + Marshaler restriction: Excessively long string. + + + Constructor on type '{0}' not found. + + + Field not found. + + + Field '{0}' not found. + + + Could not find a manifest resource entry called "{0}" in assembly "{1}". Please check spelling, capitalization, and build rules to ensure "{0}" is being linked into the assembly. + + + A case-insensitive lookup for resource file "{0}" in assembly "{1}" found multiple entries. Remove the duplicates or specify the exact case. + + + Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "{0}" was correctly embedded or linked into assembly "{1}" at compile time, or that all the satellite assemblies required are loadable and fully signed. + + + Could not find any resources appropriate for the specified culture (or the neutral culture) on disk. + + + Unable to open Package Resource Index. + + + Unable to load resources for resource file "{0}" in package "{1}". + + + Member not found. + + + Member '{0}' not found. + + + TypedReference can only be made on nested value Types. + + + FieldInfo does not match the target Type. + + + Method '{0}' not found. + + + Module '{0}' not found. + + + The satellite assembly named "{1}" for fallback culture "{0}" either could not be found or could not be loaded. This is generally a setup problem. Please consider reinstalling or repairing the application. + + + Resource lookup fell back to the ultimate fallback resources in a satellite assembly, but that satellite either was not found or could not be loaded. Please consider reinstalling or repairing the application. + + + Type '{0}' not found. + + + Delegates that are not of type MulticastDelegate may not be combined. + + + An assembly (probably "{1}") must be rewritten using the code contracts binary rewriter (CCRewrite) because it is calling Contract.{0} and the CONTRACTS_FULL symbol is defined. Remove any explicit definitions of the CONTRACTS_FULL symbol from your project and rebuild. CCRewrite can be downloaded from http://go.microsoft.com/fwlink/?LinkID=169180. \r\nAfter the rewriter is installed, it can be enabled in Visual Studio from the project's Properties page on the Code Contracts pane. Ensure that "Perform Runtime Contract Checking" is enabled, which will define CONTRACTS_FULL. + + + [{0}]\r\nArguments: {1}\r\nDebugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663AndVersion={2}AndFile={3}AndKey={4} + + + Resource files longer than 2^63 bytes are not currently implemented. + + + This non-CLS method is not implemented. + + + Activation Attributes are not supported. + + + Activation Attributes are not supported for types not deriving from MarshalByRefObject. + + + Activation Attributes not supported for COM Objects. + + + The operation is ambiguous because the permission represents multiple identities. + + + {0} is not supported in AppX. + + + Assembly.Load with a Codebase is not supported. + + + Assembly.LoadFrom with hashValue is not supported. + + + Cannot create boxed ByRef-like values. + + + Cannot create arrays of ByRef-like values. + + + ByRef return value not supported in reflection invocation. + + + Vararg calling convention not supported. + + + Equals() on Span and ReadOnlySpan is not supported. Use operator== instead. + + + GetHashCode() on Span and ReadOnlySpan is not supported. + + + Unable to save a ModuleBuilder if it was created underneath an AssemblyBuilder. Call Save on the AssemblyBuilder instead. + + + Cannot write to a BufferedStream while the read buffer is not empty if the underlying stream is not seekable. Ensure that the stream underlying this BufferedStream can seek or avoid interleaving read and write operations on this BufferedStream. + + + ChangeType operation is not supported. + + + The ISO-2022-CN Encoding (Code page 50229) is not supported. + + + Resolving to a collectible assembly is not supported. + + + A non-collectible assembly may not reference a collectible assembly. + + + COM Interop is not supported for collectible types. + + + Delegate marshaling for types within collectible assemblies is not supported. + + + Object cannot be created through this constructor. + + + CreateInstance cannot be used with an object of type TypeBuilder. + + + Only one DBNull instance may exist, and calls to DBNull deserialization methods are not allowed. + + + Declarative unionizing of these permissions is not supported. + + + Assert, Deny, and PermitOnly are not supported on methods with a Vararg calling convention. + + + Application code cannot use Activator.CreateInstance to create types that derive from System.Delegate. Delegate.CreateDelegate can be used instead. + + + Delegates cannot be marshaled from native code into a domain other than their home domain. + + + DelegateSerializationHolder objects are designed to represent a delegate during serialization and are not serializable themselves. + + + The invoked member is not supported in a dynamic assembly. + + + Cannot execute code on a dynamic assembly without run access. + + + Wrong MethodAttributes or CallingConventions for DynamicMethod. Only public, static, standard supported + + + The invoked member is not supported in a dynamic module. + + + File encryption support only works on NTFS partitions. + + + FileStream was asked to open a device that was not a file. For support for devices like 'com1:' or 'lpt1:', call CreateFile, then use the FileStream constructors that take an OS handle as an IntPtr. + + + Collection was of a fixed size. + + + Generic methods with NativeCallableAttribute are not supported. + + + The 'get' method is not supported on this property. + + + The type definition of the global function is not completed. + + + Serialization of global methods (including implicit serialization via the use of asynchronous delegates) is not supported. + + + Invoking default method with named arguments is not supported. + + + Illegal one-byte branch at position: {0}. Requested branch was: {1}. + + + A type must implement IComparable<T> or IComparable to support comparison. + + + Mutating a key collection derived from a dictionary is not allowed. + + + Cannot create uninitialized instances of types requiring managed activation. + + + The arithmetic type '{0}' does not have a maximum value. + + + The number of WaitHandles must be less than or equal to 64. + + + Memory stream is not expandable. + + + Method is not supported. + + + The arithmetic type '{0}' does not have a minimum value. + + + Module argument must be a ModuleBuilder. + + + Methods with NativeCallableAttribute cannot be used as delegate target. + + + The arithmetic type '{0}' cannot represent negative infinity. + + + No data is available for encoding {0}. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. + + + Non-blittable parameter types are not supported for NativeCallable methods. + + + Not supported in a non-reflected type. + + + Non-static methods with NativeCallableAttribute are not supported. + + + UrlAttribute is the only attribute supported for MarshalByRefObject. + + + Parent does not have a default constructor. The default constructor must be explicitly defined. + + + Type '{0}' was not completed. + + + The MethodRental.SwapMethodBody method can only be called to swap the method body of a method in a dynamic module. + + + Cannot resolve {0} to a TypeInfo object. + + + This feature is not currently implemented. + + + Found an obsolete .resources file in assembly '{0}'. Rebuild that .resources file then rebuild that assembly. + + + The given Variant type is not supported by this OleAut function. + + + The arithmetic type '{0}' cannot represent the number one. + + + Cannot create arrays of open type. + + + Output streams do not support TypeBuilders. + + + A Primary Interop Assembly is not supported in AppX. + + + This Surrogate does not support PopulateData(). + + + The arithmetic type '{0}' cannot represent positive infinity. + + + The specified operation is not supported on Ranges. + + + Accessor does not support reading. + + + Collection is read-only. + + + Type.ReflectionOnlyGetType is not supported. + + + Assembly.ReflectionOnlyLoad is not supported. + + + Cannot read resources that depend on serialization. + + + Union is not implemented. + + + The 'set' method is not supported on this property. + + + SignalAndWait on a STA thread is not supported. + + + This operation is not supported on SortedList nested types because they require modifying the original SortedList. + + + The string comparison type passed in is currently not supported. + + + Derived classes must provide an implementation. + + + Not supported in an array method of a type definition that is not complete. + + + Stack size too deep. Possibly too many arguments. + + + Type is not supported. + + + Direct deserialization of type '{0}' is not supported. + + + The invoked member is not supported before the type is created. + + + This operation is not supported for an UnmanagedMemoryStream created from a SafeBuffer. + + + The UnitySerializationHolder object is designed to transmit information about other types and is not serializable itself. + + + TypeCode '{0}' was not valid. + + + Stream does not support reading. + + + This accessor was created with a SafeBuffer; use the SafeBuffer to gain access to the pointer. + + + Stream does not support seeking. + + + Stream does not support writing. + + + COM Interop is not supported for user-defined types. + + + DllImport cannot be used on user-defined methods. + + + Custom marshalers for value types are not currently supported. + + + Mutating a value collection derived from a dictionary is not allowed. + + + Arrays of System.Void are not supported. + + + WaitAll for multiple handles on a STA thread is not supported. + + + Windows Runtime is not supported in partial trust. + + + Accessor does not support writing. + + + This .resources file should not be read with this reader. The resource reader type is "{0}". + + + The arithmetic type '{0}' cannot represent the number zero. + + + The pointer for this method was null. + + + Cannot access a closed file. + + + Cannot access a disposed object. + + + Object name: '{0}'. + + + Cannot read from a closed TextReader. + + + Cannot access a closed registry key. + + + Cannot access a closed resource set. + + + Cannot access a closed Stream. + + + Cannot access a closed accessor. + + + Cannot write to a closed TextWriter. + + + The operation was canceled. + + + GetPartitions returned an incorrect number of partitions. + + + The GCHandle MDA has run out of available cookies. + + + Value was either too large or too small for an unsigned byte. + + + Value was either too large or too small for a character. + + + Value was either too large or too small for a Currency. + + + Value was either too large or too small for a Decimal. + + + Value was either too large or too small for a Double. + + + The duration cannot be returned for TimeSpan.MinValue because the absolute value of TimeSpan.MinValue exceeds the value of TimeSpan.MaxValue. + + + Value was either too large or too small for an Int16. + + + Value was either too large or too small for an Int32. + + + Value was either too large or too small for an Int64. + + + Negating the minimum value of a twos complement number is invalid. + + + The string was being parsed as an unsigned number and could not have a negative sign. + + + Value was either too large or too small for a signed byte. + + + Value was either too large or too small for a Single. + + + The TimeSpan could not be parsed because at least one of the numeric components is out of range or contains too many digits. + + + TimeSpan overflowed because the duration is too long. + + + Value was either too large or too small for a UInt16. + + + Value was either too large or too small for a UInt32. + + + Value was either too large or too small for a UInt64. + + + The Partitioner source returned a null enumerator. + + + This method requires the use of an OrderedPartitioner with the KeysNormalized property set to true. + + + The Partitioner used here must support dynamic partitioning. + + + The Partitioner used here returned a null partitioner source. + + + One of the actions was null. + + + Break was called after Stop was called. + + + This method is not supported. + + + Stop was called after Break was called. + + + Dynamic partitions are not supported by this partitioner. + + + Can not call GetEnumerator on partitions after the source enumerable is disposed + + + MoveNext must be called at least once before calling Current. + + + The named version of this synchronization primitive is not supported on this platform. + + + Wait operations on multiple wait handles including a named synchronization primitive are not supported on this platform. + + + Locking/unlocking file regions is not supported on this platform. Use FileShare on the entire file instead. + + + ReflectionOnly loading is not supported on this platform. + + + This operation is only supported on Windows Vista and above. + + + This operation is only supported on Windows 2000, Windows XP, and higher. + + + This operation is only supported on Windows 2000 SP3 or later operating systems. + + + Windows Runtime is not supported on this operating system. + + + ApplicationTrust grant set does not contain ActivationContext's minimum request set. + + + All assemblies loaded as part of AppDomain initialization must be fully trusted. + + + Error occurred while performing a policy operation. + + + PolicyLevel object not based on a file cannot be saved. + + + Postcondition failed. + + + Postcondition failed: {0} + + + Postcondition failed after throwing an exception. + + + Postcondition failed after throwing an exception: {0} + + + Precondition failed. + + + Precondition failed: {0} + + + The process does not possess some privilege required for this operation. + + + The process does not possess the '{0}' privilege which is required for this operation. + + + Publisher + + + Only single dimension arrays are supported here. + + + The specified arrays must have the same number of dimensions. + + + Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. + + + The target application domain has been unloaded. + + + The application domain in which the thread was running has been unloaded. + + + Pointer types cannot be passed in a remote call. + + + The delegate must have only one target. + + + The context is not valid. + + + An attempt was made to calculate the address of a value type field on a remote object. This was likely caused by an attempt to directly get or set the value of a field within this embedded value type. Avoid this and instead provide and use access methods for each field in the object that will be accessed remotely. + + + Bad return value or out-argument inside the return message. + + + Permission denied: cannot call non-public or static methods remotely. + + + classToProxy argument must derive from MarshalByRef type. + + + The transparent proxy field of a real proxy must be null. + + + The given type cannot be passed in a remote call. + + + ResourceReader is closed. + + + Stream is not a valid resource file. + + + Multiple custom attributes of the same type found. + + + Ambiguous match found. + + + An Int32 must be provided for the filter criteria. + + + A String must be provided for the filter criteria. + + + '{0}' field specified was not found. + + + '{0}' property specified was not found. + + + Object does not match target type. + + + Non-static field requires a target. + + + Non-static method requires a target. + + + Caller is not a friend. + + + An object that does not derive from System.Exception has been wrapped in a RuntimeWrappedException. + + + The time zone ID '{0}' was found on the local computer, but the application does not have permission to read the file. + + + The time zone ID '{0}' was found on the local computer, but the application does not have permission to read the registry information. + + + Request for the permission of type '{0}' failed. + + + Request failed. + + + Stack walk modifier must be reverted before another modification of the same type can be performed. + + + + That assembly does not allow partially trusted callers. + + + Requested registry access is not allowed. + + + The initialCount argument must be non-negative and less than or equal to the maximumCount. + + + The maximumCount argument must be a positive number. If a maximum is not required, use the constructor without a maxCount parameter. + + + The semaphore has been disposed. + + + The releaseCount argument must be greater than zero. + + + The timeout must represent a value between -1 and Int32.MaxValue, inclusive. + + + Non existent ParameterInfo. Position bigger than member's parameters length. + + + The value of the field '{0}' is invalid. The serialized data is corrupt. + + + Invalid serialized DateTime data. Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. + + + Insufficient state to deserialize the object. Missing field '{0}'. More information is needed. + + + Insufficient state to return the real object. + + + An error occurred while deserializing the object. The serialized data is corrupt. + + + Cannot serialize delegates over unmanaged function pointers, dynamic methods or methods outside the delegate creator's assembly. + + + The serialized data contained an invalid escape sequence '\\{0}'. + + + Object fields may not be properly initialized. + + + OnDeserialization method was called while the object was not being deserialized. + + + An IntPtr or UIntPtr with an eight byte value cannot be deserialized on a machine with a four byte word size. + + + Only system-provided types can be passed to the GetUninitializedObject method. '{0}' is not a valid instance of a type. + + + The keys and values arrays have different sizes. + + + The deserialized value of the member "{0}" in the class "{1}" is out of range. + + + Unknown member type. + + + Field {0} is missing. + + + Invalid serialized DateTime data. Unable to find 'ticks' or 'dateData'. + + + The Keys for this Hashtable are missing. + + + The values for this dictionary are missing. + + + Type '{0}' in Assembly '{1}' is not marked as serializable. + + + Serialized member does not have a ParameterInfo. + + + Member '{0}' was not found. + + + One of the serialized keys is null. + + + The method signature cannot be null. + + + Version value must be positive. + + + Cannot add the same member twice to a SerializationInfo object. + + + The serialized Capacity property of StringBuilder must be positive, less than or equal to MaxCapacity and greater than or equal to the String length. + + + The serialized MaxCapacity property of StringBuilder must be positive and greater than or equal to the String length. + + + The given module {0} cannot be found within the assembly {1}. + + + Cannot get the member '{0}'. + + + Site + + + The calling thread does not hold the lock. + + + Thread tracking is disabled. + + + The timeout must be a value between -1 and Int32.MaxValue, inclusive. + + + The calling thread already holds the lock. + + + The tookLock argument must be set to false before calling this method. + + + The condition argument is null. + + + The timeout must represent a value between -1 and Int32.MaxValue, inclusive. + + + in {0}:line {1} + + + name = {0} + + + StrongName - {0}{1}{2} + + + version = {0} + + + The specified TaskContinuationOptions combined LongRunning and ExecuteSynchronously. Synchronous continuations should not be long running. + + + The specified TaskContinuationOptions excluded all continuation kinds. + + + (Internal)An attempt was made to create a LongRunning SelfReplicating task. + + + The value needs to translate in milliseconds to -1 (signifying an infinite timeout), 0 or a positive integer less than or equal to Int32.MaxValue. + + + The value needs to be either -1 (signifying an infinite timeout), 0 or a positive integer. + + + A task may only be disposed if it is in a completion state (RanToCompletion, Faulted or Canceled). + + + It is invalid to specify TaskCreationOptions.LongRunning in calls to FromAsync. + + + It is invalid to specify TaskCreationOptions.PreferFairness in calls to FromAsync. + + + It is invalid to specify TaskCreationOptions.SelfReplicating in calls to FromAsync. + + + FromAsync was called with a TaskManager that had already shut down. + + + The tasks argument contains no tasks. + + + It is invalid to exclude specific continuation kinds for continuations off of multiple tasks. + + + The tasks argument included a null value. + + + RunSynchronously may not be called on a task that was already started. + + + RunSynchronously may not be called on a continuation task. + + + RunSynchronously may not be called on a task not bound to a delegate, such as the task returned from an asynchronous method. + + + RunSynchronously may not be called on a task that has already completed. + + + Start may not be called on a task that was already started. + + + Start may not be called on a continuation task. + + + Start may not be called on a promise-style task. + + + Start may not be called on a task that has completed. + + + The task has been disposed. + + + The tasks array included at least one null element. + + + The awaited task has not yet completed. + + + A task was canceled. + + + The exceptions collection was empty. + + + The exceptions collection included at least one null element. + + + A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. + + + (Internal)Expected an Exception or an IEnumerable<Exception> + + + ExecuteTask may not be called for a task which was already executed. + + + ExecuteTask may not be called for a task which was previously queued to a different TaskScheduler. + + + The current SynchronizationContext may not be used as a TaskScheduler. + + + The TryExecuteTaskInline call to the underlying scheduler succeeded, but the task body was not invoked. + + + An exception was thrown by a TaskScheduler. + + + It is invalid to specify TaskCreationOptions.SelfReplicating for a Task<TResult>. + + + {Not yet computed} + + + A task's Exception may only be set directly if the task was created without a function. + + + An attempt was made to transition a task to a final state when it had already completed. + + + The wait completed due to an abandoned mutex. + + + No handle of the given name exists. + + + A WaitHandle with system-wide name '{0}' cannot be created. A WaitHandle of a different type might have the same name. + + + The WaitHandle cannot be signaled because it would exceed its maximum count. + + + Adding the specified count to the semaphore would cause it to exceed its maximum count. + + + The ThreadLocal object has been disposed. + + + ValueFactory attempted to access the Value property of this instance. + + + The ThreadLocal object is not tracking values. To use the Values property, use a ThreadLocal constructor that accepts the trackAllValues parameter and set the parameter to true. + + + Unable to reset abort because no abort was requested. + + + The time zone ID '{0}' was not found on the local computer. + + + Type constructor threw an exception. + + + The type initializer for '{0}' threw an exception. + + + Assembly imported from type library '{0}'. + + + Could not resolve nested type '{0}' in type "{1}'. + + + Could not resolve type '{0}'. + + + Could not resolve type '{0}' in assembly '{1}'. + + + Access to the path is denied. + + + Access to the path '{0}' is denied. + + + MemoryStream's internal buffer cannot be accessed. + + + Access to the registry key '{0}' is denied. + + + Cannot write to the registry key. + + + Cannot execute an assembly in the system domain. + + + Unknown error "{0}". + + + Url + + + Operation could destabilize the runtime. + + + The weak reference is no longer valid. + + + at + + + Invalid XML in file '{0}' near element '{1}'. + + + Expected > character. + + + Expected / character or string. + + + Invalid syntax. + + + Invalid XML in file "{0}" near element "{1}". The <satelliteassemblies> section only supports <assembly> tags. + + + Invalid XML in file "{0}" near "{1}" and "{2}". In the <satelliteassemblies> section, the <assembly> tag must have exactly 1 attribute called 'name', whose value is a fully-qualified assembly name. + + + Invalid XML in file "{0}". In the <satelliteassemblies> section, the <assembly> tag must have exactly 1 attribute called 'name', whose value is a fully-qualified assembly name. + + + Invalid syntax on line {0}. + + + Invalid syntax on line {0} - '{1}'. + + + Unexpected > character. + + + Unexpected end of file. + + + Zone - {0} + + diff --git a/src/mscorlib/System.Private.CoreLib.csproj b/src/mscorlib/System.Private.CoreLib.csproj index 4d64021..66cbe3f 100644 --- a/src/mscorlib/System.Private.CoreLib.csproj +++ b/src/mscorlib/System.Private.CoreLib.csproj @@ -96,6 +96,7 @@ 4.0.0.0 4 6 + true @@ -627,9 +628,6 @@ - - - @@ -982,13 +980,6 @@ - - - - System.Private.CoreLib - $(DefineConstants) - - true @@ -1023,6 +1014,7 @@ $(IntermediateOutputPath)\System.Private.CoreLib.res - + + diff --git a/src/mscorlib/shared/System/IO/Error.cs b/src/mscorlib/shared/System/IO/Error.cs index acf5b35..2aef895 100644 --- a/src/mscorlib/shared/System/IO/Error.cs +++ b/src/mscorlib/shared/System/IO/Error.cs @@ -18,7 +18,7 @@ namespace System.IO { internal static Exception GetStreamIsClosed() { - return new ObjectDisposedException(null, SR.ObjectDisposed_StreamIsClosed); + return new ObjectDisposedException(null, SR.ObjectDisposed_StreamClosed); } internal static Exception GetEndOfFile() diff --git a/src/mscorlib/shared/System/Runtime/CompilerServices/TupleElementNamesAttribute.cs b/src/mscorlib/shared/System/Runtime/CompilerServices/TupleElementNamesAttribute.cs index 65b120e..ad923df 100644 --- a/src/mscorlib/shared/System/Runtime/CompilerServices/TupleElementNamesAttribute.cs +++ b/src/mscorlib/shared/System/Runtime/CompilerServices/TupleElementNamesAttribute.cs @@ -54,4 +54,4 @@ namespace System.Runtime.CompilerServices /// public IList TransformNames => _transformNames; } -} \ No newline at end of file +} diff --git a/src/mscorlib/shared/System/StringSplitOptions.cs b/src/mscorlib/shared/System/StringSplitOptions.cs index 43b626a..d702055 100644 --- a/src/mscorlib/shared/System/StringSplitOptions.cs +++ b/src/mscorlib/shared/System/StringSplitOptions.cs @@ -10,4 +10,4 @@ namespace System None = 0, RemoveEmptyEntries = 1 } -} \ No newline at end of file +} diff --git a/src/mscorlib/shared/System/TupleExtensions.cs b/src/mscorlib/shared/System/TupleExtensions.cs index b63cb41..106a88a 100644 --- a/src/mscorlib/shared/System/TupleExtensions.cs +++ b/src/mscorlib/shared/System/TupleExtensions.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. @@ -927,4 +927,4 @@ namespace System private static Tuple CreateLongRef(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, TRest rest) where TRest : ITuple => new Tuple(item1, item2, item3, item4, item5, item6, item7, rest); } -} \ No newline at end of file +} diff --git a/src/mscorlib/src/Debug.cs b/src/mscorlib/src/Debug.cs index 3398c0e..35cb680 100644 --- a/src/mscorlib/src/Debug.cs +++ b/src/mscorlib/src/Debug.cs @@ -26,4 +26,4 @@ namespace System BCLDebug.Assert(false, message); } } -} \ No newline at end of file +} diff --git a/src/mscorlib/src/Interop/Windows/kernel32/Interop.Globalization.cs b/src/mscorlib/src/Interop/Windows/kernel32/Interop.Globalization.cs index d187e00..2bb349d 100644 --- a/src/mscorlib/src/Interop/Windows/kernel32/Interop.Globalization.cs +++ b/src/mscorlib/src/Interop/Windows/kernel32/Interop.Globalization.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/Microsoft/Win32/Registry.cs b/src/mscorlib/src/Microsoft/Win32/Registry.cs index 47a6072..d0dbb0f 100644 --- a/src/mscorlib/src/Microsoft/Win32/Registry.cs +++ b/src/mscorlib/src/Microsoft/Win32/Registry.cs @@ -106,7 +106,7 @@ namespace Microsoft.Win32 basekey = Registry.CurrentConfig; break; default: - throw new ArgumentException(Environment.GetResourceString("Arg_RegInvalidKeyName", nameof(keyName))); + throw new ArgumentException(SR.Format(SR.Arg_RegInvalidKeyName, nameof(keyName))); } if (i == -1 || i == keyName.Length) { diff --git a/src/mscorlib/src/Microsoft/Win32/RegistryKey.cs b/src/mscorlib/src/Microsoft/Win32/RegistryKey.cs index 89974e4..6524c2e 100644 --- a/src/mscorlib/src/Microsoft/Win32/RegistryKey.cs +++ b/src/mscorlib/src/Microsoft/Win32/RegistryKey.cs @@ -545,7 +545,7 @@ namespace Microsoft.Win32 { if (options < RegistryValueOptions.None || options > RegistryValueOptions.DoNotExpandEnvironmentNames) { - throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)options), nameof(options)); + throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)options), nameof(options)); } bool doNotExpand = (options == RegistryValueOptions.DoNotExpandEnvironmentNames); CheckPermission(RegistryInternalCheck.CheckValueReadPermission, name, false, RegistryKeyPermissionCheck.Default); @@ -669,7 +669,7 @@ namespace Microsoft.Win32 } catch (OverflowException e) { - throw new IOException(Environment.GetResourceString("Arg_RegGetOverflowBug"), e); + throw new IOException(SR.Arg_RegGetOverflowBug, e); } } char[] blob = new char[datasize / 2]; @@ -699,7 +699,7 @@ namespace Microsoft.Win32 } catch (OverflowException e) { - throw new IOException(Environment.GetResourceString("Arg_RegGetOverflowBug"), e); + throw new IOException(SR.Arg_RegGetOverflowBug, e); } } char[] blob = new char[datasize / 2]; @@ -732,7 +732,7 @@ namespace Microsoft.Win32 } catch (OverflowException e) { - throw new IOException(Environment.GetResourceString("Arg_RegGetOverflowBug"), e); + throw new IOException(SR.Arg_RegGetOverflowBug, e); } } char[] blob = new char[datasize / 2]; @@ -754,7 +754,7 @@ namespace Microsoft.Win32 } catch (OverflowException e) { - throw new IOException(Environment.GetResourceString("Arg_RegGetOverflowBug"), e); + throw new IOException(SR.Arg_RegGetOverflowBug, e); } blob[blob.Length - 1] = (char)0; } @@ -844,11 +844,11 @@ namespace Microsoft.Win32 if (name != null && name.Length > MaxValueLength) { - throw new ArgumentException(Environment.GetResourceString("Arg_RegValStrLenBug")); + throw new ArgumentException(SR.Arg_RegValStrLenBug); } if (!Enum.IsDefined(typeof(RegistryValueKind), valueKind)) - throw new ArgumentException(Environment.GetResourceString("Arg_RegBadKeyKind"), nameof(valueKind)); + throw new ArgumentException(SR.Arg_RegBadKeyKind, nameof(valueKind)); EnsureWriteable(); @@ -1013,7 +1013,7 @@ namespace Microsoft.Win32 else if (value is String[]) return RegistryValueKind.MultiString; else - throw new ArgumentException(Environment.GetResourceString("Arg_RegSetBadArrType", value.GetType().Name)); + throw new ArgumentException(SR.Format(SR.Arg_RegSetBadArrType, value.GetType().Name)); } else return RegistryValueKind.String; @@ -1043,7 +1043,7 @@ namespace Microsoft.Win32 { case Win32Native.ERROR_ACCESS_DENIED: if (str != null) - throw new UnauthorizedAccessException(Environment.GetResourceString("UnauthorizedAccess_RegistryKeyGeneric_Key", str)); + throw new UnauthorizedAccessException(SR.Format(SR.UnauthorizedAccess_RegistryKeyGeneric_Key, str)); else throw new UnauthorizedAccessException(); @@ -1068,7 +1068,7 @@ namespace Microsoft.Win32 goto default; case Win32Native.ERROR_FILE_NOT_FOUND: - throw new IOException(Environment.GetResourceString("Arg_RegKeyNotFound"), errorCode); + throw new IOException(SR.Arg_RegKeyNotFound, errorCode); default: throw new IOException(Win32Native.GetMessage(errorCode), errorCode); diff --git a/src/mscorlib/src/Microsoft/Win32/Win32Native.cs b/src/mscorlib/src/Microsoft/Win32/Win32Native.cs index 6f618c2..c571f06 100644 --- a/src/mscorlib/src/Microsoft/Win32/Win32Native.cs +++ b/src/mscorlib/src/Microsoft/Win32/Win32Native.cs @@ -296,7 +296,7 @@ namespace Microsoft.Win32 // if (bytes == null || bytes.Length != 44) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidREG_TZI_FORMAT"), nameof(bytes)); + throw new ArgumentException(SR.Argument_InvalidREG_TZI_FORMAT, nameof(bytes)); } Bias = BitConverter.ToInt32(bytes, 0); StandardBias = BitConverter.ToInt32(bytes, 4); @@ -499,7 +499,7 @@ namespace Microsoft.Win32 else { StringBuilderCache.Release(sb); - return Environment.GetResourceString("UnknownError_Num", errorCode); + return SR.Format(SR.UnknownError_Num, errorCode); } } diff --git a/src/mscorlib/src/SR.cs b/src/mscorlib/src/SR.cs deleted file mode 100644 index 6d0be7e..0000000 --- a/src/mscorlib/src/SR.cs +++ /dev/null @@ -1,1020 +0,0 @@ -using System; -using System.Globalization; - -// CoreFX creates SR in the System namespace. While putting the CoreCLR SR adapter in the root -// may be unconventional, it allows us to keep the shared code identical. - -internal static class SR -{ - public static string Arg_ArrayZeroError - { - get { return Environment.GetResourceString("Arg_ArrayZeroError"); } - } - - public static string Arg_ExternalException - { - get { return Environment.GetResourceString("Arg_ExternalException"); } - } - - public static string Arg_HexStyleNotSupported - { - get { return Environment.GetResourceString("Arg_HexStyleNotSupported"); } - } - - public static string Arg_InvalidHexStyle - { - get { return Environment.GetResourceString("Arg_InvalidHexStyle"); } - } - - public static string Arg_OutOfMemoryException - { - get { return Environment.GetResourceString("Arg_OutOfMemoryException"); } - } - - public static string ArgumentNull_Array - { - get { return Environment.GetResourceString("ArgumentNull_Array"); } - } - - public static string ArgumentNull_ArrayValue - { - get { return Environment.GetResourceString("ArgumentNull_ArrayValue"); } - } - - public static string ArgumentNull_Obj - { - get { return Environment.GetResourceString("ArgumentNull_Obj"); } - } - - public static string ArgumentNull_String - { - get { return Environment.GetResourceString("ArgumentNull_String"); } - } - - public static string ArgumentOutOfRange_AddValue - { - get { return Environment.GetResourceString("ArgumentOutOfRange_AddValue"); } - } - - public static string ArgumentOutOfRange_BadHourMinuteSecond - { - get { return Environment.GetResourceString("ArgumentOutOfRange_BadHourMinuteSecond"); } - } - - public static string ArgumentOutOfRange_BadYearMonthDay - { - get { return Environment.GetResourceString("ArgumentOutOfRange_BadYearMonthDay"); } - } - - public static string ArgumentOutOfRange_Bounds_Lower_Upper - { - get { return Environment.GetResourceString("ArgumentOutOfRange_Bounds_Lower_Upper"); } - } - - public static string ArgumentOutOfRange_CalendarRange - { - get { return Environment.GetResourceString("ArgumentOutOfRange_CalendarRange"); } - } - - public static string ArgumentOutOfRange_Count - { - get { return Environment.GetResourceString("ArgumentOutOfRange_Count"); } - } - - public static string ArgumentOutOfRange_Day - { - get { return Environment.GetResourceString("ArgumentOutOfRange_Day"); } - } - - public static string ArgumentOutOfRange_Enum - { - get { return Environment.GetResourceString("ArgumentOutOfRange_Enum"); } - } - - public static string ArgumentOutOfRange_Era - { - get { return Environment.GetResourceString("ArgumentOutOfRange_Era"); } - } - - public static string ArgumentOutOfRange_Index - { - get { return Environment.GetResourceString("ArgumentOutOfRange_Index"); } - } - - public static string ArgumentOutOfRange_IndexCountBuffer - { - get { return Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer"); } - } - - public static string ArgumentOutOfRange_InvalidEraValue - { - get { return Environment.GetResourceString("ArgumentOutOfRange_InvalidEraValue"); } - } - - public static string ArgumentOutOfRange_Month - { - get { return Environment.GetResourceString("ArgumentOutOfRange_Month"); } - } - - public static string ArgumentOutOfRange_NeedNonNegNum - { - get { return Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum"); } - } - - public static string ArgumentOutOfRange_NeedPosNum - { - get { return Environment.GetResourceString("ArgumentOutOfRange_NeedPosNum"); } - } - - public static string Arg_ArgumentOutOfRangeException - { - get { return Environment.GetResourceString("Arg_ArgumentOutOfRangeException"); } - } - - public static string ArgumentOutOfRange_OffsetLength - { - get { return Environment.GetResourceString("ArgumentOutOfRange_OffsetLength"); } - } - - public static string ArgumentOutOfRange_Range - { - get { return Environment.GetResourceString("ArgumentOutOfRange_Range"); } - } - - public static string Argument_CompareOptionOrdinal - { - get { return Environment.GetResourceString("Argument_CompareOptionOrdinal"); } - } - - public static string Argument_ConflictingDateTimeRoundtripStyles - { - get { return Environment.GetResourceString("Argument_ConflictingDateTimeRoundtripStyles"); } - } - - public static string Argument_ConflictingDateTimeStyles - { - get { return Environment.GetResourceString("Argument_ConflictingDateTimeStyles"); } - } - - public static string Argument_CultureIetfNotSupported - { - get { return Environment.GetResourceString("Argument_CultureIetfNotSupported"); } - } - - public static string Argument_CultureInvalidIdentifier - { - get { return Environment.GetResourceString("Argument_CultureInvalidIdentifier"); } - } - - public static string Argument_CultureNotSupported - { - get { return Environment.GetResourceString("Argument_CultureNotSupported"); } - } - - public static string Argument_CultureIsNeutral - { - get { return Environment.GetResourceString("Argument_CultureIsNeutral"); } - } - - public static string Argument_CustomCultureCannotBePassedByNumber - { - get { return Environment.GetResourceString("Argument_CustomCultureCannotBePassedByNumber"); } - } - - public static string Argument_EmptyDecString - { - get { return Environment.GetResourceString("Argument_EmptyDecString"); } - } - - public static string Argument_IdnBadBidi - { - get { return Environment.GetResourceString("Argument_IdnBadBidi"); } - } - - public static string Argument_IdnBadLabelSize - { - get { return Environment.GetResourceString("Argument_IdnBadLabelSize"); } - } - - public static string Argument_IdnBadNameSize - { - get { return Environment.GetResourceString("Argument_IdnBadNameSize"); } - } - - public static string Argument_IdnBadPunycode - { - get { return Environment.GetResourceString("Argument_IdnBadPunycode"); } - } - - public static string Argument_IdnBadStd3 - { - get { return Environment.GetResourceString("Argument_IdnBadStd3"); } - } - - public static string Argument_IdnIllegalName - { - get { return Environment.GetResourceString("Argument_IdnIllegalName"); } - } - - public static string Argument_InvalidArrayLength - { - get { return Environment.GetResourceString("Argument_InvalidArrayLength"); } - } - - public static string Argument_InvalidCalendar - { - get { return Environment.GetResourceString("Argument_InvalidCalendar"); } - } - - public static string Argument_InvalidCharSequence - { - get { return Environment.GetResourceString("Argument_InvalidCharSequence"); } - } - - public static string Argument_InvalidCharSequenceNoIndex - { - get { return Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex"); } - } - - public static string Argument_InvalidCultureName - { - get { return Environment.GetResourceString("Argument_InvalidCultureName"); } - } - - public static string Argument_InvalidDateTimeStyles - { - get { return Environment.GetResourceString("Argument_InvalidDateTimeStyles"); } - } - - public static string Argument_InvalidDigitSubstitution - { - get { return Environment.GetResourceString("Argument_InvalidDigitSubstitution"); } - } - - public static string Argument_InvalidFlag - { - get { return Environment.GetResourceString("Argument_InvalidFlag"); } - } - - public static string Argument_InvalidGroupSize - { - get { return Environment.GetResourceString("Argument_InvalidGroupSize"); } - } - - public static string Argument_InvalidNativeDigitCount - { - get { return Environment.GetResourceString("Argument_InvalidNativeDigitCount"); } - } - - public static string Argument_InvalidNativeDigitValue - { - get { return Environment.GetResourceString("Argument_InvalidNativeDigitValue"); } - } - - public static string Argument_InvalidNeutralRegionName - { - get { return Environment.GetResourceString("Argument_InvalidNeutralRegionName"); } - } - - public static string Argument_InvalidNumberStyles - { - get { return Environment.GetResourceString("Argument_InvalidNumberStyles"); } - } - - public static string Argument_InvalidResourceCultureName - { - get { return Environment.GetResourceString("Argument_InvalidResourceCultureName"); } - } - - public static string Argument_NoEra - { - get { return Environment.GetResourceString("Argument_NoEra"); } - } - - public static string Argument_NoRegionInvariantCulture - { - get { return Environment.GetResourceString("Argument_NoRegionInvariantCulture"); } - } - - public static string Argument_OneOfCulturesNotSupported - { - get { return Environment.GetResourceString("Argument_OneOfCulturesNotSupported"); } - } - - public static string Argument_OnlyMscorlib - { - get { return Environment.GetResourceString("Argument_OnlyMscorlib"); } - } - - public static string Argument_ResultCalendarRange - { - get { return Environment.GetResourceString("Argument_ResultCalendarRange"); } - } - - public static string Format_BadFormatSpecifier - { - get { return Environment.GetResourceString("Format_BadFormatSpecifier"); } - } - - public static string InvalidOperation_DateTimeParsing - { - get { return Environment.GetResourceString("InvalidOperation_DateTimeParsing"); } - } - - public static string InvalidOperation_EnumEnded - { - get { return Environment.GetResourceString("InvalidOperation_EnumEnded"); } - } - - public static string InvalidOperation_EnumNotStarted - { - get { return Environment.GetResourceString("InvalidOperation_EnumNotStarted"); } - } - - public static string InvalidOperation_ReadOnly - { - get { return Environment.GetResourceString("InvalidOperation_ReadOnly"); } - } - - public static string Overflow_TimeSpanTooLong - { - get { return Environment.GetResourceString("Overflow_TimeSpanTooLong"); } - } - - public static string Serialization_MemberOutOfRange - { - get { return Environment.GetResourceString("Serialization_MemberOutOfRange"); } - } - - public static string Arg_InvalidHandle - { - get { return Environment.GetResourceString("Arg_InvalidHandle"); } - } - - public static string ObjectDisposed_FileClosed - { - get { return Environment.GetResourceString("ObjectDisposed_FileClosed"); } - } - - public static string Arg_HandleNotAsync - { - get { return Environment.GetResourceString("Arg_HandleNotAsync"); } - } - - public static string ArgumentNull_Path - { - get { return Environment.GetResourceString("ArgumentNull_Path"); } - } - - public static string Argument_EmptyPath - { - get { return Environment.GetResourceString("Argument_EmptyPath"); } - } - - public static string Argument_InvalidFileModeAndAccessCombo - { - get { return Environment.GetResourceString("Argument_InvalidFileMode&AccessCombo"); } - } - - public static string Argument_InvalidAppendMode - { - get { return Environment.GetResourceString("Argument_InvalidAppendMode"); } - } - - public static string ArgumentNull_Buffer - { - get { return Environment.GetResourceString("ArgumentNull_Buffer"); } - } - - public static string Argument_InvalidOffLen - { - get { return Environment.GetResourceString("Argument_InvalidOffLen"); } - } - - public static string IO_UnknownFileName - { - get { return Environment.GetResourceString("IO_UnknownFileName"); } - } - - public static string IO_FileStreamHandlePosition - { - get { return Environment.GetResourceString("IO.IO_FileStreamHandlePosition"); } - } - - public static string NotSupported_FileStreamOnNonFiles - { - get { return Environment.GetResourceString("NotSupported_FileStreamOnNonFiles"); } - } - - public static string IO_BindHandleFailed - { - get { return Environment.GetResourceString("IO.IO_BindHandleFailed"); } - } - - public static string Arg_HandleNotSync - { - get { return Environment.GetResourceString("Arg_HandleNotSync"); } - } - - public static string IO_SetLengthAppendTruncate - { - get { return Environment.GetResourceString("IO.IO_SetLengthAppendTruncate"); } - } - - public static string ArgumentOutOfRange_FileLengthTooBig - { - get { return Environment.GetResourceString("ArgumentOutOfRange_FileLengthTooBig"); } - } - - public static string Argument_InvalidSeekOrigin - { - get { return Environment.GetResourceString("Argument_InvalidSeekOrigin"); } - } - - public static string IO_SeekAppendOverwrite - { - get { return Environment.GetResourceString("IO.IO_SeekAppendOverwrite"); } - } - - public static string IO_FileTooLongOrHandleNotSync - { - get { return Environment.GetResourceString("IO_FileTooLongOrHandleNotSync"); } - } - - public static string IndexOutOfRange_IORaceCondition - { - get { return Environment.GetResourceString("IndexOutOfRange_IORaceCondition"); } - } - - public static string IO_FileNotFound - { - get { return Environment.GetResourceString("IO.FileNotFound"); } - } - - public static string IO_FileNotFound_FileName - { - get { return Environment.GetResourceString("IO.FileNotFound_FileName"); } - } - - public static string IO_PathNotFound_NoPathName - { - get { return Environment.GetResourceString("IO.PathNotFound_NoPathName"); } - } - - public static string IO_PathNotFound_Path - { - get { return Environment.GetResourceString("IO.PathNotFound_Path"); } - } - - public static string UnauthorizedAccess_IODenied_NoPathName - { - get { return Environment.GetResourceString("UnauthorizedAccess_IODenied_NoPathName"); } - } - - public static string UnauthorizedAccess_IODenied_Path - { - get { return Environment.GetResourceString("UnauthorizedAccess_IODenied_Path"); } - } - - public static string IO_AlreadyExists_Name - { - get { return Environment.GetResourceString("IO.IO_AlreadyExists_Name"); } - } - - public static string IO_PathTooLong - { - get { return Environment.GetResourceString("IO.PathTooLong"); } - } - - public static string IO_SharingViolation_NoFileName - { - get { return Environment.GetResourceString("IO.IO_SharingViolation_NoFileName"); } - } - - public static string IO_SharingViolation_File - { - get { return Environment.GetResourceString("IO.IO_SharingViolation_File"); } - } - - public static string IO_FileExists_Name - { - get { return Environment.GetResourceString("IO.IO_FileExists_Name"); } - } - - public static string NotSupported_UnwritableStream - { - get { return Environment.GetResourceString("NotSupported_UnwritableStream"); } - } - - public static string NotSupported_UnreadableStream - { - get { return Environment.GetResourceString("NotSupported_UnreadableStream"); } - } - - public static string NotSupported_UnseekableStream - { - get { return Environment.GetResourceString("NotSupported_UnseekableStream"); } - } - - public static string IO_EOF_ReadBeyondEOF - { - get { return Environment.GetResourceString("IO.EOF_ReadBeyondEOF"); } - } - - public static string Argument_InvalidHandle - { - get { return Environment.GetResourceString("Argument_InvalidHandle"); } - } - - public static string Argument_AlreadyBoundOrSyncHandle - { - get { return Environment.GetResourceString("Argument_AlreadyBoundOrSyncHandle"); } - } - - public static string Argument_PreAllocatedAlreadyAllocated - { - get { return Environment.GetResourceString("Argument_PreAllocatedAlreadyAllocated"); } - } - - public static string Argument_NativeOverlappedAlreadyFree - { - get { return Environment.GetResourceString("Argument_NativeOverlappedAlreadyFree"); } - } - - public static string Argument_NativeOverlappedWrongBoundHandle - { - get { return Environment.GetResourceString("Argument_NativeOverlappedWrongBoundHandle"); } - } - - public static string InvalidOperation_NativeOverlappedReused - { - get { return Environment.GetResourceString("InvalidOperation_NativeOverlappedReused"); } - } - - public static string ArgumentOutOfRange_Length - { - get { return Environment.GetResourceString("ArgumentOutOfRange_Length"); } - } - - public static string ArgumentOutOfRange_IndexString - { - get { return Environment.GetResourceString("ArgumentOutOfRange_IndexString"); } - } - - public static string ArgumentOutOfRange_Capacity - { - get { return Environment.GetResourceString("ArgumentOutOfRange_Capacity"); } - } - - public static string Arg_CryptographyException - { - get { return Environment.GetResourceString("Arg_CryptographyException"); } - } - - public static string ArgumentException_BufferNotFromPool - { - get { return Environment.GetResourceString("ArgumentException_BufferNotFromPool"); } - } - - public static string Argument_InvalidPathChars - { - get { return Environment.GetResourceString("Argument_InvalidPathChars"); } - } - - public static string Argument_PathFormatNotSupported - { - get { return Environment.GetResourceString("Argument_PathFormatNotSupported"); } - } - - public static string Arg_PathIllegal - { - get { return Environment.GetResourceString("Arg_PathIllegal"); } - } - - public static string Arg_PathIllegalUNC - { - get { return Environment.GetResourceString("Arg_PathIllegalUNC"); } - } - - public static string Arg_InvalidSearchPattern - { - get { return Environment.GetResourceString("Arg_InvalidSearchPattern"); } - } - - public static string InvalidOperation_Cryptography - { - get { return Environment.GetResourceString("InvalidOperation_Cryptography"); } - } - - public static string Format(string formatString, params object[] args) - { - return string.Format(CultureInfo.CurrentCulture, formatString, args); - } - - internal static string ArgumentException_ValueTupleIncorrectType - { - get { return Environment.GetResourceString("ArgumentException_ValueTupleIncorrectType"); } - } - - internal static string ArgumentException_ValueTupleLastArgumentNotATuple - { - get { return Environment.GetResourceString("ArgumentException_ValueTupleLastArgumentNotATuple"); } - } - - internal static string SpinLock_TryEnter_ArgumentOutOfRange - { - get { return Environment.GetResourceString("SpinLock_TryEnter_ArgumentOutOfRange"); } - } - - internal static string SpinLock_TryReliableEnter_ArgumentException - { - get { return Environment.GetResourceString("SpinLock_TryReliableEnter_ArgumentException"); } - } - - internal static string SpinLock_TryEnter_LockRecursionException - { - get { return Environment.GetResourceString("SpinLock_TryEnter_LockRecursionException"); } - } - - internal static string SpinLock_Exit_SynchronizationLockException - { - get { return Environment.GetResourceString("SpinLock_Exit_SynchronizationLockException"); } - } - - internal static string SpinLock_IsHeldByCurrentThread - { - get { return Environment.GetResourceString("SpinLock_IsHeldByCurrentThread"); } - } - - internal static string ObjectDisposed_StreamIsClosed - { - get { return Environment.GetResourceString("ObjectDisposed_StreamIsClosed"); } - } - - internal static string Arg_SystemException - { - get { return Environment.GetResourceString("Arg_SystemException"); } - } - - internal static string Arg_StackOverflowException - { - get { return Environment.GetResourceString("Arg_StackOverflowException"); } - } - - internal static string Arg_DataMisalignedException - { - get { return Environment.GetResourceString("Arg_DataMisalignedException"); } - } - - internal static string Arg_ExecutionEngineException - { - get { return Environment.GetResourceString("Arg_ExecutionEngineException"); } - } - - internal static string Arg_AccessException - { - get { return Environment.GetResourceString("Arg_AccessException"); } - } - - internal static string Arg_AccessViolationException - { - get { return Environment.GetResourceString("Arg_AccessViolationException"); } - } - - internal static string Arg_ApplicationException - { - get { return Environment.GetResourceString("Arg_ApplicationException"); } - } - - internal static string Arg_ArgumentException - { - get { return Environment.GetResourceString("Arg_ArgumentException"); } - } - - internal static string Arg_ParamName_Name - { - get { return Environment.GetResourceString("Arg_ParamName_Name"); } - } - - internal static string ArgumentNull_Generic - { - get { return Environment.GetResourceString("ArgumentNull_Generic"); } - } - - internal static string Arg_ArithmeticException - { - get { return Environment.GetResourceString("Arg_ArithmeticException"); } - } - - internal static string Arg_ArrayTypeMismatchException - { - get { return Environment.GetResourceString("Arg_ArrayTypeMismatchException"); } - } - - internal static string Arg_DivideByZero - { - get { return Environment.GetResourceString("Arg_DivideByZero"); } - } - - internal static string Arg_DuplicateWaitObjectException - { - get { return Environment.GetResourceString("Arg_DuplicateWaitObjectException"); } - } - - internal static string Arg_EntryPointNotFoundException - { - get { return Environment.GetResourceString("Arg_EntryPointNotFoundException"); } - } - - internal static string Arg_FieldAccessException - { - get { return Environment.GetResourceString("Arg_FieldAccessException"); } - } - - internal static string Arg_FormatException - { - get { return Environment.GetResourceString("Arg_FormatException"); } - } - - internal static string Arg_IndexOutOfRangeException - { - get { return Environment.GetResourceString("Arg_IndexOutOfRangeException"); } - } - - internal static string Arg_InsufficientExecutionStackException - { - get { return Environment.GetResourceString("Arg_InsufficientExecutionStackException"); } - } - - internal static string Arg_InvalidCastException - { - get { return Environment.GetResourceString("Arg_InvalidCastException"); } - } - - internal static string Arg_InvalidOperationException - { - get { return Environment.GetResourceString("Arg_InvalidOperationException"); } - } - - internal static string InvalidProgram_Default - { - get { return Environment.GetResourceString("InvalidProgram_Default"); } - } - - internal static string Arg_MethodAccessException - { - get { return Environment.GetResourceString("Arg_MethodAccessException"); } - } - - internal static string Arg_MulticastNotSupportedException - { - get { return Environment.GetResourceString("Arg_MulticastNotSupportedException"); } - } - - internal static string Arg_NotFiniteNumberException - { - get { return Environment.GetResourceString("Arg_NotFiniteNumberException"); } - } - - internal static string Arg_NotImplementedException - { - get { return Environment.GetResourceString("Arg_NotImplementedException"); } - } - - internal static string Arg_NotSupportedException - { - get { return Environment.GetResourceString("Arg_NotSupportedException"); } - } - - internal static string Arg_NullReferenceException - { - get { return Environment.GetResourceString("Arg_NullReferenceException"); } - } - - internal static string ObjectDisposed_Generic - { - get { return Environment.GetResourceString("ObjectDisposed_Generic"); } - } - - internal static string ObjectDisposed_ObjectName_Name - { - get { return Environment.GetResourceString("ObjectDisposed_ObjectName_Name"); } - } - - internal static string Arg_OverflowException - { - get { return Environment.GetResourceString("Arg_OverflowException"); } - } - - internal static string Arg_PlatformNotSupported - { - get { return Environment.GetResourceString("Arg_PlatformNotSupported"); } - } - - internal static string Arg_RankException - { - get { return Environment.GetResourceString("Arg_RankException"); } - } - - internal static string Arg_TimeoutException - { - get { return Environment.GetResourceString("Arg_TimeoutException"); } - } - - internal static string Arg_TypeAccessException - { - get { return Environment.GetResourceString("Arg_TypeAccessException"); } - } - - internal static string TypeInitialization_Default - { - get { return Environment.GetResourceString("TypeInitialization_Default"); } - } - - internal static string TypeInitialization_Type - { - get { return Environment.GetResourceString("TypeInitialization_Type"); } - } - - internal static string Arg_UnauthorizedAccessException - { - get { return Environment.GetResourceString("Arg_UnauthorizedAccessException"); } - } - - internal static string ArgumentOutOfRange_GenericPositive - { - get { return Environment.GetResourceString("ArgumentOutOfRange_GenericPositive"); } - } - - internal static string ArgumentOutOfRange_LengthTooLarge - { - get { return Environment.GetResourceString("ArgumentOutOfRange_LengthTooLarge"); } - } - - internal static string Arg_ArrayPlusOffTooSmall - { - get { return Environment.GetResourceString("Arg_ArrayPlusOffTooSmall"); } - } - - internal static string Arg_KeyNotFound => - Environment.GetResourceString("Arg_KeyNotFound"); - - internal static string PlatformNotSupported_OSXFileLocking => - Environment.GetResourceString("PlatformNotSupported_OSXFileLocking"); - - internal static string UnknownError_Num - { - get { return Environment.GetResourceString("UnknownError_Num"); } - } - - internal static string Lazy_ctor_ModeInvalid - { - get { return Environment.GetResourceString("Lazy_ctor_ModeInvalid"); } - } - - internal static string Lazy_Value_RecursiveCallsToValue - { - get { return Environment.GetResourceString("Lazy_Value_RecursiveCallsToValue"); } - } - - internal static string Lazy_CreateValue_NoParameterlessCtorForT - { - get { return Environment.GetResourceString("Lazy_CreateValue_NoParameterlessCtorForT"); } - } - - internal static string Lazy_ToString_ValueNotCreated - { - get { return Environment.GetResourceString("Lazy_ToString_ValueNotCreated"); } - } - - internal static string Serialization_NonSerType - { - get { return Environment.GetResourceString("Serialization_NonSerType"); } - } - - - internal static string NotSupported_SubclassOverride - { - get { return Environment.GetResourceString("NotSupported_SubclassOverride"); } - } - - internal static string InvalidCast_IConvertible => - Environment.GetResourceString("InvalidCast_IConvertible"); - - internal static string InvalidCast_DBNull => - Environment.GetResourceString("InvalidCast_DBNull"); - - internal static string InvalidCast_Empty => - Environment.GetResourceString("InvalidCast_Empty"); - - internal static string InvalidCast_FromTo => - Environment.GetResourceString("InvalidCast_FromTo"); - - internal static string Arg_UnknownTypeCode => - Environment.GetResourceString("Arg_UnknownTypeCode"); - - internal static string InvalidCast_CannotCastNullToValueType => - Environment.GetResourceString("InvalidCast_CannotCastNullToValueType"); - - internal static string Overflow_Char => - Environment.GetResourceString("Overflow_Char"); - - internal static string Overflow_Byte => - Environment.GetResourceString("Overflow_Byte"); - - internal static string Overflow_SByte => - Environment.GetResourceString("Overflow_SByte"); - - internal static string Overflow_Int16 => - Environment.GetResourceString("Overflow_Int16"); - - internal static string Overflow_UInt16 => - Environment.GetResourceString("Overflow_UInt16"); - - internal static string Overflow_Int32 => - Environment.GetResourceString("Overflow_Int32"); - - internal static string Overflow_UInt32 => - Environment.GetResourceString("Overflow_UInt32"); - - internal static string Overflow_Int64 => - Environment.GetResourceString("Overflow_Int64"); - - internal static string Overflow_UInt64 => - Environment.GetResourceString("Overflow_UInt64"); - - internal static string Arg_InvalidBase => - Environment.GetResourceString("Arg_InvalidBase"); - - internal static string ArgumentOutOfRange_OffsetOut => - Environment.GetResourceString("ArgumentOutOfRange_OffsetOut"); - - internal static string Format_BadBase64Char => - Environment.GetResourceString("Format_BadBase64Char"); - - internal static string Format_BadBase64CharArrayLength => - Environment.GetResourceString("Format_BadBase64CharArrayLength"); - - internal static string Format_NeedSingleChar => - Environment.GetResourceString("Format_BadBase64CharArrayLength"); - - internal static string Arg_EnumIllegalVal => - Environment.GetResourceString("Arg_EnumIllegalVal"); - - internal static string InvalidOperation_NoPublicAddMethod => - Environment.GetResourceString("InvalidOperation_NoPublicAddMethod"); - - internal static string InvalidOperation_NoPublicRemoveMethod => - Environment.GetResourceString("InvalidOperation_NoPublicRemoveMethod"); - - internal static string InvalidOperation_NotSupportedOnWinRTEvent => - Environment.GetResourceString("InvalidOperation_NotSupportedOnWinRTEvent"); - - internal static string NotSupported_AbstractNonCLS => - Environment.GetResourceString("NotSupported_AbstractNonCLS"); - - internal static string Serialization_InsufficientState => - Environment.GetResourceString("Serialization_InsufficientState"); - - internal static string Serialization_BadParameterInfo => - Environment.GetResourceString("Serialization_BadParameterInfo"); - - internal static string Serialization_NoParameterInfo => - Environment.GetResourceString("Serialization_NoParameterInfo"); - - internal static string InvalidFilterCriteriaException_CritString => - Environment.GetResourceString("InvalidFilterCriteriaException_CritString"); - - internal static string NotSupported_NoTypeInfo => - Environment.GetResourceString("NotSupported_NoTypeInfo"); - - internal static string PlatformNotSupported_ReflectionOnly => - Environment.GetResourceString("PlatformNotSupported_ReflectionOnly"); - - internal static string Arg_EnumAndObjectMustBeSameType => - Environment.GetResourceString("Arg_EnumAndObjectMustBeSameType"); - - internal static string Arg_EnumUnderlyingTypeAndObjectMustBeSameType => - Environment.GetResourceString("Arg_EnumUnderlyingTypeAndObjectMustBeSameType"); - - internal static string Arg_MustBeEnum => - Environment.GetResourceString("Arg_MustBeEnum"); - - internal static string Arg_MustBeEnumBaseTypeOrEnum => - Environment.GetResourceString("Arg_MustBeEnumBaseTypeOrEnum"); - - internal static string Arg_NotGenericParameter => - Environment.GetResourceString("Arg_NotGenericParameter"); - - internal static string Argument_InvalidEnum => - Environment.GetResourceString("Argument_InvalidEnum"); - - internal static string InvalidFilterCriteriaException_CritInt => - Environment.GetResourceString("InvalidFilterCriteriaException_CritInt"); - - internal static string InvalidOperation_UnknownEnumType => - Environment.GetResourceString("InvalidOperation_UnknownEnumType"); - - internal static string Arg_SecurityException => - Environment.GetResourceString("Arg_SecurityException"); -} diff --git a/src/mscorlib/src/System.Private.CoreLib.txt b/src/mscorlib/src/System.Private.CoreLib.txt deleted file mode 100644 index 0197305..0000000 --- a/src/mscorlib/src/System.Private.CoreLib.txt +++ /dev/null @@ -1,1970 +0,0 @@ -; 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. - -; These are the managed resources for mscorlib.dll. -; See those first three bytes in the file? This is in UTF-8. Leave the -; Unicode byte order mark (U+FEFF) written in UTF-8 at the start of this file. - -; For resource info, see the ResourceManager documentation and the ResGen tool, -; which is a managed app using ResourceWriter. -; ResGen now supports limited preprocessing of txt files, you can use -; #if SYMBOL and #if !SYMBOL to control what sets of resources are included in -; the resulting resources. - -; The naming scheme is: [Namespace.] ExceptionName _ Reason -; We'll suppress "System." where possible. -; Examples: -; Argument_Null -; Reflection.TargetInvokation_someReason - -; Usage Notes: -; * Keep exceptions in alphabetical order by package -; * A single space may exist on either side of the equal sign. -; * Follow the naming conventions. -; * Any lines starting with a '#' or ';' are ignored -; * Equal signs aren't legal characters for keys, but may occur in values. -; * Correctly punctuate all sentences. Most resources should end in a period. -; Remember, your mother will probably read some of these messages. -; * You may use " (quote), \n and \t. Use \\ for a single '\' character. -; * String inserts work. i.e., BadNumber_File = Wrong number in file "{0}". - -; Real words, used by code like Environment.StackTrace -#if INCLUDE_RUNTIME -Word_At = at -StackTrace_InFileLineNumber = in {0}:line {1} -UnknownError_Num = Unknown error "{0}". -AllocatedFrom = Allocated from: - -; Note this one is special, used as a divider between stack traces! -Exception_EndOfInnerExceptionStack = --- End of inner exception stack trace --- -Exception_WasThrown = Exception of type '{0}' was thrown. - -; The following are used in the implementation of ExceptionDispatchInfo -Exception_EndStackTraceFromPreviousThrow = --- End of stack trace from previous location where exception was thrown --- - -Arg_ParamName_Name = Parameter name: {0} -ArgumentOutOfRange_ActualValue = Actual value was {0}. - -NoDebugResources = [{0}]\r\nArguments: {1}\r\nDebugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version={2}&File={3}&Key={4} -#endif // INCLUDE_RUNTIME - -#if INCLUDE_DEBUG - -; For code contracts -AssumptionFailed = Assumption failed. -AssumptionFailed_Cnd = Assumption failed: {0} -AssertionFailed = Assertion failed. -AssertionFailed_Cnd = Assertion failed: {0} -PreconditionFailed = Precondition failed. -PreconditionFailed_Cnd = Precondition failed: {0} -PostconditionFailed = Postcondition failed. -PostconditionFailed_Cnd = Postcondition failed: {0} -PostconditionOnExceptionFailed = Postcondition failed after throwing an exception. -PostconditionOnExceptionFailed_Cnd = Postcondition failed after throwing an exception: {0} -InvariantFailed = Invariant failed. -InvariantFailed_Cnd = Invariant failed: {0} -MustUseCCRewrite = An assembly (probably "{1}") must be rewritten using the code contracts binary rewriter (CCRewrite) because it is calling Contract.{0} and the CONTRACTS_FULL symbol is defined. Remove any explicit definitions of the CONTRACTS_FULL symbol from your project and rebuild. CCRewrite can be downloaded from http://go.microsoft.com/fwlink/?LinkID=169180. \r\nAfter the rewriter is installed, it can be enabled in Visual Studio from the project's Properties page on the Code Contracts pane. Ensure that "Perform Runtime Contract Checking" is enabled, which will define CONTRACTS_FULL. - -; AccessException -Acc_CreateGeneric = Cannot create a type for which Type.ContainsGenericParameters is true. -Acc_CreateAbst = Cannot create an abstract class. -Acc_CreateInterface = Cannot create an instance of an interface. -Acc_NotClassInit = Type initializer was not callable. -Acc_CreateGenericEx = Cannot create an instance of {0} because Type.ContainsGenericParameters is true. -Acc_CreateArgIterator = Cannot dynamically create an instance of ArgIterator. -Acc_CreateAbstEx = Cannot create an instance of {0} because it is an abstract class. -Acc_CreateInterfaceEx = Cannot create an instance of {0} because it is an interface. -Acc_CreateVoid = Cannot dynamically create an instance of System.Void. -Acc_ReadOnly = Cannot set a constant field. -Acc_RvaStatic = SkipVerification permission is needed to modify an image-based (RVA) static field. -Access_Void = Cannot create an instance of void. - -; ArgumentException -Arg_TypedReference_Null = The TypedReference must be initialized. -Argument_AddingDuplicate__ = Item has already been added. Key in dictionary: '{0}' Key being added: '{1}' -Argument_AddingDuplicate = An item with the same key has already been added. -Argument_AddingDuplicateWithKey = An item with the same key has already been added. Key: {0} -Argument_MethodDeclaringTypeGenericLcg = Method '{0}' has a generic declaring type '{1}'. Explicitly provide the declaring type to GetTokenFor. -Argument_MethodDeclaringTypeGeneric = Cannot resolve method {0} because the declaring type of the method handle {1} is generic. Explicitly provide the declaring type to GetMethodFromHandle. -Argument_FieldDeclaringTypeGeneric = Cannot resolve field {0} because the declaring type of the field handle {1} is generic. Explicitly provide the declaring type to GetFieldFromHandle. -Argument_ApplicationTrustShouldHaveIdentity = An ApplicationTrust must have an application identity before it can be persisted. -Argument_ConversionOverflow = Conversion buffer overflow. -Argument_CodepageNotSupported = {0} is not a supported code page. -Argument_CultureNotSupported = Culture is not supported. -Argument_CultureInvalidIdentifier = {0} is an invalid culture identifier. -Argument_OneOfCulturesNotSupported = Culture name {0} or {1} is not supported. -Argument_CultureIetfNotSupported = Culture IETF Name {0} is not a recognized IETF name. -Argument_CultureIsNeutral = Culture ID {0} (0x{0:X4}) is a neutral culture; a region cannot be created from it. -Argument_InvalidNeutralRegionName = The region name {0} should not correspond to neutral culture; a specific culture name is required. -Argument_InvalidGenericInstArray = Generic arguments must be provided for each generic parameter and each generic argument must be a RuntimeType. -Argument_GenericArgsCount = The number of generic arguments provided doesn't equal the arity of the generic type definition. -Argument_CultureInvalidFormat = Culture '{0}' is a neutral culture. It cannot be used in formatting and parsing and therefore cannot be set as the thread's current culture. -Argument_CompareOptionOrdinal = CompareOption.Ordinal cannot be used with other options. -Argument_CustomCultureCannotBePassedByNumber = Customized cultures cannot be passed by LCID, only by name. -Argument_EncodingConversionOverflowChars = The output char buffer is too small to contain the decoded characters, encoding '{0}' fallback '{1}'. -Argument_EncodingConversionOverflowBytes = The output byte buffer is too small to contain the encoded data, encoding '{0}' fallback '{1}'. -Argument_EncoderFallbackNotEmpty = Must complete Convert() operation or call Encoder.Reset() before calling GetBytes() or GetByteCount(). Encoder '{0}' fallback '{1}'. -Argument_EmptyFileName = Empty file name is not legal. -Argument_EmptyPath = Empty path name is not legal. -Argument_EmptyName = Empty name is not legal. -Argument_ImplementIComparable = At least one object must implement IComparable. -Argument_InvalidType = The type of arguments passed into generic comparer methods is invalid. -Argument_InvalidTypeForCA=Cannot build type parameter for custom attribute with a type that does not support the AssemblyQualifiedName property. The type instance supplied was of type '{0}'. -Argument_IllegalEnvVarName = Environment variable name cannot contain equal character. -Argument_IllegalAppId = Application identity does not have same number of components as manifest paths. -Argument_IllegalAppBase = The application base specified is not valid. -Argument_UnableToParseManifest = Unexpected error while parsing the specified manifest. -Argument_IllegalAppIdMismatch = Application identity does not match identities in manifests. -Argument_InvalidAppId = Invalid identity: no deployment or application identity specified. -Argument_InvalidGenericArg = The generic type parameter was not valid -Argument_InvalidArrayLength = Length of the array must be {0}. -Argument_InvalidArrayType = Target array type is not compatible with the type of items in the collection. -Argument_InvalidAppendMode = Append access can be requested only in write-only mode. -Argument_InvalidEnumValue = The value '{0}' is not valid for this usage of the type {1}. -Argument_EnumIsNotIntOrShort = The underlying type of enum argument must be Int32 or Int16. -Argument_InvalidEnum = The Enum type should contain one and only one instance field. -Argument_InvalidKeyStore = '{0}' is not a valid KeyStore name. -Argument_InvalidFileMode&AccessCombo = Combining FileMode: {0} with FileAccess: {1} is invalid. -Argument_InvalidFileMode&RightsCombo = Combining FileMode: {0} with FileSystemRights: {1} is invalid. -Argument_InvalidFileModeTruncate&RightsCombo = Combining FileMode: {0} with FileSystemRights: {1} is invalid. FileMode.Truncate is valid only when used with FileSystemRights.Write. -Argument_InvalidFlag = Value of flags is invalid. -Argument_InvalidAnyFlag = No flags can be set. -Argument_InvalidHandle = The handle is invalid. -Argument_InvalidRegistryKeyPermissionCheck = The specified RegistryKeyPermissionCheck value is invalid. -Argument_InvalidRegistryOptionsCheck = The specified RegistryOptions value is invalid. -Argument_InvalidRegistryViewCheck = The specified RegistryView value is invalid. -Argument_InvalidSubPath = The directory specified, '{0}', is not a subdirectory of '{1}'. -Argument_NoRegionInvariantCulture = There is no region associated with the Invariant Culture (Culture ID: 0x7F). -Argument_ResultCalendarRange = The result is out of the supported range for this calendar. The result should be between {0} (Gregorian date) and {1} (Gregorian date), inclusive. -Argument_ResultIslamicCalendarRange = The date is out of the supported range for the Islamic calendar. The date should be greater than July 18th, 622 AD (Gregorian date). -Argument_NeverValidGenericArgument = The type '{0}' may not be used as a type argument. -Argument_NotEnoughGenArguments = The type or method has {1} generic parameter(s), but {0} generic argument(s) were provided. A generic argument must be provided for each generic parameter. -Argument_NullFullTrustAssembly = A null StrongName was found in the full trust assembly list. -Argument_GenConstraintViolation = GenericArguments[{0}], '{1}', on '{2}' violates the constraint of type '{3}'. -Argument_InvalidToken = Token {0:x} is not valid in the scope of module {1}. -Argument_InvalidTypeToken = Token {0:x} is not a valid Type token. -Argument_ResolveType = Token {0:x} is not a valid Type token in the scope of module {1}. -Argument_ResolveMethod = Token {0:x} is not a valid MethodBase token in the scope of module {1}. -Argument_ResolveField = Token {0:x} is not a valid FieldInfo token in the scope of module {1}. -Argument_ResolveMember = Token {0:x} is not a valid MemberInfo token in the scope of module {1}. -Argument_ResolveString = Token {0:x} is not a valid string token in the scope of module {1}. -Argument_ResolveModuleType = Token {0} resolves to the special module type representing this module. -Argument_ResolveMethodHandle = Type handle '{0}' and method handle with declaring type '{1}' are incompatible. Get RuntimeMethodHandle and declaring RuntimeTypeHandle off the same MethodBase. -Argument_ResolveFieldHandle = Type handle '{0}' and field handle with declaring type '{1}' are incompatible. Get RuntimeFieldHandle and declaring RuntimeTypeHandle off the same FieldInfo. -Argument_ResourceScopeWrongDirection = Resource type in the ResourceScope enum is going from a more restrictive resource type to a more general one. From: "{0}" To: "{1}" -Argument_BadResourceScopeTypeBits = Unknown value for the ResourceScope: {0} Too many resource type bits may be set. -Argument_BadResourceScopeVisibilityBits = Unknown value for the ResourceScope: {0} Too many resource visibility bits may be set. -Argument_WaitHandleNameTooLong = The name can be no more than {0} characters in length. -Argument_EnumTypeDoesNotMatch = The argument type, '{0}', is not the same as the enum type '{1}'. -InvalidOperation_MethodBuilderBaked = The signature of the MethodBuilder can no longer be modified because an operation on the MethodBuilder caused the methodDef token to be created. For example, a call to SetCustomAttribute requires the methodDef token to emit the CustomAttribute token. -InvalidOperation_GenericParametersAlreadySet = The generic parameters are already defined on this MethodBuilder. -Arg_AccessException = Cannot access member. -Arg_AppDomainUnloadedException = Attempted to access an unloaded AppDomain. -Arg_ApplicationException = Error in the application. -Arg_ArgumentOutOfRangeException = Specified argument was out of the range of valid values. -Arg_ArithmeticException = Overflow or underflow in the arithmetic operation. -Arg_ArrayLengthsDiffer = Array lengths must be the same. -Arg_ArrayPlusOffTooSmall = Destination array is not long enough to copy all the items in the collection. Check array index and length. -Arg_ArrayTypeMismatchException = Attempted to access an element as a type incompatible with the array. -Arg_BadDecimal = Read an invalid decimal value from the buffer. -Arg_BadImageFormatException = Format of the executable (.exe) or library (.dll) is invalid. -Argument_BadImageFormatExceptionResolve = A BadImageFormatException has been thrown while parsing the signature. This is likely due to lack of a generic context. Ensure genericTypeArguments and genericMethodArguments are provided and contain enough context. -Arg_BufferTooSmall = Not enough space available in the buffer. -Arg_CATypeResolutionFailed = Failed to resolve type from string "{0}" which was embedded in custom attribute blob. -Arg_CannotHaveNegativeValue = String cannot contain a minus sign if the base is not 10. -Arg_CannotUnloadAppDomainException = Attempt to unload the AppDomain failed. -Arg_CannotMixComparisonInfrastructure = The usage of IKeyComparer and IHashCodeProvider/IComparer interfaces cannot be mixed; use one or the other. -Arg_ContextMarshalException = Attempted to marshal an object across a context boundary. -Arg_DataMisalignedException = A datatype misalignment was detected in a load or store instruction. -Arg_DevicesNotSupported = FileStream will not open Win32 devices such as disk partitions and tape drives. Avoid use of "\\\\.\\" in the path. -Arg_DuplicateWaitObjectException = Duplicate objects in argument. -Arg_EntryPointNotFoundException = Entry point was not found. -Arg_DllNotFoundException = Dll was not found. -Arg_ExecutionEngineException = Internal error in the runtime. -Arg_FieldAccessException = Attempted to access a field that is not accessible by the caller. -Arg_FileIsDirectory_Name = The target file "{0}" is a directory, not a file. -Arg_FormatException = One of the identified items was in an invalid format. -Arg_IndexOutOfRangeException = Index was outside the bounds of the array. -Arg_InsufficientExecutionStackException = Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space. -Arg_InvalidCastException = Specified cast is not valid. -Arg_InvalidOperationException = Operation is not valid due to the current state of the object. -Arg_CorruptedCustomCultureFile = The file of the custom culture {0} is corrupt. Try to unregister this culture. -Arg_InvokeMember = InvokeMember can be used only for COM objects. -Arg_InvalidNeutralResourcesLanguage_Asm_Culture = The NeutralResourcesLanguageAttribute on the assembly "{0}" specifies an invalid culture name: "{1}". -Arg_InvalidNeutralResourcesLanguage_FallbackLoc = The NeutralResourcesLanguageAttribute specifies an invalid or unrecognized ultimate resource fallback location: "{0}". -Arg_InvalidSatelliteContract_Asm_Ver = Satellite contract version attribute on the assembly '{0}' specifies an invalid version: {1}. -Arg_MethodAccessException = Attempt to access the method failed. -Arg_MethodAccessException_WithMethodName = Attempt to access the method "{0}" on type "{1}" failed. -Arg_MethodAccessException_WithCaller = Attempt by security transparent method '{0}' to access security critical method '{1}' failed. -Arg_MissingFieldException = Attempted to access a non-existing field. -Arg_MissingMemberException = Attempted to access a missing member. -Arg_MissingMethodException = Attempted to access a missing method. -Arg_MulticastNotSupportedException = Attempted to add multiple callbacks to a delegate that does not support multicast. -Arg_NotFiniteNumberException = Number encountered was not a finite quantity. -Arg_NotSupportedException = Specified method is not supported. -Arg_UnboundGenParam = Late bound operations cannot be performed on types or methods for which ContainsGenericParameters is true. -Arg_UnboundGenField = Late bound operations cannot be performed on fields with types for which Type.ContainsGenericParameters is true. -Arg_NotGenericParameter = Method may only be called on a Type for which Type.IsGenericParameter is true. -Arg_GenericParameter = Method must be called on a Type for which Type.IsGenericParameter is false. -Arg_NotGenericTypeDefinition = {0} is not a GenericTypeDefinition. MakeGenericType may only be called on a type for which Type.IsGenericTypeDefinition is true. -Arg_NotGenericMethodDefinition = {0} is not a GenericMethodDefinition. MakeGenericMethod may only be called on a method for which MethodBase.IsGenericMethodDefinition is true. -Arg_BadLiteralFormat = Encountered an invalid type for a default value. -Arg_MissingActivationArguments = The AppDomainSetup must specify the activation arguments for this call. -Argument_BadParameterTypeForCAB = Cannot emit a CustomAttribute with argument of type {0}. -Argument_InvalidMemberForNamedArgument = The member must be either a field or a property. -Argument_InvalidTypeName = The name of the type is invalid. - -; Note - don't change the NullReferenceException default message. This was -; negotiated carefully with the VB team to avoid saying "null" or "nothing". -Arg_NullReferenceException = Object reference not set to an instance of an object. - -Arg_AccessViolationException = Attempted to read or write protected memory. This is often an indication that other memory is corrupt. -Arg_OverflowException = Arithmetic operation resulted in an overflow. -Arg_PathGlobalRoot = Paths that begin with \\\\?\\GlobalRoot are internal to the kernel and should not be opened by managed applications. -Arg_PathIllegal = The path is not of a legal form. -Arg_PathIllegalUNC = The UNC path should be of the form \\\\server\\share. -Arg_RankException = Attempted to operate on an array with the incorrect number of dimensions. -Arg_RankMultiDimNotSupported = Only single dimensional arrays are supported for the requested action. -Arg_NonZeroLowerBound = The lower bound of target array must be zero. -Arg_RegSubKeyValueAbsent = No value exists with that name. -Arg_ResourceFileUnsupportedVersion = The ResourceReader class does not know how to read this version of .resources files. Expected version: {0} This file: {1} -Arg_ResourceNameNotExist = The specified resource name "{0}" does not exist in the resource file. -Arg_SecurityException = Security error. -Arg_SerializationException = Serialization error. -Arg_StackOverflowException = Operation caused a stack overflow. -Arg_SurrogatesNotAllowedAsSingleChar = Unicode surrogate characters must be written out as pairs together in the same call, not individually. Consider passing in a character array instead. -Arg_SynchronizationLockException = Object synchronization method was called from an unsynchronized block of code. -Arg_RWLockRestoreException = ReaderWriterLock.RestoreLock was called without releasing all locks acquired since the call to ReleaseLock. -Arg_SystemException = System error. -Arg_TimeoutException = The operation has timed out. -Arg_UnauthorizedAccessException = Attempted to perform an unauthorized operation. -Arg_ArgumentException = Value does not fall within the expected range. -Arg_DirectoryNotFoundException = Attempted to access a path that is not on the disk. -Arg_DriveNotFoundException = Attempted to access a drive that is not available. -Arg_EndOfStreamException = Attempted to read past the end of the stream. -Arg_HexStyleNotSupported = The number style AllowHexSpecifier is not supported on floating point data types. -Arg_IOException = I/O error occurred. -Arg_InvalidHexStyle = With the AllowHexSpecifier bit set in the enum bit field, the only other valid bits that can be combined into the enum value must be a subset of those in HexNumber. -Arg_KeyNotFound = The given key was not present in the dictionary. -Argument_InvalidNumberStyles = An undefined NumberStyles value is being used. -Argument_InvalidDateTimeStyles = An undefined DateTimeStyles value is being used. -Argument_InvalidTimeSpanStyles = An undefined TimeSpanStyles value is being used. -Argument_DateTimeOffsetInvalidDateTimeStyles = The DateTimeStyles value 'NoCurrentDateDefault' is not allowed when parsing DateTimeOffset. -Argument_NativeResourceAlreadyDefined = Native resource has already been defined. -Argument_BadObjRef = Invalid ObjRef provided to '{0}'. -Argument_InvalidCultureName = Culture name '{0}' is not supported. -Argument_NameTooLong = The name '{0}' is too long to be a Culture or Region name, which is limited to {1} characters. -Argument_NameContainsInvalidCharacters = The name '{0}' contains characters that are not valid for a Culture or Region. -Argument_InvalidRegionName = Region name '{0}' is not supported. -Argument_CannotCreateTypedReference = Cannot use function evaluation to create a TypedReference object. -Arg_ArrayZeroError = Array must not be of length zero. -Arg_BogusIComparer = Unable to sort because the IComparer.Compare() method returns inconsistent results. Either a value does not compare equal to itself, or one value repeatedly compared to another value yields different results. IComparer: '{0}'. -Arg_CreatInstAccess = Cannot specify both CreateInstance and another access type. -Arg_CryptographyException = Error occurred during a cryptographic operation. -Arg_DateTimeRange = Combination of arguments to the DateTime constructor is out of the legal range. -Arg_DecBitCtor = Decimal byte array constructor requires an array of length four containing valid decimal bytes. -Arg_DlgtTargMeth = Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type. -Arg_DlgtTypeMis = Delegates must be of the same type. -Arg_DlgtNullInst = Delegate to an instance method cannot have null 'this'. -Arg_DllInitFailure = One machine may not have remote administration enabled, or both machines may not be running the remote registry service. -Arg_EmptyArray = Array may not be empty. -Arg_EmptyOrNullArray = Array may not be empty or null. -Arg_EmptyCollection = Collection must not be empty. -Arg_EmptyOrNullString = String may not be empty or null. -Argument_ItemNotExist = The specified item does not exist in this KeyedCollection. -Argument_EncodingNotSupported = '{0}' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. -Argument_FallbackBufferNotEmpty = Cannot change fallback when buffer is not empty. Previous Convert() call left data in the fallback buffer. -Argument_InvalidCodePageConversionIndex = Unable to translate Unicode character \\u{0:X4} at index {1} to specified code page. -Argument_InvalidCodePageBytesIndex = Unable to translate bytes {0} at index {1} from specified code page to Unicode. -Argument_RecursiveFallback = Recursive fallback not allowed for character \\u{0:X4}. -Argument_RecursiveFallbackBytes = Recursive fallback not allowed for bytes {0}. -Arg_EnumAndObjectMustBeSameType = Object must be the same type as the enum. The type passed in was '{0}'; the enum type was '{1}'. -Arg_EnumIllegalVal = Illegal enum value: {0}. -Arg_EnumNotSingleFlag = Must set exactly one flag. -Arg_EnumAtLeastOneFlag = Must set at least one flag. -Arg_EnumUnderlyingTypeAndObjectMustBeSameType = Enum underlying type and the object must be same type or object must be a String. Type passed in was '{0}'; the enum underlying type was '{1}'. -Arg_EnumFormatUnderlyingTypeAndObjectMustBeSameType = Enum underlying type and the object must be same type or object. Type passed in was '{0}'; the enum underlying type was '{1}'. -Arg_EnumMustHaveUnderlyingValueField = All enums must have an underlying value__ field. -Arg_COMAccess = Must specify property Set or Get or method call for a COM Object. -Arg_COMPropSetPut = Only one of the following binding flags can be set: BindingFlags.SetProperty, BindingFlags.PutDispProperty, BindingFlags.PutRefDispProperty. -Arg_FldSetGet = Cannot specify both Get and Set on a field. -Arg_PropSetGet = Cannot specify both Get and Set on a property. -Arg_CannotBeNaN = TimeSpan does not accept floating point Not-a-Number values. -Arg_FldGetPropSet = Cannot specify both GetField and SetProperty. -Arg_FldSetPropGet = Cannot specify both SetField and GetProperty. -Arg_FldSetInvoke = Cannot specify Set on a Field and Invoke on a method. -Arg_FldGetArgErr = No arguments can be provided to Get a field value. -Arg_FldSetArgErr = Only the field value can be specified to set a field value. -Arg_GetMethNotFnd = Property Get method was not found. -Arg_GuidArrayCtor = Byte array for GUID must be exactly {0} bytes long. -Arg_HandleNotAsync = Handle does not support asynchronous operations. The parameters to the FileStream constructor may need to be changed to indicate that the handle was opened synchronously (that is, it was not opened for overlapped I/O). -Arg_HandleNotSync = Handle does not support synchronous operations. The parameters to the FileStream constructor may need to be changed to indicate that the handle was opened asynchronously (that is, it was opened explicitly for overlapped I/O). -Arg_HTCapacityOverflow = Hashtable's capacity overflowed and went negative. Check load factor, capacity and the current size of the table. -Arg_IndexMustBeInt = All indexes must be of type Int32. -Arg_InvalidConsoleColor = The ConsoleColor enum value was not defined on that enum. Please use a defined color from the enum. -Arg_InvalidFileAttrs = Invalid File or Directory attributes value. -Arg_InvalidHandle = Invalid handle. -Arg_InvalidTypeInSignature = The signature Type array contains some invalid type (i.e. null, void) -Arg_InvalidTypeInRetType = The return Type contains some invalid type (i.e. null, ByRef) -Arg_EHClauseNotFilter = This ExceptionHandlingClause is not a filter. -Arg_EHClauseNotClause = This ExceptionHandlingClause is not a clause. -Arg_ReflectionOnlyCA = It is illegal to reflect on the custom attributes of a Type loaded via ReflectionOnlyGetType (see Assembly.ReflectionOnly) -- use CustomAttributeData instead. -Arg_ReflectionOnlyInvoke = It is illegal to invoke a method on a Type loaded via ReflectionOnlyGetType. -Arg_ReflectionOnlyField = It is illegal to get or set the value on a field on a Type loaded via ReflectionOnlyGetType. -Arg_MemberInfoNullModule = The Module object containing the member cannot be null. -Arg_ParameterInfoNullMember = The MemberInfo object defining the parameter cannot be null. -Arg_ParameterInfoNullModule = The Module object containing the parameter cannot be null. -Arg_AssemblyNullModule = The manifest module of the assembly cannot be null. -Arg_LongerThanSrcArray = Source array was not long enough. Check the source index, length, and the array's lower bounds. -Arg_LongerThanDestArray = Destination array was not long enough. Check the destination index, length, and the array's lower bounds. -Arg_LowerBoundsMustMatch = The arrays' lower bounds must be identical. -Arg_MustBeBoolean = Object must be of type Boolean. -Arg_MustBeByte = Object must be of type Byte. -Arg_MustBeChar = Object must be of type Char. -Arg_MustBeDateTime = Object must be of type DateTime. -Arg_MustBeDateTimeOffset = Object must be of type DateTimeOffset. -Arg_MustBeDecimal = Object must be of type Decimal. -Arg_MustBeDelegate = Type must derive from Delegate. -Arg_MustBeDouble = Object must be of type Double. -Arg_MustBeDriveLetterOrRootDir = Object must be a root directory ("C:\\") or a drive letter ("C"). -Arg_MustBeEnum = Type provided must be an Enum. -Arg_MustBeEnumBaseTypeOrEnum = The value passed in must be an enum base or an underlying type for an enum, such as an Int32. -Arg_MustBeGuid = Object must be of type GUID. -Arg_MustBeIdentityReferenceType = Type must be an IdentityReference, such as NTAccount or SecurityIdentifier. -Arg_MustBeInterface = Type passed must be an interface. -Arg_MustBeInt16 = Object must be of type Int16. -Arg_MustBeInt32 = Object must be of type Int32. -Arg_MustBeInt64 = Object must be of type Int64. -Arg_MustBePrimArray = Object must be an array of primitives. -Arg_MustBePointer = Type must be a Pointer. -Arg_MustBeStatic = Method must be a static method. -Arg_MustBeString = Object must be of type String. -Arg_MustBeStringPtrNotAtom = The pointer passed in as a String must not be in the bottom 64K of the process's address space. -Arg_MustBeSByte = Object must be of type SByte. -Arg_MustBeSingle = Object must be of type Single. -Arg_MustBeTimeSpan = Object must be of type TimeSpan. -Arg_MustBeType = Type must be a type provided by the runtime. -Arg_MustBeUInt16 = Object must be of type UInt16. -Arg_MustBeUInt32 = Object must be of type UInt32. -Arg_MustBeUInt64 = Object must be of type UInt64. -Arg_MustBeVersion = Object must be of type Version. -Arg_MustBeTrue = Argument must be true. -Arg_MustAllBeRuntimeType = At least one type argument is not a runtime type. -Arg_NamedParamNull = Named parameter value must not be null. -Arg_NamedParamTooBig = Named parameter array cannot be bigger than argument array. -Arg_Need1DArray = Array was not a one-dimensional array. -Arg_Need2DArray = Array was not a two-dimensional array. -Arg_Need3DArray = Array was not a three-dimensional array. -Arg_NeedAtLeast1Rank = Must provide at least one rank. -Arg_NoDefCTor = No parameterless constructor defined for this object. -Arg_BitArrayTypeUnsupported = Only supported array types for CopyTo on BitArrays are Boolean[], Int32[] and Byte[]. -Arg_DivideByZero = Attempted to divide by zero. -Arg_NoAccessSpec = Must specify binding flags describing the invoke operation required (BindingFlags.InvokeMethod CreateInstance GetField SetField GetProperty SetProperty). -Arg_NoStaticVirtual = Method cannot be both static and virtual. -Arg_NotFoundIFace = Interface not found. -Arg_ObjObjEx = Object of type '{0}' cannot be converted to type '{1}'. -Arg_ObjObj = Object type cannot be converted to target type. -Arg_FieldDeclTarget = Field '{0}' defined on type '{1}' is not a field on the target object which is of type '{2}'. -Arg_OleAutDateInvalid = Not a legal OleAut date. -Arg_OleAutDateScale = OleAut date did not convert to a DateTime correctly. -Arg_PlatformNotSupported = Operation is not supported on this platform. -Arg_PlatformSecureString = SecureString is only supported on Windows 2000 SP3 and higher platforms. -Arg_ParmCnt = Parameter count mismatch. -Arg_ParmArraySize = Must specify one or more parameters. -Arg_Path2IsRooted = Second path fragment must not be a drive or UNC name. -Arg_PathIsVolume = Path must not be a drive. -Arg_PrimWiden = Cannot widen from source type to target type either because the source type is a not a primitive type or the conversion cannot be accomplished. -Arg_NullIndex = Arrays indexes must be set to an object instance. -Arg_VarMissNull = Missing parameter does not have a default value. -Arg_PropSetInvoke = Cannot specify Set on a property and Invoke on a method. -Arg_PropNotFound = Could not find the specified property. -Arg_RankIndices = Indices length does not match the array rank. -Arg_RanksAndBounds = Number of lengths and lowerBounds must match. -Arg_RegSubKeyAbsent = Cannot delete a subkey tree because the subkey does not exist. -Arg_RemoveArgNotFound = Cannot remove the specified item because it was not found in the specified Collection. -Arg_RegKeyDelHive = Cannot delete a registry hive's subtree. -Arg_RegKeyNoRemoteConnect = No remote connection to '{0}' while trying to read the registry. -Arg_RegKeyOutOfRange = Registry HKEY was out of the legal range. -Arg_RegKeyNotFound = The specified registry key does not exist. -Arg_RegKeyStrLenBug = Registry key names should not be greater than 255 characters. -Arg_RegValStrLenBug = Registry value names should not be greater than 16,383 characters. -Arg_RegBadKeyKind = The specified RegistryValueKind is an invalid value. -Arg_RegGetOverflowBug = RegistryKey.GetValue does not allow a String that has a length greater than Int32.MaxValue. -Arg_RegSetMismatchedKind = The type of the value object did not match the specified RegistryValueKind or the object could not be properly converted. -Arg_RegSetBadArrType = RegistryKey.SetValue does not support arrays of type '{0}'. Only Byte[] and String[] are supported. -Arg_RegSetStrArrNull = RegistryKey.SetValue does not allow a String[] that contains a null String reference. -Arg_RegInvalidKeyName = Registry key name must start with a valid base key name. -Arg_ResMgrNotResSet = Type parameter must refer to a subclass of ResourceSet. -Arg_SetMethNotFnd = Property set method not found. -Arg_TypeRefPrimitve = TypedReferences cannot be redefined as primitives. -Arg_UnknownTypeCode = Unknown TypeCode value. -Arg_VersionString = Version string portion was too short or too long. -Arg_NoITypeInfo = Specified TypeInfo was invalid because it did not support the ITypeInfo interface. -Arg_NoITypeLib = Specified TypeLib was invalid because it did not support the ITypeLib interface. -Arg_NoImporterCallback = Specified type library importer callback was invalid because it did not support the ITypeLibImporterNotifySink interface. -Arg_ImporterLoadFailure = The type library importer encountered an error during type verification. Try importing without class members. -Arg_InvalidBase = Invalid Base. -Arg_EnumValueNotFound = Requested value '{0}' was not found. -Arg_EnumLitValueNotFound = Literal value was not found. -Arg_MustContainEnumInfo = Must specify valid information for parsing in the string. -Arg_InvalidSearchPattern = Search pattern cannot contain ".." to move up directories and can be contained only internally in file/directory names, as in "a..b". -Arg_NegativeArgCount = Argument count must not be negative. -Arg_InvalidAccessEntry = Specified access entry is invalid because it is unrestricted. The global flags should be specified instead. -Arg_InvalidFileName = Specified file name was invalid. -Arg_InvalidFileExtension = Specified file extension was not a valid extension. -Arg_COMException = Error HRESULT E_FAIL has been returned from a call to a COM component. -Arg_ExternalException = External component has thrown an exception. -Arg_InvalidComObjectException = Attempt has been made to use a COM object that does not have a backing class factory. -Arg_InvalidOleVariantTypeException = Specified OLE variant was invalid. -Arg_MarshalDirectiveException = Marshaling directives are invalid. -Arg_MarshalAsAnyRestriction = AsAny cannot be used on return types, ByRef parameters, ArrayWithOffset, or parameters passed from unmanaged to managed. -Arg_NDirectBadObject = No PInvoke conversion exists for value passed to Object-typed parameter. -Arg_SafeArrayTypeMismatchException = Specified array was not of the expected type. -Arg_VTableCallsNotSupportedException = Attempted to make an early bound call on a COM dispatch-only interface. -Arg_SafeArrayRankMismatchException = Specified array was not of the expected rank. -Arg_AmbiguousMatchException = Ambiguous match found. -Arg_CustomAttributeFormatException = Binary format of the specified custom attribute was invalid. -Arg_InvalidFilterCriteriaException = Specified filter criteria was invalid. -Arg_TypeLoadNullStr = A null or zero length string does not represent a valid Type. -Arg_TargetInvocationException = Exception has been thrown by the target of an invocation. -Arg_TargetParameterCountException = Number of parameters specified does not match the expected number. -Arg_TypeAccessException = Attempt to access the type failed. -Arg_TypeLoadException = Failure has occurred while loading a type. -Arg_TypeUnloadedException = Type had been unloaded. -Arg_ThreadStateException = Thread was in an invalid state for the operation being executed. -Arg_ThreadStartException = Thread failed to start. -Arg_WrongAsyncResult = IAsyncResult object did not come from the corresponding async method on this type. -Arg_WrongType = The value "{0}" is not of type "{1}" and cannot be used in this generic collection. -Argument_InvalidArgumentForComparison = Type of argument is not compatible with the generic comparer. -Argument_ALSInvalidCapacity = Specified capacity must not be less than the current capacity. -Argument_ALSInvalidSlot = Specified slot number was invalid. -Argument_IdnIllegalName = Decoded string is not a valid IDN name. -Argument_IdnBadBidi = Left to right characters may not be mixed with right to left characters in IDN labels. -Argument_IdnBadLabelSize = IDN labels must be between 1 and 63 characters long. -Argument_IdnBadNameSize = IDN names must be between 1 and {0} characters long. -Argument_IdnBadPunycode = Invalid IDN encoded string. -Argument_IdnBadStd3 = Label contains character '{0}' not allowed with UseStd3AsciiRules -Arg_InvalidANSIString = The ANSI string passed in could not be converted from the default ANSI code page to Unicode. -Arg_InvalidUTF8String = The UTF8 string passed in could not be converted to Unicode. -Argument_InvalidCharSequence = Invalid Unicode code point found at index {0}. -Argument_InvalidCharSequenceNoIndex = String contains invalid Unicode code points. -Argument_InvalidCalendar = Not a valid calendar for the given culture. -Argument_InvalidNormalizationForm = Invalid or unsupported normalization form. -Argument_InvalidPathChars = Illegal characters in path. -Argument_InvalidOffLen = Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection. -Argument_InvalidSeekOrigin = Invalid seek origin. -Argument_SeekOverflow = The specified seek offset '{0}' would result in a negative Stream position. -Argument_InvalidUnity = Invalid Unity type. -Argument_LongEnvVarName = Environment variable name cannot contain 1024 or more characters. -Argument_LongEnvVarValue = Environment variable name or value is too long. -Argument_StringFirstCharIsZero = The first char in the string is the null character. -Argument_OnlyMscorlib = Only mscorlib's assembly is valid. -Argument_PathEmpty = Path cannot be the empty string or all whitespace. -Argument_PathFormatNotSupported = The given path's format is not supported. -Argument_PathUriFormatNotSupported = URI formats are not supported. -Argument_TypeNameTooLong = Type name was too long. The fully qualified type name must be less than 1,024 characters. -Argument_StreamNotReadable = Stream was not readable. -Argument_StreamNotWritable = Stream was not writable. -Argument_InvalidNumberOfMembers = MemberData contains an invalid number of members. -Argument_InvalidValue = Value was invalid. -Argument_InvalidKey = Key was invalid. -Argument_MinMaxValue = '{0}' cannot be greater than {1}. -Argument_InvalidGroupSize = Every element in the value array should be between one and nine, except for the last element, which can be zero. -Argument_MustHaveAttributeBaseClass = Type passed in must be derived from System.Attribute or System.Attribute itself. -Argument_NoUninitializedStrings = Uninitialized Strings cannot be created. -Argument_UnequalMembers = Supplied MemberInfo does not match the expected type. -Argument_BadFormatSpecifier = Format specifier was invalid. -Argument_InvalidHighSurrogate = Found a high surrogate char without a following low surrogate at index: {0}. The input may not be in this encoding, or may not contain valid Unicode (UTF-16) characters. -Argument_InvalidLowSurrogate = Found a low surrogate char without a preceding high surrogate at index: {0}. The input may not be in this encoding, or may not contain valid Unicode (UTF-16) characters. -Argument_UnmatchingSymScope = Non-matching symbol scope. -Argument_NotInExceptionBlock = Not currently in an exception block. -Argument_BadExceptionCodeGen = Incorrect code generation for exception block. -Argument_NotExceptionType = Does not extend Exception. -Argument_DuplicateResourceName = Duplicate resource name within an assembly. -Argument_BadPersistableModuleInTransientAssembly = Cannot have a persistable module in a transient assembly. -Argument_InvalidPermissionState = Invalid permission state. -Argument_UnrestrictedIdentityPermission = Identity permissions cannot be unrestricted. -Argument_WrongType = Operation on type '{0}' attempted with target of incorrect type. -Argument_IllegalZone = Illegal security permission zone specified. -Argument_HasToBeArrayClass = Must be an array type. -Argument_InvalidDirectory = Invalid directory, '{0}'. -Argument_DataLengthDifferent = Parameters 'members' and 'data' must have the same length. -Argument_SigIsFinalized = Completed signature cannot be modified. -Argument_ArraysInvalid = Array or pointer types are not valid. -Argument_GenericsInvalid = Generic types are not valid. -Argument_LargeInteger = Integer or token was too large to be encoded. -Argument_BadSigFormat = Incorrect signature format. -Argument_UnmatchedMethodForLocal = Local passed in does not belong to this ILGenerator. -Argument_DuplicateName = Tried to add NamedPermissionSet with non-unique name. -Argument_InvalidXMLElement = Invalid XML. Missing required tag <{0}> for type '{1}'. -Argument_InvalidXMLMissingAttr = Invalid XML. Missing required attribute '{0}'. -Argument_CannotGetTypeTokenForByRef = Cannot get TypeToken for a ByRef type. -Argument_NotASimpleNativeType = The UnmanagedType passed to DefineUnmanagedMarshal is not a simple type. None of the following values may be used: UnmanagedType.ByValTStr, UnmanagedType.SafeArray, UnmanagedType.ByValArray, UnmanagedType.LPArray, UnmanagedType.CustomMarshaler. -Argument_NotACustomMarshaler = Not a custom marshal. -Argument_NoUnmanagedElementCount = Unmanaged marshal does not have ElementCount. -Argument_NoNestedMarshal = Only LPArray or SafeArray has nested unmanaged marshal. -Argument_InvalidXML = Invalid Xml. -Argument_NoUnderlyingCCW = The object has no underlying COM data associated with it. -Argument_BadFieldType = Bad field type in defining field. -Argument_InvalidXMLBadVersion = Invalid Xml - can only parse elements of version one. -Argument_NotAPermissionElement = 'elem' was not a permission element. -Argument_NPMSInvalidName = Name can be neither null nor empty. -Argument_InvalidElementTag = Invalid element tag '{0}'. -Argument_InvalidElementText = Invalid element text '{0}'. -Argument_InvalidElementName = Invalid element name '{0}'. -Argument_InvalidElementValue = Invalid element value '{0}'. -Argument_AttributeNamesMustBeUnique = Attribute names must be unique. -Argument_InvalidHexFormat = Improperly formatted hex string. -Argument_InvalidSite = Invalid site. -Argument_InterfaceMap = 'this' type cannot be an interface itself. -Argument_ArrayGetInterfaceMap = Interface maps for generic interfaces on arrays cannot be retrieved. -Argument_InvalidName = Invalid name. -Argument_InvalidDirectoryOnUrl = Invalid directory on URL. -Argument_InvalidUrl = Invalid URL. -Argument_InvalidKindOfTypeForCA = This type cannot be represented as a custom attribute. -Argument_MustSupplyContainer = When supplying a FieldInfo for fixing up a nested type, a valid ID for that containing object must also be supplied. -Argument_MustSupplyParent = When supplying the ID of a containing object, the FieldInfo that identifies the current field within that object must also be supplied. -Argument_NoClass = Element does not specify a class. -Argument_WrongElementType = '{0}' element required. -Argument_UnableToGeneratePermissionSet = Unable to generate permission set; input XML may be malformed. -Argument_NoEra = No Era was supplied. -Argument_AssemblyAlreadyFullTrust = Assembly was already fully trusted. -Argument_AssemblyNotFullTrust = Assembly was not fully trusted. -Argument_AssemblyWinMD = Assembly must not be a Windows Runtime assembly. -Argument_MemberAndArray = Cannot supply both a MemberInfo and an Array to indicate the parent of a value type. -Argument_ObjNotComObject = The object's type must be __ComObject or derived from __ComObject. -Argument_ObjIsWinRTObject = The object's type must not be a Windows Runtime type. -Argument_TypeNotComObject = The type must be __ComObject or be derived from __ComObject. -Argument_TypeIsWinRTType = The type must not be a Windows Runtime type. -Argument_CantCallSecObjFunc = Cannot evaluate a security function. -Argument_StructMustNotBeValueClass = The structure must not be a value class. -Argument_NoSpecificCulture = Please select a specific culture, such as zh-CN, zh-HK, zh-TW, zh-MO, zh-SG. -Argument_InvalidResourceCultureName = The given culture name '{0}' cannot be used to locate a resource file. Resource filenames must consist of only letters, numbers, hyphens or underscores. -Argument_InvalidParamInfo = Invalid type for ParameterInfo member in Attribute class. -Argument_EmptyDecString = Decimal separator cannot be the empty string. -Argument_OffsetOfFieldNotFound = Field passed in is not a marshaled member of the type '{0}'. -Argument_EmptyStrongName = StrongName cannot have an empty string for the assembly name. -Argument_NotSerializable = Argument passed in is not serializable. -Argument_EmptyApplicationName = ApplicationId cannot have an empty string for the name. -Argument_NoDomainManager = The domain manager specified by the host could not be instantiated. -Argument_NoMain = Main entry point not defined. -Argument_InvalidDateTimeKind = Invalid DateTimeKind value. -Argument_ConflictingDateTimeStyles = The DateTimeStyles values AssumeLocal and AssumeUniversal cannot be used together. -Argument_ConflictingDateTimeRoundtripStyles = The DateTimeStyles value RoundtripKind cannot be used with the values AssumeLocal, AssumeUniversal or AdjustToUniversal. -Argument_InvalidDigitSubstitution = The DigitSubstitution property must be of a valid member of the DigitShapes enumeration. Valid entries include Context, NativeNational or None. -Argument_InvalidNativeDigitCount = The NativeDigits array must contain exactly ten members. -Argument_InvalidNativeDigitValue = Each member of the NativeDigits array must be a single text element (one or more UTF16 code points) with a Unicode Nd (Number, Decimal Digit) property indicating it is a digit. -ArgumentException_InvalidAceBinaryForm = The binary form of an ACE object is invalid. -ArgumentException_InvalidAclBinaryForm = The binary form of an ACL object is invalid. -ArgumentException_InvalidSDSddlForm = The SDDL form of a security descriptor object is invalid. -Argument_InvalidSafeHandle = The SafeHandle is invalid. -Argument_CannotPrepareAbstract = Abstract methods cannot be prepared. -Argument_ArrayTooLarge = The input array length must not exceed Int32.MaxValue / {0}. Otherwise BitArray.Length would exceed Int32.MaxValue. -Argument_RelativeUrlMembershipCondition = UrlMembershipCondition requires an absolute URL. -Argument_EmptyWaithandleArray = Waithandle array may not be empty. -Argument_InvalidSafeBufferOffLen = Offset and length were greater than the size of the SafeBuffer. -Argument_NotEnoughBytesToRead = There are not enough bytes remaining in the accessor to read at this position. -Argument_NotEnoughBytesToWrite = There are not enough bytes remaining in the accessor to write at this position. -Argument_OffsetAndLengthOutOfBounds = Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection. -Argument_OffsetAndCapacityOutOfBounds = Offset and capacity were greater than the size of the view. -Argument_UnmanagedMemAccessorWrapAround = The UnmanagedMemoryAccessor capacity and offset would wrap around the high end of the address space. -Argument_UnrecognizedLoaderOptimization = Unrecognized LOADER_OPTIMIZATION property value. Supported values may include "SingleDomain", "MultiDomain", "MultiDomainHost", and "NotSpecified". -ArgumentException_NotAllCustomSortingFuncsDefined = Implementations of all the NLS functions must be provided. -ArgumentException_MinSortingVersion = The runtime does not support a version of "{0}" less than {1}. -Argument_PreAllocatedAlreadyAllocated = 'preAllocated' is already in use. -Argument_NativeOverlappedWrongBoundHandle = 'overlapped' was not allocated by this ThreadPoolBoundHandle instance. -Argument_NativeOverlappedAlreadyFree = 'overlapped' has already been freed. -Argument_AlreadyBoundOrSyncHandle = 'handle' has already been bound to the thread pool, or was not opened for asynchronous I/O. -Argument_InvalidTypeWithPointersNotSupported = Cannot use type '{0}'. Only value types without pointers or references are supported. -Argument_DestinationTooShort = Destination is too short. - -; -; ===================================================== -; Reflection Emit resource strings -Arugment_EmitMixedContext1 = Type '{0}' was loaded in the ReflectionOnly context but the AssemblyBuilder was not created as AssemblyBuilderAccess.ReflectionOnly. -Arugment_EmitMixedContext2 = Type '{0}' was not loaded in the ReflectionOnly context but the AssemblyBuilder was created as AssemblyBuilderAccess.ReflectionOnly. -Argument_BadSizeForData = Data size must be > 0 and < 0x3f0000 -Argument_InvalidLabel = Invalid Label. -Argument_RedefinedLabel = Label multiply defined. -Argument_UnclosedExceptionBlock = The IL Generator cannot be used while there are unclosed exceptions. -Argument_MissingDefaultConstructor = was missing default constructor. -Argument_TooManyFinallyClause = Exception blocks may have at most one finally clause. -Argument_NotInTheSameModuleBuilder = The argument passed in was not from the same ModuleBuilder. -Argument_BadCurrentLocalVariable = Bad current local variable for setting symbol information. -Argument_DuplicateModuleName = Duplicate dynamic module name within an assembly. -Argument_DuplicateTypeName = Duplicate type name within an assembly. -Argument_InvalidAssemblyName = Assembly names may not begin with whitespace or contain the characters '/', or '\\' or ':'. -Argument_InvalidGenericInstantiation = The given generic instantiation was invalid. -Argument_DuplicatedFileName = Duplicate file names. -Argument_GlobalFunctionHasToBeStatic = Global members must be static. -Argument_BadPInvokeOnInterface = PInvoke methods cannot exist on interfaces. -Argument_BadPInvokeMethod = PInvoke methods must be static and native and cannot be abstract. -Argument_MethodRedefined = Method has been already defined. -Argument_BadTypeAttrAbstractNFinal = Bad type attributes. A type cannot be both abstract and final. -Argument_BadTypeAttrNestedVisibilityOnNonNestedType = Bad type attributes. Nested visibility flag set on a non-nested type. -Argument_BadTypeAttrNonNestedVisibilityNestedType = Bad type attributes. Non-nested visibility flag set on a nested type. -Argument_BadTypeAttrInvalidLayout = Bad type attributes. Invalid layout attribute specified. -Argument_BadTypeAttrReservedBitsSet = Bad type attributes. Reserved bits set on the type. -Argument_BadFieldSig = Field signatures do not have return types. -Argument_ShouldOnlySetVisibilityFlags = Should only set visibility flags when creating EnumBuilder. -Argument_BadNestedTypeFlags = Visibility of interfaces must be one of the following: NestedAssembly, NestedFamANDAssem, NestedFamily, NestedFamORAssem, NestedPrivate or NestedPublic. -Argument_ShouldNotSpecifyExceptionType = Should not specify exception type for catch clause for filter block. -Argument_BadLabel = Bad label in ILGenerator. -Argument_BadLabelContent = Bad label content in ILGenerator. -Argument_EmitWriteLineType = EmitWriteLine does not support this field or local type. -Argument_ConstantNull = Null is not a valid constant value for this type. -Argument_ConstantDoesntMatch = Constant does not match the defined type. -Argument_ConstantNotSupported = {0} is not a supported constant type. -Argument_BadConstructor = Cannot have private or static constructor. -Argument_BadConstructorCallConv = Constructor must have standard calling convention. -Argument_BadPropertyForConstructorBuilder = Property must be on the same type of the given ConstructorInfo. -Argument_NotAWritableProperty = Not a writable property. -Argument_BadFieldForConstructorBuilder = Field must be on the same type of the given ConstructorInfo. -Argument_BadAttributeOnInterfaceMethod = Interface method must be abstract and virtual. -ArgumentException_BadMethodImplBody = MethodOverride's body must be from this type. -Argument_BadParameterCountsForConstructor = Parameter count does not match passed in argument value count. -Argument_BadParameterTypeForConstructor = Passed in argument value at index {0} does not match the parameter type. -Argument_BadTypeInCustomAttribute = An invalid type was used as a custom attribute constructor argument, field or property. -Argument_DateTimeBadBinaryData = The binary data must result in a DateTime with ticks between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. -Argument_VerStringTooLong = The unmanaged Version information is too large to persist. -Argument_UnknownUnmanagedCallConv = Unknown unmanaged calling convention for function signature. -Argument_BadConstantValue = Bad default value. -Argument_IllegalName = Illegal name. -Argument_cvtres_NotFound = Cannot find cvtres.exe -Argument_BadCAForUnmngRSC = Bad '{0}' while generating unmanaged resource information. -Argument_MustBeInterfaceMethod = The MemberInfo must be an interface method. -Argument_CORDBBadVarArgCallConv = Cannot evaluate a VarArgs function. -Argument_CORDBBadMethod = Cannot find the method on the object instance. -Argument_InvalidOpCodeOnDynamicMethod = Ldtoken, Ldftn and Ldvirtftn OpCodes cannot target DynamicMethods. -Argument_InvalidTypeForDynamicMethod = Invalid type owner for DynamicMethod. -Argument_NeedGenericMethodDefinition = Method must represent a generic method definition on a generic type definition. -Argument_MethodNeedGenericDeclaringType = The specified method cannot be dynamic or global and must be declared on a generic type definition. -Argument_ConstructorNeedGenericDeclaringType = The specified constructor must be declared on a generic type definition. -Argument_FieldNeedGenericDeclaringType = The specified field must be declared on a generic type definition. -Argument_InvalidMethodDeclaringType = The specified method must be declared on the generic type definition of the specified type. -Argument_InvalidConstructorDeclaringType = The specified constructor must be declared on the generic type definition of the specified type. -Argument_InvalidFieldDeclaringType = The specified field must be declared on the generic type definition of the specified type. -Argument_NeedNonGenericType = The specified Type must not be a generic type definition. -Argument_MustBeTypeBuilder = 'type' must contain a TypeBuilder as a generic argument. -Argument_CannotSetParentToInterface = Cannot set parent to an interface. -Argument_MismatchedArrays = Two arrays, {0} and {1}, must be of the same size. -Argument_NeedNonGenericObject = The specified object must not be an instance of a generic type. -Argument_NeedStructWithNoRefs = The specified Type must be a struct containing no references. -Argument_NotMethodCallOpcode = The specified opcode cannot be passed to EmitCall. - -; ===================================================== -; -Argument_ModuleAlreadyLoaded = The specified module has already been loaded. -Argument_MustHaveLayoutOrBeBlittable = The specified structure must be blittable or have layout information. -Argument_NotSimpleFileName = The filename must not include a path specification. -Argument_TypeMustBeVisibleFromCom = The specified type must be visible from COM. -Argument_TypeMustBeComCreatable = The type must be creatable from COM. -Argument_TypeMustNotBeComImport = The type must not be imported from COM. -Argument_PolicyFileDoesNotExist = The requested policy file does not exist. -Argument_NonNullObjAndCtx = Either obj or ctx must be null. -Argument_NoModuleFileExtension = Module file name '{0}' must have file extension. -Argument_TypeDoesNotContainMethod = Type does not contain the given method. -Argument_StringZeroLength = String cannot be of zero length. -Argument_MustBeString = String is too long or has invalid contents. -Argument_AbsolutePathRequired = Absolute path information is required. -Argument_ManifestFileDoesNotExist = The specified manifest file does not exist. -Argument_MustBeRuntimeType = Type must be a runtime Type object. -Argument_TypeNotValid = The Type object is not valid. -Argument_MustBeRuntimeMethodInfo = MethodInfo must be a runtime MethodInfo object. -Argument_MustBeRuntimeFieldInfo = FieldInfo must be a runtime FieldInfo object. -Argument_InvalidFieldInfo = The FieldInfo object is not valid. -Argument_InvalidConstructorInfo = The ConstructorInfo object is not valid. -Argument_MustBeRuntimeAssembly = Assembly must be a runtime Assembly object. -Argument_MustBeRuntimeModule = Module must be a runtime Module object. -Argument_MustBeRuntimeParameterInfo = ParameterInfo must be a runtime ParameterInfo object. -Argument_InvalidParameterInfo = The ParameterInfo object is not valid. -Argument_MustBeRuntimeReflectionObject = The object must be a runtime Reflection object. -Argument_InvalidMarshalByRefObject = The MarshalByRefObject is not valid. -Argument_TypedReferenceInvalidField = Field in TypedReferences cannot be static or init only. -Argument_HandleLeak = Cannot pass a GCHandle across AppDomains. -Argument_ArgumentZero = Argument cannot be zero. -Argument_ImproperType = Improper types in collection. -Argument_NotAMembershipCondition = The type does not implement IMembershipCondition -Argument_NotAPermissionType = The type does not implement IPermission -Argument_NotACodeGroupType = The type does not inherit from CodeGroup -Argument_NotATP = Type must be a TransparentProxy -Argument_AlreadyACCW = The object already has a CCW associated with it. -Argument_OffsetLocalMismatch = The UTC Offset of the local dateTime parameter does not match the offset argument. -Argument_OffsetUtcMismatch = The UTC Offset for Utc DateTime instances must be 0. -Argument_UTCOutOfRange = The UTC time represented when the offset is applied must be between year 0 and 10,000. -Argument_OffsetOutOfRange = Offset must be within plus or minus 14 hours. -Argument_OffsetPrecision = Offset must be specified in whole minutes. -Argument_FlagNotSupported = One or more flags are not supported. -Argument_MustBeFalse = Argument must be initialized to false -Argument_ToExclusiveLessThanFromExclusive = fromInclusive must be less than or equal to toExclusive. -Argument_FrameworkNameTooShort=FrameworkName cannot have less than two components or more than three components. -Argument_FrameworkNameInvalid=FrameworkName is invalid. -Argument_FrameworkNameMissingVersion=FrameworkName version component is missing. -#if FEATURE_COMINTEROP -Argument_TypeNotActivatableViaWindowsRuntime = Type '{0}' does not have an activation factory because it is not activatable by Windows Runtime. -Argument_WinRTSystemRuntimeType = Cannot marshal type '{0}' to Windows Runtime. Only 'System.RuntimeType' is supported. -Argument_Unexpected_TypeSource = Unexpected TypeKind when marshaling Windows.Foundation.TypeName. -#endif // FEATURE_COMINTEROP - -; ArgumentNullException -ArgumentNull_Array = Array cannot be null. -ArgumentNull_ArrayValue = Found a null value within an array. -ArgumentNull_ArrayElement = At least one element in the specified array was null. -ArgumentNull_Assembly = Assembly cannot be null. -ArgumentNull_AssemblyName = AssemblyName cannot be null. -ArgumentNull_AssemblyNameName = AssemblyName.Name cannot be null or an empty string. -ArgumentNull_Buffer = Buffer cannot be null. -ArgumentNull_Collection = Collection cannot be null. -ArgumentNull_CultureInfo = CultureInfo cannot be null. -ArgumentNull_Dictionary = Dictionary cannot be null. -ArgumentNull_FileName = File name cannot be null. -ArgumentNull_Key = Key cannot be null. -ArgumentNull_Graph = Object Graph cannot be null. -ArgumentNull_Path = Path cannot be null. -ArgumentNull_Stream = Stream cannot be null. -ArgumentNull_String = String reference not set to an instance of a String. -ArgumentNull_Type = Type cannot be null. -ArgumentNull_Obj = Object cannot be null. -ArgumentNull_GUID = GUID cannot be null. -ArgumentNull_NullMember = Member at position {0} was null. -ArgumentNull_Generic = Value cannot be null. -ArgumentNull_WithParamName = Parameter '{0}' cannot be null. -ArgumentNull_Child = Cannot have a null child. -ArgumentNull_SafeHandle = SafeHandle cannot be null. -ArgumentNull_CriticalHandle = CriticalHandle cannot be null. -ArgumentNull_TypedRefType = Type in TypedReference cannot be null. -ArgumentNull_ApplicationTrust = The application trust cannot be null. -ArgumentNull_TypeRequiredByResourceScope = The type parameter cannot be null when scoping the resource's visibility to Private or Assembly. -ArgumentNull_Waithandles = The waitHandles parameter cannot be null. - -; ArgumentOutOfRangeException -ArgumentOutOfRange_AddressSpace = The number of bytes cannot exceed the virtual address space on a 32 bit machine. -ArgumentOutOfRange_ArrayLB = Number was less than the array's lower bound in the first dimension. -ArgumentOutOfRange_ArrayLBAndLength = Higher indices will exceed Int32.MaxValue because of large lower bound and/or length. -ArgumentOutOfRange_ArrayLength = The length of the array must be between {0} and {1}, inclusive. -ArgumentOutOfRange_ArrayLengthMultiple = The length of the array must be a multiple of {0}. -ArgumentOutOfRange_ArrayListInsert = Insertion index was out of range. Must be non-negative and less than or equal to size. -ArgumentOutOfRange_ArrayTooSmall = Destination array is not long enough to copy all the required data. Check array length and offset. -ArgumentOutOfRange_BeepFrequency = Console.Beep's frequency must be between {0} and {1}. -ArgumentOutOfRange_BiggerThanCollection = Larger than collection size. -ArgumentOutOfRange_Bounds_Lower_Upper = Argument must be between {0} and {1}. -ArgumentOutOfRange_Count = Count must be positive and count must refer to a location within the string/array/collection. -ArgumentOutOfRange_CalendarRange = Specified time is not supported in this calendar. It should be between {0} (Gregorian date) and {1} (Gregorian date), inclusive. -ArgumentOutOfRange_ConsoleBufferBoundaries = The value must be greater than or equal to zero and less than the console's buffer size in that dimension. -ArgumentOutOfRange_ConsoleBufferLessThanWindowSize = The console buffer size must not be less than the current size and position of the console window, nor greater than or equal to Int16.MaxValue. -ArgumentOutOfRange_ConsoleWindowBufferSize = The new console window size would force the console buffer size to be too large. -ArgumentOutOfRange_ConsoleTitleTooLong = The console title is too long. -ArgumentOutOfRange_ConsoleWindowPos = The window position must be set such that the current window size fits within the console's buffer, and the numbers must not be negative. -ArgumentOutOfRange_ConsoleWindowSize_Size = The value must be less than the console's current maximum window size of {0} in that dimension. Note that this value depends on screen resolution and the console font. -ArgumentOutOfRange_ConsoleKey = Console key values must be between 0 and 255. -ArgumentOutOfRange_CursorSize = The cursor size is invalid. It must be a percentage between 1 and 100. -ArgumentOutOfRange_BadYearMonthDay = Year, Month, and Day parameters describe an un-representable DateTime. -ArgumentOutOfRange_BadHourMinuteSecond = Hour, Minute, and Second parameters describe an un-representable DateTime. -ArgumentOutOfRange_DateArithmetic = The added or subtracted value results in an un-representable DateTime. -ArgumentOutOfRange_DateTimeBadMonths = Months value must be between +/-120000. -ArgumentOutOfRange_DateTimeBadYears = Years value must be between +/-10000. -ArgumentOutOfRange_DateTimeBadTicks = Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. -ArgumentOutOfRange_Day = Day must be between 1 and {0} for month {1}. -ArgumentOutOfRange_DecimalRound = Decimal can only round to between 0 and 28 digits of precision. -ArgumentOutOfRange_DecimalScale = Decimal's scale value must be between 0 and 28, inclusive. -ArgumentOutOfRange_Era = Time value was out of era range. -ArgumentOutOfRange_Enum = Enum value was out of legal range. -ArgumentOutOfRange_FileLengthTooBig = Specified file length was too large for the file system. -ArgumentOutOfRange_FileTimeInvalid = Not a valid Win32 FileTime. -ArgumentOutOfRange_GetByteCountOverflow = Too many characters. The resulting number of bytes is larger than what can be returned as an int. -ArgumentOutOfRange_GetCharCountOverflow = Too many bytes. The resulting number of chars is larger than what can be returned as an int. -ArgumentOutOfRange_HashtableLoadFactor = Load factor needs to be between 0.1 and 1.0. -ArgumentOutOfRange_HugeArrayNotSupported = Arrays larger than 2GB are not supported. -ArgumentOutOfRange_InvalidHighSurrogate = A valid high surrogate character is between 0xd800 and 0xdbff, inclusive. -ArgumentOutOfRange_InvalidLowSurrogate = A valid low surrogate character is between 0xdc00 and 0xdfff, inclusive. -ArgumentOutOfRange_InvalidEraValue = Era value was not valid. -ArgumentOutOfRange_InvalidUserDefinedAceType = User-defined ACEs must not have a well-known ACE type. -ArgumentOutOfRange_InvalidUTF32 = A valid UTF32 value is between 0x000000 and 0x10ffff, inclusive, and should not include surrogate codepoint values (0x00d800 ~ 0x00dfff). -ArgumentOutOfRange_Index = Index was out of range. Must be non-negative and less than the size of the collection. -ArgumentOutOfRange_IndexString = Index was out of range. Must be non-negative and less than the length of the string. -ArgumentOutOfRange_StreamLength = Stream length must be non-negative and less than 2^31 - 1 - origin. -ArgumentOutOfRange_LessEqualToIntegerMaxVal = Argument must be less than or equal to 2^31 - 1 milliseconds. -ArgumentOutOfRange_Month = Month must be between one and twelve. -ArgumentOutOfRange_MustBeNonNegInt32 = Value must be non-negative and less than or equal to Int32.MaxValue. -ArgumentOutOfRange_NeedNonNegNum = Non-negative number required. -ArgumentOutOfRange_NeedNonNegOrNegative1 = Number must be either non-negative and less than or equal to Int32.MaxValue or -1. -ArgumentOutOfRange_NeedPosNum = Positive number required. -ArgumentOutOfRange_NegativeCapacity = Capacity must be positive. -ArgumentOutOfRange_NegativeCount = Count cannot be less than zero. -ArgumentOutOfRange_NegativeLength = Length cannot be less than zero. -ArgumentOutOfRange_NegFileSize = Length must be non-negative. -ArgumentOutOfRange_ObjectID = objectID cannot be less than or equal to zero. -ArgumentOutOfRange_SmallCapacity = capacity was less than the current size. -ArgumentOutOfRange_QueueGrowFactor = Queue grow factor must be between {0} and {1}. -ArgumentOutOfRange_RoundingDigits = Rounding digits must be between 0 and 15, inclusive. -ArgumentOutOfRange_StartIndex = StartIndex cannot be less than zero. -ArgumentOutOfRange_MustBePositive = '{0}' must be greater than zero. -ArgumentOutOfRange_MustBeNonNegNum = '{0}' must be non-negative. -ArgumentOutOfRange_LengthGreaterThanCapacity = The length cannot be greater than the capacity. -ArgumentOutOfRange_ListInsert = Index must be within the bounds of the List. -ArgumentOutOfRange_StartIndexLessThanLength = startIndex must be less than length of string. -ArgumentOutOfRange_StartIndexLargerThanLength = startIndex cannot be larger than length of string. -ArgumentOutOfRange_EndIndexStartIndex = endIndex cannot be greater than startIndex. -ArgumentOutOfRange_IndexCount = Index and count must refer to a location within the string. -ArgumentOutOfRange_IndexCountBuffer = Index and count must refer to a location within the buffer. -ArgumentOutOfRange_IndexLength = Index and length must refer to a location within the string. -ArgumentOutOfRange_InvalidThreshold = The specified threshold for creating dictionary is out of range. -ArgumentOutOfRange_Capacity = Capacity exceeds maximum capacity. -ArgumentOutOfRange_Length = The specified length exceeds maximum capacity of SecureString. -ArgumentOutOfRange_LengthTooLarge = The specified length exceeds the maximum value of {0}. -ArgumentOutOfRange_SmallMaxCapacity = MaxCapacity must be one or greater. -ArgumentOutOfRange_GenericPositive = Value must be positive. -ArgumentOutOfRange_Range = Valid values are between {0} and {1}, inclusive. -ArgumentOutOfRange_AddValue = Value to add was out of range. -ArgumentOutOfRange_OffsetLength = Offset and length must refer to a position in the string. -ArgumentOutOfRange_OffsetOut = Either offset did not refer to a position in the string, or there is an insufficient length of destination character array. -ArgumentOutOfRange_PartialWCHAR = Pointer startIndex and length do not refer to a valid string. -ArgumentOutOfRange_ParamSequence = The specified parameter index is not in range. -ArgumentOutOfRange_Version = Version's parameters must be greater than or equal to zero. -ArgumentOutOfRange_TimeoutTooLarge = Time-out interval must be less than 2^32-2. -ArgumentOutOfRange_UIntPtrMax-1 = The length of the buffer must be less than the maximum UIntPtr value for your platform. -ArgumentOutOfRange_UnmanagedMemStreamLength = UnmanagedMemoryStream length must be non-negative and less than 2^63 - 1 - baseAddress. -ArgumentOutOfRange_UnmanagedMemStreamWrapAround = The UnmanagedMemoryStream capacity would wrap around the high end of the address space. -ArgumentOutOfRange_PeriodTooLarge = Period must be less than 2^32-2. -ArgumentOutOfRange_Year = Year must be between 1 and 9999. -ArgumentOutOfRange_BinaryReaderFillBuffer = The number of bytes requested does not fit into BinaryReader's internal buffer. -ArgumentOutOfRange_PositionLessThanCapacityRequired = The position may not be greater or equal to the capacity of the accessor. - -; ArithmeticException -Arithmetic_NaN = Function does not accept floating point Not-a-Number values. - -; ArrayTypeMismatchException -ArrayTypeMismatch_CantAssignType = Source array type cannot be assigned to destination array type. -ArrayTypeMismatch_ConstrainedCopy = Array.ConstrainedCopy will only work on array types that are provably compatible, without any form of boxing, unboxing, widening, or casting of each array element. Change the array types (i.e., copy a Derived[] to a Base[]), or use a mitigation strategy in the CER for Array.Copy's less powerful reliability contract, such as cloning the array or throwing away the potentially corrupt destination array. - -; BadImageFormatException -BadImageFormat_ResType&SerBlobMismatch = The type serialized in the .resources file was not the same type that the .resources file said it contained. Expected '{0}' but read '{1}'. -BadImageFormat_ResourcesIndexTooLong = Corrupt .resources file. String for name index '{0}' extends past the end of the file. -BadImageFormat_ResourcesNameTooLong = Corrupt .resources file. Resource name extends past the end of the file. -BadImageFormat_ResourcesNameInvalidOffset = Corrupt .resources file. Invalid offset '{0}' into name section. -BadImageFormat_ResourcesHeaderCorrupted = Corrupt .resources file. Unable to read resources from this file because of invalid header information. Try regenerating the .resources file. -BadImageFormat_ResourceNameCorrupted = Corrupt .resources file. A resource name extends past the end of the stream. -BadImageFormat_ResourceNameCorrupted_NameIndex = Corrupt .resources file. The resource name for name index {0} extends past the end of the stream. -BadImageFormat_ResourceDataLengthInvalid = Corrupt .resources file. The specified data length '{0}' is not a valid position in the stream. -BadImageFormat_TypeMismatch = Corrupt .resources file. The specified type doesn't match the available data in the stream. -BadImageFormat_InvalidType = Corrupt .resources file. The specified type doesn't exist. -BadImageFormat_ResourcesIndexInvalid = Corrupt .resources file. The resource index '{0}' is outside the valid range. -BadImageFormat_StreamPositionInvalid = Corrupt .resources file. The specified position '{0}' is not a valid position in the stream. -BadImageFormat_ResourcesDataInvalidOffset = Corrupt .resources file. Invalid offset '{0}' into data section. -BadImageFormat_NegativeStringLength = Corrupt .resources file. String length must be non-negative. -BadImageFormat_ParameterSignatureMismatch = The parameters and the signature of the method don't match. -BadImageFormat_BadILFormat = Bad IL format. - -; Cryptography -; These strings still appear in bcl.small but should go away eventually -Cryptography_CSSM_Error = Error 0x{0} from the operating system security framework: '{1}'. -Cryptography_CSSM_Error_Unknown = Error 0x{0} from the operating system security framework. -Cryptography_InvalidDSASignatureSize = Length of the DSA signature was not 40 bytes. -Cryptography_InvalidHandle = {0} is an invalid handle. -Cryptography_InvalidOID = Object identifier (OID) is unknown. -Cryptography_OAEPDecoding = Error occurred while decoding OAEP padding. -Cryptography_PasswordDerivedBytes_InvalidIV = The Initialization vector should have the same length as the algorithm block size in bytes. -Cryptography_SSE_InvalidDataSize = Length of the data to encrypt is invalid. -Cryptography_X509_ExportFailed = The certificate export operation failed. -Cryptography_X509_InvalidContentType = Invalid content type. -Cryptography_CryptoStream_FlushFinalBlockTwice = FlushFinalBlock() method was called twice on a CryptoStream. It can only be called once. -Cryptography_HashKeySet = Hash key cannot be changed after the first write to the stream. -Cryptography_HashNotYetFinalized = Hash must be finalized before the hash value is retrieved. -Cryptography_InsufficientBuffer = Input buffer contains insufficient data. -Cryptography_InvalidBlockSize = Specified block size is not valid for this algorithm. -Cryptography_InvalidCipherMode = Specified cipher mode is not valid for this algorithm. -Cryptography_InvalidIVSize = Specified initialization vector (IV) does not match the block size for this algorithm. -Cryptography_InvalidKeySize = Specified key is not a valid size for this algorithm. -Cryptography_PasswordDerivedBytes_FewBytesSalt = Salt is not at least eight bytes. -Cryptography_PKCS7_InvalidPadding = Padding is invalid and cannot be removed. -Cryptography_UnknownHashAlgorithm='{0}' is not a known hash algorithm. - -; EventSource -EventSource_ToString = EventSource({0}, {1}) -EventSource_EventSourceGuidInUse = An instance of EventSource with Guid {0} already exists. -EventSource_KeywordNeedPowerOfTwo = Value {0} for keyword {1} needs to be a power of 2. -EventSource_UndefinedKeyword = Use of undefined keyword value {0} for event {1}. -EventSource_UnsupportedEventTypeInManifest = Unsupported type {0} in event source. -EventSource_ListenerNotFound = Listener not found. -EventSource_ListenerCreatedInsideCallback = Creating an EventListener inside a EventListener callback. -EventSource_AttributeOnNonVoid = Event attribute placed on method {0} which does not return 'void'. -EventSource_NeedPositiveId = Event IDs must be positive integers. -EventSource_ReservedOpcode = Opcode values less than 11 are reserved for system use. -EventSource_ReservedKeywords = Keywords values larger than 0x0000100000000000 are reserved for system use -EventSource_PayloadTooBig=The payload for a single event is too large. -EventSource_NoFreeBuffers=No Free Buffers available from the operating system (e.g. event rate too fast). -EventSource_NullInput=Null passed as a event argument. -EventSource_TooManyArgs=Too many arguments. -EventSource_SessionIdError=Bit position in AllKeywords ({0}) must equal the command argument named "EtwSessionKeyword" ({1}). -EventSource_EnumKindMismatch = The type of {0} is not expected in {1}. -EventSource_MismatchIdToWriteEvent = Event {0} is givien event ID {1} but {2} was passed to WriteEvent. -EventSource_EventIdReused = Event {0} has ID {1} which is already in use. -EventSource_EventNameReused = Event name {0} used more than once. If you wish to overload a method, the overloaded method should have a NonEvent attribute. -EventSource_UndefinedChannel = Use of undefined channel value {0} for event {1}. -EventSource_UndefinedOpcode = Use of undefined opcode value {0} for event {1}. -ArgumentOutOfRange_MaxArgExceeded = The total number of parameters must not exceed {0}. -ArgumentOutOfRange_MaxStringsExceeded = The number of String parameters must not exceed {0}. -ArgumentOutOfRange_NeedValidId = The ID parameter must be in the range {0} through {1}. -EventSource_NeedGuid = The Guid of an EventSource must be non zero. -EventSource_NeedName = The name of an EventSource must not be null. -EventSource_EtwAlreadyRegistered = The provider has already been registered with the operating system. -EventSource_ListenerWriteFailure = An error occurred when writing to a listener. -EventSource_TypeMustDeriveFromEventSource = Event source types must derive from EventSource. -EventSource_TypeMustBeSealedOrAbstract = Event source types must be sealed or abstract. -EventSource_TaskOpcodePairReused = Event {0} (with ID {1}) has the same task/opcode pair as event {2} (with ID {3}). -EventSource_EventMustHaveTaskIfNonDefaultOpcode = Event {0} (with ID {1}) has a non-default opcode but not a task. -EventSource_EventNameDoesNotEqualTaskPlusOpcode = Event {0} (with ID {1}) has a name that is not the concatenation of its task name and opcode. -EventSource_PeriodIllegalInProviderName = Period character ('.') is illegal in an ETW provider name ({0}). -EventSource_IllegalOpcodeValue = Opcode {0} has a value of {1} which is outside the legal range (11-238). -EventSource_OpcodeCollision = Opcodes {0} and {1} are defined with the same value ({2}). -EventSource_IllegalTaskValue = Task {0} has a value of {1} which is outside the legal range (1-65535). -EventSource_TaskCollision = Tasks {0} and {1} are defined with the same value ({2}). -EventSource_IllegalKeywordsValue = Keyword {0} has a value of {1} which is outside the legal range (0-0x0000080000000000). -EventSource_KeywordCollision = Keywords {0} and {1} are defined with the same value ({2}). -EventSource_EventChannelOutOfRange = Channel {0} has a value of {1} which is outside the legal range (16-254). -EventSource_ChannelTypeDoesNotMatchEventChannelValue = Channel {0} does not match event channel value {1}. -EventSource_MaxChannelExceeded = Attempt to define more than the maximum limit of 8 channels for a provider. -EventSource_DuplicateStringKey = Multiple definitions for string "{0}". -EventSource_EventWithAdminChannelMustHaveMessage = Event {0} specifies an Admin channel {1}. It must specify a Message property. -EventSource_UnsupportedMessageProperty = Event {0} specifies an illegal or unsupported formatting message ("{1}"). -EventSource_AbstractMustNotDeclareKTOC = Abstract event source must not declare {0} nested type. -EventSource_AbstractMustNotDeclareEventMethods = Abstract event source must not declare event methods ({0} with ID {1}). -EventSource_EventMustNotBeExplicitImplementation = Event method {0} (with ID {1}) is an explicit interface method implementation. Re-write method as implicit implementation. -EventSource_EventParametersMismatch = Event {0} was called with {1} argument(s), but it is defined with {2} parameter(s). -EventSource_InvalidCommand = Invalid command value. -EventSource_InvalidEventFormat = Can't specify both etw event format flags. -EventSource_AddScalarOutOfRange = Getting out of bounds during scalar addition. -EventSource_PinArrayOutOfRange = Pins are out of range. -EventSource_DataDescriptorsOutOfRange = Data descriptors are out of range. -EventSource_NotSupportedArrayOfNil = Arrays of Nil are not supported. -EventSource_NotSupportedArrayOfBinary = Arrays of Binary are not supported. -EventSource_NotSupportedArrayOfNullTerminatedString = Arrays of null-terminated string are not supported. -EventSource_TooManyFields = Too many fields in structure. -EventSource_RecursiveTypeDefinition = Recursive type definition is not supported. -EventSource_NotSupportedEnumType = Enum type {0} underlying type {1} is not supported for serialization. -EventSource_NonCompliantTypeError = The API supports only anonymous types or types decorated with the EventDataAttribute. Non-compliant type: {0} dataType. -EventSource_NotSupportedNestedArraysEnums = Nested arrays/enumerables are not supported. -EventSource_IncorrentlyAuthoredTypeInfo = Incorrectly-authored TypeInfo - a type should be serialized as one field or as one group -EventSource_NotSupportedCustomSerializedData = Enumerables of custom-serialized data are not supported -EventSource_StopsFollowStarts = An event with stop suffix must follow a corresponding event with a start suffix. -EventSource_NoRelatedActivityId = EventSource expects the first parameter of the Event method to be of type Guid and to be named "relatedActivityId" when calling WriteEventWithRelatedActivityId. -EventSource_VarArgsParameterMismatch = The parameters to the Event method do not match the parameters to the WriteEvent method. This may cause the event to be displayed incorrectly. - -; ExecutionEngineException -ExecutionEngine_InvalidAttribute = Attribute cannot have multiple definitions. -ExecutionEngine_MissingSecurityDescriptor = Unable to retrieve security descriptor for this frame. - -;;ExecutionContext -ExecutionContext_UndoFailed = Undo operation on a component context threw an exception -ExecutionContext_ExceptionInAsyncLocalNotification = An exception was not handled in an AsyncLocal notification callback. - - -; FieldAccessException -FieldAccess_InitOnly = InitOnly (aka ReadOnly) fields can only be initialized in the type/instance constructor. - -; FormatException -Format_AttributeUsage = Duplicate AttributeUsageAttribute found on attribute type {0}. -Format_Bad7BitInt32 = Too many bytes in what should have been a 7 bit encoded Int32. -Format_BadBase = Invalid digits for the specified base. -Format_BadBase64Char = The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters. -Format_BadBase64CharArrayLength = Invalid length for a Base-64 char array or string. -Format_BadBoolean = String was not recognized as a valid Boolean. -Format_BadDateTime = String was not recognized as a valid DateTime. -Format_BadDateTimeCalendar = The DateTime represented by the string is not supported in calendar {0}. -Format_BadDayOfWeek = String was not recognized as a valid DateTime because the day of week was incorrect. -Format_DateOutOfRange = The DateTime represented by the string is out of range. -Format_BadDatePattern = Could not determine the order of year, month, and date from '{0}'. -Format_BadFormatSpecifier = Format specifier was invalid. -Format_BadTimeSpan = String was not recognized as a valid TimeSpan. -Format_BadQuote = Cannot find a matching quote character for the character '{0}'. -Format_EmptyInputString = Input string was either empty or contained only whitespace. -Format_ExtraJunkAtEnd = Additional non-parsable characters are at the end of the string. -Format_GuidBrace = Expected {0xdddddddd, etc}. -Format_GuidComma = Could not find a comma, or the length between the previous token and the comma was zero (i.e., '0x,'etc.). -Format_GuidBraceAfterLastNumber = Could not find a brace, or the length between the previous token and the brace was zero (i.e., '0x,'etc.). -Format_GuidDashes = Dashes are in the wrong position for GUID parsing. -Format_GuidEndBrace = Could not find the ending brace. -Format_GuidHexPrefix = Expected hex 0x in '{0}'. -Format_GuidInvLen = Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). -Format_GuidInvalidChar = Guid string should only contain hexadecimal characters. -Format_GuidUnrecognized = Unrecognized Guid format. -Format_InvalidEnumFormatSpecification = Format String can be only "G", "g", "X", "x", "F", "f", "D" or "d". -Format_InvalidGuidFormatSpecification = Format String can be only "D", "d", "N", "n", "P", "p", "B", "b", "X" or "x". -Format_InvalidString = Input string was not in a correct format. -Format_IndexOutOfRange = Index (zero based) must be greater than or equal to zero and less than the size of the argument list. -Format_UnknowDateTimeWord = The string was not recognized as a valid DateTime. There is an unknown word starting at index {0}. -Format_NeedSingleChar = String must be exactly one character long. -Format_NoParsibleDigits = Could not find any recognizable digits. -Format_RepeatDateTimePattern = DateTime pattern '{0}' appears more than once with different values. -Format_StringZeroLength = String cannot have zero length. -Format_TwoTimeZoneSpecifiers = The String being parsed cannot contain two TimeZone specifiers. -Format_UTCOutOfRange= The UTC representation of the date falls outside the year range 1-9999. -Format_OffsetOutOfRange=The time zone offset must be within plus or minus 14 hours. -Format_MissingIncompleteDate=There must be at least a partial date with a year present in the input. - -; IndexOutOfRangeException -IndexOutOfRange_ArrayRankIndex = Array does not have that many dimensions. -IndexOutOfRange_IORaceCondition = Probable I/O race condition detected while copying memory. The I/O package is not thread safe by default. In multithreaded applications, a stream must be accessed in a thread-safe way, such as a thread-safe wrapper returned by TextReader's or TextWriter's Synchronized methods. This also applies to classes like StreamWriter and StreamReader. -IndexOutOfRange_UMSPosition = Unmanaged memory stream position was beyond the capacity of the stream. - -; InsufficientMemoryException -InsufficientMemory_MemFailPoint = Insufficient available memory to meet the expected demands of an operation at this time. Please try again later. -InsufficientMemory_MemFailPoint_TooBig = Insufficient memory to meet the expected demands of an operation, and this system is likely to never satisfy this request. If this is a 32 bit system, consider booting in 3 GB mode. -InsufficientMemory_MemFailPoint_VAFrag = Insufficient available memory to meet the expected demands of an operation at this time, possibly due to virtual address space fragmentation. Please try again later. - - -; InvalidCastException -InvalidCast_DBNull = Object cannot be cast to DBNull. -InvalidCast_DownCastArrayElement = At least one element in the source array could not be cast down to the destination array type. -InvalidCast_Empty = Object cannot be cast to Empty. -InvalidCast_FromDBNull = Object cannot be cast from DBNull to other types. -InvalidCast_FromTo = Invalid cast from '{0}' to '{1}'. -InvalidCast_IConvertible = Object must implement IConvertible. -InvalidCast_OATypeMismatch = OleAut reported a type mismatch. -InvalidCast_StoreArrayElement = Object cannot be stored in an array of this type. -InvalidCast_CannotCoerceByRefVariant = Object cannot be coerced to the original type of the ByRef VARIANT it was obtained from. -InvalidCast_CannotCastNullToValueType = Null object cannot be converted to a value type. -#if FEATURE_COMINTEROP -InvalidCast_WinRTIPropertyValueElement = Object in an IPropertyValue is of type '{0}', which cannot be converted to a '{1}'. -InvalidCast_WinRTIPropertyValueCoersion = Object in an IPropertyValue is of type '{0}' with value '{1}', which cannot be converted to a '{2}'. -InvalidCast_WinRTIPropertyValueArrayCoersion = Object in an IPropertyValue is of type '{0}' which cannot be convereted to a '{1}' due to array element '{2}': {3}. -#endif // FEATURE_COMINTEROP - -; InvalidOperationException -InvalidOperation_ActivationArgsAppTrustMismatch = The activation arguments and application trust for the AppDomain must correspond to the same application identity. -InvalidOperation_AddContextFrozen = Attempted to add properties to a frozen context. -InvalidOperation_AppDomainSandboxAPINeedsExplicitAppBase = This API requires the ApplicationBase to be specified explicitly in the AppDomainSetup parameter. -InvalidOperation_CantCancelCtrlBreak = Applications may not prevent control-break from terminating their process. -InvalidOperation_CalledTwice = The method cannot be called twice on the same instance. -InvalidOperation_CollectionCorrupted = A prior operation on this collection was interrupted by an exception. Collection's state is no longer trusted. -InvalidOperation_CriticalTransparentAreMutuallyExclusive = SecurityTransparent and SecurityCritical attributes cannot be applied to the assembly scope at the same time. -InvalidOperation_ExceptionStateCrossAppDomain = Thread.ExceptionState cannot access an ExceptionState from a different AppDomain. -InvalidOperation_DebuggerLaunchFailed = Debugger unable to launch. -InvalidOperation_ApartmentStateSwitchFailed = Failed to set the specified COM apartment state. -InvalidOperation_EmptyQueue = Queue empty. -InvalidOperation_EmptyStack = Stack empty. -InvalidOperation_CannotRemoveFromStackOrQueue = Removal is an invalid operation for Stack or Queue. -InvalidOperation_EnumEnded = Enumeration already finished. -InvalidOperation_EnumFailedVersion = Collection was modified; enumeration operation may not execute. -InvalidOperation_EnumNotStarted = Enumeration has not started. Call MoveNext. -InvalidOperation_EnumOpCantHappen = Enumeration has either not started or has already finished. -InvalidOperation_ModifyRONumFmtInfo = Unable to modify a read-only NumberFormatInfo object. -InvalidOperation_MustBeSameThread = This operation must take place on the same thread on which the object was created. -InvalidOperation_MustRevertPrivilege = Must revert the privilege prior to attempting this operation. -InvalidOperation_ReadOnly = Instance is read-only. -InvalidOperation_RegRemoveSubKey = Registry key has subkeys and recursive removes are not supported by this method. -InvalidOperation_IComparerFailed = Failed to compare two elements in the array. -InvalidOperation_InternalState = Invalid internal state. -InvalidOperation_DuplicatePropertyName = Another property by this name already exists. -InvalidOperation_NotCurrentDomain = You can only define a dynamic assembly on the current AppDomain. -InvalidOperation_ContextAlreadyFrozen = Context is already frozen. -InvalidOperation_WriteOnce = This property has already been set and cannot be modified. -InvalidOperation_MethodBaked = Type definition of the method is complete. -InvalidOperation_MethodHasBody = Method already has a body. -InvalidOperation_ModificationOfNonCanonicalAcl = This access control list is not in canonical form and therefore cannot be modified. -InvalidOperation_Method = This method is not supported by the current object. -InvalidOperation_NativeOverlappedReused = NativeOverlapped cannot be reused for multiple operations. -InvalidOperation_NotADebugModule = Not a debug ModuleBuilder. -InvalidOperation_NoMultiModuleAssembly = You cannot have more than one dynamic module in each dynamic assembly in this version of the runtime. -InvalidOperation_OpenLocalVariableScope = Local variable scope was not properly closed. -InvalidOperation_SetVolumeLabelFailed = Volume labels can only be set for writable local volumes. -InvalidOperation_SetData = An additional permission should not be supplied for setting loader information. -InvalidOperation_SetData_OnlyOnce = SetData can only be used to set the value of a given name once. -InvalidOperation_SetData_OnlyLocationURI = SetData cannot be used to set the value for '{0}'. -InvalidOperation_TypeHasBeenCreated = Unable to change after type has been created. -InvalidOperation_TypeNotCreated = Type has not been created. -InvalidOperation_NoUnderlyingTypeOnEnum = Underlying type information on enumeration is not specified. -InvalidOperation_ResMgrBadResSet_Type = '{0}': ResourceSet derived classes must provide a constructor that takes a String file name and a constructor that takes a Stream. -InvalidOperation_AssemblyHasBeenSaved = Assembly '{0}' has been saved. -InvalidOperation_ModuleHasBeenSaved = Module '{0}' has been saved. -InvalidOperation_CannotAlterAssembly = Unable to alter assembly information. -InvalidOperation_BadTransientModuleReference = Unable to make a reference to a transient module from a non-transient module. -InvalidOperation_BadILGeneratorUsage = ILGenerator usage is invalid. -InvalidOperation_BadInstructionOrIndexOutOfBound = MSIL instruction is invalid or index is out of bounds. -InvalidOperation_ShouldNotHaveMethodBody = Method body should not exist. -InvalidOperation_EntryMethodNotDefinedInAssembly = Entry method is not defined in the same assembly. -InvalidOperation_CantSaveTransientAssembly = Cannot save a transient assembly. -InvalidOperation_BadResourceContainer = Unable to add resource to transient module or transient assembly. -InvalidOperation_CantInstantiateAbstractClass = Instances of abstract classes cannot be created. -InvalidOperation_CantInstantiateFunctionPointer = Instances of function pointers cannot be created. -InvalidOperation_BadTypeAttributesNotAbstract = Type must be declared abstract if any of its methods are abstract. -InvalidOperation_BadInterfaceNotAbstract = Interface must be declared abstract. -InvalidOperation_ConstructorNotAllowedOnInterface = Interface cannot have constructors. -InvalidOperation_BadMethodBody = Method '{0}' cannot have a method body. -InvalidOperation_MetaDataError = Metadata operation failed. -InvalidOperation_BadEmptyMethodBody = Method '{0}' does not have a method body. -InvalidOperation_EndInvokeCalledMultiple = EndInvoke can only be called once for each asynchronous operation. -InvalidOperation_EndReadCalledMultiple = EndRead can only be called once for each asynchronous operation. -InvalidOperation_EndWriteCalledMultiple = EndWrite can only be called once for each asynchronous operation. -InvalidOperation_AsmLoadedForReflectionOnly = Assembly has been loaded as ReflectionOnly. This API requires an assembly capable of execution. -InvalidOperation_NoAsmName = Assembly does not have an assembly name. In order to be registered for use by COM, an assembly must have a valid assembly name. -InvalidOperation_NoAsmCodeBase = Assembly does not have a code base. -InvalidOperation_HandleIsNotInitialized = Handle is not initialized. -InvalidOperation_HandleIsNotPinned = Handle is not pinned. -InvalidOperation_SlotHasBeenFreed = LocalDataStoreSlot storage has been freed. -InvalidOperation_GlobalsHaveBeenCreated = Type definition of the global function has been completed. -InvalidOperation_NotAVarArgCallingConvention = Calling convention must be VarArgs. -InvalidOperation_CannotImportGlobalFromDifferentModule = Unable to import a global method or field from a different module. -InvalidOperation_NonStaticComRegFunction = COM register function must be static. -InvalidOperation_NonStaticComUnRegFunction = COM unregister function must be static. -InvalidOperation_InvalidComRegFunctionSig = COM register function must have a System.Type parameter and a void return type. -InvalidOperation_InvalidComUnRegFunctionSig = COM unregister function must have a System.Type parameter and a void return type. -InvalidOperation_MultipleComRegFunctions = Type '{0}' has more than one COM registration function. -InvalidOperation_MultipleComUnRegFunctions = Type '{0}' has more than one COM unregistration function. -InvalidOperation_MustCallInitialize = You must call Initialize on this object instance before using it. -InvalidOperation_MustLockForReadOrWrite = Object must be locked for read or write. -InvalidOperation_MustLockForWrite = Object must be locked for read. -InvalidOperation_NoValue = Nullable object must have a value. -InvalidOperation_ResourceNotStream_Name = Resource '{0}' was not a Stream - call GetObject instead. -InvalidOperation_ResourceNotString_Name = Resource '{0}' was not a String - call GetObject instead. -InvalidOperation_ResourceNotString_Type = Resource was of type '{0}' instead of String - call GetObject instead. -InvalidOperation_ResourceWriterSaved = The resource writer has already been closed and cannot be edited. -InvalidOperation_UnderlyingArrayListChanged = This range in the underlying list is invalid. A possible cause is that elements were removed. -InvalidOperation_AnonymousCannotImpersonate = An anonymous identity cannot perform an impersonation. -InvalidOperation_DefaultConstructorILGen = Unable to access ILGenerator on a constructor created with DefineDefaultConstructor. -InvalidOperation_DefaultConstructorDefineBody = The method body of the default constructor cannot be changed. -InvalidOperation_ComputerName = Computer name could not be obtained. -InvalidOperation_MismatchedAsyncResult = The IAsyncResult object provided does not match this delegate. -InvalidOperation_PIAMustBeStrongNamed = Primary interop assemblies must be strongly named. -InvalidOperation_HashInsertFailed = Hashtable insert failed. Load factor too high. The most common cause is multiple threads writing to the Hashtable simultaneously. -InvalidOperation_UnknownEnumType = Unknown enum type. -InvalidOperation_GetVersion = OSVersion's call to GetVersionEx failed. -InvalidOperation_DateTimeParsing = Internal Error in DateTime and Calendar operations. -InvalidOperation_UserDomainName = UserDomainName native call failed. -InvalidOperation_WaitOnTransparentProxy = Cannot wait on a transparent proxy. -InvalidOperation_NoPublicAddMethod = Cannot add the event handler since no public add method exists for the event. -InvalidOperation_NoPublicRemoveMethod = Cannot remove the event handler since no public remove method exists for the event. -InvalidOperation_NotSupportedOnWinRTEvent = Adding or removing event handlers dynamically is not supported on WinRT events. -InvalidOperation_ConsoleKeyAvailableOnFile = Cannot see if a key has been pressed when either application does not have a console or when console input has been redirected from a file. Try Console.In.Peek. -InvalidOperation_ConsoleReadKeyOnFile = Cannot read keys when either application does not have a console or when console input has been redirected from a file. Try Console.Read. -InvalidOperation_ThreadWrongThreadStart = The thread was created with a ThreadStart delegate that does not accept a parameter. -InvalidOperation_ThreadAPIsNotSupported = Use CompressedStack.(Capture/Run) or ExecutionContext.(Capture/Run) APIs instead. -InvalidOperation_NotNewCaptureContext = Cannot apply a context that has been marshaled across AppDomains, that was not acquired through a Capture operation or that has already been the argument to a Set call. -InvalidOperation_NullContext = Cannot call Set on a null context -InvalidOperation_CannotCopyUsedContext = Only newly captured contexts can be copied -InvalidOperation_CannotUseSwitcherOtherThread = Undo operation must be performed on the thread where the corresponding context was Set. -InvalidOperation_SwitcherCtxMismatch = The Undo operation encountered a context that is different from what was applied in the corresponding Set operation. The possible cause is that a context was Set on the thread and not reverted(undone). -InvalidOperation_CannotOverrideSetWithoutRevert = Must override both HostExecutionContextManager.SetHostExecutionContext and HostExecutionContextManager.Revert. -InvalidOperation_CannotUseAFCOtherThread = AsyncFlowControl object must be used on the thread where it was created. -InvalidOperation_CannotRestoreUnsupressedFlow = Cannot restore context flow when it is not suppressed. -InvalidOperation_CannotSupressFlowMultipleTimes = Context flow is already suppressed. -InvalidOperation_CannotUseAFCMultiple = AsyncFlowControl object can be used only once to call Undo(). -InvalidOperation_AsyncFlowCtrlCtxMismatch = AsyncFlowControl objects can be used to restore flow only on a Context that had its flow suppressed. -InvalidOperation_TimeoutsNotSupported = Timeouts are not supported on this stream. -InvalidOperation_Overlapped_Pack = Cannot pack a packed Overlapped again. -InvalidOperation_OnlyValidForDS = Adding ACEs with Object Flags and Object GUIDs is only valid for directory-object ACLs. -InvalidOperation_WrongAsyncResultOrEndReadCalledMultiple = Either the IAsyncResult object did not come from the corresponding async method on this type, or EndRead was called multiple times with the same IAsyncResult. -InvalidOperation_WrongAsyncResultOrEndWriteCalledMultiple = Either the IAsyncResult object did not come from the corresponding async method on this type, or EndWrite was called multiple times with the same IAsyncResult. -InvalidOperation_WrongAsyncResultOrEndCalledMultiple = Either the IAsyncResult object did not come from the corresponding async method on this type, or the End method was called multiple times with the same IAsyncResult. -InvalidOperation_NoSecurityDescriptor = The object does not contain a security descriptor. -InvalidOperation_NotAllowedInReflectionOnly = The requested operation is invalid in the ReflectionOnly context. -InvalidOperation_NotAllowedInDynamicMethod = The requested operation is invalid for DynamicMethod. -InvalidOperation_PropertyInfoNotAvailable = This API does not support PropertyInfo tokens. -InvalidOperation_EventInfoNotAvailable = This API does not support EventInfo tokens. -InvalidOperation_UnexpectedWin32Error = Unexpected error when calling an operating system function. The returned error code is 0x{0:x}. -InvalidOperation_AssertTransparentCode = Cannot perform CAS Asserts in Security Transparent methods -InvalidOperation_NullModuleHandle = The requested operation is invalid when called on a null ModuleHandle. -InvalidOperation_NotWithConcurrentGC = This API is not available when the concurrent GC is enabled. -InvalidOperation_WithoutARM = This API is not available when AppDomain Resource Monitoring is not turned on. -InvalidOperation_NotGenericType = This operation is only valid on generic types. -InvalidOperation_TypeCannotBeBoxed = The given type cannot be boxed. -InvalidOperation_HostModifiedSecurityState = The security state of an AppDomain was modified by an AppDomainManager configured with the NoSecurityChanges flag. -InvalidOperation_StrongNameKeyPairRequired = A strong name key pair is required to emit a strong-named dynamic assembly. -#if FEATURE_COMINTEROP -InvalidOperation_EventTokenTableRequiresDelegate = Type '{0}' is not a delegate type. EventTokenTable may only be used with delegate types. -#endif // FEATURE_COMINTEROP -InvalidOperation_NullArray = The underlying array is null. -;system.security.claims -InvalidOperation_ClaimCannotBeRemoved = The Claim '{0}' was not able to be removed. It is either not part of this Identity or it is a claim that is owned by the Principal that contains this Identity. For example, the Principal will own the claim when creating a GenericPrincipal with roles. The roles will be exposed through the Identity that is passed in the constructor, but not actually owned by the Identity. Similar logic exists for a RolePrincipal. -InvalidOperationException_ActorGraphCircular = Actor cannot be set so that circular directed graph will exist chaining the subjects together. -InvalidOperation_AsyncIOInProgress = The stream is currently in use by a previous operation on the stream. -InvalidOperation_APIInvalidForCurrentContext = The API '{0}' cannot be used on the current platform. See http://go.microsoft.com/fwlink/?LinkId=248273 for more information. - -; InvalidProgramException -InvalidProgram_Default = Common Language Runtime detected an invalid program. - -; Verification Exception -Verification_Exception = Operation could destabilize the runtime. - -; IL stub marshaler exceptions -Marshaler_StringTooLong = Marshaler restriction: Excessively long string. - -; Missing (General) -MissingConstructor_Name = Constructor on type '{0}' not found. -MissingField = Field not found. -MissingField_Name = Field '{0}' not found. -MissingMember = Member not found. -MissingMember_Name = Member '{0}' not found. -MissingMethod_Name = Method '{0}' not found. -MissingModule = Module '{0}' not found. -MissingType = Type '{0}' not found. - -; MissingManifestResourceException -Arg_MissingManifestResourceException = Unable to find manifest resource. -MissingManifestResource_LooselyLinked = Could not find a manifest resource entry called "{0}" in assembly "{1}". Please check spelling, capitalization, and build rules to ensure "{0}" is being linked into the assembly. -MissingManifestResource_NoNeutralAsm = Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "{0}" was correctly embedded or linked into assembly "{1}" at compile time, or that all the satellite assemblies required are loadable and fully signed. -MissingManifestResource_NoNeutralDisk = Could not find any resources appropriate for the specified culture (or the neutral culture) on disk. -MissingManifestResource_MultipleBlobs = A case-insensitive lookup for resource file "{0}" in assembly "{1}" found multiple entries. Remove the duplicates or specify the exact case. -MissingManifestResource_ResWFileNotLoaded = Unable to load resources for resource file "{0}" in package "{1}". -MissingManifestResource_NoPRIresources = Unable to open Package Resource Index. - -; MissingMember -MissingMemberTypeRef = FieldInfo does not match the target Type. -MissingMemberNestErr = TypedReference can only be made on nested value Types. - -; MissingSatelliteAssemblyException -MissingSatelliteAssembly_Default = Resource lookup fell back to the ultimate fallback resources in a satellite assembly, but that satellite either was not found or could not be loaded. Please consider reinstalling or repairing the application. -MissingSatelliteAssembly_Culture_Name = The satellite assembly named "{1}" for fallback culture "{0}" either could not be found or could not be loaded. This is generally a setup problem. Please consider reinstalling or repairing the application. - -; MulticastNotSupportedException -Multicast_Combine = Delegates that are not of type MulticastDelegate may not be combined. - -; NotImplementedException -Arg_NotImplementedException = The method or operation is not implemented. -NotImplemented_ResourcesLongerThan2^63 = Resource files longer than 2^63 bytes are not currently implemented. - -; NotSupportedException -NotSupported_NYI = This feature is not currently implemented. -NotSupported_AbstractNonCLS = This non-CLS method is not implemented. -NotSupported_ChangeType = ChangeType operation is not supported. -NotSupported_ByRefLike = Cannot create boxed ByRef-like values. -NotSupported_ByRefLike[] = Cannot create arrays of ByRef-like values. -NotSupported_OpenType = Cannot create arrays of open type. -NotSupported_DBNullSerial = Only one DBNull instance may exist, and calls to DBNull deserialization methods are not allowed. -NotSupported_DelegateSerHolderSerial = DelegateSerializationHolder objects are designed to represent a delegate during serialization and are not serializable themselves. -NotSupported_DelegateCreationFromPT = Application code cannot use Activator.CreateInstance to create types that derive from System.Delegate. Delegate.CreateDelegate can be used instead. -NotSupported_EncryptionNeedsNTFS = File encryption support only works on NTFS partitions. -NotSupported_FileStreamOnNonFiles = FileStream was asked to open a device that was not a file. For support for devices like 'com1:' or 'lpt1:', call CreateFile, then use the FileStream constructors that take an OS handle as an IntPtr. -NotSupported_FixedSizeCollection = Collection was of a fixed size. -NotSupported_KeyCollectionSet = Mutating a key collection derived from a dictionary is not allowed. -NotSupported_ValueCollectionSet = Mutating a value collection derived from a dictionary is not allowed. -NotSupported_MemStreamNotExpandable = Memory stream is not expandable. -NotSupported_ObsoleteResourcesFile = Found an obsolete .resources file in assembly '{0}'. Rebuild that .resources file then rebuild that assembly. -NotSupported_OleAutBadVarType = The given Variant type is not supported by this OleAut function. -NotSupported_PopulateData = This Surrogate does not support PopulateData(). -NotSupported_ReadOnlyCollection = Collection is read-only. -NotSupported_RangeCollection = The specified operation is not supported on Ranges. -NotSupported_SortedListNestedWrite = This operation is not supported on SortedList nested types because they require modifying the original SortedList. -NotSupported_SubclassOverride = Derived classes must provide an implementation. -NotSupported_TypeCannotDeserialized = Direct deserialization of type '{0}' is not supported. -NotSupported_UnreadableStream = Stream does not support reading. -NotSupported_UnseekableStream = Stream does not support seeking. -NotSupported_UnwritableStream = Stream does not support writing. -NotSupported_CannotWriteToBufferedStreamIfReadBufferCannotBeFlushed = Cannot write to a BufferedStream while the read buffer is not empty if the underlying stream is not seekable. Ensure that the stream underlying this BufferedStream can seek or avoid interleaving read and write operations on this BufferedStream. -NotSupported_Method = Method is not supported. -NotSupported_Constructor = Object cannot be created through this constructor. -NotSupported_DynamicModule = The invoked member is not supported in a dynamic module. -NotSupported_TypeNotYetCreated = The invoked member is not supported before the type is created. -NotSupported_SymbolMethod = Not supported in an array method of a type definition that is not complete. -NotSupported_NotDynamicModule = The MethodRental.SwapMethodBody method can only be called to swap the method body of a method in a dynamic module. -NotSupported_DynamicAssembly = The invoked member is not supported in a dynamic assembly. -NotSupported_NotAllTypesAreBaked = Type '{0}' was not completed. -NotSupported_CannotSaveModuleIndividually = Unable to save a ModuleBuilder if it was created underneath an AssemblyBuilder. Call Save on the AssemblyBuilder instead. -NotSupported_MaxWaitHandles = The number of WaitHandles must be less than or equal to 64. -NotSupported_IllegalOneByteBranch = Illegal one-byte branch at position: {0}. Requested branch was: {1}. -NotSupported_OutputStreamUsingTypeBuilder = Output streams do not support TypeBuilders. -NotSupported_ValueClassCM = Custom marshalers for value types are not currently supported. -NotSupported_Void[] = Arrays of System.Void are not supported. -NotSupported_NoParentDefaultConstructor = Parent does not have a default constructor. The default constructor must be explicitly defined. -NotSupported_NonReflectedType = Not supported in a non-reflected type. -NotSupported_GlobalFunctionNotBaked = The type definition of the global function is not completed. -NotSupported_SecurityPermissionUnion = Union is not implemented. -NotSupported_UnitySerHolder = The UnitySerializationHolder object is designed to transmit information about other types and is not serializable itself. -NotSupported_UnknownTypeCode = TypeCode '{0}' was not valid. -NotSupported_WaitAllSTAThread = WaitAll for multiple handles on a STA thread is not supported. -NotSupported_SignalAndWaitSTAThread = SignalAndWait on a STA thread is not supported. -NotSupported_CreateInstanceWithTypeBuilder = CreateInstance cannot be used with an object of type TypeBuilder. -NotSupported_NonUrlAttrOnMBR = UrlAttribute is the only attribute supported for MarshalByRefObject. -NotSupported_ActivAttrOnNonMBR = Activation Attributes are not supported for types not deriving from MarshalByRefObject. -NotSupported_ActivAttr = Activation Attributes are not supported. -NotSupported_ActivForCom = Activation Attributes not supported for COM Objects. -NotSupported_NoCodepageData = No data is available for encoding {0}. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. -NotSupported_CodePage50229 = The ISO-2022-CN Encoding (Code page 50229) is not supported. -NotSupported_DynamicAssemblyNoRunAccess = Cannot execute code on a dynamic assembly without run access. -NotSupported_IDispInvokeDefaultMemberWithNamedArgs = Invoking default method with named arguments is not supported. -NotSupported_Type = Type is not supported. -NotSupported_GetMethod = The 'get' method is not supported on this property. -NotSupported_SetMethod = The 'set' method is not supported on this property. -NotSupported_DeclarativeUnion = Declarative unionizing of these permissions is not supported. -NotSupported_StringComparison = The string comparison type passed in is currently not supported. -NotSupported_WrongResourceReader_Type = This .resources file should not be read with this reader. The resource reader type is "{0}". -NotSupported_MustBeModuleBuilder = Module argument must be a ModuleBuilder. -NotSupported_CallToVarArg = Vararg calling convention not supported. -NotSupported_TooManyArgs = Stack size too deep. Possibly too many arguments. -NotSupported_DeclSecVarArg = Assert, Deny, and PermitOnly are not supported on methods with a Vararg calling convention. -NotSupported_AmbiguousIdentity = The operation is ambiguous because the permission represents multiple identities. -NotSupported_DynamicMethodFlags = Wrong MethodAttributes or CallingConventions for DynamicMethod. Only public, static, standard supported -NotSupported_GlobalMethodSerialization = Serialization of global methods (including implicit serialization via the use of asynchronous delegates) is not supported. -NotSupported_InComparableType = A type must implement IComparable or IComparable to support comparison. -NotSupported_ManagedActivation = Cannot create uninitialized instances of types requiring managed activation. -NotSupported_ByRefReturn = ByRef return value not supported in reflection invocation. -NotSupported_DelegateMarshalToWrongDomain = Delegates cannot be marshaled from native code into a domain other than their home domain. -NotSupported_ResourceObjectSerialization = Cannot read resources that depend on serialization. -NotSupported_One = The arithmetic type '{0}' cannot represent the number one. -NotSupported_Zero = The arithmetic type '{0}' cannot represent the number zero. -NotSupported_MaxValue = The arithmetic type '{0}' does not have a maximum value. -NotSupported_MinValue = The arithmetic type '{0}' does not have a minimum value. -NotSupported_PositiveInfinity = The arithmetic type '{0}' cannot represent positive infinity. -NotSupported_NegativeInfinity = The arithmetic type '{0}' cannot represent negative infinity. -NotSupported_UmsSafeBuffer = This operation is not supported for an UnmanagedMemoryStream created from a SafeBuffer. -NotSupported_Reading = Accessor does not support reading. -NotSupported_Writing = Accessor does not support writing. -NotSupported_UnsafePointer = This accessor was created with a SafeBuffer; use the SafeBuffer to gain access to the pointer. -NotSupported_CollectibleCOM = COM Interop is not supported for collectible types. -NotSupported_CollectibleAssemblyResolve = Resolving to a collectible assembly is not supported. -NotSupported_CollectibleBoundNonCollectible = A non-collectible assembly may not reference a collectible assembly. -NotSupported_CollectibleDelegateMarshal = Delegate marshaling for types within collectible assemblies is not supported. -NotSupported_NonStaticMethod = Non-static methods with NativeCallableAttribute are not supported. -NotSupported_NativeCallableTarget = Methods with NativeCallableAttribute cannot be used as delegate target. -NotSupported_GenericMethod = Generic methods with NativeCallableAttribute are not supported. -NotSupported_NonBlittableTypes = Non-blittable parameter types are not supported for NativeCallable methods. - -NotSupported_UserDllImport = DllImport cannot be used on user-defined methods. -NotSupported_UserCOM = COM Interop is not supported for user-defined types. - -#if FEATURE_APPX -NotSupported_AppX = {0} is not supported in AppX. -LoadOfFxAssemblyNotSupported_AppX = {0} of .NET Framework assemblies is not supported in AppX. -#endif -#if FEATURE_COMINTEROP -NotSupported_WinRT_PartialTrust = Windows Runtime is not supported in partial trust. -#endif // FEATURE_COMINTEROP -; ReflectionTypeLoadException -ReflectionTypeLoad_LoadFailed = Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. -#if FEATURE_COMINTEROP -NotSupported_PIAInAppxProcess = A Primary Interop Assembly is not supported in AppX. -#endif -NotSupported_AssemblyLoadCodeBase = Assembly.Load with a Codebase is not supported. -NotSupported_AssemblyLoadFromHash = Assembly.LoadFrom with hashValue is not supported. -NotSupported_CannotCallEqualsOnSpan = Equals() on Span and ReadOnlySpan is not supported. Use operator== instead. -NotSupported_CannotCallGetHashCodeOnSpan = GetHashCode() on Span and ReadOnlySpan is not supported. -NotSupported_ReflectionOnlyLoad = Assembly.ReflectionOnlyLoad is not supported. -NotSupported_ReflectionOnlyGetType = Type.ReflectionOnlyGetType is not supported. - -; TypeLoadException -TypeLoad_ResolveType = Could not resolve type '{0}'. -TypeLoad_ResolveTypeFromAssembly = Could not resolve type '{0}' in assembly '{1}'. -TypeLoad_ResolveNestedType = Could not resolve nested type '{0}' in type "{1}'. -FileNotFound_ResolveAssembly = Could not resolve assembly '{0}'. - -; NullReferenceException -NullReference_This = The pointer for this method was null. - -; ObjectDisposedException -ObjectDisposed_Generic = Cannot access a disposed object. -ObjectDisposed_FileClosed = Cannot access a closed file. -ObjectDisposed_ObjectName_Name = Object name: '{0}'. -ObjectDisposed_ReaderClosed = Cannot read from a closed TextReader. -ObjectDisposed_ResourceSet = Cannot access a closed resource set. -ObjectDisposed_RegKeyClosed = Cannot access a closed registry key. -ObjectDisposed_StreamClosed = Cannot access a closed Stream. -ObjectDisposed_WriterClosed = Cannot write to a closed TextWriter. -ObjectDisposed_ViewAccessorClosed = Cannot access a closed accessor. - -; OperationCanceledException -OperationCanceled = The operation was canceled. - -; OutOfMemoryException -OutOfMemory_GCHandleMDA = The GCHandle MDA has run out of available cookies. - -; OverflowException -Overflow_Byte = Value was either too large or too small for an unsigned byte. -Overflow_Char = Value was either too large or too small for a character. -Overflow_Currency = Value was either too large or too small for a Currency. -Overflow_Decimal = Value was either too large or too small for a Decimal. -Overflow_Int16 = Value was either too large or too small for an Int16. -Overflow_Int32 = Value was either too large or too small for an Int32. -Overflow_Int64 = Value was either too large or too small for an Int64. -Overflow_NegateTwosCompNum = Negating the minimum value of a twos complement number is invalid. -Overflow_NegativeUnsigned = The string was being parsed as an unsigned number and could not have a negative sign. -Overflow_SByte = Value was either too large or too small for a signed byte. -Overflow_Single = Value was either too large or too small for a Single. -Overflow_Double = Value was either too large or too small for a Double. -Overflow_TimeSpanTooLong = TimeSpan overflowed because the duration is too long. -Overflow_TimeSpanElementTooLarge = The TimeSpan could not be parsed because at least one of the numeric components is out of range or contains too many digits. -Overflow_Duration = The duration cannot be returned for TimeSpan.MinValue because the absolute value of TimeSpan.MinValue exceeds the value of TimeSpan.MaxValue. -Overflow_UInt16 = Value was either too large or too small for a UInt16. -Overflow_UInt32 = Value was either too large or too small for a UInt32. -Overflow_UInt64 = Value was either too large or too small for a UInt64. - -; PlatformNotsupportedException -PlatformNotSupported_RequiresLonghorn = This operation is only supported on Windows Vista and above. -PlatformNotSupported_RequiresNT = This operation is only supported on Windows 2000, Windows XP, and higher. -PlatformNotSupported_RequiresW2kSP3 = This operation is only supported on Windows 2000 SP3 or later operating systems. -#if FEATURE_COMINTEROP -PlatformNotSupported_WinRT = Windows Runtime is not supported on this operating system. -#endif // FEATURE_COMINTEROP - -; PolicyException -; This still appears in bcl.small but should go away eventually -Policy_Default = Error occurred while performing a policy operation. -Policy_CannotLoadSemiTrustAssembliesDuringInit = All assemblies loaded as part of AppDomain initialization must be fully trusted. -Policy_SaveNotFileBased = PolicyLevel object not based on a file cannot be saved. -Policy_AppTrustMustGrantAppRequest = ApplicationTrust grant set does not contain ActivationContext's minimum request set. - -Error_SecurityPolicyFileParse = Error occurred while parsing the '{0}' policy level. The default policy level was used instead. -Error_SecurityPolicyFileParseEx = Error '{1}' occurred while parsing the '{0}' policy level. The default policy level was used instead. - -; RankException -Rank_MultiDimNotSupported = Only single dimension arrays are supported here. -Rank_MustMatch = The specified arrays must have the same number of dimensions. - -; TypeInitializationException -TypeInitialization_Default = Type constructor threw an exception. -TypeInitialization_Type = The type initializer for '{0}' threw an exception. - -; TypeLoadException - - -; -; Reflection exceptions -; -RtType.InvalidCaller = Caller is not a friend. - -;CustomAttributeFormatException -RFLCT.InvalidPropFail = '{0}' property specified was not found. -RFLCT.InvalidFieldFail = '{0}' field specified was not found. - -;InvalidFilterCriteriaException -InvalidFilterCriteriaException_CritString = A String must be provided for the filter criteria. -InvalidFilterCriteriaException_CritInt = An Int32 must be provided for the filter criteria. - -; TargetException -RFLCT.Targ_ITargMismatch = Object does not match target type. -RFLCT.Targ_StatMethReqTarg = Non-static method requires a target. -RFLCT.Targ_StatFldReqTarg = Non-static field requires a target. - -;AmbiguousMatchException -RFLCT.Ambiguous = Ambiguous match found. -RFLCT.AmbigCust = Multiple custom attributes of the same type found. - -; -; Remoting exceptions -; -Remoting_AppDomainUnloaded_ThreadUnwound = The application domain in which the thread was running has been unloaded. -Remoting_AppDomainUnloaded = The target application domain has been unloaded. -Remoting_CantRemotePointerType = Pointer types cannot be passed in a remote call. -Remoting_TypeCantBeRemoted = The given type cannot be passed in a remote call. -Remoting_Delegate_TooManyTargets = The delegate must have only one target. -Remoting_InvalidContext = The context is not valid. -Remoting_InvalidValueTypeFieldAccess = An attempt was made to calculate the address of a value type field on a remote object. This was likely caused by an attempt to directly get or set the value of a field within this embedded value type. Avoid this and instead provide and use access methods for each field in the object that will be accessed remotely. -Remoting_Message_BadRetValOrOutArg = Bad return value or out-argument inside the return message. -Remoting_NonPublicOrStaticCantBeCalledRemotely = Permission denied: cannot call non-public or static methods remotely. -Remoting_Proxy_ProxyTypeIsNotMBR = classToProxy argument must derive from MarshalByRef type. -Remoting_TP_NonNull = The transparent proxy field of a real proxy must be null. - -; Resources exceptions -; -Resources_StreamNotValid = Stream is not a valid resource file. -ResourceReaderIsClosed = ResourceReader is closed. - -; RuntimeWrappedException -RuntimeWrappedException = An object that does not derive from System.Exception has been wrapped in a RuntimeWrappedException. - -; UnauthorizedAccessException -UnauthorizedAccess_MemStreamBuffer = MemoryStream's internal buffer cannot be accessed. -UnauthorizedAccess_IODenied_Path = Access to the path '{0}' is denied. -UnauthorizedAccess_IODenied_NoPathName = Access to the path is denied. -UnauthorizedAccess_RegistryKeyGeneric_Key = Access to the registry key '{0}' is denied. -UnauthorizedAccess_RegistryNoWrite = Cannot write to the registry key. -UnauthorizedAccess_SystemDomain = Cannot execute an assembly in the system domain. - -; -; Security exceptions -; - -;SecurityException -; These still appear in bcl.small but should go away eventually -Security_Generic = Request for the permission of type '{0}' failed. -Security_GenericNoType = Request failed. -Security_NoAPTCA = That assembly does not allow partially trusted callers. -Security_RegistryPermission = Requested registry access is not allowed. -Security_MustRevertOverride = Stack walk modifier must be reverted before another modification of the same type can be performed. - -; -; HostProtection exceptions -; - -HostProtection_HostProtection = Attempted to perform an operation that was forbidden by the CLR host. -HostProtection_ProtectedResources = The protected resources (only available with full trust) were: -HostProtection_DemandedResources = The demanded resources were: - -; -; IO exceptions -; - -; EOFException -IO.EOF_ReadBeyondEOF = Unable to read beyond the end of the stream. - -; FileNotFoundException -IO.FileNotFound = Unable to find the specified file. -IO.FileNotFound_FileName = Could not find file '{0}'. -IO.FileName_Name = File name: '{0}' -IO.FileLoad = Could not load the specified file. - -; IOException -IO.IO_AlreadyExists_Name = Cannot create "{0}" because a file or directory with the same name already exists. -IO.IO_BindHandleFailed = BindHandle for ThreadPool failed on this handle. -IO.IO_FileExists_Name = The file '{0}' already exists. -IO.IO_FileStreamHandlePosition = The OS handle's position is not what FileStream expected. Do not use a handle simultaneously in one FileStream and in Win32 code or another FileStream. This may cause data loss. -IO.IO_FileTooLong2GB = The file is too long. This operation is currently limited to supporting files less than 2 gigabytes in size. -IO.IO_FileTooLongOrHandleNotSync = IO operation will not work. Most likely the file will become too long or the handle was not opened to support synchronous IO operations. -IO.IO_FixedCapacity = Unable to expand length of this stream beyond its capacity. -IO.IO_InvalidStringLen_Len = BinaryReader encountered an invalid string length of {0} characters. -IO.IO_NoConsole = There is no console. -IO.IO_NoPermissionToDirectoryName = -IO.IO_SeekBeforeBegin = An attempt was made to move the position before the beginning of the stream. -IO.IO_SeekAppendOverwrite = Unable seek backward to overwrite data that previously existed in a file opened in Append mode. -IO.IO_SetLengthAppendTruncate = Unable to truncate data that previously existed in a file opened in Append mode. -IO.IO_SharingViolation_File = The process cannot access the file '{0}' because it is being used by another process. -IO.IO_SharingViolation_NoFileName = The process cannot access the file because it is being used by another process. -IO.IO_StreamTooLong = Stream was too long. -IO.IO_CannotCreateDirectory = The specified directory '{0}' cannot be created. -IO.IO_SourceDestMustBeDifferent = Source and destination path must be different. -IO.IO_SourceDestMustHaveSameRoot = Source and destination path must have identical roots. Move will not work across volumes. - -; DirectoryNotFoundException -IO.DriveNotFound_Drive = Could not find the drive '{0}'. The drive might not be ready or might not be mapped. -IO.PathNotFound_Path = Could not find a part of the path '{0}'. -IO.PathNotFound_NoPathName = Could not find a part of the path. - -; PathTooLongException -IO.PathTooLong = The specified file name or path is too long, or a component of the specified path is too long. - -; SecurityException -FileSecurityState_OperationNotPermitted = File operation not permitted. Access to path '{0}' is denied. - -; PrivilegeNotHeldException -PrivilegeNotHeld_Default = The process does not possess some privilege required for this operation. -PrivilegeNotHeld_Named = The process does not possess the '{0}' privilege which is required for this operation. - -; General strings used in the IO package -IO_UnknownFileName = [Unknown] -IO_StreamWriterBufferedDataLost = A StreamWriter was not closed and all buffered data within that StreamWriter was not flushed to the underlying stream. (This was detected when the StreamWriter was finalized with data in its buffer.) A portion of the data was lost. Consider one of calling Close(), Flush(), setting the StreamWriter's AutoFlush property to true, or allocating the StreamWriter with a "using" statement. Stream type: {0}\r\nFile name: {1}\r\nAllocated from:\r\n {2} -IO_StreamWriterBufferedDataLostCaptureAllocatedFromCallstackNotEnabled = callstack information is not captured by default for performance reasons. Please enable captureAllocatedCallStack config switch for streamWriterBufferedDataLost MDA (refer to MSDN MDA documentation for how to do this). - -; -; Serialization Exceptions -; -; SerializationException -Serialization_InvalidData=An error occurred while deserializing the object. The serialized data is corrupt. -Serialization_InvalidPtrValue = An IntPtr or UIntPtr with an eight byte value cannot be deserialized on a machine with a four byte word size. -Serialization_MemberTypeNotRecognized = Unknown member type. -Serialization_InsufficientState = Insufficient state to return the real object. -Serialization_InvalidFieldState = Object fields may not be properly initialized. -Serialization_MissField = Field {0} is missing. -Serialization_NullSignature = The method signature cannot be null. -Serialization_UnknownMember = Cannot get the member '{0}'. -Serialization_InsufficientDeserializationState = Insufficient state to deserialize the object. Missing field '{0}'. More information is needed. -Serialization_UnableToFindModule = The given module {0} cannot be found within the assembly {1}. -Serialization_InvalidOnDeser = OnDeserialization method was called while the object was not being deserialized. -Serialization_MissingKeys = The Keys for this Hashtable are missing. -Serialization_MissingValues = The values for this dictionary are missing. -Serialization_NullKey = One of the serialized keys is null. -Serialization_KeyValueDifferentSizes = The keys and values arrays have different sizes. -Serialization_SameNameTwice = Cannot add the same member twice to a SerializationInfo object. -Serialization_BadParameterInfo = Non existent ParameterInfo. Position bigger than member's parameters length. -Serialization_NoParameterInfo = Serialized member does not have a ParameterInfo. -Serialization_NotFound = Member '{0}' was not found. -Serialization_StringBuilderMaxCapacity = The serialized MaxCapacity property of StringBuilder must be positive and greater than or equal to the String length. -Serialization_StringBuilderCapacity = The serialized Capacity property of StringBuilder must be positive, less than or equal to MaxCapacity and greater than or equal to the String length. -Serialization_InvalidDelegateType = Cannot serialize delegates over unmanaged function pointers, dynamic methods or methods outside the delegate creator's assembly. -Serialization_OptionalFieldVersionValue = Version value must be positive. -Serialization_MissingDateTimeData = Invalid serialized DateTime data. Unable to find 'ticks' or 'dateData'. -Serialization_DateTimeTicksOutOfRange = Invalid serialized DateTime data. Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks. -; The following serialization exception messages appear in native resources too (mscorrc.rc) -Serialization_MemberOutOfRange = The deserialized value of the member "{0}" in the class "{1}" is out of range. - - -; -; StringBuilder Exceptions -; -Arg_LongerThanSrcString = Source string was not long enough. Check sourceIndex and count. - - -; -; System.Threading -; - -; -; Thread Exceptions -; -ThreadState_NoAbortRequested = Unable to reset abort because no abort was requested. -Threading.WaitHandleTooManyPosts = The WaitHandle cannot be signaled because it would exceed its maximum count. -; -; WaitHandleCannotBeOpenedException -; -Threading.WaitHandleCannotBeOpenedException = No handle of the given name exists. -Threading.WaitHandleCannotBeOpenedException_InvalidHandle = A WaitHandle with system-wide name '{0}' cannot be created. A WaitHandle of a different type might have the same name. - -; -; AbandonedMutexException -; -Threading.AbandonedMutexException = The wait completed due to an abandoned mutex. - -; AggregateException -AggregateException_ctor_DefaultMessage=One or more errors occurred. -AggregateException_ctor_InnerExceptionNull=An element of innerExceptions was null. -AggregateException_DeserializationFailure=The serialization stream contains no inner exceptions. -AggregateException_ToString={0}{1}---> (Inner Exception #{2}) {3}{4}{5} - -; Cancellation -CancellationToken_CreateLinkedToken_TokensIsEmpty=No tokens were supplied. -CancellationTokenSource_Disposed=The CancellationTokenSource has been disposed. -CancellationToken_SourceDisposed=The CancellationTokenSource associated with this CancellationToken has been disposed. - -; Exceptions shared by all concurrent collection -ConcurrentCollection_SyncRoot_NotSupported=The SyncRoot property may not be used for the synchronization of concurrent collections. - -; Exceptions shared by ConcurrentStack and ConcurrentQueue -ConcurrentStackQueue_OnDeserialization_NoData=The serialization stream contains no elements. - -; ConcurrentStack -ConcurrentStack_PushPopRange_StartOutOfRange=The startIndex argument must be greater than or equal to zero. -ConcurrentStack_PushPopRange_CountOutOfRange=The count argument must be greater than or equal to zero. -ConcurrentStack_PushPopRange_InvalidCount=The sum of the startIndex and count arguments must be less than or equal to the collection's Count. - -; ConcurrentDictionary -ConcurrentDictionary_ItemKeyIsNull=TKey is a reference type and item.Key is null. -ConcurrentDictionary_SourceContainsDuplicateKeys=The source argument contains duplicate keys. -ConcurrentDictionary_IndexIsNegative=The index argument is less than zero. -ConcurrentDictionary_ConcurrencyLevelMustBePositive=The concurrencyLevel argument must be positive. -ConcurrentDictionary_CapacityMustNotBeNegative=The capacity argument must be greater than or equal to zero. -ConcurrentDictionary_ArrayNotLargeEnough=The index is equal to or greater than the length of the array, or the number of elements in the dictionary is greater than the available space from index to the end of the destination array. -ConcurrentDictionary_ArrayIncorrectType=The array is multidimensional, or the type parameter for the set cannot be cast automatically to the type of the destination array. -ConcurrentDictionary_KeyAlreadyExisted=The key already existed in the dictionary. -ConcurrentDictionary_TypeOfKeyIncorrect=The key was of an incorrect type for this dictionary. -ConcurrentDictionary_TypeOfValueIncorrect=The value was of an incorrect type for this dictionary. - -; Partitioner -Partitioner_DynamicPartitionsNotSupported=Dynamic partitions are not supported by this partitioner. - -; OrderablePartitioner -OrderablePartitioner_GetPartitions_WrongNumberOfPartitions=GetPartitions returned an incorrect number of partitions. - -; PartitionerStatic -PartitionerStatic_CurrentCalledBeforeMoveNext=MoveNext must be called at least once before calling Current. -PartitionerStatic_CanNotCallGetEnumeratorAfterSourceHasBeenDisposed=Can not call GetEnumerator on partitions after the source enumerable is disposed - -; CDSCollectionETWBCLProvider events -event_ConcurrentStack_FastPushFailed=Push to ConcurrentStack spun {0} time(s). -event_ConcurrentStack_FastPopFailed=Pop from ConcurrentStack spun {0} time(s). -event_ConcurrentDictionary_AcquiringAllLocks=ConcurrentDictionary acquiring all locks on {0} bucket(s). -event_ConcurrentBag_TryTakeSteals=ConcurrentBag stealing in TryTake. -event_ConcurrentBag_TryPeekSteals=ConcurrentBag stealing in TryPeek. - -; CountdownEvent -CountdownEvent_Decrement_BelowZero=Invalid attempt made to decrement the event's count below zero. -CountdownEvent_Increment_AlreadyZero=The event is already signaled and cannot be incremented. -CountdownEvent_Increment_AlreadyMax=The increment operation would cause the CurrentCount to overflow. - -; Parallel -Parallel_Invoke_ActionNull=One of the actions was null. -Parallel_ForEach_OrderedPartitionerKeysNotNormalized=This method requires the use of an OrderedPartitioner with the KeysNormalized property set to true. -Parallel_ForEach_PartitionerNotDynamic=The Partitioner used here must support dynamic partitioning. -Parallel_ForEach_PartitionerReturnedNull=The Partitioner used here returned a null partitioner source. -Parallel_ForEach_NullEnumerator=The Partitioner source returned a null enumerator. - -; Semaphore -Argument_SemaphoreInitialMaximum=The initial count for the semaphore must be greater than or equal to zero and less than the maximum count. - -; SemaphoreFullException -Threading_SemaphoreFullException=Adding the specified count to the semaphore would cause it to exceed its maximum count. - -; Lazy -Lazy_ctor_ValueSelectorNull=The valueSelector argument is null. -Lazy_ctor_InfoNull=The info argument is null. -Lazy_ctor_deserialization_ValueInvalid=The Value cannot be null. -Lazy_ctor_ModeInvalid=The mode argument specifies an invalid value. -Lazy_CreateValue_NoParameterlessCtorForT=The lazily-initialized type does not have a public, parameterless constructor. -Lazy_StaticInit_InvalidOperation=ValueFactory returned null. -Lazy_Value_RecursiveCallsToValue=ValueFactory attempted to access the Value property of this instance. -Lazy_ToString_ValueNotCreated=Value is not created. - - -;ThreadLocal -ThreadLocal_Value_RecursiveCallsToValue=ValueFactory attempted to access the Value property of this instance. -ThreadLocal_Disposed=The ThreadLocal object has been disposed. -ThreadLocal_ValuesNotAvailable=The ThreadLocal object is not tracking values. To use the Values property, use a ThreadLocal constructor that accepts the trackAllValues parameter and set the parameter to true. - -; SemaphoreSlim -SemaphoreSlim_ctor_InitialCountWrong=The initialCount argument must be non-negative and less than or equal to the maximumCount. -SemaphoreSlim_ctor_MaxCountWrong=The maximumCount argument must be a positive number. If a maximum is not required, use the constructor without a maxCount parameter. -SemaphoreSlim_Wait_TimeoutWrong=The timeout must represent a value between -1 and Int32.MaxValue, inclusive. -SemaphoreSlim_Release_CountWrong=The releaseCount argument must be greater than zero. -SemaphoreSlim_Disposed=The semaphore has been disposed. - -; ManualResetEventSlim -ManualResetEventSlim_ctor_SpinCountOutOfRange=The spinCount argument must be in the range 0 to {0}, inclusive. -ManualResetEventSlim_ctor_TooManyWaiters=There are too many threads currently waiting on the event. A maximum of {0} waiting threads are supported. -ManualResetEventSlim_Disposed=The event has been disposed. - -; SpinLock -SpinLock_TryEnter_ArgumentOutOfRange=The timeout must be a value between -1 and Int32.MaxValue, inclusive. -SpinLock_TryEnter_LockRecursionException=The calling thread already holds the lock. -SpinLock_TryReliableEnter_ArgumentException=The tookLock argument must be set to false before calling this method. -SpinLock_Exit_SynchronizationLockException=The calling thread does not hold the lock. -SpinLock_IsHeldByCurrentThread=Thread tracking is disabled. - -; SpinWait -SpinWait_SpinUntil_TimeoutWrong=The timeout must represent a value between -1 and Int32.MaxValue, inclusive. -SpinWait_SpinUntil_ArgumentNull=The condition argument is null. - -; CdsSyncEtwBCLProvider events -event_SpinLock_FastPathFailed=SpinLock beginning to spin. -event_SpinWait_NextSpinWillYield=Next spin will yield. -event_Barrier_PhaseFinished=Barrier finishing phase {1}. - -#if PLATFORM_UNIX -; Unix threading -PlatformNotSupported_NamedSynchronizationPrimitives=The named version of this synchronization primitive is not supported on this platform. -PlatformNotSupported_NamedSyncObjectWaitAnyWaitAll=Wait operations on multiple wait handles including a named synchronization primitive are not supported on this platform. -; OSX File locking -PlatformNotSupported_OSXFileLocking=Locking/unlocking file regions is not supported on this platform. Use FileShare on the entire file instead. -#endif - -; -; System.Threading.Tasks -; - -; AsyncMethodBuilder -AsyncMethodBuilder_InstanceNotInitialized=The builder was not properly initialized. - -; TaskAwaiter and YieldAwaitable -AwaitableAwaiter_InstanceNotInitialized=The awaitable or awaiter was not properly initialized. -TaskAwaiter_TaskNotCompleted=The awaited task has not yet completed. - -; Task -TaskT_SetException_HasAnInitializer=A task's Exception may only be set directly if the task was created without a function. -TaskT_TransitionToFinal_AlreadyCompleted=An attempt was made to transition a task to a final state when it had already completed. -TaskT_ctor_SelfReplicating=It is invalid to specify TaskCreationOptions.SelfReplicating for a Task. -TaskT_DebuggerNoResult={Not yet computed} - -; Task -Task_ctor_LRandSR=(Internal)An attempt was made to create a LongRunning SelfReplicating task. -Task_ThrowIfDisposed=The task has been disposed. -Task_Dispose_NotCompleted=A task may only be disposed if it is in a completion state (RanToCompletion, Faulted or Canceled). -Task_Start_Promise=Start may not be called on a promise-style task. -Task_Start_AlreadyStarted=Start may not be called on a task that was already started. -Task_Start_TaskCompleted=Start may not be called on a task that has completed. -Task_Start_ContinuationTask=Start may not be called on a continuation task. -Task_RunSynchronously_AlreadyStarted=RunSynchronously may not be called on a task that was already started. -Task_RunSynchronously_TaskCompleted=RunSynchronously may not be called on a task that has already completed. -Task_RunSynchronously_Promise=RunSynchronously may not be called on a task not bound to a delegate, such as the task returned from an asynchronous method. -Task_RunSynchronously_Continuation=RunSynchronously may not be called on a continuation task. -Task_ContinueWith_NotOnAnything=The specified TaskContinuationOptions excluded all continuation kinds. -Task_ContinueWith_ESandLR=The specified TaskContinuationOptions combined LongRunning and ExecuteSynchronously. Synchronous continuations should not be long running. -Task_MultiTaskContinuation_NullTask=The tasks argument included a null value. -Task_MultiTaskContinuation_FireOptions=It is invalid to exclude specific continuation kinds for continuations off of multiple tasks. -Task_MultiTaskContinuation_EmptyTaskList=The tasks argument contains no tasks. -Task_FromAsync_TaskManagerShutDown=FromAsync was called with a TaskManager that had already shut down. -Task_FromAsync_SelfReplicating=It is invalid to specify TaskCreationOptions.SelfReplicating in calls to FromAsync. -Task_FromAsync_LongRunning=It is invalid to specify TaskCreationOptions.LongRunning in calls to FromAsync. -Task_FromAsync_PreferFairness=It is invalid to specify TaskCreationOptions.PreferFairness in calls to FromAsync. -Task_WaitMulti_NullTask=The tasks array included at least one null element. -Task_Delay_InvalidMillisecondsDelay=The value needs to be either -1 (signifying an infinite timeout), 0 or a positive integer. -Task_Delay_InvalidDelay=The value needs to translate in milliseconds to -1 (signifying an infinite timeout), 0 or a positive integer less than or equal to Int32.MaxValue. - -; TaskCanceledException -TaskCanceledException_ctor_DefaultMessage=A task was canceled. - -;TaskCompletionSource -TaskCompletionSourceT_TrySetException_NullException=The exceptions collection included at least one null element. -TaskCompletionSourceT_TrySetException_NoExceptions=The exceptions collection was empty. - -;TaskExceptionHolder -TaskExceptionHolder_UnknownExceptionType=(Internal)Expected an Exception or an IEnumerable -TaskExceptionHolder_UnhandledException=A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. - -; TaskScheduler -TaskScheduler_ExecuteTask_TaskAlreadyExecuted=ExecuteTask may not be called for a task which was already executed. -TaskScheduler_ExecuteTask_WrongTaskScheduler=ExecuteTask may not be called for a task which was previously queued to a different TaskScheduler. -TaskScheduler_InconsistentStateAfterTryExecuteTaskInline=The TryExecuteTaskInline call to the underlying scheduler succeeded, but the task body was not invoked. -TaskScheduler_FromCurrentSynchronizationContext_NoCurrent=The current SynchronizationContext may not be used as a TaskScheduler. - -; TaskSchedulerException -TaskSchedulerException_ctor_DefaultMessage=An exception was thrown by a TaskScheduler. - -; -; ParallelState ( used in Parallel.For(), Parallel.ForEach() ) -ParallelState_Break_InvalidOperationException_BreakAfterStop=Break was called after Stop was called. -ParallelState_Stop_InvalidOperationException_StopAfterBreak=Stop was called after Break was called. -ParallelState_NotSupportedException_UnsupportedMethod=This method is not supported. - -; -; TPLETWProvider events -event_ParallelLoopBegin=Beginning {3} loop {2} from Task {1}. -event_ParallelLoopEnd=Ending loop {2} after {3} iterations. -event_ParallelInvokeBegin=Beginning ParallelInvoke {2} from Task {1} for {4} actions. -event_ParallelInvokeEnd=Ending ParallelInvoke {2}. -event_ParallelFork=Task {1} entering fork/join {2}. -event_ParallelJoin=Task {1} leaving fork/join {2}. -event_TaskScheduled=Task {2} scheduled to TaskScheduler {0}. -event_TaskStarted=Task {2} executing. -event_TaskCompleted=Task {2} completed. -event_TaskWaitBegin=Beginning wait ({3}) on Task {2}. -event_TaskWaitEnd=Ending wait on Task {2}. - - -; -; Weak Reference Exception -; -WeakReference_NoLongerValid = The weak reference is no longer valid. - - -; -; Interop Exceptions -; -Interop.COM_TypeMismatch = Type mismatch between source and destination types. -Interop_Marshal_Unmappable_Char = Cannot marshal: Encountered unmappable character. - -; -; Loader Exceptions -; -Loader_InvalidPath = Relative path must be a string that contains the substring, "..", or does not contain a root directory. -Loader_Name = Name: -Loader_NoContextPolicies = There are no context policies. -Loader_ContextPolicies = Context Policies: - -; -; AppDomain Exceptions -AppDomain_RequireApplicationName = ApplicationName must be set before the DynamicBase can be set. -AppDomain_AppBaseNotSet = The ApplicationBase must be set before retrieving this property. -AppDomain_BindingModelIsLocked = Binding model is already locked for the AppDomain and cannot be reset. -Argument_CustomAssemblyLoadContextRequestedNameMismatch = Resolved assembly's simple name should be the same as of the requested assembly. - -; -; XMLSyntaxExceptions -XMLSyntax_UnexpectedEndOfFile = Unexpected end of file. -XMLSyntax_ExpectedCloseBracket = Expected > character. -XMLSyntax_ExpectedSlashOrString = Expected / character or string. -XMLSyntax_UnexpectedCloseBracket = Unexpected > character. -XMLSyntax_SyntaxError = Invalid syntax on line {0}. -XMLSyntax_SyntaxErrorEx = Invalid syntax on line {0} - '{1}'. -XMLSyntax_InvalidSyntax = Invalid syntax. -XML_Syntax_InvalidSyntaxInFile = Invalid XML in file '{0}' near element '{1}'. -XMLSyntax_InvalidSyntaxSatAssemTag = Invalid XML in file "{0}" near element "{1}". The section only supports tags. -XMLSyntax_InvalidSyntaxSatAssemTagBadAttr = Invalid XML in file "{0}" near "{1}" and "{2}". In the section, the tag must have exactly 1 attribute called 'name', whose value is a fully-qualified assembly name. -XMLSyntax_InvalidSyntaxSatAssemTagNoAttr = Invalid XML in file "{0}". In the section, the tag must have exactly 1 attribute called 'name', whose value is a fully-qualified assembly name. - -; MembershipConditions -StrongName_ToString = StrongName - {0}{1}{2} -StrongName_Name = name = {0} -StrongName_Version = version = {0} -Site_ToString = Site -Publisher_ToString = Publisher -Hash_ToString = Hash - {0} = {1} -ApplicationDirectory_ToString = ApplicationDirectory -Zone_ToString = Zone - {0} -All_ToString = All code -Url_ToString = Url -GAC_ToString = GAC - -; Interop non exception strings. -TypeLibConverter_ImportedTypeLibProductName = Assembly imported from type library '{0}'. - -; -; begin System.TimeZoneInfo ArgumentException's -; -Argument_AdjustmentRulesNoNulls = The AdjustmentRule array cannot contain null elements. -Argument_AdjustmentRulesOutOfOrder = The elements of the AdjustmentRule array must be in chronological order and must not overlap. -Argument_AdjustmentRulesAmbiguousOverlap = The elements of the AdjustmentRule array must not contain ambiguous time periods that extend beyond the DateStart or DateEnd properties of the element. -Argument_AdjustmentRulesrDaylightSavingTimeOverlap = The elements of the AdjustmentRule array must not contain Daylight Saving Time periods that overlap adjacent elements in such a way as to cause invalid or ambiguous time periods. -Argument_AdjustmentRulesrDaylightSavingTimeOverlapNonRuleRange = The elements of the AdjustmentRule array must not contain Daylight Saving Time periods that overlap the DateStart or DateEnd properties in such a way as to cause invalid or ambiguous time periods. -Argument_AdjustmentRulesInvalidOverlap = The elements of the AdjustmentRule array must not contain invalid time periods that extend beyond the DateStart or DateEnd properties of the element. -Argument_ConvertMismatch = The conversion could not be completed because the supplied DateTime did not have the Kind property set correctly. For example, when the Kind property is DateTimeKind.Local, the source time zone must be TimeZoneInfo.Local. -Argument_DateTimeHasTimeOfDay = The supplied DateTime includes a TimeOfDay setting. This is not supported. -Argument_DateTimeIsInvalid = The supplied DateTime represents an invalid time. For example, when the clock is adjusted forward, any time in the period that is skipped is invalid. -Argument_DateTimeIsNotAmbiguous = The supplied DateTime is not in an ambiguous time range. -Argument_DateTimeOffsetIsNotAmbiguous = The supplied DateTimeOffset is not in an ambiguous time range. -Argument_DateTimeKindMustBeUnspecifiedOrUtc = The supplied DateTime must have the Kind property set to DateTimeKind.Unspecified or DateTimeKind.Utc. -Argument_DateTimeHasTicks = The supplied DateTime must have the Year, Month, and Day properties set to 1. The time cannot be specified more precisely than whole milliseconds. -Argument_InvalidId = The specified ID parameter '{0}' is not supported. -Argument_InvalidSerializedString = The specified serialized string '{0}' is not supported. -Argument_InvalidREG_TZI_FORMAT = The REG_TZI_FORMAT structure is corrupt. -Argument_OutOfOrderDateTimes = The DateStart property must come before the DateEnd property. -Argument_TimeSpanHasSeconds = The TimeSpan parameter cannot be specified more precisely than whole minutes. -Argument_TimeZoneInfoBadTZif = The tzfile does not begin with the magic characters 'TZif'. Please verify that the file is not corrupt. -Argument_TimeZoneInfoInvalidTZif = The TZif data structure is corrupt. -Argument_TransitionTimesAreIdentical = The DaylightTransitionStart property must not equal the DaylightTransitionEnd property. -; -; begin System.TimeZoneInfo ArgumentOutOfRangeException's -; -ArgumentOutOfRange_DayParam = The Day parameter must be in the range 1 through 31. -ArgumentOutOfRange_DayOfWeek = The DayOfWeek enumeration must be in the range 0 through 6. -ArgumentOutOfRange_MonthParam = The Month parameter must be in the range 1 through 12. -ArgumentOutOfRange_UtcOffset = The TimeSpan parameter must be within plus or minus 14.0 hours. -ArgumentOutOfRange_UtcOffsetAndDaylightDelta = The sum of the BaseUtcOffset and DaylightDelta properties must within plus or minus 14.0 hours. -ArgumentOutOfRange_Week = The Week parameter must be in the range 1 through 5. -; -; begin System.TimeZoneInfo InvalidTimeZoneException's -; -InvalidTimeZone_InvalidRegistryData = The time zone ID '{0}' was found on the local computer, but the registry information was corrupt. -InvalidTimeZone_InvalidFileData = The time zone ID '{0}' was found on the local computer, but the file at '{1}' was corrupt. -InvalidTimeZone_InvalidWin32APIData = The Local time zone was found on the local computer, but the data was corrupt. -InvalidTimeZone_NoTTInfoStructures = There are no ttinfo structures in the tzfile. At least one ttinfo structure is required in order to construct a TimeZoneInfo object. -InvalidTimeZone_UnparseablePosixMDateString = '{0}' is not a valid POSIX-TZ-environment-variable MDate rule. A valid rule has the format 'Mm.w.d'. -InvalidTimeZone_JulianDayNotSupported = Julian dates in POSIX strings are unsupported. -; -; begin System.TimeZoneInfo SecurityException's -; -Security_CannotReadRegistryData = The time zone ID '{0}' was found on the local computer, but the application does not have permission to read the registry information. -Security_CannotReadFileData = The time zone ID '{0}' was found on the local computer, but the application does not have permission to read the file. -; -; begin System.TimeZoneInfo SerializationException's -; -Serialization_CorruptField = The value of the field '{0}' is invalid. The serialized data is corrupt. -Serialization_InvalidEscapeSequence = The serialized data contained an invalid escape sequence '\\{0}'. -; -; begin System.TimeZoneInfo TimeZoneNotFoundException's -; -TimeZoneNotFound_MissingData = The time zone ID '{0}' was not found on the local computer. -; -; end System.TimeZoneInfo -; - - -; Tuple -ArgumentException_TupleIncorrectType=Argument must be of type {0}. -ArgumentException_TupleNonIComparableElement=The tuple contains an element of type {0} which does not implement the IComparable interface. -ArgumentException_TupleLastArgumentNotATuple=The last element of an eight element tuple must be a Tuple. -ArgumentException_OtherNotArrayOfCorrectLength=Object is not a array with the same number of elements as the array to compare it to. - -; WinRT collection adapters -Argument_IndexOutOfArrayBounds=The specified index is out of bounds of the specified array. -Argument_InsufficientSpaceToCopyCollection=The specified space is not sufficient to copy the elements from this Collection. -ArgumentOutOfRange_IndexLargerThanMaxValue=This collection cannot work with indices larger than Int32.MaxValue - 1 (0x7FFFFFFF - 1). -ArgumentOutOfRange_IndexOutOfRange=The specified index is outside the current index range of this collection. -InvalidOperation_CollectionBackingListTooLarge=The collection backing this List contains too many elements. -InvalidOperation_CollectionBackingDictionaryTooLarge=The collection backing this Dictionary contains too many elements. -InvalidOperation_CannotRemoveLastFromEmptyCollection=Cannot remove the last element from an empty collection. - -; Buffers -ArgumentException_BufferNotFromPool=The buffer is not associated with this pool and may not be returned to it. - -;------------------ -; Encoding names: -; -;Total items: 147 -; -Globalization.cp_1200 = Unicode -Globalization.cp_1201 = Unicode (Big-Endian) -Globalization.cp_65001 = Unicode (UTF-8) -Globalization.cp_65000 = Unicode (UTF-7) -Globalization.cp_12000 = Unicode (UTF-32) -Globalization.cp_12001 = Unicode (UTF-32 Big-Endian) -Globalization.cp_20127 = US-ASCII -Globalization.cp_28591 = Western European (ISO) - -#endif // INCLUDE_DEBUG - -;------------------ - -; ValueTuple -ArgumentException_ValueTupleIncorrectType=Argument must be of type {0}. -ArgumentException_ValueTupleLastArgumentNotAValueTuple=The last element of an eight element ValueTuple must be a ValueTuple. - -; SafeSerializationEventArgs -Serialization_NonSerType=Type '{0}' in Assembly '{1}' is not marked as serializable. - diff --git a/src/mscorlib/src/System/Activator.cs b/src/mscorlib/src/System/Activator.cs index 3ee9ec5..34c6ea5 100644 --- a/src/mscorlib/src/System/Activator.cs +++ b/src/mscorlib/src/System/Activator.cs @@ -66,7 +66,7 @@ namespace System Contract.EndContractBlock(); if (type is System.Reflection.Emit.TypeBuilder) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_CreateInstanceWithTypeBuilder")); + throw new NotSupportedException(SR.NotSupported_CreateInstanceWithTypeBuilder); // If they didn't specify a lookup, then we will provide the default lookup. if ((bindingAttr & (BindingFlags)LookupMask) == 0) @@ -74,13 +74,13 @@ namespace System if (activationAttributes != null && activationAttributes.Length > 0) { - throw new PlatformNotSupportedException(Environment.GetResourceString("NotSupported_ActivAttr")); + throw new PlatformNotSupportedException(SR.NotSupported_ActivAttr); } RuntimeType rt = type.UnderlyingSystemType as RuntimeType; if (rt == null) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(type)); + throw new ArgumentException(SR.Arg_MustBeType, nameof(type)); StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; return rt.CreateInstanceImpl(bindingAttr, binder, args, culture, activationAttributes, ref stackMark); @@ -164,7 +164,7 @@ namespace System RuntimeType rt = type.UnderlyingSystemType as RuntimeType; if (rt == null) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(type)); + throw new ArgumentException(SR.Arg_MustBeType, nameof(type)); StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; return rt.CreateInstanceDefaultCtor(!nonPublic, false, true, ref stackMark); @@ -178,7 +178,7 @@ namespace System // This is a workaround to maintain compatibility with V2. Without this we would throw a NotSupportedException for void[]. // Array, Ref, and Pointer types don't have default constructors. if (rt.HasElementType) - throw new MissingMethodException(Environment.GetResourceString("Arg_NoDefCTor")); + throw new MissingMethodException(SR.Arg_NoDefCTor); StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; @@ -371,7 +371,7 @@ namespace System if (Attr.Length > 0) { if (((ComVisibleAttribute)Attr[0]).Value == false) - throw new TypeLoadException(Environment.GetResourceString("Argument_TypeMustBeVisibleFromCom")); + throw new TypeLoadException(SR.Argument_TypeMustBeVisibleFromCom); } Log(assembly != null, "CreateInstance:: ", "Loaded " + assembly.FullName, "Failed to Load: " + assemblyName); diff --git a/src/mscorlib/src/System/AggregateException.cs b/src/mscorlib/src/System/AggregateException.cs index 3a3b08d..22bc323 100644 --- a/src/mscorlib/src/System/AggregateException.cs +++ b/src/mscorlib/src/System/AggregateException.cs @@ -38,7 +38,7 @@ namespace System /// Initializes a new instance of the class. /// public AggregateException() - : base(Environment.GetResourceString("AggregateException_ctor_DefaultMessage")) + : base(SR.AggregateException_ctor_DefaultMessage) { m_innerExceptions = new ReadOnlyCollection(new Exception[0]); } @@ -83,7 +83,7 @@ namespace System /// An element of is /// null. public AggregateException(IEnumerable innerExceptions) : - this(Environment.GetResourceString("AggregateException_ctor_DefaultMessage"), innerExceptions) + this(SR.AggregateException_ctor_DefaultMessage, innerExceptions) { } @@ -97,7 +97,7 @@ namespace System /// An element of is /// null. public AggregateException(params Exception[] innerExceptions) : - this(Environment.GetResourceString("AggregateException_ctor_DefaultMessage"), innerExceptions) + this(SR.AggregateException_ctor_DefaultMessage, innerExceptions) { } @@ -161,7 +161,7 @@ namespace System if (exceptionsCopy[i] == null) { - throw new ArgumentException(Environment.GetResourceString("AggregateException_ctor_InnerExceptionNull")); + throw new ArgumentException(SR.AggregateException_ctor_InnerExceptionNull); } } @@ -180,7 +180,7 @@ namespace System /// An element of is /// null. internal AggregateException(IEnumerable innerExceptionInfos) : - this(Environment.GetResourceString("AggregateException_ctor_DefaultMessage"), innerExceptionInfos) + this(SR.AggregateException_ctor_DefaultMessage, innerExceptionInfos) { } @@ -240,7 +240,7 @@ namespace System if (exceptionsCopy[i] == null) { - throw new ArgumentException(Environment.GetResourceString("AggregateException_ctor_InnerExceptionNull")); + throw new ArgumentException(SR.AggregateException_ctor_InnerExceptionNull); } } @@ -267,7 +267,7 @@ namespace System Exception[] innerExceptions = info.GetValue("InnerExceptions", typeof(Exception[])) as Exception[]; if (innerExceptions == null) { - throw new SerializationException(Environment.GetResourceString("AggregateException_DeserializationFailure")); + throw new SerializationException(SR.AggregateException_DeserializationFailure); } m_innerExceptions = new ReadOnlyCollection(innerExceptions); @@ -466,7 +466,7 @@ namespace System { text = String.Format( CultureInfo.InvariantCulture, - Environment.GetResourceString("AggregateException_ToString"), + SR.AggregateException_ToString, text, Environment.NewLine, i, m_innerExceptions[i].ToString(), "<---", Environment.NewLine); } diff --git a/src/mscorlib/src/System/AppContext/AppContext.cs b/src/mscorlib/src/System/AppContext/AppContext.cs index b8d3076..7c7e74f 100644 --- a/src/mscorlib/src/System/AppContext/AppContext.cs +++ b/src/mscorlib/src/System/AppContext/AppContext.cs @@ -116,7 +116,7 @@ namespace System if (switchName == null) throw new ArgumentNullException(nameof(switchName)); if (switchName.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(switchName)); + throw new ArgumentException(SR.Argument_EmptyName, nameof(switchName)); // By default, the switch is not enabled. isEnabled = false; @@ -212,7 +212,7 @@ namespace System if (switchName == null) throw new ArgumentNullException(nameof(switchName)); if (switchName.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(switchName)); + throw new ArgumentException(SR.Argument_EmptyName, nameof(switchName)); SwitchValueState switchValue = (isEnabled ? SwitchValueState.HasTrueValue : SwitchValueState.HasFalseValue) | SwitchValueState.HasLookedForOverride; diff --git a/src/mscorlib/src/System/AppDomain.cs b/src/mscorlib/src/System/AppDomain.cs index 4db0c15..8933896 100644 --- a/src/mscorlib/src/System/AppDomain.cs +++ b/src/mscorlib/src/System/AppDomain.cs @@ -133,7 +133,7 @@ namespace System if (nested != null) nestedDelegates.Add(nested); else - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeStatic"), + throw new ArgumentException(SR.Arg_MustBeStatic, list[i].Method.ReflectedType.FullName + "::" + list[i].Method.Name); } else @@ -341,7 +341,7 @@ namespace System // uninitialized object through remoting, etc. if (_pDomain.IsNull()) { - throw new InvalidOperationException(Environment.GetResourceString("Argument_InvalidHandle")); + throw new InvalidOperationException(SR.Argument_InvalidHandle); } return new AppDomainHandle(_pDomain); @@ -397,20 +397,20 @@ namespace System } catch (FileNotFoundException e) { - throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"), e); + throw new TypeLoadException(SR.Argument_NoDomainManager, e); } catch (SecurityException e) { - throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"), e); + throw new TypeLoadException(SR.Argument_NoDomainManager, e); } catch (TypeLoadException e) { - throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager"), e); + throw new TypeLoadException(SR.Argument_NoDomainManager, e); } if (_domainManager == null) { - throw new TypeLoadException(Environment.GetResourceString("Argument_NoDomainManager")); + throw new TypeLoadException(SR.Argument_NoDomainManager); } // If this domain was not created by a managed call to CreateDomain, then the AppDomainSetup @@ -501,7 +501,7 @@ namespace System { #if FEATURE_APPX if (IsAppXModel()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_AppX", "Assembly.LoadFrom")); + throw new NotSupportedException(SR.Format(SR.NotSupported_AppX, "Assembly.LoadFrom")); #endif } @@ -513,7 +513,7 @@ namespace System { #if FEATURE_APPX if (IsAppXModel()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_AppX", "Assembly.LoadFile")); + throw new NotSupportedException(SR.Format(SR.NotSupported_AppX, "Assembly.LoadFile")); #endif } @@ -525,7 +525,7 @@ namespace System { #if FEATURE_APPX if (IsAppXModel()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_AppX", "Assembly.ReflectionOnlyLoad")); + throw new NotSupportedException(SR.Format(SR.NotSupported_AppX, "Assembly.ReflectionOnlyLoad")); #endif } @@ -537,7 +537,7 @@ namespace System { #if FEATURE_APPX if (IsAppXModel()) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_AppX", "Assembly.Load(byte[], ...)")); + throw new NotSupportedException(SR.Format(SR.NotSupported_AppX, "Assembly.Load(byte[], ...)")); #endif } @@ -682,16 +682,16 @@ namespace System String fn = nGetFriendlyName(); if (fn != null) { - sb.Append(Environment.GetResourceString("Loader_Name") + fn); + sb.Append(SR.Loader_Name + fn); sb.Append(Environment.NewLine); } if (_Policies == null || _Policies.Length == 0) - sb.Append(Environment.GetResourceString("Loader_NoContextPolicies") + sb.Append(SR.Loader_NoContextPolicies + Environment.NewLine); else { - sb.Append(Environment.GetResourceString("Loader_ContextPolicies") + sb.Append(SR.Loader_ContextPolicies + Environment.NewLine); for (int i = 0; i < _Policies.Length; i++) { @@ -729,7 +729,7 @@ namespace System } if (currentVal != null) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_SetData_OnlyOnce")); + throw new InvalidOperationException(SR.InvalidOperation_SetData_OnlyOnce); } lock (((ICollection)LocalStore).SyncRoot) @@ -785,7 +785,7 @@ namespace System private AppDomain() { - throw new NotSupportedException(Environment.GetResourceString(ResId.NotSupported_Constructor)); + throw new NotSupportedException(SR.GetResourceString(ResId.NotSupported_Constructor)); } [MethodImplAttribute(MethodImplOptions.InternalCall)] @@ -1153,7 +1153,7 @@ namespace System throw new ArgumentNullException("APPBASE"); if (PathInternal.IsPartiallyQualified(propertyValues[i])) - throw new ArgumentException(Environment.GetResourceString("Argument_AbsolutePathRequired")); + throw new ArgumentException(SR.Argument_AbsolutePathRequired); newSetup.ApplicationBase = NormalizePath(propertyValues[i], fullCheck: true); } @@ -1168,7 +1168,7 @@ namespace System case "MultiDomain": newSetup.LoaderOptimization = LoaderOptimization.MultiDomain; break; case "MultiDomainHost": newSetup.LoaderOptimization = LoaderOptimization.MultiDomainHost; break; case "NotSpecified": newSetup.LoaderOptimization = LoaderOptimization.NotSpecified; break; - default: throw new ArgumentException(Environment.GetResourceString("Argument_UnrecognizedLoaderOptimization"), "LOADER_OPTIMIZATION"); + default: throw new ArgumentException(SR.Argument_UnrecognizedLoaderOptimization, "LOADER_OPTIMIZATION"); } } else if (propertyNames[i] == "TRUSTED_PLATFORM_ASSEMBLIES" || @@ -1254,7 +1254,7 @@ namespace System continue; if (PathInternal.IsPartiallyQualified(path)) - throw new ArgumentException(Environment.GetResourceString("Argument_AbsolutePathRequired")); + throw new ArgumentException(SR.Argument_AbsolutePathRequired); string appPath = NormalizePath(path, fullCheck: true); sb.Append(appPath); diff --git a/src/mscorlib/src/System/AppDomainSetup.cs b/src/mscorlib/src/System/AppDomainSetup.cs index 34e6cb6..2529660 100644 --- a/src/mscorlib/src/System/AppDomainSetup.cs +++ b/src/mscorlib/src/System/AppDomainSetup.cs @@ -261,7 +261,7 @@ namespace System // with it for "file:\\" + "\\server" and "file:\\\" + "\localpath" if ((len > 8) && ((path[8] == '\\') || (path[8] == '/'))) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidPathChars")); + throw new ArgumentException(SR.Argument_InvalidPathChars); // file:\\\ means local path else @@ -369,7 +369,7 @@ namespace System String appBase = Value[(int)LoaderInformation.ApplicationBaseValue]; if ((appBase == null) || (appBase.Length == 0)) - throw new MemberAccessException(Environment.GetResourceString("AppDomain_AppBaseNotSet")); + throw new MemberAccessException(SR.AppDomain_AppBaseNotSet); StringBuilder result = StringBuilderCache.Acquire(); diff --git a/src/mscorlib/src/System/AppDomainUnloadedException.cs b/src/mscorlib/src/System/AppDomainUnloadedException.cs index b8b6150..b11ae33 100644 --- a/src/mscorlib/src/System/AppDomainUnloadedException.cs +++ b/src/mscorlib/src/System/AppDomainUnloadedException.cs @@ -20,7 +20,7 @@ namespace System internal class AppDomainUnloadedException : SystemException { public AppDomainUnloadedException() - : base(Environment.GetResourceString("Arg_AppDomainUnloadedException")) + : base(SR.Arg_AppDomainUnloadedException) { SetErrorCode(__HResults.COR_E_APPDOMAINUNLOADED); } diff --git a/src/mscorlib/src/System/ArgIterator.cs b/src/mscorlib/src/System/ArgIterator.cs index 394d579..b608e7e 100644 --- a/src/mscorlib/src/System/ArgIterator.cs +++ b/src/mscorlib/src/System/ArgIterator.cs @@ -131,7 +131,7 @@ namespace System // Inherited from object public override bool Equals(Object o) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NYI")); + throw new NotSupportedException(SR.NotSupported_NYI); } #else public ArgIterator(RuntimeArgumentHandle arglist) diff --git a/src/mscorlib/src/System/ArgumentOutOfRangeException.cs b/src/mscorlib/src/System/ArgumentOutOfRangeException.cs index a20b43f..a5f838a 100644 --- a/src/mscorlib/src/System/ArgumentOutOfRangeException.cs +++ b/src/mscorlib/src/System/ArgumentOutOfRangeException.cs @@ -33,7 +33,7 @@ namespace System get { if (_rangeMessage == null) - _rangeMessage = Environment.GetResourceString("Arg_ArgumentOutOfRangeException"); + _rangeMessage = SR.Arg_ArgumentOutOfRangeException; return _rangeMessage; } } @@ -81,7 +81,7 @@ namespace System String s = base.Message; if (m_actualValue != null) { - String valueMessage = Environment.GetResourceString("ArgumentOutOfRange_ActualValue", m_actualValue.ToString()); + String valueMessage = SR.Format(SR.ArgumentOutOfRange_ActualValue, m_actualValue.ToString()); if (s == null) return valueMessage; return s + Environment.NewLine + valueMessage; diff --git a/src/mscorlib/src/System/Attribute.cs b/src/mscorlib/src/System/Attribute.cs index 7ffbedf..baa9a71 100644 --- a/src/mscorlib/src/System/Attribute.cs +++ b/src/mscorlib/src/System/Attribute.cs @@ -431,7 +431,7 @@ namespace System return AttributeUsageAttribute.Default; throw new FormatException( - Environment.GetResourceString("Format_AttributeUsage", type)); + SR.Format(SR.Format_AttributeUsage, type)); } private static Attribute[] CreateAttributeArrayHelper(Type elementType, int elementCount) @@ -459,7 +459,7 @@ namespace System throw new ArgumentNullException(nameof(type)); if (!type.IsSubclassOf(typeof(Attribute)) && type != typeof(Attribute)) - throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass")); + throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass); Contract.EndContractBlock(); switch (element.MemberType) @@ -514,7 +514,7 @@ namespace System throw new ArgumentNullException(nameof(attributeType)); if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute)) - throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass")); + throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass); Contract.EndContractBlock(); switch (element.MemberType) @@ -545,7 +545,7 @@ namespace System if (attrib.Length == 1) return attrib[0]; - throw new AmbiguousMatchException(Environment.GetResourceString("RFLCT.AmbigCust")); + throw new AmbiguousMatchException(SR.RFLCT_AmbigCust); } #endregion @@ -570,10 +570,10 @@ namespace System throw new ArgumentNullException(nameof(attributeType)); if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute)) - throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass")); + throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass); if (element.Member == null) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidParameterInfo"), nameof(element)); + throw new ArgumentException(SR.Argument_InvalidParameterInfo, nameof(element)); Contract.EndContractBlock(); @@ -590,7 +590,7 @@ namespace System throw new ArgumentNullException(nameof(element)); if (element.Member == null) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidParameterInfo"), nameof(element)); + throw new ArgumentException(SR.Argument_InvalidParameterInfo, nameof(element)); Contract.EndContractBlock(); @@ -616,7 +616,7 @@ namespace System throw new ArgumentNullException(nameof(attributeType)); if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute)) - throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass")); + throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass); Contract.EndContractBlock(); MemberInfo member = element.Member; @@ -634,7 +634,7 @@ namespace System default: Debug.Assert(false, "Invalid type for ParameterInfo member in Attribute class"); - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidParamInfo")); + throw new ArgumentException(SR.Argument_InvalidParamInfo); } } @@ -658,7 +658,7 @@ namespace System if (attrib.Length == 1) return attrib[0]; - throw new AmbiguousMatchException(Environment.GetResourceString("RFLCT.AmbigCust")); + throw new AmbiguousMatchException(SR.RFLCT_AmbigCust); } #endregion @@ -692,7 +692,7 @@ namespace System throw new ArgumentNullException(nameof(attributeType)); if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute)) - throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass")); + throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass); Contract.EndContractBlock(); return (Attribute[])element.GetCustomAttributes(attributeType, inherit); @@ -713,7 +713,7 @@ namespace System throw new ArgumentNullException(nameof(attributeType)); if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute)) - throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass")); + throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass); Contract.EndContractBlock(); return element.IsDefined(attributeType, false); @@ -736,7 +736,7 @@ namespace System if (attrib.Length == 1) return attrib[0]; - throw new AmbiguousMatchException(Environment.GetResourceString("RFLCT.AmbigCust")); + throw new AmbiguousMatchException(SR.RFLCT_AmbigCust); } #endregion @@ -756,7 +756,7 @@ namespace System throw new ArgumentNullException(nameof(attributeType)); if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute)) - throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass")); + throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass); Contract.EndContractBlock(); return (Attribute[])element.GetCustomAttributes(attributeType, inherit); @@ -791,7 +791,7 @@ namespace System throw new ArgumentNullException(nameof(attributeType)); if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute)) - throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass")); + throw new ArgumentException(SR.Argument_MustHaveAttributeBaseClass); Contract.EndContractBlock(); return element.IsDefined(attributeType, false); @@ -814,7 +814,7 @@ namespace System if (attrib.Length == 1) return attrib[0]; - throw new AmbiguousMatchException(Environment.GetResourceString("RFLCT.AmbigCust")); + throw new AmbiguousMatchException(SR.RFLCT_AmbigCust); } #endregion diff --git a/src/mscorlib/src/System/BadImageFormatException.cs b/src/mscorlib/src/System/BadImageFormatException.cs index 13d9556..9cb692f 100644 --- a/src/mscorlib/src/System/BadImageFormatException.cs +++ b/src/mscorlib/src/System/BadImageFormatException.cs @@ -26,7 +26,7 @@ namespace System private String _fusionLog; // fusion log (when applicable) public BadImageFormatException() - : base(Environment.GetResourceString("Arg_BadImageFormatException")) + : base(SR.Arg_BadImageFormatException) { SetErrorCode(__HResults.COR_E_BADIMAGEFORMAT); } @@ -71,7 +71,7 @@ namespace System { if ((_fileName == null) && (HResult == System.__HResults.COR_E_EXCEPTION)) - _message = Environment.GetResourceString("Arg_BadImageFormatException"); + _message = SR.Arg_BadImageFormatException; else _message = FileLoadException.FormatFileLoadExceptionMessage(_fileName, HResult); @@ -88,7 +88,7 @@ namespace System String s = GetType().FullName + ": " + Message; if (_fileName != null && _fileName.Length != 0) - s += Environment.NewLine + Environment.GetResourceString("IO.FileName_Name", _fileName); + s += Environment.NewLine + SR.Format(SR.IO_FileName_Name, _fileName); if (InnerException != null) s = s + " ---> " + InnerException.ToString(); diff --git a/src/mscorlib/src/System/Boolean.cs b/src/mscorlib/src/System/Boolean.cs index 7a7ac0e..6be8e31 100644 --- a/src/mscorlib/src/System/Boolean.cs +++ b/src/mscorlib/src/System/Boolean.cs @@ -134,7 +134,7 @@ namespace System } if (!(obj is Boolean)) { - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeBoolean")); + throw new ArgumentException(SR.Arg_MustBeBoolean); } if (m_value == ((Boolean)obj).m_value) @@ -174,7 +174,7 @@ namespace System Boolean result = false; if (!TryParse(value, out result)) { - throw new FormatException(Environment.GetResourceString("Format_BadBoolean")); + throw new FormatException(SR.Format_BadBoolean); } else { @@ -268,7 +268,7 @@ namespace System /// char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Boolean", "Char")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Boolean", "Char")); } /// @@ -340,7 +340,7 @@ namespace System /// DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Boolean", "DateTime")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Boolean", "DateTime")); } /// diff --git a/src/mscorlib/src/System/Buffer.cs b/src/mscorlib/src/System/Buffer.cs index 5c14d73..92b938d 100644 --- a/src/mscorlib/src/System/Buffer.cs +++ b/src/mscorlib/src/System/Buffer.cs @@ -142,7 +142,7 @@ namespace System // Is it of primitive types? if (!IsPrimitiveTypeArray(array)) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBePrimArray"), nameof(array)); + throw new ArgumentException(SR.Arg_MustBePrimArray, nameof(array)); // Is the index in valid range of the array? if (index < 0 || index >= _ByteLength(array)) @@ -168,7 +168,7 @@ namespace System // Is it of primitive types? if (!IsPrimitiveTypeArray(array)) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBePrimArray"), nameof(array)); + throw new ArgumentException(SR.Arg_MustBePrimArray, nameof(array)); // Is the index in valid range of the array? if (index < 0 || index >= _ByteLength(array)) @@ -196,7 +196,7 @@ namespace System // Is it of primitive types? if (!IsPrimitiveTypeArray(array)) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBePrimArray"), nameof(array)); + throw new ArgumentException(SR.Arg_MustBePrimArray, nameof(array)); return _ByteLength(array); } diff --git a/src/mscorlib/src/System/Byte.cs b/src/mscorlib/src/System/Byte.cs index 9d60360..e041af2 100644 --- a/src/mscorlib/src/System/Byte.cs +++ b/src/mscorlib/src/System/Byte.cs @@ -51,7 +51,7 @@ namespace System } if (!(value is Byte)) { - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeByte")); + throw new ArgumentException(SR.Arg_MustBeByte); } return m_value - (((Byte)value).m_value); @@ -123,10 +123,10 @@ namespace System } catch (OverflowException e) { - throw new OverflowException(Environment.GetResourceString("Overflow_Byte"), e); + throw new OverflowException(SR.Overflow_Byte, e); } - if (i < MinValue || i > MaxValue) throw new OverflowException(Environment.GetResourceString("Overflow_Byte")); + if (i < MinValue || i > MaxValue) throw new OverflowException(SR.Overflow_Byte); return (byte)i; } @@ -276,7 +276,7 @@ namespace System /// DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Byte", "DateTime")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Byte", "DateTime")); } /// diff --git a/src/mscorlib/src/System/Char.cs b/src/mscorlib/src/System/Char.cs index bf3818f..5fa886c 100644 --- a/src/mscorlib/src/System/Char.cs +++ b/src/mscorlib/src/System/Char.cs @@ -141,7 +141,7 @@ namespace System } if (!(value is Char)) { - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeChar")); + throw new ArgumentException(SR.Arg_MustBeChar); } return (m_value - ((Char)value).m_value); @@ -189,7 +189,7 @@ namespace System if (s.Length != 1) { - throw new FormatException(Environment.GetResourceString("Format_NeedSingleChar")); + throw new FormatException(SR.Format_NeedSingleChar); } return s[0]; } @@ -475,7 +475,7 @@ namespace System /// bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Char", "Boolean")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "Boolean")); } /// @@ -535,25 +535,25 @@ namespace System /// float IConvertible.ToSingle(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Char", "Single")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "Single")); } /// double IConvertible.ToDouble(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Char", "Double")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "Double")); } /// Decimal IConvertible.ToDecimal(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Char", "Decimal")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "Decimal")); } /// DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Char", "DateTime")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "DateTime")); } /// @@ -1038,7 +1038,7 @@ namespace System // are considered as irregular code unit sequence, but they are not illegal. if ((utf32 < 0 || utf32 > UNICODE_PLANE16_END) || (utf32 >= HIGH_SURROGATE_START && utf32 <= LOW_SURROGATE_END)) { - throw new ArgumentOutOfRangeException(nameof(utf32), Environment.GetResourceString("ArgumentOutOfRange_InvalidUTF32")); + throw new ArgumentOutOfRangeException(nameof(utf32), SR.ArgumentOutOfRange_InvalidUTF32); } Contract.EndContractBlock(); @@ -1069,11 +1069,11 @@ namespace System { if (!IsHighSurrogate(highSurrogate)) { - throw new ArgumentOutOfRangeException(nameof(highSurrogate), Environment.GetResourceString("ArgumentOutOfRange_InvalidHighSurrogate")); + throw new ArgumentOutOfRangeException(nameof(highSurrogate), SR.ArgumentOutOfRange_InvalidHighSurrogate); } if (!IsLowSurrogate(lowSurrogate)) { - throw new ArgumentOutOfRangeException(nameof(lowSurrogate), Environment.GetResourceString("ArgumentOutOfRange_InvalidLowSurrogate")); + throw new ArgumentOutOfRangeException(nameof(lowSurrogate), SR.ArgumentOutOfRange_InvalidLowSurrogate); } Contract.EndContractBlock(); return (((highSurrogate - CharUnicodeInfo.HIGH_SURROGATE_START) * 0x400) + (lowSurrogate - CharUnicodeInfo.LOW_SURROGATE_START) + UNICODE_PLANE01_START); @@ -1096,7 +1096,7 @@ namespace System if (index < 0 || index >= s.Length) { - throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index); } Contract.EndContractBlock(); // Check if the character at index is a high surrogate. @@ -1117,19 +1117,19 @@ namespace System } else { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHighSurrogate", index), nameof(s)); + throw new ArgumentException(SR.Format(SR.Argument_InvalidHighSurrogate, index), nameof(s)); } } else { // Found a high surrogate at the end of the string. - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidHighSurrogate", index), nameof(s)); + throw new ArgumentException(SR.Format(SR.Argument_InvalidHighSurrogate, index), nameof(s)); } } else { // Find a low surrogate at the character pointed by index. - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidLowSurrogate", index), nameof(s)); + throw new ArgumentException(SR.Format(SR.Argument_InvalidLowSurrogate, index), nameof(s)); } } // Not a high-surrogate or low-surrogate. Genereate the UTF32 value for the BMP characters. diff --git a/src/mscorlib/src/System/Collections/ArrayList.cs b/src/mscorlib/src/System/Collections/ArrayList.cs index 96aca31..c95f9b9 100644 --- a/src/mscorlib/src/System/Collections/ArrayList.cs +++ b/src/mscorlib/src/System/Collections/ArrayList.cs @@ -62,7 +62,7 @@ namespace System.Collections // public ArrayList(int capacity) { - if (capacity < 0) throw new ArgumentOutOfRangeException(nameof(capacity), Environment.GetResourceString("ArgumentOutOfRange_MustBeNonNegNum", nameof(capacity))); + if (capacity < 0) throw new ArgumentOutOfRangeException(nameof(capacity), SR.Format(SR.ArgumentOutOfRange_MustBeNonNegNum, nameof(capacity))); Contract.EndContractBlock(); if (capacity == 0) @@ -78,7 +78,7 @@ namespace System.Collections public ArrayList(ICollection c) { if (c == null) - throw new ArgumentNullException(nameof(c), Environment.GetResourceString("ArgumentNull_Collection")); + throw new ArgumentNullException(nameof(c), SR.ArgumentNull_Collection); Contract.EndContractBlock(); int count = c.Count; @@ -108,7 +108,7 @@ namespace System.Collections { if (value < _size) { - throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_SmallCapacity")); + throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_SmallCapacity); } Contract.Ensures(Capacity >= 0); Contract.EndContractBlock(); @@ -180,13 +180,13 @@ namespace System.Collections { get { - if (index < 0 || index >= _size) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index")); + if (index < 0 || index >= _size) throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index); Contract.EndContractBlock(); return _items[index]; } set { - if (index < 0 || index >= _size) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index")); + if (index < 0 || index >= _size) throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index); Contract.EndContractBlock(); _items[index] = value; _version++; @@ -269,7 +269,7 @@ namespace System.Collections public virtual void CopyTo(Array array, int arrayIndex) { if ((array != null) && (array.Rank != 1)) - throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported")); + throw new ArgumentException(SR.Arg_RankMultiDimNotSupported); Contract.EndContractBlock(); // Delegate rest of error checking to Array.Copy. Array.Copy(_items, 0, array, arrayIndex, _size); @@ -324,7 +324,7 @@ namespace System.Collections public virtual void Insert(int index, Object value) { // Note that insertions at the end are legal. - if (index < 0 || index > _size) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_ArrayListInsert")); + if (index < 0 || index > _size) throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_ArrayListInsert); //Contract.Ensures(Count == Contract.OldValue(Count) + 1); Contract.EndContractBlock(); @@ -346,8 +346,8 @@ namespace System.Collections public virtual void InsertRange(int index, ICollection c) { if (c == null) - throw new ArgumentNullException(nameof(c), Environment.GetResourceString("ArgumentNull_Collection")); - if (index < 0 || index > _size) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentNullException(nameof(c), SR.ArgumentNull_Collection); + if (index < 0 || index > _size) throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index); //Contract.Ensures(Count == Contract.OldValue(Count) + c.Count); Contract.EndContractBlock(); @@ -399,7 +399,7 @@ namespace System.Collections // public virtual void RemoveAt(int index) { - if (index < 0 || index >= _size) throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index")); + if (index < 0 || index >= _size) throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index); Contract.Ensures(Count >= 0); //Contract.Ensures(Count == Contract.OldValue(Count) - 1); Contract.EndContractBlock(); @@ -467,7 +467,7 @@ namespace System.Collections } set { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection")); + throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } } @@ -478,12 +478,12 @@ namespace System.Collections public virtual int Add(Object obj) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection")); + throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public virtual void Clear() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection")); + throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public virtual bool Contains(Object obj) @@ -508,17 +508,17 @@ namespace System.Collections public virtual void Insert(int index, Object obj) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection")); + throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public virtual void Remove(Object value) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection")); + throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } public virtual void RemoveAt(int index) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_ReadOnlyCollection")); + throw new NotSupportedException(SR.NotSupported_ReadOnlyCollection); } } @@ -552,7 +552,7 @@ namespace System.Collections { if (version != list._version) { - throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumFailedVersion)); + throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumFailedVersion)); } if (isArrayList) @@ -594,11 +594,11 @@ namespace System.Collections { // check if enumeration has not started or has terminated if (index == -1) { - throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumNotStarted)); + throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumNotStarted)); } else { - throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumEnded)); + throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumEnded)); } } @@ -610,7 +610,7 @@ namespace System.Collections { if (version != list._version) { - throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumFailedVersion)); + throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumFailedVersion)); } currentElement = dummyObject; diff --git a/src/mscorlib/src/System/Collections/Comparer.cs b/src/mscorlib/src/System/Collections/Comparer.cs index f1480e1..7f4f9f0 100644 --- a/src/mscorlib/src/System/Collections/Comparer.cs +++ b/src/mscorlib/src/System/Collections/Comparer.cs @@ -87,7 +87,7 @@ namespace System.Collections if (ib != null) return -ib.CompareTo(a); - throw new ArgumentException(Environment.GetResourceString("Argument_ImplementIComparable")); + throw new ArgumentException(SR.Argument_ImplementIComparable); } public void GetObjectData(SerializationInfo info, StreamingContext context) diff --git a/src/mscorlib/src/System/Collections/CompatibleComparer.cs b/src/mscorlib/src/System/Collections/CompatibleComparer.cs index 54c9132..1c90707 100644 --- a/src/mscorlib/src/System/Collections/CompatibleComparer.cs +++ b/src/mscorlib/src/System/Collections/CompatibleComparer.cs @@ -33,7 +33,7 @@ namespace System.Collections if (ia != null) return ia.CompareTo(b); - throw new ArgumentException(Environment.GetResourceString("Argument_ImplementIComparable")); + throw new ArgumentException(SR.Argument_ImplementIComparable); } public new bool Equals(Object a, Object b) diff --git a/src/mscorlib/src/System/Collections/Concurrent/ConcurrentQueue.cs b/src/mscorlib/src/System/Collections/Concurrent/ConcurrentQueue.cs index 991e17d..c6211da 100644 --- a/src/mscorlib/src/System/Collections/Concurrent/ConcurrentQueue.cs +++ b/src/mscorlib/src/System/Collections/Concurrent/ConcurrentQueue.cs @@ -205,7 +205,7 @@ namespace System.Collections.Concurrent /// cref="ICollection"/>. This property is not supported. /// /// The SyncRoot property is not supported. - object ICollection.SyncRoot { get { throw new NotSupportedException(Environment.GetResourceString("ConcurrentCollection_SyncRoot_NotSupported")); } } + object ICollection.SyncRoot { get { throw new NotSupportedException(SR.ConcurrentCollection_SyncRoot_NotSupported); } } /// Returns an enumerator that iterates through a collection. /// An that can be used to iterate through the collection. @@ -443,7 +443,7 @@ namespace System.Collections.Concurrent long count = GetCount(head, headHead, tail, tailTail); if (index > array.Length - count) { - throw new ArgumentException(Environment.GetResourceString("Arg_ArrayPlusOffTooSmall")); + throw new ArgumentException(SR.Arg_ArrayPlusOffTooSmall); } // Copy the items to the target array diff --git a/src/mscorlib/src/System/Collections/Concurrent/ConcurrentStack.cs b/src/mscorlib/src/System/Collections/Concurrent/ConcurrentStack.cs index 7b2bb9c..82bc4f9 100644 --- a/src/mscorlib/src/System/Collections/Concurrent/ConcurrentStack.cs +++ b/src/mscorlib/src/System/Collections/Concurrent/ConcurrentStack.cs @@ -135,7 +135,7 @@ namespace System.Collections.Concurrent { get { - throw new NotSupportedException(Environment.GetResourceString("ConcurrentCollection_SyncRoot_NotSupported")); + throw new NotSupportedException(SR.ConcurrentCollection_SyncRoot_NotSupported); } } diff --git a/src/mscorlib/src/System/Collections/EmptyReadOnlyDictionaryInternal.cs b/src/mscorlib/src/System/Collections/EmptyReadOnlyDictionaryInternal.cs index a0ce919..c36f57c 100644 --- a/src/mscorlib/src/System/Collections/EmptyReadOnlyDictionaryInternal.cs +++ b/src/mscorlib/src/System/Collections/EmptyReadOnlyDictionaryInternal.cs @@ -43,13 +43,13 @@ namespace System.Collections throw new ArgumentNullException(nameof(array)); if (array.Rank != 1) - throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported")); + throw new ArgumentException(SR.Arg_RankMultiDimNotSupported); if (index < 0) - throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_NeedNonNegNum); if (array.Length - index < this.Count) - throw new ArgumentException(Environment.GetResourceString("ArgumentOutOfRange_Index"), nameof(index)); + throw new ArgumentException(SR.ArgumentOutOfRange_Index, nameof(index)); Contract.EndContractBlock(); // the actual copy is a NOP @@ -87,7 +87,7 @@ namespace System.Collections { if (key == null) { - throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key")); + throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key); } Contract.EndContractBlock(); return null; @@ -96,17 +96,17 @@ namespace System.Collections { if (key == null) { - throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key")); + throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key); } if (!key.GetType().IsSerializable) - throw new ArgumentException(Environment.GetResourceString("Argument_NotSerializable"), nameof(key)); + throw new ArgumentException(SR.Argument_NotSerializable, nameof(key)); if ((value != null) && (!value.GetType().IsSerializable)) - throw new ArgumentException(Environment.GetResourceString("Argument_NotSerializable"), nameof(value)); + throw new ArgumentException(SR.Argument_NotSerializable, nameof(value)); Contract.EndContractBlock(); - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ReadOnly")); + throw new InvalidOperationException(SR.InvalidOperation_ReadOnly); } } @@ -135,22 +135,22 @@ namespace System.Collections { if (key == null) { - throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key")); + throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key); } if (!key.GetType().IsSerializable) - throw new ArgumentException(Environment.GetResourceString("Argument_NotSerializable"), nameof(key)); + throw new ArgumentException(SR.Argument_NotSerializable, nameof(key)); if ((value != null) && (!value.GetType().IsSerializable)) - throw new ArgumentException(Environment.GetResourceString("Argument_NotSerializable"), nameof(value)); + throw new ArgumentException(SR.Argument_NotSerializable, nameof(value)); Contract.EndContractBlock(); - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ReadOnly")); + throw new InvalidOperationException(SR.InvalidOperation_ReadOnly); } public void Clear() { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ReadOnly")); + throw new InvalidOperationException(SR.InvalidOperation_ReadOnly); } public bool IsReadOnly @@ -176,7 +176,7 @@ namespace System.Collections public void Remove(Object key) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ReadOnly")); + throw new InvalidOperationException(SR.InvalidOperation_ReadOnly); } private sealed class NodeEnumerator : IDictionaryEnumerator @@ -196,7 +196,7 @@ namespace System.Collections { get { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); + throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen); } } @@ -210,7 +210,7 @@ namespace System.Collections { get { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); + throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen); } } @@ -218,7 +218,7 @@ namespace System.Collections { get { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); + throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen); } } @@ -226,7 +226,7 @@ namespace System.Collections { get { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); + throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen); } } } diff --git a/src/mscorlib/src/System/Collections/Generic/ArraySortHelper.cs b/src/mscorlib/src/System/Collections/Generic/ArraySortHelper.cs index d3284be..e313cda 100644 --- a/src/mscorlib/src/System/Collections/Generic/ArraySortHelper.cs +++ b/src/mscorlib/src/System/Collections/Generic/ArraySortHelper.cs @@ -50,7 +50,7 @@ namespace System.Collections.Generic internal static void ThrowOrIgnoreBadComparer(Object comparer) { - throw new ArgumentException(Environment.GetResourceString("Arg_BogusIComparer", comparer)); + throw new ArgumentException(SR.Format(SR.Arg_BogusIComparer, comparer)); } } @@ -109,7 +109,7 @@ namespace System.Collections.Generic } catch (Exception e) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_IComparerFailed"), e); + throw new InvalidOperationException(SR.InvalidOperation_IComparerFailed, e); } } @@ -126,7 +126,7 @@ namespace System.Collections.Generic } catch (Exception e) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_IComparerFailed"), e); + throw new InvalidOperationException(SR.InvalidOperation_IComparerFailed, e); } } @@ -149,7 +149,7 @@ namespace System.Collections.Generic } catch (Exception e) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_IComparerFailed"), e); + throw new InvalidOperationException(SR.InvalidOperation_IComparerFailed, e); } } @@ -399,7 +399,7 @@ namespace System.Collections.Generic } catch (Exception e) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_IComparerFailed"), e); + throw new InvalidOperationException(SR.InvalidOperation_IComparerFailed, e); } } @@ -421,7 +421,7 @@ namespace System.Collections.Generic } catch (Exception e) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_IComparerFailed"), e); + throw new InvalidOperationException(SR.InvalidOperation_IComparerFailed, e); } } @@ -723,7 +723,7 @@ namespace System.Collections.Generic } catch (Exception e) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_IComparerFailed"), e); + throw new InvalidOperationException(SR.InvalidOperation_IComparerFailed, e); } } @@ -980,7 +980,7 @@ namespace System.Collections.Generic } catch (Exception e) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_IComparerFailed"), e); + throw new InvalidOperationException(SR.InvalidOperation_IComparerFailed, e); } } diff --git a/src/mscorlib/src/System/Collections/Generic/EqualityComparer.cs b/src/mscorlib/src/System/Collections/Generic/EqualityComparer.cs index a717558..0cd1bc1 100644 --- a/src/mscorlib/src/System/Collections/Generic/EqualityComparer.cs +++ b/src/mscorlib/src/System/Collections/Generic/EqualityComparer.cs @@ -320,11 +320,11 @@ namespace System.Collections.Generic if (array == null) throw new ArgumentNullException(nameof(array)); if (startIndex < 0) - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index); if (count < 0) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_Count")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_Count); if (count > array.Length - startIndex) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); if (count == 0) return -1; fixed (byte* pbytes = array) diff --git a/src/mscorlib/src/System/Collections/Hashtable.cs b/src/mscorlib/src/System/Collections/Hashtable.cs index 3a8d263..f21ee99 100644 --- a/src/mscorlib/src/System/Collections/Hashtable.cs +++ b/src/mscorlib/src/System/Collections/Hashtable.cs @@ -203,9 +203,9 @@ namespace System.Collections public Hashtable(int capacity, float loadFactor) { if (capacity < 0) - throw new ArgumentOutOfRangeException(nameof(capacity), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(capacity), SR.ArgumentOutOfRange_NeedNonNegNum); if (!(loadFactor >= 0.1f && loadFactor <= 1.0f)) - throw new ArgumentOutOfRangeException(nameof(loadFactor), Environment.GetResourceString("ArgumentOutOfRange_HashtableLoadFactor", .1, 1.0)); + throw new ArgumentOutOfRangeException(nameof(loadFactor), SR.Format(SR.ArgumentOutOfRange_HashtableLoadFactor, .1, 1.0)); Contract.EndContractBlock(); // Based on perf work, .72 is the optimal load factor for this table. @@ -213,7 +213,7 @@ namespace System.Collections double rawsize = capacity / this.loadFactor; if (rawsize > Int32.MaxValue) - throw new ArgumentException(Environment.GetResourceString("Arg_HTCapacityOverflow")); + throw new ArgumentException(SR.Arg_HTCapacityOverflow); // Avoid awfully small sizes int hashsize = (rawsize > InitialSize) ? HashHelpers.GetPrime((int)rawsize) : InitialSize; @@ -343,7 +343,7 @@ namespace System.Collections { if (key == null) { - throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key")); + throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key); } Contract.EndContractBlock(); @@ -415,13 +415,13 @@ namespace System.Collections public virtual void CopyTo(Array array, int arrayIndex) { if (array == null) - throw new ArgumentNullException(nameof(array), Environment.GetResourceString("ArgumentNull_Array")); + throw new ArgumentNullException(nameof(array), SR.ArgumentNull_Array); if (array.Rank != 1) - throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported")); + throw new ArgumentException(SR.Arg_RankMultiDimNotSupported); if (arrayIndex < 0) - throw new ArgumentOutOfRangeException(nameof(arrayIndex), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(arrayIndex), SR.ArgumentOutOfRange_NeedNonNegNum); if (array.Length - arrayIndex < Count) - throw new ArgumentException(Environment.GetResourceString("Arg_ArrayPlusOffTooSmall")); + throw new ArgumentException(SR.Arg_ArrayPlusOffTooSmall); Contract.EndContractBlock(); CopyEntries(array, arrayIndex); } @@ -455,7 +455,7 @@ namespace System.Collections { if (key == null) { - throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key")); + throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key); } Contract.EndContractBlock(); @@ -698,7 +698,7 @@ namespace System.Collections { if (key == null) { - throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key")); + throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key); } Contract.EndContractBlock(); if (count >= loadsize) @@ -760,7 +760,7 @@ namespace System.Collections { if (add) { - throw new ArgumentException(Environment.GetResourceString("Argument_AddingDuplicate__", buckets[bucketNumber].key, key)); + throw new ArgumentException(SR.Format(SR.Argument_AddingDuplicate__, buckets[bucketNumber].key, key)); } isWriterInProgress = true; buckets[bucketNumber].val = nvalue; @@ -804,7 +804,7 @@ namespace System.Collections // Then verify that our double hash function (h2, described at top of file) // meets the requirements described above. You should never see this assert. Debug.Assert(false, "hash table insert failed! Load factor too high, or our double hashing function is incorrect."); - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_HashInsertFailed")); + throw new InvalidOperationException(SR.InvalidOperation_HashInsertFailed); } private void putEntry(bucket[] newBuckets, Object key, Object nvalue, int hashcode) @@ -841,7 +841,7 @@ namespace System.Collections { if (key == null) { - throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key")); + throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key); } Contract.EndContractBlock(); Debug.Assert(!isWriterInProgress, "Race condition detected in usages of Hashtable - multiple threads appear to be writing to a Hashtable instance simultaneously! Don't do that - use Hashtable.Synchronized."); @@ -880,7 +880,7 @@ namespace System.Collections bn = (int)(((long)bn + incr) % (uint)buckets.Length); } while (b.hash_coll < 0 && ++ntry < buckets.Length); - //throw new ArgumentException(Environment.GetResourceString("Arg_RemoveArgNotFound")); + //throw new ArgumentException(SR.Arg_RemoveArgNotFound); } // Returns the object to synchronize on for this hash table. @@ -975,7 +975,7 @@ namespace System.Collections // Explicitly check to see if anyone changed the Hashtable while we // were serializing it. That's a race condition in their code. if (version != oldVersion) - throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumFailedVersion)); + throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumFailedVersion)); } } @@ -995,7 +995,7 @@ namespace System.Collections if (siInfo == null) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidOnDeser")); + throw new SerializationException(SR.Serialization_InvalidOnDeser); } int hashsize = 0; @@ -1052,21 +1052,21 @@ namespace System.Collections if (serKeys == null) { - throw new SerializationException(Environment.GetResourceString("Serialization_MissingKeys")); + throw new SerializationException(SR.Serialization_MissingKeys); } if (serValues == null) { - throw new SerializationException(Environment.GetResourceString("Serialization_MissingValues")); + throw new SerializationException(SR.Serialization_MissingValues); } if (serKeys.Length != serValues.Length) { - throw new SerializationException(Environment.GetResourceString("Serialization_KeyValueDifferentSizes")); + throw new SerializationException(SR.Serialization_KeyValueDifferentSizes); } for (int i = 0; i < serKeys.Length; i++) { if (serKeys[i] == null) { - throw new SerializationException(Environment.GetResourceString("Serialization_NullKey")); + throw new SerializationException(SR.Serialization_NullKey); } Insert(serKeys[i], serValues[i], true); } @@ -1094,12 +1094,12 @@ namespace System.Collections if (array == null) throw new ArgumentNullException(nameof(array)); if (array.Rank != 1) - throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported")); + throw new ArgumentException(SR.Arg_RankMultiDimNotSupported); if (arrayIndex < 0) - throw new ArgumentOutOfRangeException(nameof(arrayIndex), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(arrayIndex), SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); if (array.Length - arrayIndex < _hashtable.count) - throw new ArgumentException(Environment.GetResourceString("Arg_ArrayPlusOffTooSmall")); + throw new ArgumentException(SR.Arg_ArrayPlusOffTooSmall); _hashtable.CopyKeys(array, arrayIndex); } @@ -1141,12 +1141,12 @@ namespace System.Collections if (array == null) throw new ArgumentNullException(nameof(array)); if (array.Rank != 1) - throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported")); + throw new ArgumentException(SR.Arg_RankMultiDimNotSupported); if (arrayIndex < 0) - throw new ArgumentOutOfRangeException(nameof(arrayIndex), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(arrayIndex), SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); if (array.Length - arrayIndex < _hashtable.count) - throw new ArgumentException(Environment.GetResourceString("Arg_ArrayPlusOffTooSmall")); + throw new ArgumentException(SR.Arg_ArrayPlusOffTooSmall); _hashtable.CopyValues(array, arrayIndex); } @@ -1273,7 +1273,7 @@ namespace System.Collections { if (key == null) { - throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key")); + throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key); } Contract.EndContractBlock(); return _table.ContainsKey(key); @@ -1386,14 +1386,14 @@ namespace System.Collections { get { - if (current == false) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumNotStarted)); + if (current == false) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumNotStarted)); return currentKey; } } public virtual bool MoveNext() { - if (version != hashtable.version) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumFailedVersion)); + if (version != hashtable.version) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumFailedVersion)); while (bucket > 0) { bucket--; @@ -1414,7 +1414,7 @@ namespace System.Collections { get { - if (current == false) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumOpCantHappen)); + if (current == false) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumOpCantHappen)); return new DictionaryEntry(currentKey, currentValue); } } @@ -1424,7 +1424,7 @@ namespace System.Collections { get { - if (current == false) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumOpCantHappen)); + if (current == false) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumOpCantHappen)); if (getObjectRetType == Keys) return currentKey; @@ -1439,14 +1439,14 @@ namespace System.Collections { get { - if (current == false) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumOpCantHappen)); + if (current == false) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumOpCantHappen)); return currentValue; } } public virtual void Reset() { - if (version != hashtable.version) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumFailedVersion)); + if (version != hashtable.version) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumFailedVersion)); current = false; bucket = hashtable.buckets.Length; currentKey = null; @@ -1523,7 +1523,7 @@ namespace System.Collections public static int GetPrime(int min) { if (min < 0) - throw new ArgumentException(Environment.GetResourceString("Arg_HTCapacityOverflow")); + throw new ArgumentException(SR.Arg_HTCapacityOverflow); Contract.EndContractBlock(); for (int i = 0; i < primes.Length; i++) diff --git a/src/mscorlib/src/System/Collections/ListDictionaryInternal.cs b/src/mscorlib/src/System/Collections/ListDictionaryInternal.cs index bfd1158..3f92038 100644 --- a/src/mscorlib/src/System/Collections/ListDictionaryInternal.cs +++ b/src/mscorlib/src/System/Collections/ListDictionaryInternal.cs @@ -38,7 +38,7 @@ namespace System.Collections { if (key == null) { - throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key")); + throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key); } Contract.EndContractBlock(); DictionaryNode node = head; @@ -57,7 +57,7 @@ namespace System.Collections { if (key == null) { - throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key")); + throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key); } Contract.EndContractBlock(); @@ -159,7 +159,7 @@ namespace System.Collections { if (key == null) { - throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key")); + throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key); } Contract.EndContractBlock(); @@ -171,7 +171,7 @@ namespace System.Collections { if (node.key.Equals(key)) { - throw new ArgumentException(Environment.GetResourceString("Argument_AddingDuplicate__", node.key, key)); + throw new ArgumentException(SR.Format(SR.Argument_AddingDuplicate__, node.key, key)); } last = node; } @@ -207,7 +207,7 @@ namespace System.Collections { if (key == null) { - throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key")); + throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key); } Contract.EndContractBlock(); for (DictionaryNode node = head; node != null; node = node.next) @@ -226,13 +226,13 @@ namespace System.Collections throw new ArgumentNullException(nameof(array)); if (array.Rank != 1) - throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported")); + throw new ArgumentException(SR.Arg_RankMultiDimNotSupported); if (index < 0) - throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_NeedNonNegNum); if (array.Length - index < this.Count) - throw new ArgumentException(Environment.GetResourceString("ArgumentOutOfRange_Index"), nameof(index)); + throw new ArgumentException(SR.ArgumentOutOfRange_Index, nameof(index)); Contract.EndContractBlock(); for (DictionaryNode node = head; node != null; node = node.next) @@ -256,7 +256,7 @@ namespace System.Collections { if (key == null) { - throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key")); + throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key); } Contract.EndContractBlock(); version++; @@ -315,7 +315,7 @@ namespace System.Collections { if (current == null) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); + throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen); } return new DictionaryEntry(current.key, current.value); } @@ -327,7 +327,7 @@ namespace System.Collections { if (current == null) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); + throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen); } return current.key; } @@ -339,7 +339,7 @@ namespace System.Collections { if (current == null) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); + throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen); } return current.value; } @@ -349,7 +349,7 @@ namespace System.Collections { if (version != list.version) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumFailedVersion")); + throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion); } if (start) { @@ -370,7 +370,7 @@ namespace System.Collections { if (version != list.version) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumFailedVersion")); + throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion); } start = true; current = null; @@ -394,12 +394,12 @@ namespace System.Collections if (array == null) throw new ArgumentNullException(nameof(array)); if (array.Rank != 1) - throw new ArgumentException(Environment.GetResourceString("Arg_RankMultiDimNotSupported")); + throw new ArgumentException(SR.Arg_RankMultiDimNotSupported); if (index < 0) - throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); if (array.Length - index < list.Count) - throw new ArgumentException(Environment.GetResourceString("ArgumentOutOfRange_Index"), nameof(index)); + throw new ArgumentException(SR.ArgumentOutOfRange_Index, nameof(index)); for (DictionaryNode node = list.head; node != null; node = node.next) { array.SetValue(isKeys ? node.key : node.value, index); @@ -465,7 +465,7 @@ namespace System.Collections { if (current == null) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumOpCantHappen")); + throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen); } return isKeys ? current.key : current.value; } @@ -475,7 +475,7 @@ namespace System.Collections { if (version != list.version) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumFailedVersion")); + throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion); } if (start) { @@ -496,7 +496,7 @@ namespace System.Collections { if (version != list.version) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EnumFailedVersion")); + throw new InvalidOperationException(SR.InvalidOperation_EnumFailedVersion); } start = true; current = null; diff --git a/src/mscorlib/src/System/CurrentTimeZone.cs b/src/mscorlib/src/System/CurrentTimeZone.cs index d55df27..d095747 100644 --- a/src/mscorlib/src/System/CurrentTimeZone.cs +++ b/src/mscorlib/src/System/CurrentTimeZone.cs @@ -150,7 +150,7 @@ namespace System { if (year < 1 || year > 9999) { - throw new ArgumentOutOfRangeException(nameof(year), Environment.GetResourceString("ArgumentOutOfRange_Range", 1, 9999)); + throw new ArgumentOutOfRangeException(nameof(year), SR.Format(SR.ArgumentOutOfRange_Range, 1, 9999)); } Contract.EndContractBlock(); diff --git a/src/mscorlib/src/System/DBNull.cs b/src/mscorlib/src/System/DBNull.cs index 817f6e5..0b859e7 100644 --- a/src/mscorlib/src/System/DBNull.cs +++ b/src/mscorlib/src/System/DBNull.cs @@ -23,7 +23,7 @@ namespace System private DBNull(SerializationInfo info, StreamingContext context) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DBNullSerial")); + throw new NotSupportedException(SR.NotSupported_DBNullSerial); } public static readonly DBNull Value = new DBNull(); @@ -51,85 +51,85 @@ namespace System /// bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull")); + throw new InvalidCastException(SR.InvalidCast_FromDBNull); } /// char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull")); + throw new InvalidCastException(SR.InvalidCast_FromDBNull); } /// sbyte IConvertible.ToSByte(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull")); + throw new InvalidCastException(SR.InvalidCast_FromDBNull); } /// byte IConvertible.ToByte(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull")); + throw new InvalidCastException(SR.InvalidCast_FromDBNull); } /// short IConvertible.ToInt16(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull")); + throw new InvalidCastException(SR.InvalidCast_FromDBNull); } /// ushort IConvertible.ToUInt16(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull")); + throw new InvalidCastException(SR.InvalidCast_FromDBNull); } /// int IConvertible.ToInt32(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull")); + throw new InvalidCastException(SR.InvalidCast_FromDBNull); } /// uint IConvertible.ToUInt32(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull")); + throw new InvalidCastException(SR.InvalidCast_FromDBNull); } /// long IConvertible.ToInt64(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull")); + throw new InvalidCastException(SR.InvalidCast_FromDBNull); } /// ulong IConvertible.ToUInt64(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull")); + throw new InvalidCastException(SR.InvalidCast_FromDBNull); } /// float IConvertible.ToSingle(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull")); + throw new InvalidCastException(SR.InvalidCast_FromDBNull); } /// double IConvertible.ToDouble(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull")); + throw new InvalidCastException(SR.InvalidCast_FromDBNull); } /// decimal IConvertible.ToDecimal(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull")); + throw new InvalidCastException(SR.InvalidCast_FromDBNull); } /// DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromDBNull")); + throw new InvalidCastException(SR.InvalidCast_FromDBNull); } /// diff --git a/src/mscorlib/src/System/DateTime.cs b/src/mscorlib/src/System/DateTime.cs index 360acee..894e849 100644 --- a/src/mscorlib/src/System/DateTime.cs +++ b/src/mscorlib/src/System/DateTime.cs @@ -142,7 +142,7 @@ namespace System public DateTime(long ticks) { if (ticks < MinTicks || ticks > MaxTicks) - throw new ArgumentOutOfRangeException(nameof(ticks), Environment.GetResourceString("ArgumentOutOfRange_DateTimeBadTicks")); + throw new ArgumentOutOfRangeException(nameof(ticks), SR.ArgumentOutOfRange_DateTimeBadTicks); Contract.EndContractBlock(); dateData = (UInt64)ticks; } @@ -156,11 +156,11 @@ namespace System { if (ticks < MinTicks || ticks > MaxTicks) { - throw new ArgumentOutOfRangeException(nameof(ticks), Environment.GetResourceString("ArgumentOutOfRange_DateTimeBadTicks")); + throw new ArgumentOutOfRangeException(nameof(ticks), SR.ArgumentOutOfRange_DateTimeBadTicks); } if (kind < DateTimeKind.Unspecified || kind > DateTimeKind.Local) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidDateTimeKind"), nameof(kind)); + throw new ArgumentException(SR.Argument_InvalidDateTimeKind, nameof(kind)); } Contract.EndContractBlock(); dateData = ((UInt64)ticks | ((UInt64)kind << KindShift)); @@ -170,7 +170,7 @@ namespace System { if (ticks < MinTicks || ticks > MaxTicks) { - throw new ArgumentOutOfRangeException(nameof(ticks), Environment.GetResourceString("ArgumentOutOfRange_DateTimeBadTicks")); + throw new ArgumentOutOfRangeException(nameof(ticks), SR.ArgumentOutOfRange_DateTimeBadTicks); } Contract.Requires(kind == DateTimeKind.Local, "Internal Constructor is for local times only"); Contract.EndContractBlock(); @@ -206,7 +206,7 @@ namespace System { if (kind < DateTimeKind.Unspecified || kind > DateTimeKind.Local) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidDateTimeKind"), nameof(kind)); + throw new ArgumentException(SR.Argument_InvalidDateTimeKind, nameof(kind)); } Contract.EndContractBlock(); Int64 ticks = DateToTicks(year, month, day) + TimeToTicks(hour, minute, second); @@ -231,13 +231,13 @@ namespace System { if (millisecond < 0 || millisecond >= MillisPerSecond) { - throw new ArgumentOutOfRangeException(nameof(millisecond), Environment.GetResourceString("ArgumentOutOfRange_Range", 0, MillisPerSecond - 1)); + throw new ArgumentOutOfRangeException(nameof(millisecond), SR.Format(SR.ArgumentOutOfRange_Range, 0, MillisPerSecond - 1)); } Contract.EndContractBlock(); Int64 ticks = DateToTicks(year, month, day) + TimeToTicks(hour, minute, second); ticks += millisecond * TicksPerMillisecond; if (ticks < MinTicks || ticks > MaxTicks) - throw new ArgumentException(Environment.GetResourceString("Arg_DateTimeRange")); + throw new ArgumentException(SR.Arg_DateTimeRange); dateData = (UInt64)ticks; } @@ -245,17 +245,17 @@ namespace System { if (millisecond < 0 || millisecond >= MillisPerSecond) { - throw new ArgumentOutOfRangeException(nameof(millisecond), Environment.GetResourceString("ArgumentOutOfRange_Range", 0, MillisPerSecond - 1)); + throw new ArgumentOutOfRangeException(nameof(millisecond), SR.Format(SR.ArgumentOutOfRange_Range, 0, MillisPerSecond - 1)); } if (kind < DateTimeKind.Unspecified || kind > DateTimeKind.Local) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidDateTimeKind"), nameof(kind)); + throw new ArgumentException(SR.Argument_InvalidDateTimeKind, nameof(kind)); } Contract.EndContractBlock(); Int64 ticks = DateToTicks(year, month, day) + TimeToTicks(hour, minute, second); ticks += millisecond * TicksPerMillisecond; if (ticks < MinTicks || ticks > MaxTicks) - throw new ArgumentException(Environment.GetResourceString("Arg_DateTimeRange")); + throw new ArgumentException(SR.Arg_DateTimeRange); dateData = ((UInt64)ticks | ((UInt64)kind << KindShift)); } @@ -268,13 +268,13 @@ namespace System throw new ArgumentNullException(nameof(calendar)); if (millisecond < 0 || millisecond >= MillisPerSecond) { - throw new ArgumentOutOfRangeException(nameof(millisecond), Environment.GetResourceString("ArgumentOutOfRange_Range", 0, MillisPerSecond - 1)); + throw new ArgumentOutOfRangeException(nameof(millisecond), SR.Format(SR.ArgumentOutOfRange_Range, 0, MillisPerSecond - 1)); } Contract.EndContractBlock(); Int64 ticks = calendar.ToDateTime(year, month, day, hour, minute, second, 0).Ticks; ticks += millisecond * TicksPerMillisecond; if (ticks < MinTicks || ticks > MaxTicks) - throw new ArgumentException(Environment.GetResourceString("Arg_DateTimeRange")); + throw new ArgumentException(SR.Arg_DateTimeRange); dateData = (UInt64)ticks; } @@ -284,17 +284,17 @@ namespace System throw new ArgumentNullException(nameof(calendar)); if (millisecond < 0 || millisecond >= MillisPerSecond) { - throw new ArgumentOutOfRangeException(nameof(millisecond), Environment.GetResourceString("ArgumentOutOfRange_Range", 0, MillisPerSecond - 1)); + throw new ArgumentOutOfRangeException(nameof(millisecond), SR.Format(SR.ArgumentOutOfRange_Range, 0, MillisPerSecond - 1)); } if (kind < DateTimeKind.Unspecified || kind > DateTimeKind.Local) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidDateTimeKind"), nameof(kind)); + throw new ArgumentException(SR.Argument_InvalidDateTimeKind, nameof(kind)); } Contract.EndContractBlock(); Int64 ticks = calendar.ToDateTime(year, month, day, hour, minute, second, 0).Ticks; ticks += millisecond * TicksPerMillisecond; if (ticks < MinTicks || ticks > MaxTicks) - throw new ArgumentException(Environment.GetResourceString("Arg_DateTimeRange")); + throw new ArgumentException(SR.Arg_DateTimeRange); dateData = ((UInt64)ticks | ((UInt64)kind << KindShift)); } @@ -339,12 +339,12 @@ namespace System } else { - throw new SerializationException(Environment.GetResourceString("Serialization_MissingDateTimeData")); + throw new SerializationException(SR.Serialization_MissingDateTimeData); } Int64 ticks = InternalTicks; if (ticks < MinTicks || ticks > MaxTicks) { - throw new SerializationException(Environment.GetResourceString("Serialization_DateTimeTicksOutOfRange")); + throw new SerializationException(SR.Serialization_DateTimeTicksOutOfRange); } } @@ -380,7 +380,7 @@ namespace System { long millis = (long)(value * scale + (value >= 0 ? 0.5 : -0.5)); if (millis <= -MaxMillis || millis >= MaxMillis) - throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_AddValue")); + throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_AddValue); return AddTicks(millis * TicksPerMillisecond); } @@ -447,7 +447,7 @@ namespace System // public DateTime AddMonths(int months) { - if (months < -120000 || months > 120000) throw new ArgumentOutOfRangeException(nameof(months), Environment.GetResourceString("ArgumentOutOfRange_DateTimeBadMonths")); + if (months < -120000 || months > 120000) throw new ArgumentOutOfRangeException(nameof(months), SR.ArgumentOutOfRange_DateTimeBadMonths); Contract.EndContractBlock(); int y = GetDatePart(DatePartYear); int m = GetDatePart(DatePartMonth); @@ -465,7 +465,7 @@ namespace System } if (y < 1 || y > 9999) { - throw new ArgumentOutOfRangeException(nameof(months), Environment.GetResourceString("ArgumentOutOfRange_DateArithmetic")); + throw new ArgumentOutOfRangeException(nameof(months), SR.ArgumentOutOfRange_DateArithmetic); } int days = DaysInMonth(y, m); if (d > days) d = days; @@ -492,7 +492,7 @@ namespace System long ticks = InternalTicks; if (value > MaxTicks - ticks || value < MinTicks - ticks) { - throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_DateArithmetic")); + throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_DateArithmetic); } return new DateTime((UInt64)(ticks + value) | InternalKind); } @@ -511,7 +511,7 @@ namespace System { // DateTimeOffset.AddYears(int years) is implemented on top of DateTime.AddYears(int value). Use the more appropriate // parameter name out of the two for the exception. - throw new ArgumentOutOfRangeException("years", Environment.GetResourceString("ArgumentOutOfRange_DateTimeBadYears")); + throw new ArgumentOutOfRangeException("years", SR.ArgumentOutOfRange_DateTimeBadYears); } Contract.EndContractBlock(); return AddMonths(value * 12); @@ -540,7 +540,7 @@ namespace System if (value == null) return 1; if (!(value is DateTime)) { - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDateTime")); + throw new ArgumentException(SR.Arg_MustBeDateTime); } return Compare(this, (DateTime)value); @@ -565,7 +565,7 @@ namespace System return n * TicksPerDay; } } - throw new ArgumentOutOfRangeException(null, Environment.GetResourceString("ArgumentOutOfRange_BadYearMonthDay")); + throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadYearMonthDay); } // Return the tick count corresponding to the given hour, minute, second. @@ -578,7 +578,7 @@ namespace System { return (TimeSpan.TimeToTicks(hour, minute, second)); } - throw new ArgumentOutOfRangeException(null, Environment.GetResourceString("ArgumentOutOfRange_BadHourMinuteSecond")); + throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadHourMinuteSecond); } // Returns the number of days in the month given by the year and @@ -586,7 +586,7 @@ namespace System // public static int DaysInMonth(int year, int month) { - if (month < 1 || month > 12) throw new ArgumentOutOfRangeException(nameof(month), Environment.GetResourceString("ArgumentOutOfRange_Month")); + if (month < 1 || month > 12) throw new ArgumentOutOfRangeException(nameof(month), SR.ArgumentOutOfRange_Month); Contract.EndContractBlock(); // IsLeapYear checks the year argument int[] days = IsLeapYear(year) ? DaysToMonth366 : DaysToMonth365; @@ -599,7 +599,7 @@ namespace System { // The check done this way will take care of NaN if (!(value < OADateMaxAsDouble) || !(value > OADateMinAsDouble)) - throw new ArgumentException(Environment.GetResourceString("Arg_OleAutDateInvalid")); + throw new ArgumentException(SR.Arg_OleAutDateInvalid); // Conversion to long will not cause an overflow here, as at this point the "value" is in between OADateMinAsDouble and OADateMaxAsDouble long millis = (long)(value * MillisPerDay + (value >= 0 ? 0.5 : -0.5)); @@ -613,7 +613,7 @@ namespace System millis += DoubleDateOffset / TicksPerMillisecond; - if (millis < 0 || millis >= MaxMillis) throw new ArgumentException(Environment.GetResourceString("Arg_OleAutDateScale")); + if (millis < 0 || millis >= MaxMillis) throw new ArgumentException(SR.Arg_OleAutDateScale); return millis * TicksPerMillisecond; } @@ -688,7 +688,7 @@ namespace System } if (ticks < MinTicks || ticks > MaxTicks) { - throw new ArgumentException(Environment.GetResourceString("Argument_DateTimeBadBinaryData"), nameof(dateData)); + throw new ArgumentException(SR.Argument_DateTimeBadBinaryData, nameof(dateData)); } return new DateTime(ticks, DateTimeKind.Local, isAmbiguousLocalDst); } @@ -704,7 +704,7 @@ namespace System { Int64 ticks = dateData & (Int64)TicksMask; if (ticks < MinTicks || ticks > MaxTicks) - throw new ArgumentException(Environment.GetResourceString("Argument_DateTimeBadBinaryData"), nameof(dateData)); + throw new ArgumentException(SR.Argument_DateTimeBadBinaryData, nameof(dateData)); return new DateTime((UInt64)dateData); } @@ -721,7 +721,7 @@ namespace System { if (fileTime < 0 || fileTime > MaxTicks - FileTimeOffset) { - throw new ArgumentOutOfRangeException(nameof(fileTime), Environment.GetResourceString("ArgumentOutOfRange_FileTimeInvalid")); + throw new ArgumentOutOfRangeException(nameof(fileTime), SR.ArgumentOutOfRange_FileTimeInvalid); } Contract.EndContractBlock(); @@ -1091,7 +1091,7 @@ namespace System { if (year < 1 || year > 9999) { - throw new ArgumentOutOfRangeException(nameof(year), Environment.GetResourceString("ArgumentOutOfRange_Year")); + throw new ArgumentOutOfRangeException(nameof(year), SR.ArgumentOutOfRange_Year); } Contract.EndContractBlock(); return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0); @@ -1157,7 +1157,7 @@ namespace System long valueTicks = value._ticks; if (ticks - MinTicks < valueTicks || ticks - MaxTicks > valueTicks) { - throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_DateArithmetic")); + throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_DateArithmetic); } return new DateTime((UInt64)(ticks - valueTicks) | InternalKind); } @@ -1170,7 +1170,7 @@ namespace System if (value < TicksPerDay) // This is a fix for VB. They want the default day to be 1/1/0001 rathar then 12/30/1899. value += DoubleDateOffset; // We could have moved this fix down but we would like to keep the bounds check. if (value < OADateMinAsTicks) - throw new OverflowException(Environment.GetResourceString("Arg_OleAutDateInvalid")); + throw new OverflowException(SR.Arg_OleAutDateInvalid); // Currently, our max date == OA's max date (12/31/9999), so we don't // need an overflow check in that direction. long millis = (value - DoubleDateOffset) / TicksPerMillisecond; @@ -1202,7 +1202,7 @@ namespace System ticks -= FileTimeOffset; if (ticks < 0) { - throw new ArgumentOutOfRangeException(null, Environment.GetResourceString("ArgumentOutOfRange_FileTimeInvalid")); + throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_FileTimeInvalid); } return ticks; } @@ -1225,14 +1225,14 @@ namespace System if (tick > DateTime.MaxTicks) { if (throwOnOverflow) - throw new ArgumentException(Environment.GetResourceString("Arg_ArgumentOutOfRangeException")); + throw new ArgumentException(SR.Arg_ArgumentOutOfRangeException); else return new DateTime(DateTime.MaxTicks, DateTimeKind.Local); } if (tick < DateTime.MinTicks) { if (throwOnOverflow) - throw new ArgumentException(Environment.GetResourceString("Arg_ArgumentOutOfRangeException")); + throw new ArgumentException(SR.Arg_ArgumentOutOfRangeException); else return new DateTime(DateTime.MinTicks, DateTimeKind.Local); } @@ -1321,7 +1321,7 @@ namespace System long valueTicks = t._ticks; if (valueTicks > MaxTicks - ticks || valueTicks < MinTicks - ticks) { - throw new ArgumentOutOfRangeException(nameof(t), Environment.GetResourceString("ArgumentOutOfRange_DateArithmetic")); + throw new ArgumentOutOfRangeException(nameof(t), SR.ArgumentOutOfRange_DateArithmetic); } return new DateTime((UInt64)(ticks + valueTicks) | d.InternalKind); } @@ -1332,7 +1332,7 @@ namespace System long valueTicks = t._ticks; if (ticks - MinTicks < valueTicks || ticks - MaxTicks > valueTicks) { - throw new ArgumentOutOfRangeException(nameof(t), Environment.GetResourceString("ArgumentOutOfRange_DateArithmetic")); + throw new ArgumentOutOfRangeException(nameof(t), SR.ArgumentOutOfRange_DateArithmetic); } return new DateTime((UInt64)(ticks - valueTicks) | d.InternalKind); } @@ -1423,79 +1423,79 @@ namespace System /// bool IConvertible.ToBoolean(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "DateTime", "Boolean")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "DateTime", "Boolean")); } /// char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "DateTime", "Char")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "DateTime", "Char")); } /// sbyte IConvertible.ToSByte(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "DateTime", "SByte")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "DateTime", "SByte")); } /// byte IConvertible.ToByte(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "DateTime", "Byte")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "DateTime", "Byte")); } /// short IConvertible.ToInt16(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "DateTime", "Int16")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "DateTime", "Int16")); } /// ushort IConvertible.ToUInt16(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "DateTime", "UInt16")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "DateTime", "UInt16")); } /// int IConvertible.ToInt32(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "DateTime", "Int32")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "DateTime", "Int32")); } /// uint IConvertible.ToUInt32(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "DateTime", "UInt32")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "DateTime", "UInt32")); } /// long IConvertible.ToInt64(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "DateTime", "Int64")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "DateTime", "Int64")); } /// ulong IConvertible.ToUInt64(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "DateTime", "UInt64")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "DateTime", "UInt64")); } /// float IConvertible.ToSingle(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "DateTime", "Single")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "DateTime", "Single")); } /// double IConvertible.ToDouble(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "DateTime", "Double")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "DateTime", "Double")); } /// Decimal IConvertible.ToDecimal(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "DateTime", "Decimal")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "DateTime", "Decimal")); } /// diff --git a/src/mscorlib/src/System/DateTimeOffset.cs b/src/mscorlib/src/System/DateTimeOffset.cs index 9f85edf..35253ba 100644 --- a/src/mscorlib/src/System/DateTimeOffset.cs +++ b/src/mscorlib/src/System/DateTimeOffset.cs @@ -95,14 +95,14 @@ namespace System { if (offset != TimeZoneInfo.GetLocalUtcOffset(dateTime, TimeZoneInfoOptions.NoThrowOnInvalidTime)) { - throw new ArgumentException(Environment.GetResourceString("Argument_OffsetLocalMismatch"), nameof(offset)); + throw new ArgumentException(SR.Argument_OffsetLocalMismatch, nameof(offset)); } } else if (dateTime.Kind == DateTimeKind.Utc) { if (offset != TimeSpan.Zero) { - throw new ArgumentException(Environment.GetResourceString("Argument_OffsetUtcMismatch"), nameof(offset)); + throw new ArgumentException(SR.Argument_OffsetUtcMismatch, nameof(offset)); } } m_offsetMinutes = ValidateOffset(offset); @@ -482,7 +482,7 @@ namespace System if (obj == null) return 1; if (!(obj is DateTimeOffset)) { - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDateTimeOffset")); + throw new ArgumentException(SR.Arg_MustBeDateTimeOffset); } DateTime objUtc = ((DateTimeOffset)obj).UtcDateTime; @@ -555,7 +555,7 @@ namespace System if (seconds < UnixMinSeconds || seconds > UnixMaxSeconds) { throw new ArgumentOutOfRangeException(nameof(seconds), - string.Format(Environment.GetResourceString("ArgumentOutOfRange_Range"), UnixMinSeconds, UnixMaxSeconds)); + string.Format(SR.ArgumentOutOfRange_Range, UnixMinSeconds, UnixMaxSeconds)); } long ticks = seconds * TimeSpan.TicksPerSecond + UnixEpochTicks; @@ -570,7 +570,7 @@ namespace System if (milliseconds < MinMilliseconds || milliseconds > MaxMilliseconds) { throw new ArgumentOutOfRangeException(nameof(milliseconds), - string.Format(Environment.GetResourceString("ArgumentOutOfRange_Range"), MinMilliseconds, MaxMilliseconds)); + string.Format(SR.ArgumentOutOfRange_Range, MinMilliseconds, MaxMilliseconds)); } long ticks = milliseconds * TimeSpan.TicksPerMillisecond + UnixEpochTicks; @@ -588,7 +588,7 @@ namespace System } catch (ArgumentException e) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData"), e); + throw new SerializationException(SR.Serialization_InvalidData, e); } } @@ -846,11 +846,11 @@ namespace System Int64 ticks = offset.Ticks; if (ticks % TimeSpan.TicksPerMinute != 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_OffsetPrecision"), nameof(offset)); + throw new ArgumentException(SR.Argument_OffsetPrecision, nameof(offset)); } if (ticks < MinOffset || ticks > MaxOffset) { - throw new ArgumentOutOfRangeException(nameof(offset), Environment.GetResourceString("Argument_OffsetOutOfRange")); + throw new ArgumentOutOfRangeException(nameof(offset), SR.Argument_OffsetOutOfRange); } return (Int16)(offset.Ticks / TimeSpan.TicksPerMinute); } @@ -866,7 +866,7 @@ namespace System Int64 utcTicks = dateTime.Ticks - offset.Ticks; if (utcTicks < DateTime.MinTicks || utcTicks > DateTime.MaxTicks) { - throw new ArgumentOutOfRangeException(nameof(offset), Environment.GetResourceString("Argument_UTCOutOfRange")); + throw new ArgumentOutOfRangeException(nameof(offset), SR.Argument_UTCOutOfRange); } // make sure the Kind is set to Unspecified // @@ -877,15 +877,15 @@ namespace System { if ((style & DateTimeFormatInfo.InvalidDateTimeStyles) != 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidDateTimeStyles"), parameterName); + throw new ArgumentException(SR.Argument_InvalidDateTimeStyles, parameterName); } if (((style & (DateTimeStyles.AssumeLocal)) != 0) && ((style & (DateTimeStyles.AssumeUniversal)) != 0)) { - throw new ArgumentException(Environment.GetResourceString("Argument_ConflictingDateTimeStyles"), parameterName); + throw new ArgumentException(SR.Argument_ConflictingDateTimeStyles, parameterName); } if ((style & DateTimeStyles.NoCurrentDateDefault) != 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_DateTimeOffsetInvalidDateTimeStyles"), parameterName); + throw new ArgumentException(SR.Argument_DateTimeOffsetInvalidDateTimeStyles, parameterName); } Contract.EndContractBlock(); diff --git a/src/mscorlib/src/System/Decimal.cs b/src/mscorlib/src/System/Decimal.cs index dedcc92..7245396 100644 --- a/src/mscorlib/src/System/Decimal.cs +++ b/src/mscorlib/src/System/Decimal.cs @@ -286,7 +286,7 @@ namespace System return; } } - throw new ArgumentException(Environment.GetResourceString("Arg_DecBitCtor")); + throw new ArgumentException(SR.Arg_DecBitCtor); } // Constructs a Decimal from its constituent parts. @@ -294,7 +294,7 @@ namespace System public Decimal(int lo, int mid, int hi, bool isNegative, byte scale) { if (scale > 28) - throw new ArgumentOutOfRangeException(nameof(scale), Environment.GetResourceString("ArgumentOutOfRange_DecimalScale")); + throw new ArgumentOutOfRangeException(nameof(scale), SR.ArgumentOutOfRange_DecimalScale); Contract.EndContractBlock(); this.lo = lo; this.mid = mid; @@ -314,7 +314,7 @@ namespace System } catch (ArgumentException e) { - throw new SerializationException(Environment.GetResourceString("Overflow_Decimal"), e); + throw new SerializationException(SR.Overflow_Decimal, e); } } @@ -328,7 +328,7 @@ namespace System } catch (ArgumentException e) { - throw new SerializationException(Environment.GetResourceString("Overflow_Decimal"), e); + throw new SerializationException(SR.Overflow_Decimal, e); } } @@ -343,7 +343,7 @@ namespace System this.flags = flags; return; } - throw new ArgumentException(Environment.GetResourceString("Arg_DecBitCtor")); + throw new ArgumentException(SR.Arg_DecBitCtor); } // Returns the absolute value of the given Decimal. If d is @@ -399,7 +399,7 @@ namespace System if (value == null) return 1; if (!(value is Decimal)) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDecimal")); + throw new ArgumentException(SR.Arg_MustBeDecimal); Decimal other = (Decimal)value; return FCallCompare(ref this, ref other); @@ -782,10 +782,10 @@ namespace System public static Decimal Round(Decimal d, int decimals, MidpointRounding mode) { if ((decimals < 0) || (decimals > 28)) - throw new ArgumentOutOfRangeException(nameof(decimals), Environment.GetResourceString("ArgumentOutOfRange_DecimalRound")); + throw new ArgumentOutOfRangeException(nameof(decimals), SR.ArgumentOutOfRange_DecimalRound); if (mode < MidpointRounding.ToEven || mode > MidpointRounding.AwayFromZero) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidEnumValue", mode, nameof(MidpointRounding)), nameof(mode)); + throw new ArgumentException(SR.Format(SR.Argument_InvalidEnumValue, mode, nameof(MidpointRounding)), nameof(mode)); } Contract.EndContractBlock(); @@ -824,9 +824,9 @@ namespace System } catch (OverflowException e) { - throw new OverflowException(Environment.GetResourceString("Overflow_Byte"), e); + throw new OverflowException(SR.Overflow_Byte, e); } - if (temp < Byte.MinValue || temp > Byte.MaxValue) throw new OverflowException(Environment.GetResourceString("Overflow_Byte")); + if (temp < Byte.MinValue || temp > Byte.MaxValue) throw new OverflowException(SR.Overflow_Byte); return (byte)temp; } @@ -844,9 +844,9 @@ namespace System } catch (OverflowException e) { - throw new OverflowException(Environment.GetResourceString("Overflow_SByte"), e); + throw new OverflowException(SR.Overflow_SByte, e); } - if (temp < SByte.MinValue || temp > SByte.MaxValue) throw new OverflowException(Environment.GetResourceString("Overflow_SByte")); + if (temp < SByte.MinValue || temp > SByte.MaxValue) throw new OverflowException(SR.Overflow_SByte); return (sbyte)temp; } @@ -863,9 +863,9 @@ namespace System } catch (OverflowException e) { - throw new OverflowException(Environment.GetResourceString("Overflow_Int16"), e); + throw new OverflowException(SR.Overflow_Int16, e); } - if (temp < Int16.MinValue || temp > Int16.MaxValue) throw new OverflowException(Environment.GetResourceString("Overflow_Int16")); + if (temp < Int16.MinValue || temp > Int16.MaxValue) throw new OverflowException(SR.Overflow_Int16); return (short)temp; } @@ -913,7 +913,7 @@ namespace System if (i <= 0) return i; } } - throw new OverflowException(Environment.GetResourceString("Overflow_Int32")); + throw new OverflowException(SR.Overflow_Int32); } // Converts a Decimal to a long. The Decimal value is rounded towards zero @@ -936,7 +936,7 @@ namespace System if (l <= 0) return l; } } - throw new OverflowException(Environment.GetResourceString("Overflow_Int64")); + throw new OverflowException(SR.Overflow_Int64); } // Converts a Decimal to an ushort. The Decimal @@ -953,9 +953,9 @@ namespace System } catch (OverflowException e) { - throw new OverflowException(Environment.GetResourceString("Overflow_UInt16"), e); + throw new OverflowException(SR.Overflow_UInt16, e); } - if (temp < UInt16.MinValue || temp > UInt16.MaxValue) throw new OverflowException(Environment.GetResourceString("Overflow_UInt16")); + if (temp < UInt16.MinValue || temp > UInt16.MaxValue) throw new OverflowException(SR.Overflow_UInt16); return (ushort)temp; } @@ -973,7 +973,7 @@ namespace System if (d.flags >= 0 || i == 0) return i; } - throw new OverflowException(Environment.GetResourceString("Overflow_UInt32")); + throw new OverflowException(SR.Overflow_UInt32); } // Converts a Decimal to an unsigned long. The Decimal @@ -990,7 +990,7 @@ namespace System if (d.flags >= 0 || l == 0) return l; } - throw new OverflowException(Environment.GetResourceString("Overflow_UInt64")); + throw new OverflowException(SR.Overflow_UInt64); } // Converts a Decimal to a float. Since a float has fewer significant @@ -1094,7 +1094,7 @@ namespace System } catch (OverflowException e) { - throw new OverflowException(Environment.GetResourceString("Overflow_Char"), e); + throw new OverflowException(SR.Overflow_Char, e); } return (char)temp; } @@ -1240,7 +1240,7 @@ namespace System /// char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Decimal", "Char")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Decimal", "Char")); } /// @@ -1312,7 +1312,7 @@ namespace System /// DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Decimal", "DateTime")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Decimal", "DateTime")); } /// diff --git a/src/mscorlib/src/System/DefaultBinder.cs b/src/mscorlib/src/System/DefaultBinder.cs index 789698f..91790fa 100644 --- a/src/mscorlib/src/System/DefaultBinder.cs +++ b/src/mscorlib/src/System/DefaultBinder.cs @@ -40,7 +40,7 @@ namespace System ParameterModifier[] modifiers, CultureInfo cultureInfo, String[] names, out Object state) { if (match == null || match.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Arg_EmptyArray"), nameof(match)); + throw new ArgumentException(SR.Arg_EmptyArray, nameof(match)); Contract.EndContractBlock(); MethodBase[] candidates = (MethodBase[])match.Clone(); @@ -292,7 +292,7 @@ namespace System // If we didn't find a method if (CurIdx == 0) - throw new MissingMethodException(Environment.GetResourceString("MissingMember")); + throw new MissingMethodException(SR.MissingMember); if (CurIdx == 1) { @@ -375,7 +375,7 @@ namespace System } if (ambig) - throw new AmbiguousMatchException(Environment.GetResourceString("Arg_AmbiguousMatchException")); + throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException); // Reorder (if needed) if (names != null) @@ -499,7 +499,7 @@ namespace System } } if (CurIdx == 0) - throw new MissingFieldException(Environment.GetResourceString("MissingField")); + throw new MissingFieldException(SR.MissingField); if (CurIdx == 1) return candidates[0]; } @@ -522,7 +522,7 @@ namespace System } } if (ambig) - throw new AmbiguousMatchException(Environment.GetResourceString("Arg_AmbiguousMatchException")); + throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException); return candidates[currentMin]; } @@ -539,13 +539,13 @@ namespace System { realTypes[i] = types[i].UnderlyingSystemType; if (!(realTypes[i] is RuntimeType)) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(types)); + throw new ArgumentException(SR.Arg_MustBeType, nameof(types)); } types = realTypes; // We don't automatically jump out on exact match. if (match == null || match.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Arg_EmptyArray"), nameof(match)); + throw new ArgumentException(SR.Arg_EmptyArray, nameof(match)); MethodBase[] candidates = (MethodBase[])match.Clone(); @@ -606,7 +606,7 @@ namespace System } } if (ambig) - throw new AmbiguousMatchException(Environment.GetResourceString("Arg_AmbiguousMatchException")); + throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException); return candidates[currentMin]; } @@ -620,7 +620,7 @@ namespace System throw new ArgumentNullException(nameof(indexes)); } if (match == null || match.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Arg_EmptyArray"), nameof(match)); + throw new ArgumentException(SR.Arg_EmptyArray, nameof(match)); Contract.EndContractBlock(); PropertyInfo[] candidates = (PropertyInfo[])match.Clone(); @@ -718,7 +718,7 @@ namespace System } if (ambig) - throw new AmbiguousMatchException(Environment.GetResourceString("Arg_AmbiguousMatchException")); + throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException); return candidates[currentMin]; } @@ -727,7 +727,7 @@ namespace System // This is because the default is built into the low level invoke code. public override Object ChangeType(Object value, Type type, CultureInfo cultureInfo) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_ChangeType")); + throw new NotSupportedException(SR.NotSupported_ChangeType); } public override void ReorderArgumentArray(ref Object[] args, Object state) @@ -833,7 +833,7 @@ namespace System continue; if (bestMatch != null) - throw new AmbiguousMatchException(Environment.GetResourceString("Arg_AmbiguousMatchException")); + throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException); bestMatch = match[i]; } @@ -1110,7 +1110,7 @@ namespace System // This can only happen if at least one is vararg or generic. if (currentHierarchyDepth == deepestHierarchy) { - throw new AmbiguousMatchException(Environment.GetResourceString("Arg_AmbiguousMatchException")); + throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException); } // Check to see if this method is on the most derived class. diff --git a/src/mscorlib/src/System/Delegate.cs b/src/mscorlib/src/System/Delegate.cs index 5f01773..de0ff65 100644 --- a/src/mscorlib/src/System/Delegate.cs +++ b/src/mscorlib/src/System/Delegate.cs @@ -57,7 +57,7 @@ namespace System if (!BindToMethodName(target, (RuntimeType)target.GetType(), method, DelegateBindingFlags.InstanceMethodOnly | DelegateBindingFlags.ClosedDelegateOnly)) - throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth")); + throw new ArgumentException(SR.Arg_DlgtTargMeth); } // This constructor is called from a class to generate a @@ -69,7 +69,7 @@ namespace System throw new ArgumentNullException(nameof(target)); if (target.IsGenericType && target.ContainsGenericParameters) - throw new ArgumentException(Environment.GetResourceString("Arg_UnboundGenParam"), nameof(target)); + throw new ArgumentException(SR.Arg_UnboundGenParam, nameof(target)); if (method == null) throw new ArgumentNullException(nameof(method)); @@ -77,7 +77,7 @@ namespace System RuntimeType rtTarget = target as RuntimeType; if (rtTarget == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), nameof(target)); + throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(target)); // This API existed in v1/v1.1 and only expected to create open // static delegates. Constrain the call to BindToMethodName to such @@ -291,7 +291,7 @@ namespace System return source; if (!InternalEqualTypes(source, value)) - throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTypeMis")); + throw new ArgumentException(SR.Arg_DlgtTypeMis); return source.RemoveImpl(value); } @@ -312,7 +312,7 @@ namespace System protected virtual Delegate CombineImpl(Delegate d) { - throw new MulticastNotSupportedException(Environment.GetResourceString("Multicast_Combine")); + throw new MulticastNotSupportedException(SR.Multicast_Combine); } protected virtual Delegate RemoveImpl(Delegate d) @@ -351,9 +351,9 @@ namespace System RuntimeType rtType = type as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), nameof(type)); + throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(type)); if (!rtType.IsDelegate()) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), nameof(type)); + throw new ArgumentException(SR.Arg_MustBeDelegate, nameof(type)); Delegate d = InternalAlloc(rtType); // This API existed in v1/v1.1 and only expected to create closed @@ -370,7 +370,7 @@ namespace System (ignoreCase ? DelegateBindingFlags.CaselessMatching : 0))) { if (throwOnBindFailure) - throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth")); + throw new ArgumentException(SR.Arg_DlgtTargMeth); d = null; } @@ -397,7 +397,7 @@ namespace System if (target == null) throw new ArgumentNullException(nameof(target)); if (target.IsGenericType && target.ContainsGenericParameters) - throw new ArgumentException(Environment.GetResourceString("Arg_UnboundGenParam"), nameof(target)); + throw new ArgumentException(SR.Arg_UnboundGenParam, nameof(target)); if (method == null) throw new ArgumentNullException(nameof(method)); Contract.EndContractBlock(); @@ -405,11 +405,11 @@ namespace System RuntimeType rtType = type as RuntimeType; RuntimeType rtTarget = target as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), nameof(type)); + throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(type)); if (rtTarget == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), nameof(target)); + throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(target)); if (!rtType.IsDelegate()) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), nameof(type)); + throw new ArgumentException(SR.Arg_MustBeDelegate, nameof(type)); Delegate d = InternalAlloc(rtType); // This API existed in v1/v1.1 and only expected to create open @@ -422,7 +422,7 @@ namespace System (ignoreCase ? DelegateBindingFlags.CaselessMatching : 0))) { if (throwOnBindFailure) - throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth")); + throw new ArgumentException(SR.Arg_DlgtTargMeth); d = null; } @@ -442,14 +442,14 @@ namespace System RuntimeType rtType = type as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), nameof(type)); + throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(type)); RuntimeMethodInfo rmi = method as RuntimeMethodInfo; if (rmi == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), nameof(method)); + throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, nameof(method)); if (!rtType.IsDelegate()) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), nameof(type)); + throw new ArgumentException(SR.Arg_MustBeDelegate, nameof(type)); // This API existed in v1/v1.1 and only expected to create closed // instance delegates. Constrain the call to BindToMethodInfo to @@ -468,7 +468,7 @@ namespace System ref stackMark); if (d == null && throwOnBindFailure) - throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth")); + throw new ArgumentException(SR.Arg_DlgtTargMeth); return d; } @@ -492,14 +492,14 @@ namespace System RuntimeType rtType = type as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), nameof(type)); + throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(type)); RuntimeMethodInfo rmi = method as RuntimeMethodInfo; if (rmi == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), nameof(method)); + throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, nameof(method)); if (!rtType.IsDelegate()) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), nameof(type)); + throw new ArgumentException(SR.Arg_MustBeDelegate, nameof(type)); // This API is new in Whidbey and allows the full range of delegate // flexability (open or closed delegates binding to static or @@ -515,7 +515,7 @@ namespace System ref stackMark); if (d == null && throwOnBindFailure) - throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth")); + throw new ArgumentException(SR.Arg_DlgtTargMeth); return d; } @@ -562,10 +562,10 @@ namespace System RuntimeType rtType = type as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), nameof(type)); + throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(type)); if (!rtType.IsDelegate()) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), nameof(type)); + throw new ArgumentException(SR.Arg_MustBeDelegate, nameof(type)); // Initialize the method... Delegate d = InternalAlloc(rtType); @@ -578,7 +578,7 @@ namespace System method.GetMethodInfo(), RuntimeMethodHandle.GetDeclaringType(method.GetMethodInfo()), DelegateBindingFlags.RelaxedSignature | DelegateBindingFlags.SkipSecurityChecks)) - throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth")); + throw new ArgumentException(SR.Arg_DlgtTargMeth); return d; } @@ -595,10 +595,10 @@ namespace System RuntimeMethodInfo rtMethod = method as RuntimeMethodInfo; if (rtMethod == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeMethodInfo"), nameof(method)); + throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, nameof(method)); if (!type.IsDelegate()) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), nameof(type)); + throw new ArgumentException(SR.Arg_MustBeDelegate, nameof(type)); // This API is used by the formatters when deserializing a delegate. // They pass us the specific target method (that was already the @@ -613,7 +613,7 @@ namespace System DelegateBindingFlags.RelaxedSignature); if (d == null) - throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTargMeth")); + throw new ArgumentException(SR.Arg_DlgtTargMeth); return d; } diff --git a/src/mscorlib/src/System/DelegateSerializationHolder.cs b/src/mscorlib/src/System/DelegateSerializationHolder.cs index 4112816..5f8f0ef 100644 --- a/src/mscorlib/src/System/DelegateSerializationHolder.cs +++ b/src/mscorlib/src/System/DelegateSerializationHolder.cs @@ -28,10 +28,10 @@ namespace System Type c = delegateType.BaseType; if (c == null || (c != typeof(Delegate) && c != typeof(MulticastDelegate))) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDelegate"), "type"); + throw new ArgumentException(SR.Arg_MustBeDelegate, "type"); if (method.DeclaringType == null) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_GlobalMethodSerialization")); + throw new NotSupportedException(SR.NotSupported_GlobalMethodSerialization); DelegateEntry de = new DelegateEntry(delegateType.FullName, delegateType.Module.Assembly.FullName, target, method.ReflectedType.Module.Assembly.FullName, method.ReflectedType.FullName, method.Name); @@ -170,7 +170,7 @@ namespace System private void ThrowInsufficientState(string field) { throw new SerializationException( - Environment.GetResourceString("Serialization_InsufficientDeserializationState", field)); + SR.Format(SR.Serialization_InsufficientDeserializationState, field)); } private DelegateEntry OldDelegateWireFormat(SerializationInfo info, StreamingContext context) @@ -272,7 +272,7 @@ namespace System #region ISerializable public void GetObjectData(SerializationInfo info, StreamingContext context) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_DelegateSerHolderSerial")); + throw new NotSupportedException(SR.NotSupported_DelegateSerHolderSerial); } #endregion } diff --git a/src/mscorlib/src/System/Diagnostics/Assert.cs b/src/mscorlib/src/System/Diagnostics/Assert.cs index c0b4e4c..67e6914 100644 --- a/src/mscorlib/src/System/Diagnostics/Assert.cs +++ b/src/mscorlib/src/System/Diagnostics/Assert.cs @@ -67,7 +67,7 @@ namespace System.Diagnostics if (Debugger.Launch() == false) { throw new InvalidOperationException( - Environment.GetResourceString("InvalidOperation_DebuggerLaunchFailed")); + SR.InvalidOperation_DebuggerLaunchFailed); } } } diff --git a/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs b/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs index fe1afe3..76b1519 100644 --- a/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs +++ b/src/mscorlib/src/System/Diagnostics/Contracts/Contracts.cs @@ -640,7 +640,7 @@ namespace System.Diagnostics.Contracts { if (fromInclusive > toExclusive) #if CORECLR - throw new ArgumentException(Environment.GetResourceString("Argument_ToExclusiveLessThanFromExclusive")); + throw new ArgumentException(SR.Argument_ToExclusiveLessThanFromExclusive); #else throw new ArgumentException("fromInclusive must be less than or equal to toExclusive."); #endif @@ -700,7 +700,7 @@ namespace System.Diagnostics.Contracts { if (fromInclusive > toExclusive) #if CORECLR - throw new ArgumentException(Environment.GetResourceString("Argument_ToExclusiveLessThanFromExclusive")); + throw new ArgumentException(SR.Argument_ToExclusiveLessThanFromExclusive); #else throw new ArgumentException("fromInclusive must be less than or equal to toExclusive."); #endif diff --git a/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs b/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs index 1e86b91..09d1e6b 100644 --- a/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs +++ b/src/mscorlib/src/System/Diagnostics/Contracts/ContractsBCL.cs @@ -73,7 +73,7 @@ namespace System.Diagnostics.Contracts if (probablyNotRewritten == null) probablyNotRewritten = thisAssembly; String simpleName = probablyNotRewritten.GetName().Name; - System.Runtime.CompilerServices.ContractHelper.TriggerFailure(kind, Environment.GetResourceString("MustUseCCRewrite", contractKind, simpleName), null, null, null); + System.Runtime.CompilerServices.ContractHelper.TriggerFailure(kind, SR.Format(SR.MustUseCCRewrite, contractKind, simpleName), null, null, null); _assertingMustUseRewriter = false; } @@ -95,7 +95,7 @@ namespace System.Diagnostics.Contracts static partial void ReportFailure(ContractFailureKind failureKind, String userMessage, String conditionText, Exception innerException) { if (failureKind < ContractFailureKind.Precondition || failureKind > ContractFailureKind.Assume) - throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", failureKind), nameof(failureKind)); + throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, failureKind), nameof(failureKind)); Contract.EndContractBlock(); // displayMessage == null means: yes we handled it. Otherwise it is the localized failure message @@ -308,7 +308,7 @@ namespace System.Runtime.CompilerServices static partial void RaiseContractFailedEventImplementation(ContractFailureKind failureKind, String userMessage, String conditionText, Exception innerException, ref string resultFailureMessage) { if (failureKind < ContractFailureKind.Precondition || failureKind > ContractFailureKind.Assume) - throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", failureKind), nameof(failureKind)); + throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, failureKind), nameof(failureKind)); Contract.EndContractBlock(); string returnValue; @@ -382,7 +382,7 @@ namespace System.Runtime.CompilerServices // May need to rethink Assert.Fail w/ TaskDialogIndirect as a model. Window title. Main instruction. Content. Expanded info. // Optional info like string for collapsed text vs. expanded text. - String windowTitle = Environment.GetResourceString(GetResourceNameForFailure(kind)); + String windowTitle = SR.GetResourceString(GetResourceNameForFailure(kind)); const int numStackFramesToSkip = 2; // To make stack traces easier to read System.Diagnostics.Assert.Fail(conditionText, displayMessage, windowTitle, COR_E_CODECONTRACTFAILED, StackTrace.TraceFormat.Normal, numStackFramesToSkip); // If we got here, the user selected Ignore. Continue. @@ -440,11 +440,11 @@ namespace System.Runtime.CompilerServices if (!String.IsNullOrEmpty(conditionText)) { resourceName += "_Cnd"; - failureMessage = Environment.GetResourceString(resourceName, conditionText); + failureMessage = SR.Format(SR.GetResourceString(resourceName), conditionText); } else { - failureMessage = Environment.GetResourceString(resourceName); + failureMessage = SR.GetResourceString(resourceName); } // Now add in the user message, if present. diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/EventCounter.cs b/src/mscorlib/src/System/Diagnostics/Eventing/EventCounter.cs index b1f9464..2ad0581 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/EventCounter.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/EventCounter.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/Diagnostics/Eventing/EventSource_CoreCLR.cs b/src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs index 71c4212..b691dd3 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/EventSource_CoreCLR.cs @@ -128,7 +128,7 @@ namespace System.Diagnostics.Tracing private static string GetResourceString(string key, params object[] args) { - return Environment.GetResourceString(key, args); + return SR.Format(SR.GetResourceString(key), args); } private static readonly bool m_EventSourcePreventRecursion = false; @@ -214,7 +214,7 @@ namespace System.Diagnostics.Tracing { internal static string GetResourceString(string key, params object[] args) { - return Environment.GetResourceString(key, args); + return SR.Format(SR.GetResourceString(key), args); } } } diff --git a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/PropertyValue.cs b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/PropertyValue.cs index f95e36d..00ffcdc 100644 --- a/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/PropertyValue.cs +++ b/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/PropertyValue.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.InteropServices; using System.Diagnostics; diff --git a/src/mscorlib/src/System/Diagnostics/LogSwitch.cs b/src/mscorlib/src/System/Diagnostics/LogSwitch.cs index 85f4f4f..29d6a1d 100644 --- a/src/mscorlib/src/System/Diagnostics/LogSwitch.cs +++ b/src/mscorlib/src/System/Diagnostics/LogSwitch.cs @@ -37,7 +37,7 @@ namespace System.Diagnostics public LogSwitch(String name, String description, LogSwitch parent) { if (name != null && name.Length == 0) - throw new ArgumentOutOfRangeException(nameof(Name), Environment.GetResourceString("Argument_StringZeroLength")); + throw new ArgumentOutOfRangeException(nameof(Name), SR.Argument_StringZeroLength); Contract.EndContractBlock(); if ((name != null) && (parent != null)) diff --git a/src/mscorlib/src/System/Diagnostics/Stacktrace.cs b/src/mscorlib/src/System/Diagnostics/Stacktrace.cs index 20cf4a5..cdedb66 100644 --- a/src/mscorlib/src/System/Diagnostics/Stacktrace.cs +++ b/src/mscorlib/src/System/Diagnostics/Stacktrace.cs @@ -283,7 +283,7 @@ namespace System.Diagnostics { if (skipFrames < 0) throw new ArgumentOutOfRangeException(nameof(skipFrames), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); m_iNumOfFrames = 0; @@ -299,7 +299,7 @@ namespace System.Diagnostics { if (skipFrames < 0) throw new ArgumentOutOfRangeException(nameof(skipFrames), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); m_iNumOfFrames = 0; @@ -344,7 +344,7 @@ namespace System.Diagnostics if (skipFrames < 0) throw new ArgumentOutOfRangeException(nameof(skipFrames), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); m_iNumOfFrames = 0; @@ -363,7 +363,7 @@ namespace System.Diagnostics if (skipFrames < 0) throw new ArgumentOutOfRangeException(nameof(skipFrames), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); m_iNumOfFrames = 0; @@ -539,8 +539,8 @@ namespace System.Diagnostics if (traceFormat != TraceFormat.NoResourceLookup) { - word_At = Environment.GetResourceString("Word_At"); - inFileLineNum = Environment.GetResourceString("StackTrace_InFileLineNumber"); + word_At = SR.Word_At; + inFileLineNum = SR.StackTrace_InFileLineNumber; } bool fFirstFrame = true; @@ -658,7 +658,7 @@ namespace System.Diagnostics if (sf.GetIsLastFrameFromForeignExceptionStackTrace()) { sb.Append(Environment.NewLine); - sb.Append(Environment.GetResourceString("Exception_EndStackTraceFromPreviousThrow")); + sb.Append(SR.Exception_EndStackTraceFromPreviousThrow); } } } diff --git a/src/mscorlib/src/System/Diagnostics/log.cs b/src/mscorlib/src/System/Diagnostics/log.cs index 8b6ab50..b62ea49 100644 --- a/src/mscorlib/src/System/Diagnostics/log.cs +++ b/src/mscorlib/src/System/Diagnostics/log.cs @@ -88,7 +88,7 @@ namespace System.Diagnostics throw new ArgumentNullException("LogSwitch"); if (level < 0) - throw new ArgumentOutOfRangeException(nameof(level), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(level), SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Is logging for this level for this switch enabled? diff --git a/src/mscorlib/src/System/DllNotFoundException.cs b/src/mscorlib/src/System/DllNotFoundException.cs index 63b263e..dd0f27e 100644 --- a/src/mscorlib/src/System/DllNotFoundException.cs +++ b/src/mscorlib/src/System/DllNotFoundException.cs @@ -21,7 +21,7 @@ namespace System public class DllNotFoundException : TypeLoadException { public DllNotFoundException() - : base(Environment.GetResourceString("Arg_DllNotFoundException")) + : base(SR.Arg_DllNotFoundException) { SetErrorCode(__HResults.COR_E_DLLNOTFOUND); } diff --git a/src/mscorlib/src/System/Double.cs b/src/mscorlib/src/System/Double.cs index d7319b6..b6e0012 100644 --- a/src/mscorlib/src/System/Double.cs +++ b/src/mscorlib/src/System/Double.cs @@ -120,7 +120,7 @@ namespace System else return 1; } - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeDouble")); + throw new ArgumentException(SR.Arg_MustBeDouble); } public int CompareTo(Double value) @@ -330,7 +330,7 @@ namespace System /// char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Double", "Char")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Double", "Char")); } /// @@ -402,7 +402,7 @@ namespace System /// DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Double", "DateTime")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Double", "DateTime")); } /// diff --git a/src/mscorlib/src/System/Enum.cs b/src/mscorlib/src/System/Enum.cs index 0f01052..cf26a33 100644 --- a/src/mscorlib/src/System/Enum.cs +++ b/src/mscorlib/src/System/Enum.cs @@ -69,7 +69,7 @@ namespace System case CorElementType.U8: return (*(ulong*)pValue).ToString("X16", null); default: - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_UnknownEnumType")); + throw new InvalidOperationException(SR.InvalidOperation_UnknownEnumType); } } } @@ -103,7 +103,7 @@ namespace System return ((UInt64)(Int64)value).ToString("X16", null); // All unsigned types will be directly cast default: - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_UnknownEnumType")); + throw new InvalidOperationException(SR.InvalidOperation_UnknownEnumType); } } @@ -250,7 +250,7 @@ namespace System break; // All unsigned types will be directly cast default: - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_UnknownEnumType")); + throw new InvalidOperationException(SR.InvalidOperation_UnknownEnumType); } return result; @@ -316,20 +316,20 @@ namespace System switch (m_failure) { case ParseFailureKind.Argument: - return new ArgumentException(Environment.GetResourceString(m_failureMessageID)); + return new ArgumentException(SR.GetResourceString(m_failureMessageID)); case ParseFailureKind.ArgumentNull: return new ArgumentNullException(m_failureParameter); case ParseFailureKind.ArgumentWithParameter: - return new ArgumentException(Environment.GetResourceString(m_failureMessageID, m_failureMessageFormatArgument)); + return new ArgumentException(SR.Format(SR.GetResourceString(m_failureMessageID), m_failureMessageFormatArgument)); case ParseFailureKind.UnhandledException: return m_innerException; default: Debug.Assert(false, "Unknown EnumParseFailure: " + m_failure); - return new ArgumentException(Environment.GetResourceString("Arg_EnumValueNotFound")); + return new ArgumentException(SR.Arg_EnumValueNotFound); } } } @@ -402,10 +402,10 @@ namespace System RuntimeType rtType = enumType as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType)); if (!enumType.IsEnum) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType)); if (value == null) { @@ -624,7 +624,7 @@ namespace System default: // All unsigned types will be directly cast - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnumBaseTypeOrEnum"), nameof(value)); + throw new ArgumentException(SR.Arg_MustBeEnumBaseTypeOrEnum, nameof(value)); } } @@ -644,7 +644,7 @@ namespace System throw new ArgumentNullException(nameof(enumType)); if (!enumType.IsEnum) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType)); if (value == null) throw new ArgumentNullException(nameof(value)); @@ -655,7 +655,7 @@ namespace System RuntimeType rtType = enumType as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType)); // Check if both of them are of the same type Type valueType = value.GetType(); @@ -666,24 +666,24 @@ namespace System if (valueType.IsEnum) { if (!valueType.IsEquivalentTo(enumType)) - throw new ArgumentException(Environment.GetResourceString("Arg_EnumAndObjectMustBeSameType", valueType.ToString(), enumType.ToString())); + throw new ArgumentException(SR.Format(SR.Arg_EnumAndObjectMustBeSameType, valueType.ToString(), enumType.ToString())); if (format.Length != 1) { // all acceptable format string are of length 1 - throw new FormatException(Environment.GetResourceString("Format_InvalidEnumFormatSpecification")); + throw new FormatException(SR.Format_InvalidEnumFormatSpecification); } return ((Enum)value).ToString(format); } // The value must be of the same type as the Underlying type of the Enum else if (valueType != underlyingType) { - throw new ArgumentException(Environment.GetResourceString("Arg_EnumFormatUnderlyingTypeAndObjectMustBeSameType", valueType.ToString(), underlyingType.ToString())); + throw new ArgumentException(SR.Format(SR.Arg_EnumFormatUnderlyingTypeAndObjectMustBeSameType, valueType.ToString(), underlyingType.ToString())); } if (format.Length != 1) { // all acceptable format string are of length 1 - throw new FormatException(Environment.GetResourceString("Format_InvalidEnumFormatSpecification")); + throw new FormatException(SR.Format_InvalidEnumFormatSpecification); } char formatCh = format[0]; @@ -699,7 +699,7 @@ namespace System if (formatCh == 'F' || formatCh == 'f') return Enum.InternalFlagsFormat(rtType, ToUInt64(value)) ?? value.ToString(); - throw new FormatException(Environment.GetResourceString("Format_InvalidEnumFormatSpecification")); + throw new FormatException(SR.Format_InvalidEnumFormatSpecification); } #endregion @@ -916,15 +916,14 @@ namespace System Type thisType = this.GetType(); Type targetType = target.GetType(); - throw new ArgumentException(Environment.GetResourceString("Arg_EnumAndObjectMustBeSameType", - targetType.ToString(), thisType.ToString())); + throw new ArgumentException(SR.Format(SR.Arg_EnumAndObjectMustBeSameType, targetType.ToString(), thisType.ToString())); } else { // assert valid return code (3) Debug.Assert(ret == retInvalidEnumType, "Enum.InternalCompareTo return code was invalid"); - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_UnknownEnumType")); + throw new InvalidOperationException(SR.InvalidOperation_UnknownEnumType); } } #endregion @@ -936,7 +935,7 @@ namespace System if (format == null || format.Length == 0) formatCh = 'G'; else if (format.Length != 1) - throw new FormatException(Environment.GetResourceString("Format_InvalidEnumFormatSpecification")); + throw new FormatException(SR.Format_InvalidEnumFormatSpecification); else formatCh = format[0]; @@ -952,7 +951,7 @@ namespace System if (formatCh == 'F' || formatCh == 'f') return InternalFlagsFormat((RuntimeType)GetType(), ToUInt64()) ?? GetValue().ToString(); - throw new FormatException(Environment.GetResourceString("Format_InvalidEnumFormatSpecification")); + throw new FormatException(SR.Format_InvalidEnumFormatSpecification); } [Obsolete("The provider argument is not used. Please use ToString().")] @@ -969,7 +968,7 @@ namespace System if (!this.GetType().IsEquivalentTo(flag.GetType())) { - throw new ArgumentException(Environment.GetResourceString("Argument_EnumTypeDoesNotMatch", flag.GetType(), this.GetType())); + throw new ArgumentException(SR.Format(SR.Argument_EnumTypeDoesNotMatch, flag.GetType(), this.GetType())); } return InternalHasFlag(flag); @@ -1003,7 +1002,7 @@ namespace System case CorElementType.U8: return TypeCode.UInt64; default: - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_UnknownEnumType")); + throw new InvalidOperationException(SR.InvalidOperation_UnknownEnumType); } } @@ -1088,7 +1087,7 @@ namespace System /// DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Enum", "DateTime")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Enum", "DateTime")); } /// @@ -1105,11 +1104,11 @@ namespace System if (enumType == null) throw new ArgumentNullException(nameof(enumType)); if (!enumType.IsEnum) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType)); Contract.EndContractBlock(); RuntimeType rtType = enumType as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType)); return InternalBoxEnum(rtType, value); } @@ -1118,11 +1117,11 @@ namespace System if (enumType == null) throw new ArgumentNullException(nameof(enumType)); if (!enumType.IsEnum) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType)); Contract.EndContractBlock(); RuntimeType rtType = enumType as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType)); return InternalBoxEnum(rtType, value); } @@ -1131,11 +1130,11 @@ namespace System if (enumType == null) throw new ArgumentNullException(nameof(enumType)); if (!enumType.IsEnum) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType)); Contract.EndContractBlock(); RuntimeType rtType = enumType as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType)); return InternalBoxEnum(rtType, value); } @@ -1144,11 +1143,11 @@ namespace System if (enumType == null) throw new ArgumentNullException(nameof(enumType)); if (!enumType.IsEnum) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType)); Contract.EndContractBlock(); RuntimeType rtType = enumType as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType)); return InternalBoxEnum(rtType, value); } @@ -1158,11 +1157,11 @@ namespace System if (enumType == null) throw new ArgumentNullException(nameof(enumType)); if (!enumType.IsEnum) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType)); Contract.EndContractBlock(); RuntimeType rtType = enumType as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType)); return InternalBoxEnum(rtType, value); } @@ -1172,11 +1171,11 @@ namespace System if (enumType == null) throw new ArgumentNullException(nameof(enumType)); if (!enumType.IsEnum) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType)); Contract.EndContractBlock(); RuntimeType rtType = enumType as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType)); return InternalBoxEnum(rtType, value); } @@ -1185,11 +1184,11 @@ namespace System if (enumType == null) throw new ArgumentNullException(nameof(enumType)); if (!enumType.IsEnum) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType)); Contract.EndContractBlock(); RuntimeType rtType = enumType as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType)); return InternalBoxEnum(rtType, value); } @@ -1199,11 +1198,11 @@ namespace System if (enumType == null) throw new ArgumentNullException(nameof(enumType)); if (!enumType.IsEnum) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType)); Contract.EndContractBlock(); RuntimeType rtType = enumType as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType)); return InternalBoxEnum(rtType, unchecked((long)value)); } @@ -1212,11 +1211,11 @@ namespace System if (enumType == null) throw new ArgumentNullException(nameof(enumType)); if (!enumType.IsEnum) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType)); Contract.EndContractBlock(); RuntimeType rtType = enumType as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType)); return InternalBoxEnum(rtType, value); } @@ -1225,11 +1224,11 @@ namespace System if (enumType == null) throw new ArgumentNullException(nameof(enumType)); if (!enumType.IsEnum) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType)); Contract.EndContractBlock(); RuntimeType rtType = enumType as RuntimeType; if (rtType == null) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), nameof(enumType)); + throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType)); return InternalBoxEnum(rtType, value ? 1 : 0); } #endregion diff --git a/src/mscorlib/src/System/Environment.cs b/src/mscorlib/src/System/Environment.cs index 823c237..911b5b1 100644 --- a/src/mscorlib/src/System/Environment.cs +++ b/src/mscorlib/src/System/Environment.cs @@ -50,132 +50,18 @@ namespace System // that includes the contents of the environment variable. private const int MaxSystemEnvVariableLength = 1024; private const int MaxUserEnvVariableLength = 255; + private const int MaxMachineNameLength = 256; - internal sealed class ResourceHelper + // Looks up the resource string value for key. + // + // if you change this method's signature then you must change the code that calls it + // in excep.cpp and probably you will have to visit mscorlib.h to add the new signature + // as well as metasig.h to create the new signature type + internal static String GetResourceStringLocal(String key) { - internal ResourceHelper(String name) - { - m_name = name; - } - - private String m_name; - private ResourceManager SystemResMgr; - - // To avoid infinite loops when calling GetResourceString. See comments - // in GetResourceString for this field. - private List currentlyLoading; - - // process-wide state (since this is only used in one domain), - // used to avoid the TypeInitialization infinite recusion - // in GetResourceStringCode - internal bool resourceManagerInited = false; - - // Is this thread currently doing infinite resource lookups? - private int infinitelyRecursingCount; - - internal String GetResourceString(String key) - { - if (key == null || key.Length == 0) - { - Debug.Assert(false, "Environment::GetResourceString with null or empty key. Bug in caller, or weird recursive loading problem?"); - return "[Resource lookup failed - null or empty resource name]"; - } - - // We have a somewhat common potential for infinite - // loops with mscorlib's ResourceManager. If "potentially dangerous" - // code throws an exception, we will get into an infinite loop - // inside the ResourceManager and this "potentially dangerous" code. - // Potentially dangerous code includes the IO package, CultureInfo, - // parts of the loader, some parts of Reflection, Security (including - // custom user-written permissions that may parse an XML file at - // class load time), assembly load event handlers, etc. Essentially, - // this is not a bounded set of code, and we need to fix the problem. - // Fortunately, this is limited to mscorlib's error lookups and is NOT - // a general problem for all user code using the ResourceManager. - - // The solution is to make sure only one thread at a time can call - // GetResourceString. Also, since resource lookups can be - // reentrant, if the same thread comes into GetResourceString - // twice looking for the exact same resource name before - // returning, we're going into an infinite loop and we should - // return a bogus string. - - bool lockTaken = false; - try - { - Monitor.Enter(this, ref lockTaken); - - // Are we recursively looking up the same resource? Note - our backout code will set - // the ResourceHelper's currentlyLoading stack to null if an exception occurs. - if (currentlyLoading != null && currentlyLoading.Count > 0 && currentlyLoading.LastIndexOf(key) != -1) - { - // We can start infinitely recursing for one resource lookup, - // then during our failure reporting, start infinitely recursing again. - // avoid that. - if (infinitelyRecursingCount > 0) - { - return "[Resource lookup failed - infinite recursion or critical failure detected.]"; - } - infinitelyRecursingCount++; - - // Note: our infrastructure for reporting this exception will again cause resource lookup. - // This is the most direct way of dealing with that problem. - string message = $"Infinite recursion during resource lookup within {System.CoreLib.Name}. This may be a bug in {System.CoreLib.Name}, or potentially in certain extensibility points such as assembly resolve events or CultureInfo names. Resource name: {key}"; - Assert.Fail("[Recursive resource lookup bug]", message, Assert.COR_E_FAILFAST, System.Diagnostics.StackTrace.TraceFormat.NoResourceLookup); - Environment.FailFast(message); - } - if (currentlyLoading == null) - currentlyLoading = new List(); - - // Call class constructors preemptively, so that we cannot get into an infinite - // loop constructing a TypeInitializationException. If this were omitted, - // we could get the Infinite recursion assert above by failing type initialization - // between the Push and Pop calls below. - if (!resourceManagerInited) - { - RuntimeHelpers.RunClassConstructor(typeof(ResourceManager).TypeHandle); - RuntimeHelpers.RunClassConstructor(typeof(ResourceReader).TypeHandle); - RuntimeHelpers.RunClassConstructor(typeof(RuntimeResourceSet).TypeHandle); - RuntimeHelpers.RunClassConstructor(typeof(BinaryReader).TypeHandle); - resourceManagerInited = true; - } - - currentlyLoading.Add(key); // Push - - if (SystemResMgr == null) - { - SystemResMgr = new ResourceManager(m_name, typeof(Object).Assembly); - } - string s = SystemResMgr.GetString(key, null); - currentlyLoading.RemoveAt(currentlyLoading.Count - 1); // Pop - - Debug.Assert(s != null, "Managed resource string lookup failed. Was your resource name misspelled? Did you rebuild mscorlib after adding a resource to resources.txt? Debug this w/ cordbg and bug whoever owns the code that called Environment.GetResourceString. Resource name was: \"" + key + "\""); - return s; - } - catch - { - if (lockTaken) - { - // Backout code - throw away potentially corrupt state - SystemResMgr = null; - currentlyLoading = null; - } - throw; - } - finally - { - if (lockTaken) - { - Monitor.Exit(this); - } - } - } + return SR.GetResourceString(key); } - private static volatile ResourceHelper m_resHelper; // Doesn't need to be initialized as they're zero-init. - - private const int MaxMachineNameLength = 256; - // Private object for locking instead of locking on a public type for SQL reliability work. private static Object s_InternalSyncObject; private static Object InternalSyncObject @@ -363,7 +249,7 @@ namespace System StringBuilder buf = new StringBuilder(MaxMachineNameLength); int len = MaxMachineNameLength; if (Win32Native.GetComputerName(buf, ref len) == 0) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ComputerName")); + throw new InvalidOperationException(SR.InvalidOperation_ComputerName); return buf.ToString(); } } @@ -520,12 +406,12 @@ namespace System Microsoft.Win32.Win32Native.OSVERSIONINFO osvi = new Microsoft.Win32.Win32Native.OSVERSIONINFO(); if (!GetVersion(osvi)) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_GetVersion")); + throw new InvalidOperationException(SR.InvalidOperation_GetVersion); } Microsoft.Win32.Win32Native.OSVERSIONINFOEX osviEx = new Microsoft.Win32.Win32Native.OSVERSIONINFOEX(); if (!GetVersionEx(osviEx)) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_GetVersion")); + throw new InvalidOperationException(SR.InvalidOperation_GetVersion); #if PLATFORM_UNIX PlatformID id = PlatformID.Unix; @@ -600,94 +486,6 @@ namespace System return st.ToString(System.Diagnostics.StackTrace.TraceFormat.Normal); } - private static void InitResourceHelper() - { - // Only the default AppDomain should have a ResourceHelper. All calls to - // GetResourceString from any AppDomain delegate to GetResourceStringLocal - // in the default AppDomain via the fcall GetResourceFromDefault. - - bool tookLock = false; - RuntimeHelpers.PrepareConstrainedRegions(); - try - { - Monitor.Enter(Environment.InternalSyncObject, ref tookLock); - - if (m_resHelper == null) - { - ResourceHelper rh = new ResourceHelper(System.CoreLib.Name); - - System.Threading.Thread.MemoryBarrier(); - m_resHelper = rh; - } - } - finally - { - if (tookLock) - Monitor.Exit(Environment.InternalSyncObject); - } - } - - // Looks up the resource string value for key. - // - // if you change this method's signature then you must change the code that calls it - // in excep.cpp and probably you will have to visit mscorlib.h to add the new signature - // as well as metasig.h to create the new signature type - internal static String GetResourceStringLocal(String key) - { - if (m_resHelper == null) - InitResourceHelper(); - - return m_resHelper.GetResourceString(key); - } - - internal static String GetResourceString(String key) - { - return GetResourceStringLocal(key); - } - - // The reason the following overloads exist are to reduce code bloat. - // Since GetResourceString is basically only called when exceptions are - // thrown, we want the code size to be as small as possible. - // Using the params object[] overload works against this since the - // initialization of the array is done inline in the caller at the IL - // level. So we have overloads that simply wrap the params one. - - [MethodImpl(MethodImplOptions.NoInlining)] - internal static string GetResourceString(string key, object val0) - { - return GetResourceStringFormatted(key, new object[] { val0 }); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - internal static string GetResourceString(string key, object val0, object val1) - { - return GetResourceStringFormatted(key, new object[] { val0, val1 }); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - internal static string GetResourceString(string key, object val0, object val1, object val2) - { - return GetResourceStringFormatted(key, new object[] { val0, val1, val2 }); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - internal static string GetResourceString(string key, object val0, object val1, object val2, object val3) - { - return GetResourceStringFormatted(key, new object[] { val0, val1, val2, val3 }); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - internal static String GetResourceString(string key, params object[] values) - { - return GetResourceStringFormatted(key, values); - } - - private static String GetResourceStringFormatted(string key, params object[] values) - { - string rs = GetResourceString(key); - return String.Format(CultureInfo.CurrentCulture, rs, values); - } - public static extern bool HasShutdownStarted { [MethodImplAttribute(MethodImplOptions.InternalCall)] @@ -820,19 +618,19 @@ namespace System } if (variable.Length == 0) { - throw new ArgumentException(GetResourceString("Argument_StringZeroLength"), nameof(variable)); + throw new ArgumentException(SR.Argument_StringZeroLength, nameof(variable)); } if (variable[0] == '\0') { - throw new ArgumentException(GetResourceString("Argument_StringFirstCharIsZero"), nameof(variable)); + throw new ArgumentException(SR.Argument_StringFirstCharIsZero, nameof(variable)); } if (variable.Length >= MaxEnvVariableValueLength) { - throw new ArgumentException(GetResourceString("Argument_LongEnvVarValue"), nameof(variable)); + throw new ArgumentException(SR.Argument_LongEnvVarValue, nameof(variable)); } if (variable.IndexOf('=') != -1) { - throw new ArgumentException(GetResourceString("Argument_IllegalEnvVarName"), nameof(variable)); + throw new ArgumentException(SR.Argument_IllegalEnvVarName, nameof(variable)); } if (string.IsNullOrEmpty(value) || value[0] == '\0') @@ -842,7 +640,7 @@ namespace System } else if (value.Length >= MaxEnvVariableValueLength) { - throw new ArgumentException(GetResourceString("Argument_LongEnvVarValue"), nameof(value)); + throw new ArgumentException(SR.Argument_LongEnvVarValue, nameof(value)); } } @@ -852,7 +650,7 @@ namespace System target != EnvironmentVariableTarget.Machine && target != EnvironmentVariableTarget.User) { - throw new ArgumentOutOfRangeException(nameof(target), target, SR.Format(GetResourceString("Arg_EnumIllegalVal"), target)); + throw new ArgumentOutOfRangeException(nameof(target), target, SR.Format(SR.Arg_EnumIllegalVal, target)); } } @@ -953,7 +751,7 @@ namespace System } else { - throw new ArgumentException(GetResourceString("Arg_EnumIllegalVal", (int)target)); + throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)target)); } using (RegistryKey environmentKey = baseKey.OpenSubKey(keyName, writable: false)) @@ -999,7 +797,7 @@ namespace System } else { - throw new ArgumentException(GetResourceString("Arg_EnumIllegalVal", (int)target)); + throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)target)); } using (RegistryKey environmentKey = baseKey.OpenSubKey(keyName, writable: false)) @@ -1042,7 +840,7 @@ namespace System case Win32Native.ERROR_FILENAME_EXCED_RANGE: // The error message from Win32 is "The filename or extension is too long", // which is not accurate. - throw new ArgumentException(GetResourceString("Argument_LongEnvVarValue")); + throw new ArgumentException(SR.Format(SR.Argument_LongEnvVarValue)); default: throw new ArgumentException(Win32Native.GetMessage(errorCode)); } @@ -1081,7 +879,7 @@ namespace System const int MaxUserEnvVariableLength = 255; if (variable.Length >= MaxUserEnvVariableLength) { - throw new ArgumentException(GetResourceString("Argument_LongEnvVarValue"), nameof(variable)); + throw new ArgumentException(SR.Argument_LongEnvVarValue, nameof(variable)); } baseKey = Registry.CurrentUser; @@ -1089,7 +887,7 @@ namespace System } else { - throw new ArgumentException(GetResourceString("Arg_EnumIllegalVal", (int)target)); + throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)target)); } using (RegistryKey environmentKey = baseKey.OpenSubKey(keyName, writable: true)) diff --git a/src/mscorlib/src/System/Exception.cs b/src/mscorlib/src/System/Exception.cs index 6036063..096bee2 100644 --- a/src/mscorlib/src/System/Exception.cs +++ b/src/mscorlib/src/System/Exception.cs @@ -98,7 +98,7 @@ namespace System if (_className == null || HResult == 0) - throw new SerializationException(Environment.GetResourceString("Serialization_InsufficientState")); + throw new SerializationException(SR.Serialization_InsufficientState); // If we are constructing a new exception after a cross-appdomain call... if (context.State == StreamingContextStates.CrossAppDomain) @@ -130,7 +130,7 @@ namespace System { _className = GetClassName(); } - return Environment.GetResourceString("Exception_WasThrown", _className); + return SR.Format(SR.Exception_WasThrown, _className); } else { @@ -388,7 +388,7 @@ namespace System if (moduleBuilder != null) rtModule = moduleBuilder.InternalModule; else - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeReflectionObject")); + throw new ArgumentException(SR.Argument_MustBeRuntimeReflectionObject); } _source = rtModule.GetRuntimeAssembly().GetSimpleName(); @@ -422,7 +422,7 @@ namespace System if (_innerException != null) { s = s + " ---> " + _innerException.ToString(needFileLineInfo, needMessage) + Environment.NewLine + - " " + Environment.GetResourceString("Exception_EndOfInnerExceptionStack"); + " " + SR.Exception_EndOfInnerExceptionStack; } string stackTrace = GetStackTrace(needFileLineInfo); diff --git a/src/mscorlib/src/System/GC.cs b/src/mscorlib/src/System/GC.cs index 347bc3f..aeb0ca5 100644 --- a/src/mscorlib/src/System/GC.cs +++ b/src/mscorlib/src/System/GC.cs @@ -114,13 +114,13 @@ namespace System if (bytesAllocated <= 0) { throw new ArgumentOutOfRangeException(nameof(bytesAllocated), - Environment.GetResourceString("ArgumentOutOfRange_NeedPosNum")); + SR.ArgumentOutOfRange_NeedPosNum); } if ((4 == IntPtr.Size) && (bytesAllocated > Int32.MaxValue)) { throw new ArgumentOutOfRangeException("pressure", - Environment.GetResourceString("ArgumentOutOfRange_MustBeNonNegInt32")); + SR.ArgumentOutOfRange_MustBeNonNegInt32); } Contract.EndContractBlock(); @@ -132,13 +132,13 @@ namespace System if (bytesAllocated <= 0) { throw new ArgumentOutOfRangeException(nameof(bytesAllocated), - Environment.GetResourceString("ArgumentOutOfRange_NeedPosNum")); + SR.ArgumentOutOfRange_NeedPosNum); } if ((4 == IntPtr.Size) && (bytesAllocated > Int32.MaxValue)) { throw new ArgumentOutOfRangeException(nameof(bytesAllocated), - Environment.GetResourceString("ArgumentOutOfRange_MustBeNonNegInt32")); + SR.ArgumentOutOfRange_MustBeNonNegInt32); } Contract.EndContractBlock(); @@ -181,12 +181,12 @@ namespace System { if (generation < 0) { - throw new ArgumentOutOfRangeException(nameof(generation), Environment.GetResourceString("ArgumentOutOfRange_GenericPositive")); + throw new ArgumentOutOfRangeException(nameof(generation), SR.ArgumentOutOfRange_GenericPositive); } if ((mode < GCCollectionMode.Default) || (mode > GCCollectionMode.Optimized)) { - throw new ArgumentOutOfRangeException(nameof(mode), Environment.GetResourceString("ArgumentOutOfRange_Enum")); + throw new ArgumentOutOfRangeException(nameof(mode), SR.ArgumentOutOfRange_Enum); } Contract.EndContractBlock(); @@ -217,7 +217,7 @@ namespace System { if (generation < 0) { - throw new ArgumentOutOfRangeException(nameof(generation), Environment.GetResourceString("ArgumentOutOfRange_GenericPositive")); + throw new ArgumentOutOfRangeException(nameof(generation), SR.ArgumentOutOfRange_GenericPositive); } Contract.EndContractBlock(); return _CollectionCount(generation, 0); @@ -372,7 +372,7 @@ namespace System throw new ArgumentOutOfRangeException(nameof(maxGenerationThreshold), String.Format( CultureInfo.CurrentCulture, - Environment.GetResourceString("ArgumentOutOfRange_Bounds_Lower_Upper"), + SR.ArgumentOutOfRange_Bounds_Lower_Upper, 1, 99)); } @@ -382,14 +382,14 @@ namespace System throw new ArgumentOutOfRangeException(nameof(largeObjectHeapThreshold), String.Format( CultureInfo.CurrentCulture, - Environment.GetResourceString("ArgumentOutOfRange_Bounds_Lower_Upper"), + SR.ArgumentOutOfRange_Bounds_Lower_Upper, 1, 99)); } if (!_RegisterForFullGCNotification(maxGenerationThreshold, largeObjectHeapThreshold)) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotWithConcurrentGC")); + throw new InvalidOperationException(SR.InvalidOperation_NotWithConcurrentGC); } } @@ -397,7 +397,7 @@ namespace System { if (!_CancelFullGCNotification()) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotWithConcurrentGC")); + throw new InvalidOperationException(SR.InvalidOperation_NotWithConcurrentGC); } } @@ -409,7 +409,7 @@ namespace System public static GCNotificationStatus WaitForFullGCApproach(int millisecondsTimeout) { if (millisecondsTimeout < -1) - throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); return (GCNotificationStatus)_WaitForFullGCApproach(millisecondsTimeout); } @@ -422,7 +422,7 @@ namespace System public static GCNotificationStatus WaitForFullGCComplete(int millisecondsTimeout) { if (millisecondsTimeout < -1) - throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); return (GCNotificationStatus)_WaitForFullGCComplete(millisecondsTimeout); } diff --git a/src/mscorlib/src/System/Globalization/CompareInfo.Unix.cs b/src/mscorlib/src/System/Globalization/CompareInfo.Unix.cs index 24c5c4a..09b871f 100644 --- a/src/mscorlib/src/System/Globalization/CompareInfo.Unix.cs +++ b/src/mscorlib/src/System/Globalization/CompareInfo.Unix.cs @@ -292,7 +292,7 @@ namespace System.Globalization if ((options & ValidSortkeyCtorMaskOffFlags) != 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag"), nameof(options)); + throw new ArgumentException(SR.Argument_InvalidFlag, nameof(options)); } byte [] keyData; diff --git a/src/mscorlib/src/System/Globalization/DateTimeFormat.cs b/src/mscorlib/src/System/Globalization/DateTimeFormat.cs index b87731a..e34ca35 100644 --- a/src/mscorlib/src/System/Globalization/DateTimeFormat.cs +++ b/src/mscorlib/src/System/Globalization/DateTimeFormat.cs @@ -338,7 +338,7 @@ namespace System // // This means that '\' is at the end of the formatting string. // - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); } } else @@ -353,7 +353,7 @@ namespace System throw new FormatException( String.Format( CultureInfo.CurrentCulture, - Environment.GetResourceString("Format_BadQuote"), quoteChar)); + SR.Format_BadQuote, quoteChar)); } // @@ -538,7 +538,7 @@ namespace System } else { - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); } break; case 't': @@ -706,7 +706,7 @@ namespace System // This means that '%' is at the end of the format string or // "%%" appears in the format string. // - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); } break; case '\\': @@ -729,7 +729,7 @@ namespace System // // This means that '\' is at the end of the formatting string. // - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); } break; default: @@ -898,7 +898,7 @@ namespace System realFormat = dtfi.YearMonthPattern; break; default: - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); } return (realFormat); } @@ -949,7 +949,7 @@ namespace System if (offset != NullOffset) { // This format is not supported by DateTimeOffset - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); } // Universal time is always in Greogrian calendar. // @@ -1180,7 +1180,7 @@ namespace System results = new String[] { Format(dateTime, new String(format, 1), dtfi) }; break; default: - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); } return (results); } diff --git a/src/mscorlib/src/System/Globalization/DateTimeParse.cs b/src/mscorlib/src/System/Globalization/DateTimeParse.cs index cddfc29..6056b5c 100644 --- a/src/mscorlib/src/System/Globalization/DateTimeParse.cs +++ b/src/mscorlib/src/System/Globalization/DateTimeParse.cs @@ -4660,13 +4660,13 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, switch (result.failure) { case ParseFailureKind.ArgumentNull: - return new ArgumentNullException(result.failureArgumentName, Environment.GetResourceString(result.failureMessageID)); + return new ArgumentNullException(result.failureArgumentName, SR.GetResourceString(result.failureMessageID)); case ParseFailureKind.Format: - return new FormatException(Environment.GetResourceString(result.failureMessageID)); + return new FormatException(SR.GetResourceString(result.failureMessageID)); case ParseFailureKind.FormatWithParameter: - return new FormatException(Environment.GetResourceString(result.failureMessageID, result.failureMessageFormatArgument)); + return new FormatException(SR.Format(SR.GetResourceString(result.failureMessageID), result.failureMessageFormatArgument)); case ParseFailureKind.FormatBadDateTimeCalendar: - return new FormatException(Environment.GetResourceString(result.failureMessageID, result.calendar)); + return new FormatException(SR.Format(SR.GetResourceString(result.failureMessageID), result.calendar)); default: Debug.Assert(false, "Unkown DateTimeParseFailure: " + result); return null; diff --git a/src/mscorlib/src/System/Globalization/DigitShapes.cs b/src/mscorlib/src/System/Globalization/DigitShapes.cs index 0e4dcc8..b21f480 100644 --- a/src/mscorlib/src/System/Globalization/DigitShapes.cs +++ b/src/mscorlib/src/System/Globalization/DigitShapes.cs @@ -15,4 +15,4 @@ namespace System.Globalization None = 0x0001, // Gives full Unicode compatibility. NativeNational = 0x0002 // National shapes } -} \ No newline at end of file +} diff --git a/src/mscorlib/src/System/Globalization/EncodingTable.Unix.cs b/src/mscorlib/src/System/Globalization/EncodingTable.Unix.cs index 0fce2e5..dc61c9f 100644 --- a/src/mscorlib/src/System/Globalization/EncodingTable.Unix.cs +++ b/src/mscorlib/src/System/Globalization/EncodingTable.Unix.cs @@ -21,7 +21,7 @@ namespace System.Globalization CodePageDataItem dataItem = s_encodingDataTableItems[i]; arrayEncodingInfo[i] = new EncodingInfo(dataItem.CodePage, dataItem.WebName, - Environment.GetResourceString(dataItem.DisplayNameResourceKey)); + SR.GetResourceString(dataItem.DisplayNameResourceKey)); } return arrayEncodingInfo; @@ -45,7 +45,7 @@ namespace System.Globalization throw new ArgumentException( string.Format( CultureInfo.CurrentCulture, - Environment.GetResourceString("Argument_EncodingNotSupported"), name), nameof(name)); + SR.Argument_EncodingNotSupported, name), nameof(name)); } internal static CodePageDataItem GetCodePageDataItem(int codepage) diff --git a/src/mscorlib/src/System/Globalization/EncodingTable.cs b/src/mscorlib/src/System/Globalization/EncodingTable.cs index e54dfd1..6d9cc31 100644 --- a/src/mscorlib/src/System/Globalization/EncodingTable.cs +++ b/src/mscorlib/src/System/Globalization/EncodingTable.cs @@ -95,7 +95,7 @@ namespace System.Globalization throw new ArgumentException( String.Format( CultureInfo.CurrentCulture, - Environment.GetResourceString("Argument_EncodingNotSupported"), name), nameof(name)); + SR.Argument_EncodingNotSupported, name), nameof(name)); } // Return a list of all EncodingInfo objects describing all of our encodings @@ -117,7 +117,7 @@ namespace System.Globalization for (i = 0; i < lastCodePageItem; i++) { arrayEncodingInfo[i] = new EncodingInfo(codePageDataPtr[i].codePage, CodePageDataItem.CreateString(codePageDataPtr[i].Names, 0), - Environment.GetResourceString("Globalization.cp_" + codePageDataPtr[i].codePage)); + SR.GetResourceString("Globalization_cp_" + codePageDataPtr[i].codePage)); } return arrayEncodingInfo; diff --git a/src/mscorlib/src/System/Globalization/SortVersion.cs b/src/mscorlib/src/System/Globalization/SortVersion.cs index 983179c..9d6118e 100644 --- a/src/mscorlib/src/System/Globalization/SortVersion.cs +++ b/src/mscorlib/src/System/Globalization/SortVersion.cs @@ -98,4 +98,4 @@ namespace System.Globalization return !(left == right); } } -} \ No newline at end of file +} diff --git a/src/mscorlib/src/System/Globalization/TimeSpanFormat.cs b/src/mscorlib/src/System/Globalization/TimeSpanFormat.cs index 8011c0b..ca053ed 100644 --- a/src/mscorlib/src/System/Globalization/TimeSpanFormat.cs +++ b/src/mscorlib/src/System/Globalization/TimeSpanFormat.cs @@ -62,7 +62,7 @@ namespace System.Globalization return FormatStandard(value, false, format, pattern); } - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); } return FormatCustomized(value, format, DateTimeFormatInfo.GetInstance(formatProvider)); @@ -191,19 +191,19 @@ namespace System.Globalization case 'h': tokenLen = DateTimeFormat.ParseRepeatPattern(format, i, ch); if (tokenLen > 2) - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); DateTimeFormat.FormatDigits(result, hours, tokenLen); break; case 'm': tokenLen = DateTimeFormat.ParseRepeatPattern(format, i, ch); if (tokenLen > 2) - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); DateTimeFormat.FormatDigits(result, minutes, tokenLen); break; case 's': tokenLen = DateTimeFormat.ParseRepeatPattern(format, i, ch); if (tokenLen > 2) - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); DateTimeFormat.FormatDigits(result, seconds, tokenLen); break; case 'f': @@ -212,7 +212,7 @@ namespace System.Globalization // tokenLen = DateTimeFormat.ParseRepeatPattern(format, i, ch); if (tokenLen > DateTimeFormat.MaxSecondsFractionDigits) - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); tmp = (long)fraction; tmp /= (long)Math.Pow(10, DateTimeFormat.MaxSecondsFractionDigits - tokenLen); @@ -224,7 +224,7 @@ namespace System.Globalization // tokenLen = DateTimeFormat.ParseRepeatPattern(format, i, ch); if (tokenLen > DateTimeFormat.MaxSecondsFractionDigits) - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); tmp = (long)fraction; tmp /= (long)Math.Pow(10, DateTimeFormat.MaxSecondsFractionDigits - tokenLen); @@ -253,7 +253,7 @@ namespace System.Globalization // tokenLen = DateTimeFormat.ParseRepeatPattern(format, i, ch); if (tokenLen > 8) - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); DateTimeFormat.FormatDigits(result, day, tokenLen, true); break; case '\'': @@ -278,7 +278,7 @@ namespace System.Globalization // This means that '%' is at the end of the format string or // "%%" appears in the format string. // - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); } break; case '\\': @@ -296,11 +296,11 @@ namespace System.Globalization // // This means that '\' is at the end of the formatting string. // - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); } break; default: - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); } i += tokenLen; } diff --git a/src/mscorlib/src/System/Globalization/TimeSpanParse.cs b/src/mscorlib/src/System/Globalization/TimeSpanParse.cs index 0be4f2f..a29e6c2 100644 --- a/src/mscorlib/src/System/Globalization/TimeSpanParse.cs +++ b/src/mscorlib/src/System/Globalization/TimeSpanParse.cs @@ -65,7 +65,7 @@ namespace System.Globalization internal static void ValidateStyles(TimeSpanStyles style, String parameterName) { if (style != TimeSpanStyles.None && style != TimeSpanStyles.AssumeNegative) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidTimeSpanStyles"), parameterName); + throw new ArgumentException(SR.Argument_InvalidTimeSpanStyles, parameterName); } internal const int unlimitedDigits = -1; @@ -544,20 +544,20 @@ namespace System.Globalization switch (m_failure) { case ParseFailureKind.ArgumentNull: - return new ArgumentNullException(m_failureArgumentName, Environment.GetResourceString(m_failureMessageID)); + return new ArgumentNullException(m_failureArgumentName, SR.GetResourceString(m_failureMessageID)); case ParseFailureKind.FormatWithParameter: - return new FormatException(Environment.GetResourceString(m_failureMessageID, m_failureMessageFormatArgument)); + return new FormatException(SR.Format(SR.GetResourceString(m_failureMessageID), m_failureMessageFormatArgument)); case ParseFailureKind.Format: - return new FormatException(Environment.GetResourceString(m_failureMessageID)); + return new FormatException(SR.GetResourceString(m_failureMessageID)); case ParseFailureKind.Overflow: - return new OverflowException(Environment.GetResourceString(m_failureMessageID)); + return new OverflowException(SR.GetResourceString(m_failureMessageID)); default: Debug.Assert(false, "Unknown TimeSpanParseFailure: " + m_failure); - return new FormatException(Environment.GetResourceString("Format_InvalidString")); + return new FormatException(SR.Format_InvalidString); } } } diff --git a/src/mscorlib/src/System/Guid.cs b/src/mscorlib/src/System/Guid.cs index 0d4024b..c7e6220 100644 --- a/src/mscorlib/src/System/Guid.cs +++ b/src/mscorlib/src/System/Guid.cs @@ -50,7 +50,7 @@ namespace System if (b == null) throw new ArgumentNullException(nameof(b)); if (b.Length != 16) - throw new ArgumentException(Environment.GetResourceString("Arg_GuidArrayCtor", "16"), nameof(b)); + throw new ArgumentException(SR.Format(SR.Arg_GuidArrayCtor, "16"), nameof(b)); Contract.EndContractBlock(); _a = ((int)b[3] << 24) | ((int)b[2] << 16) | ((int)b[1] << 8) | b[0]; @@ -91,7 +91,7 @@ namespace System throw new ArgumentNullException(nameof(d)); // Check that array is not too big if (d.Length != 8) - throw new ArgumentException(Environment.GetResourceString("Arg_GuidArrayCtor", "8"), nameof(d)); + throw new ArgumentException(SR.Format(SR.Arg_GuidArrayCtor, "8"), nameof(d)); Contract.EndContractBlock(); _a = a; @@ -212,23 +212,23 @@ namespace System switch (m_failure) { case ParseFailureKind.ArgumentNull: - return new ArgumentNullException(m_failureArgumentName, Environment.GetResourceString(m_failureMessageID)); + return new ArgumentNullException(m_failureArgumentName, SR.GetResourceString(m_failureMessageID)); case ParseFailureKind.FormatWithInnerException: - return new FormatException(Environment.GetResourceString(m_failureMessageID), m_innerException); + return new FormatException(SR.GetResourceString(m_failureMessageID), m_innerException); case ParseFailureKind.FormatWithParameter: - return new FormatException(Environment.GetResourceString(m_failureMessageID, m_failureMessageFormatArgument)); + return new FormatException(SR.Format(SR.GetResourceString(m_failureMessageID), m_failureMessageFormatArgument)); case ParseFailureKind.Format: - return new FormatException(Environment.GetResourceString(m_failureMessageID)); + return new FormatException(SR.GetResourceString(m_failureMessageID)); case ParseFailureKind.NativeException: return m_innerException; default: Debug.Assert(false, "Unknown GuidParseFailure: " + m_failure); - return new FormatException(Environment.GetResourceString("Format_GuidUnrecognized")); + return new FormatException(SR.Format_GuidUnrecognized); } } } @@ -310,7 +310,7 @@ namespace System if (format.Length != 1) { // all acceptable format strings are of length 1 - throw new FormatException(Environment.GetResourceString("Format_InvalidGuidFormatSpecification")); + throw new FormatException(SR.Format_InvalidGuidFormatSpecification); } GuidStyles style; @@ -337,7 +337,7 @@ namespace System } else { - throw new FormatException(Environment.GetResourceString("Format_InvalidGuidFormatSpecification")); + throw new FormatException(SR.Format_InvalidGuidFormatSpecification); } GuidResult result = new GuidResult(); @@ -883,7 +883,7 @@ namespace System } else if (parseResult.throwStyle == GuidParseThrowStyle.AllButOverflow) { - throw new FormatException(Environment.GetResourceString("Format_GuidUnrecognized"), ex); + throw new FormatException(SR.Format_GuidUnrecognized, ex); } else { @@ -935,7 +935,7 @@ namespace System } else if (parseResult.throwStyle == GuidParseThrowStyle.AllButOverflow) { - throw new FormatException(Environment.GetResourceString("Format_GuidUnrecognized"), ex); + throw new FormatException(SR.Format_GuidUnrecognized, ex); } else { @@ -1110,7 +1110,7 @@ namespace System } if (!(value is Guid)) { - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeGuid"), nameof(value)); + throw new ArgumentException(SR.Arg_MustBeGuid, nameof(value)); } Guid g = (Guid)value; @@ -1331,7 +1331,7 @@ namespace System if (format.Length != 1) { // all acceptable format strings are of length 1 - throw new FormatException(Environment.GetResourceString("Format_InvalidGuidFormatSpecification")); + throw new FormatException(SR.Format_InvalidGuidFormatSpecification); } char formatCh = format[0]; @@ -1384,7 +1384,7 @@ namespace System } else { - throw new FormatException(Environment.GetResourceString("Format_InvalidGuidFormatSpecification")); + throw new FormatException(SR.Format_InvalidGuidFormatSpecification); } unsafe diff --git a/src/mscorlib/src/System/IO/BinaryReader.cs b/src/mscorlib/src/System/IO/BinaryReader.cs index 2f81b00..cebba6e 100644 --- a/src/mscorlib/src/System/IO/BinaryReader.cs +++ b/src/mscorlib/src/System/IO/BinaryReader.cs @@ -60,7 +60,7 @@ namespace System.IO throw new ArgumentNullException(nameof(encoding)); } if (!input.CanRead) - throw new ArgumentException(Environment.GetResourceString("Argument_StreamNotReadable")); + throw new ArgumentException(SR.Argument_StreamNotReadable); Contract.EndContractBlock(); m_stream = input; m_decoder = encoding.GetDecoder(); @@ -264,7 +264,7 @@ namespace System.IO catch (ArgumentException e) { // ReadDecimal cannot leak out ArgumentException - throw new IOException(Environment.GetResourceString("Arg_DecBitCtor"), e); + throw new IOException(SR.Arg_DecBitCtor, e); } } @@ -285,7 +285,7 @@ namespace System.IO stringLength = Read7BitEncodedInt(); if (stringLength < 0) { - throw new IOException(Environment.GetResourceString("IO.IO_InvalidStringLen_Len", stringLength)); + throw new IOException(SR.Format(SR.IO_InvalidStringLen_Len, stringLength)); } if (stringLength == 0) @@ -332,19 +332,19 @@ namespace System.IO { if (buffer == null) { - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), 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 (buffer.Length - index < count) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); } Contract.Ensures(Contract.Result() >= 0); Contract.Ensures(Contract.Result() <= count); @@ -524,7 +524,7 @@ namespace System.IO { if (count < 0) { - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); } Contract.Ensures(Contract.Result() != null); Contract.Ensures(Contract.Result().Length <= count); @@ -555,13 +555,13 @@ namespace System.IO public virtual int Read(byte[] buffer, int index, int count) { if (buffer == null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), 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 (buffer.Length - index < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.Ensures(Contract.Result() >= 0); Contract.Ensures(Contract.Result() <= count); Contract.EndContractBlock(); @@ -572,7 +572,7 @@ namespace System.IO public virtual byte[] ReadBytes(int count) { - if (count < 0) throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + if (count < 0) throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); Contract.Ensures(Contract.Result() != null); Contract.Ensures(Contract.Result().Length <= Contract.OldValue(count)); Contract.EndContractBlock(); @@ -610,7 +610,7 @@ namespace System.IO { if (m_buffer != null && (numBytes < 0 || numBytes > m_buffer.Length)) { - throw new ArgumentOutOfRangeException(nameof(numBytes), Environment.GetResourceString("ArgumentOutOfRange_BinaryReaderFillBuffer")); + throw new ArgumentOutOfRangeException(nameof(numBytes), SR.ArgumentOutOfRange_BinaryReaderFillBuffer); } int bytesRead = 0; int n = 0; @@ -652,7 +652,7 @@ namespace System.IO // Check for a corrupted stream. Read a max of 5 bytes. // In a future version, add a DataFormatException. if (shift == 5 * 7) // 5 bytes max per Int32, shift += 7 - throw new FormatException(Environment.GetResourceString("Format_Bad7BitInt32")); + throw new FormatException(SR.Format_Bad7BitInt32); // ReadByte handles end of stream cases for us. b = ReadByte(); diff --git a/src/mscorlib/src/System/IO/BinaryWriter.cs b/src/mscorlib/src/System/IO/BinaryWriter.cs index ffa5f6e..3d9839f 100644 --- a/src/mscorlib/src/System/IO/BinaryWriter.cs +++ b/src/mscorlib/src/System/IO/BinaryWriter.cs @@ -71,7 +71,7 @@ namespace System.IO if (encoding == null) throw new ArgumentNullException(nameof(encoding)); if (!output.CanWrite) - throw new ArgumentException(Environment.GetResourceString("Argument_StreamNotWritable")); + throw new ArgumentException(SR.Argument_StreamNotWritable); Contract.EndContractBlock(); OutStream = output; @@ -188,7 +188,7 @@ namespace System.IO public unsafe virtual void Write(char ch) { if (Char.IsSurrogate(ch)) - throw new ArgumentException(Environment.GetResourceString("Arg_SurrogatesNotAllowedAsSingleChar")); + throw new ArgumentException(SR.Arg_SurrogatesNotAllowedAsSingleChar); Contract.EndContractBlock(); Debug.Assert(_encoding.GetMaxByteCount(1) <= 16, "_encoding.GetMaxByteCount(1) <= 16)"); diff --git a/src/mscorlib/src/System/IO/Directory.cs b/src/mscorlib/src/System/IO/Directory.cs index c8c0142..c472cdf 100644 --- a/src/mscorlib/src/System/IO/Directory.cs +++ b/src/mscorlib/src/System/IO/Directory.cs @@ -55,7 +55,7 @@ namespace System.IO if (searchPattern == null) throw new ArgumentNullException(nameof(searchPattern)); if ((searchOption != SearchOption.TopDirectoryOnly) && (searchOption != SearchOption.AllDirectories)) - throw new ArgumentOutOfRangeException(nameof(searchOption), Environment.GetResourceString("ArgumentOutOfRange_Enum")); + throw new ArgumentOutOfRangeException(nameof(searchOption), SR.ArgumentOutOfRange_Enum); Contract.Ensures(Contract.Result>() != null); Contract.EndContractBlock(); @@ -135,9 +135,9 @@ namespace System.IO if (path == null) throw new ArgumentNullException(nameof(path)); if (path.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_PathEmpty")); + throw new ArgumentException(SR.Argument_PathEmpty); if (path.Length >= Path.MaxPath) - throw new PathTooLongException(Environment.GetResourceString("IO.PathTooLong")); + throw new PathTooLongException(SR.IO_PathTooLong); String fulldestDirName = Path.GetFullPath(path); diff --git a/src/mscorlib/src/System/IO/DirectoryNotFoundException.cs b/src/mscorlib/src/System/IO/DirectoryNotFoundException.cs index 31b1eba..1cc6cc4 100644 --- a/src/mscorlib/src/System/IO/DirectoryNotFoundException.cs +++ b/src/mscorlib/src/System/IO/DirectoryNotFoundException.cs @@ -28,7 +28,7 @@ namespace System.IO public class DirectoryNotFoundException : IOException { public DirectoryNotFoundException() - : base(Environment.GetResourceString("Arg_DirectoryNotFoundException")) + : base(SR.Arg_DirectoryNotFoundException) { SetErrorCode(__HResults.COR_E_DIRECTORYNOTFOUND); } diff --git a/src/mscorlib/src/System/IO/DriveNotFoundException.cs b/src/mscorlib/src/System/IO/DriveNotFoundException.cs index 6c5bb76..c48d7ac 100644 --- a/src/mscorlib/src/System/IO/DriveNotFoundException.cs +++ b/src/mscorlib/src/System/IO/DriveNotFoundException.cs @@ -21,7 +21,7 @@ namespace System.IO internal class DriveNotFoundException : IOException { public DriveNotFoundException() - : base(Environment.GetResourceString("Arg_DriveNotFoundException")) + : base(SR.Arg_DriveNotFoundException) { SetErrorCode(__HResults.COR_E_DIRECTORYNOTFOUND); } diff --git a/src/mscorlib/src/System/IO/EndOfStreamException.cs b/src/mscorlib/src/System/IO/EndOfStreamException.cs index 3b73dff..1eb1664 100644 --- a/src/mscorlib/src/System/IO/EndOfStreamException.cs +++ b/src/mscorlib/src/System/IO/EndOfStreamException.cs @@ -22,7 +22,7 @@ namespace System.IO public class EndOfStreamException : IOException { public EndOfStreamException() - : base(Environment.GetResourceString("Arg_EndOfStreamException")) + : base(SR.Arg_EndOfStreamException) { SetErrorCode(__HResults.COR_E_ENDOFSTREAM); } diff --git a/src/mscorlib/src/System/IO/File.cs b/src/mscorlib/src/System/IO/File.cs index 5c6b5fc..4aba148 100644 --- a/src/mscorlib/src/System/IO/File.cs +++ b/src/mscorlib/src/System/IO/File.cs @@ -93,7 +93,7 @@ namespace System.IO int index = 0; long fileLength = fs.Length; if (fileLength > Int32.MaxValue) - throw new IOException(Environment.GetResourceString("IO.IO_FileTooLong2GB")); + throw new IOException(SR.IO_FileTooLong2GB); int count = (int)fileLength; bytes = new byte[count]; while (count > 0) @@ -114,7 +114,7 @@ namespace System.IO if (path == null) throw new ArgumentNullException(nameof(path)); if (path.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyPath")); + throw new ArgumentException(SR.Argument_EmptyPath); Contract.EndContractBlock(); return InternalReadAllLines(path, Encoding.UTF8); diff --git a/src/mscorlib/src/System/IO/FileLoadException.cs b/src/mscorlib/src/System/IO/FileLoadException.cs index e55fdbb..6c5b268 100644 --- a/src/mscorlib/src/System/IO/FileLoadException.cs +++ b/src/mscorlib/src/System/IO/FileLoadException.cs @@ -32,7 +32,7 @@ namespace System.IO private String _fusionLog; // fusion log (when applicable) public FileLoadException() - : base(Environment.GetResourceString("IO.FileLoad")) + : base(SR.IO_FileLoad) { SetErrorCode(__HResults.COR_E_FILELOAD); } @@ -87,7 +87,7 @@ namespace System.IO String s = GetType().FullName + ": " + Message; if (_fileName != null && _fileName.Length != 0) - s += Environment.NewLine + Environment.GetResourceString("IO.FileName_Name", _fileName); + s += Environment.NewLine + SR.Format(SR.IO_FileName_Name, _fileName); if (InnerException != null) s = s + " ---> " + InnerException.ToString(); diff --git a/src/mscorlib/src/System/IO/FileNotFoundException.cs b/src/mscorlib/src/System/IO/FileNotFoundException.cs index e25667e..987aaa9 100644 --- a/src/mscorlib/src/System/IO/FileNotFoundException.cs +++ b/src/mscorlib/src/System/IO/FileNotFoundException.cs @@ -29,7 +29,7 @@ namespace System.IO private String _fusionLog; // fusion log (when applicable) public FileNotFoundException() - : base(Environment.GetResourceString("IO.FileNotFound")) + : base(SR.IO_FileNotFound) { SetErrorCode(__HResults.COR_E_FILENOTFOUND); } @@ -74,7 +74,7 @@ namespace System.IO { if ((_fileName == null) && (HResult == System.__HResults.COR_E_EXCEPTION)) - _message = Environment.GetResourceString("IO.FileNotFound"); + _message = SR.IO_FileNotFound; else if (_fileName != null) _message = FileLoadException.FormatFileLoadExceptionMessage(_fileName, HResult); @@ -91,7 +91,7 @@ namespace System.IO String s = GetType().FullName + ": " + Message; if (_fileName != null && _fileName.Length != 0) - s += Environment.NewLine + Environment.GetResourceString("IO.FileName_Name", _fileName); + s += Environment.NewLine + SR.Format(SR.IO_FileName_Name, _fileName); if (InnerException != null) s = s + " ---> " + InnerException.ToString(); diff --git a/src/mscorlib/src/System/IO/IOException.cs b/src/mscorlib/src/System/IO/IOException.cs index c2603e6..a91d891 100644 --- a/src/mscorlib/src/System/IO/IOException.cs +++ b/src/mscorlib/src/System/IO/IOException.cs @@ -33,7 +33,7 @@ namespace System.IO private String _maybeFullPath; // For debuggers on partial trust code public IOException() - : base(Environment.GetResourceString("Arg_IOException")) + : base(SR.Arg_IOException) { SetErrorCode(__HResults.COR_E_IO); } diff --git a/src/mscorlib/src/System/IO/MemoryStream.cs b/src/mscorlib/src/System/IO/MemoryStream.cs index 9201577..80b3af0 100644 --- a/src/mscorlib/src/System/IO/MemoryStream.cs +++ b/src/mscorlib/src/System/IO/MemoryStream.cs @@ -64,7 +64,7 @@ namespace System.IO { if (capacity < 0) { - throw new ArgumentOutOfRangeException(nameof(capacity), Environment.GetResourceString("ArgumentOutOfRange_NegativeCapacity")); + throw new ArgumentOutOfRangeException(nameof(capacity), SR.ArgumentOutOfRange_NegativeCapacity); } Contract.EndContractBlock(); @@ -84,7 +84,7 @@ namespace System.IO public MemoryStream(byte[] buffer, bool writable) { - if (buffer == null) throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + if (buffer == null) throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); Contract.EndContractBlock(); _buffer = buffer; _length = _capacity = buffer.Length; @@ -107,13 +107,13 @@ namespace System.IO public MemoryStream(byte[] buffer, int index, int count, bool writable, bool publiclyVisible) { if (buffer == null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), 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 (buffer.Length - index < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); _buffer = buffer; @@ -173,7 +173,7 @@ namespace System.IO { // Check for overflow if (value < 0) - throw new IOException(Environment.GetResourceString("IO.IO_StreamTooLong")); + throw new IOException(SR.IO_StreamTooLong); if (value > _capacity) { int newCapacity = value; @@ -218,7 +218,7 @@ namespace System.IO public virtual byte[] GetBuffer() { if (!_exposable) - throw new UnauthorizedAccessException(Environment.GetResourceString("UnauthorizedAccess_MemStreamBuffer")); + throw new UnauthorizedAccessException(SR.UnauthorizedAccess_MemStreamBuffer); return _buffer; } @@ -302,7 +302,7 @@ namespace System.IO { // Only update the capacity if the MS is expandable and the value is different than the current capacity. // Special behavior if the MS isn't expandable: we don't throw if value is the same as the current capacity - if (value < Length) throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_SmallCapacity")); + if (value < Length) throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_SmallCapacity); Contract.Ensures(_capacity - _origin == value); Contract.EndContractBlock(); @@ -346,14 +346,14 @@ namespace System.IO set { if (value < 0) - throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_NeedNonNegNum); Contract.Ensures(Position == value); Contract.EndContractBlock(); if (!_isOpen) __Error.StreamIsClosed(); if (value > MemStreamMaxLength) - throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_StreamLength")); + throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_StreamLength); _position = _origin + (int)value; } } @@ -361,13 +361,13 @@ namespace System.IO public override int Read([In, Out] byte[] buffer, int offset, int count) { if (buffer == null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); if (offset < 0) - throw new ArgumentOutOfRangeException(nameof(offset), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum); if (count < 0) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); if (buffer.Length - offset < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); if (!_isOpen) __Error.StreamIsClosed(); @@ -395,13 +395,13 @@ namespace System.IO public override Task ReadAsync(Byte[] buffer, int offset, int count, CancellationToken cancellationToken) { if (buffer == null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); if (offset < 0) - throw new ArgumentOutOfRangeException(nameof(offset), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum); if (count < 0) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); if (buffer.Length - offset < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); // contract validation copied from Read(...) // If cancellation was requested, bail early @@ -513,14 +513,14 @@ namespace System.IO if (!_isOpen) __Error.StreamIsClosed(); if (offset > MemStreamMaxLength) - throw new ArgumentOutOfRangeException(nameof(offset), Environment.GetResourceString("ArgumentOutOfRange_StreamLength")); + throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_StreamLength); switch (loc) { case SeekOrigin.Begin: { int tempPosition = unchecked(_origin + (int)offset); if (offset < 0 || tempPosition < _origin) - throw new IOException(Environment.GetResourceString("IO.IO_SeekBeforeBegin")); + throw new IOException(SR.IO_SeekBeforeBegin); _position = tempPosition; break; } @@ -528,7 +528,7 @@ namespace System.IO { int tempPosition = unchecked(_position + (int)offset); if (unchecked(_position + offset) < _origin || tempPosition < _origin) - throw new IOException(Environment.GetResourceString("IO.IO_SeekBeforeBegin")); + throw new IOException(SR.IO_SeekBeforeBegin); _position = tempPosition; break; } @@ -536,12 +536,12 @@ namespace System.IO { int tempPosition = unchecked(_length + (int)offset); if (unchecked(_length + offset) < _origin || tempPosition < _origin) - throw new IOException(Environment.GetResourceString("IO.IO_SeekBeforeBegin")); + throw new IOException(SR.IO_SeekBeforeBegin); _position = tempPosition; break; } default: - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidSeekOrigin")); + throw new ArgumentException(SR.Argument_InvalidSeekOrigin); } Debug.Assert(_position >= 0, "_position >= 0"); @@ -562,7 +562,7 @@ namespace System.IO { if (value < 0 || value > Int32.MaxValue) { - throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_StreamLength")); + throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_StreamLength); } Contract.Ensures(_length - _origin == value); Contract.EndContractBlock(); @@ -572,7 +572,7 @@ namespace System.IO Debug.Assert(MemStreamMaxLength == Int32.MaxValue); // Check parameter validation logic in this method if this fails. if (value > (Int32.MaxValue - _origin)) { - throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_StreamLength")); + throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_StreamLength); } int newLength = _origin + (int)value; @@ -594,13 +594,13 @@ namespace System.IO public override void Write(byte[] buffer, int offset, int count) { if (buffer == null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); if (offset < 0) - throw new ArgumentOutOfRangeException(nameof(offset), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum); if (count < 0) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); if (buffer.Length - offset < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); if (!_isOpen) __Error.StreamIsClosed(); @@ -609,7 +609,7 @@ namespace System.IO int i = _position + count; // Check for overflow if (i < 0) - throw new IOException(Environment.GetResourceString("IO.IO_StreamTooLong")); + throw new IOException(SR.IO_StreamTooLong); if (i > _length) { @@ -638,13 +638,13 @@ namespace System.IO public override Task WriteAsync(Byte[] buffer, int offset, int count, CancellationToken cancellationToken) { if (buffer == null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); if (offset < 0) - throw new ArgumentOutOfRangeException(nameof(offset), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum); if (count < 0) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); if (buffer.Length - offset < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); // contract validation copied from Write(...) // If cancellation is already requested, bail early @@ -692,7 +692,7 @@ namespace System.IO public virtual void WriteTo(Stream stream) { if (stream == null) - throw new ArgumentNullException(nameof(stream), Environment.GetResourceString("ArgumentNull_Stream")); + throw new ArgumentNullException(nameof(stream), SR.ArgumentNull_Stream); Contract.EndContractBlock(); if (!_isOpen) __Error.StreamIsClosed(); diff --git a/src/mscorlib/src/System/IO/PathTooLongException.cs b/src/mscorlib/src/System/IO/PathTooLongException.cs index 07ecb38..a0f176c 100644 --- a/src/mscorlib/src/System/IO/PathTooLongException.cs +++ b/src/mscorlib/src/System/IO/PathTooLongException.cs @@ -23,7 +23,7 @@ namespace System.IO public class PathTooLongException : IOException { public PathTooLongException() - : base(Environment.GetResourceString("IO.PathTooLong")) + : base(SR.IO_PathTooLong) { SetErrorCode(__HResults.COR_E_PATHTOOLONG); } diff --git a/src/mscorlib/src/System/IO/Stream.cs b/src/mscorlib/src/System/IO/Stream.cs index 585f599..92fe374 100644 --- a/src/mscorlib/src/System/IO/Stream.cs +++ b/src/mscorlib/src/System/IO/Stream.cs @@ -98,11 +98,11 @@ namespace System.IO get { Contract.Ensures(Contract.Result() >= 0); - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TimeoutsNotSupported")); + throw new InvalidOperationException(SR.InvalidOperation_TimeoutsNotSupported); } set { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TimeoutsNotSupported")); + throw new InvalidOperationException(SR.InvalidOperation_TimeoutsNotSupported); } } @@ -111,11 +111,11 @@ namespace System.IO get { Contract.Ensures(Contract.Result() >= 0); - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TimeoutsNotSupported")); + throw new InvalidOperationException(SR.InvalidOperation_TimeoutsNotSupported); } set { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_TimeoutsNotSupported")); + throw new InvalidOperationException(SR.InvalidOperation_TimeoutsNotSupported); } } @@ -382,15 +382,15 @@ namespace System.IO if (readTask == null) { - throw new ArgumentException(Environment.GetResourceString("InvalidOperation_WrongAsyncResultOrEndReadCalledMultiple")); + throw new ArgumentException(SR.InvalidOperation_WrongAsyncResultOrEndReadCalledMultiple); } else if (readTask != asyncResult) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_WrongAsyncResultOrEndReadCalledMultiple")); + throw new InvalidOperationException(SR.InvalidOperation_WrongAsyncResultOrEndReadCalledMultiple); } else if (!readTask._isRead) { - throw new ArgumentException(Environment.GetResourceString("InvalidOperation_WrongAsyncResultOrEndReadCalledMultiple")); + throw new ArgumentException(SR.InvalidOperation_WrongAsyncResultOrEndReadCalledMultiple); } try @@ -566,15 +566,15 @@ namespace System.IO var writeTask = _activeReadWriteTask; if (writeTask == null) { - throw new ArgumentException(Environment.GetResourceString("InvalidOperation_WrongAsyncResultOrEndWriteCalledMultiple")); + throw new ArgumentException(SR.InvalidOperation_WrongAsyncResultOrEndWriteCalledMultiple); } else if (writeTask != asyncResult) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_WrongAsyncResultOrEndWriteCalledMultiple")); + throw new InvalidOperationException(SR.InvalidOperation_WrongAsyncResultOrEndWriteCalledMultiple); } else if (writeTask._isRead) { - throw new ArgumentException(Environment.GetResourceString("InvalidOperation_WrongAsyncResultOrEndWriteCalledMultiple")); + throw new ArgumentException(SR.InvalidOperation_WrongAsyncResultOrEndWriteCalledMultiple); } try diff --git a/src/mscorlib/src/System/IO/StreamHelpers.CopyValidation.cs b/src/mscorlib/src/System/IO/StreamHelpers.CopyValidation.cs index 8ff0e04..45bbd81 100644 --- a/src/mscorlib/src/System/IO/StreamHelpers.CopyValidation.cs +++ b/src/mscorlib/src/System/IO/StreamHelpers.CopyValidation.cs @@ -17,29 +17,29 @@ namespace System.IO if (bufferSize <= 0) { - throw new ArgumentOutOfRangeException(nameof(bufferSize), bufferSize, Environment.GetResourceString("ArgumentOutOfRange_NeedPosNum")); + throw new ArgumentOutOfRangeException(nameof(bufferSize), bufferSize, SR.ArgumentOutOfRange_NeedPosNum); } bool sourceCanRead = source.CanRead; if (!sourceCanRead && !source.CanWrite) { - throw new ObjectDisposedException(null, Environment.GetResourceString("ObjectDisposed_StreamClosed")); + throw new ObjectDisposedException(null, SR.ObjectDisposed_StreamClosed); } bool destinationCanWrite = destination.CanWrite; if (!destinationCanWrite && !destination.CanRead) { - throw new ObjectDisposedException(nameof(destination), Environment.GetResourceString("ObjectDisposed_StreamClosed")); + throw new ObjectDisposedException(nameof(destination), SR.ObjectDisposed_StreamClosed); } if (!sourceCanRead) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_UnreadableStream")); + throw new NotSupportedException(SR.NotSupported_UnreadableStream); } if (!destinationCanWrite) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_UnwritableStream")); + throw new NotSupportedException(SR.NotSupported_UnwritableStream); } } } diff --git a/src/mscorlib/src/System/IO/StreamReader.cs b/src/mscorlib/src/System/IO/StreamReader.cs index c86e974..eedf6e7 100644 --- a/src/mscorlib/src/System/IO/StreamReader.cs +++ b/src/mscorlib/src/System/IO/StreamReader.cs @@ -103,7 +103,7 @@ namespace System.IO Task t = _asyncReadTask; if (t != null && !t.IsCompleted) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_AsyncIOInProgress")); + throw new InvalidOperationException(SR.InvalidOperation_AsyncIOInProgress); } // StreamReader by default will ignore illegal UTF8 characters. We don't want to @@ -149,9 +149,9 @@ namespace System.IO if (stream == null || encoding == null) throw new ArgumentNullException((stream == null ? nameof(stream) : nameof(encoding))); if (!stream.CanRead) - throw new ArgumentException(Environment.GetResourceString("Argument_StreamNotReadable")); + throw new ArgumentException(SR.Argument_StreamNotReadable); if (bufferSize <= 0) - throw new ArgumentOutOfRangeException(nameof(bufferSize), Environment.GetResourceString("ArgumentOutOfRange_NeedPosNum")); + throw new ArgumentOutOfRangeException(nameof(bufferSize), SR.ArgumentOutOfRange_NeedPosNum); Contract.EndContractBlock(); Init(stream, encoding, detectEncodingFromByteOrderMarks, bufferSize, leaveOpen); @@ -181,9 +181,9 @@ namespace System.IO if (path==null || encoding==null) throw new ArgumentNullException((path==null ? nameof(path) : nameof(encoding))); if (path.Length==0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyPath")); + throw new ArgumentException(SR.Argument_EmptyPath); if (bufferSize <= 0) - throw new ArgumentOutOfRangeException(nameof(bufferSize), Environment.GetResourceString("ArgumentOutOfRange_NeedPosNum")); + throw new ArgumentOutOfRangeException(nameof(bufferSize), SR.ArgumentOutOfRange_NeedPosNum); Contract.EndContractBlock(); Stream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultFileStreamBufferSize, FileOptions.SequentialScan); @@ -338,11 +338,11 @@ namespace System.IO public override int Read([In, Out] char[] buffer, int index, int count) { if (buffer==null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (buffer.Length - index < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); if (stream == null) @@ -396,11 +396,11 @@ namespace System.IO public override int ReadBlock([In, Out] char[] buffer, int index, int count) { if (buffer==null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (buffer.Length - index < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); if (stream == null) @@ -872,11 +872,11 @@ namespace System.IO public override Task ReadAsync(char[] buffer, int index, int count) { if (buffer==null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (buffer.Length - index < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); // If we have been inherited into a subclass, the following implementation could be incorrect @@ -1058,11 +1058,11 @@ namespace System.IO public override Task ReadBlockAsync(char[] buffer, int index, int count) { if (buffer==null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (buffer.Length - index < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); // If we have been inherited into a subclass, the following implementation could be incorrect diff --git a/src/mscorlib/src/System/IO/TextReader.cs b/src/mscorlib/src/System/IO/TextReader.cs index 15ba8fb..3da6859 100644 --- a/src/mscorlib/src/System/IO/TextReader.cs +++ b/src/mscorlib/src/System/IO/TextReader.cs @@ -93,13 +93,13 @@ namespace System.IO { public virtual int Read([In, Out] char[] buffer, int index, int count) { if (buffer==null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), 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 (buffer.Length - index < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.Ensures(Contract.Result() >= 0); Contract.Ensures(Contract.Result() <= Contract.OldValue(count)); Contract.EndContractBlock(); @@ -192,11 +192,11 @@ namespace System.IO { public virtual Task ReadAsync(char[] buffer, int index, int count) { if (buffer==null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (buffer.Length - index < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); return ReadAsyncInternal(buffer, index, count); @@ -221,11 +221,11 @@ namespace System.IO { public virtual Task ReadBlockAsync(char[] buffer, int index, int count) { if (buffer==null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (buffer.Length - index < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); @@ -362,11 +362,11 @@ namespace System.IO { public override Task ReadBlockAsync(char[] buffer, int index, int count) { if (buffer==null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (buffer.Length - index < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); @@ -377,11 +377,11 @@ namespace System.IO { public override Task ReadAsync(char[] buffer, int index, int count) { if (buffer==null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (buffer.Length - index < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); return Task.FromResult(Read(buffer, index, count)); diff --git a/src/mscorlib/src/System/IO/UnmanagedMemoryAccessor.cs b/src/mscorlib/src/System/IO/UnmanagedMemoryAccessor.cs index 731df60..5f6f588 100644 --- a/src/mscorlib/src/System/IO/UnmanagedMemoryAccessor.cs +++ b/src/mscorlib/src/System/IO/UnmanagedMemoryAccessor.cs @@ -65,15 +65,15 @@ namespace System.IO } if (offset < 0) { - throw new ArgumentOutOfRangeException(nameof(offset), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum); } if (capacity < 0) { - throw new ArgumentOutOfRangeException(nameof(capacity), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(capacity), SR.ArgumentOutOfRange_NeedNonNegNum); } if (buffer.ByteLength < (UInt64)(offset + capacity)) { - throw new ArgumentException(Environment.GetResourceString("Argument_OffsetAndCapacityOutOfBounds")); + throw new ArgumentException(SR.Argument_OffsetAndCapacityOutOfBounds); } if (access < FileAccess.Read || access > FileAccess.ReadWrite) { @@ -83,7 +83,7 @@ namespace System.IO if (_isOpen) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CalledTwice")); + throw new InvalidOperationException(SR.InvalidOperation_CalledTwice); } unsafe @@ -95,7 +95,7 @@ namespace System.IO buffer.AcquirePointer(ref pointer); if (((byte*)((Int64)pointer + offset + capacity)) < pointer) { - throw new ArgumentException(Environment.GetResourceString("Argument_UnmanagedMemAccessorWrapAround")); + throw new ArgumentException(SR.Argument_UnmanagedMemAccessorWrapAround); } } finally @@ -314,7 +314,7 @@ namespace System.IO // Check for invalid Decimal values if (!((flags & ~(SignMask | ScaleMask)) == 0 && (flags & ScaleMask) <= (28 << 16))) { - throw new ArgumentException(Environment.GetResourceString("Arg_BadDecimal")); // Throw same Exception type as Decimal(int[]) ctor for compat + throw new ArgumentException(SR.Arg_BadDecimal); // Throw same Exception type as Decimal(int[]) ctor for compat } bool isNegative = (flags & SignMask) != 0; @@ -502,17 +502,17 @@ namespace System.IO { if (position < 0) { - throw new ArgumentOutOfRangeException(nameof(position), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(position), SR.ArgumentOutOfRange_NeedNonNegNum); } Contract.EndContractBlock(); if (!_isOpen) { - throw new ObjectDisposedException("UnmanagedMemoryAccessor", Environment.GetResourceString("ObjectDisposed_ViewAccessorClosed")); + throw new ObjectDisposedException("UnmanagedMemoryAccessor", SR.ObjectDisposed_ViewAccessorClosed); } if (!CanRead) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_Reading")); + throw new NotSupportedException(SR.NotSupported_Reading); } UInt32 sizeOfT = Marshal.SizeOfType(typeof(T)); @@ -520,11 +520,11 @@ namespace System.IO { if (position >= _capacity) { - throw new ArgumentOutOfRangeException(nameof(position), Environment.GetResourceString("ArgumentOutOfRange_PositionLessThanCapacityRequired")); + throw new ArgumentOutOfRangeException(nameof(position), SR.ArgumentOutOfRange_PositionLessThanCapacityRequired); } else { - throw new ArgumentException(Environment.GetResourceString("Argument_NotEnoughBytesToRead", typeof(T).FullName), nameof(position)); + throw new ArgumentException(SR.Format(SR.Argument_NotEnoughBytesToRead, typeof (T).FullName), nameof(position)); } } @@ -545,31 +545,31 @@ namespace System.IO } if (offset < 0) { - throw new ArgumentOutOfRangeException(nameof(offset), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(offset), 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 - offset < count) { - throw new ArgumentException(Environment.GetResourceString("Argument_OffsetAndLengthOutOfBounds")); + throw new ArgumentException(SR.Argument_OffsetAndLengthOutOfBounds); } Contract.EndContractBlock(); if (!CanRead) { if (!_isOpen) { - throw new ObjectDisposedException("UnmanagedMemoryAccessor", Environment.GetResourceString("ObjectDisposed_ViewAccessorClosed")); + throw new ObjectDisposedException("UnmanagedMemoryAccessor", SR.ObjectDisposed_ViewAccessorClosed); } else { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_Reading")); + throw new NotSupportedException(SR.NotSupported_Reading); } } if (position < 0) { - throw new ArgumentOutOfRangeException(nameof(position), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(position), SR.ArgumentOutOfRange_NeedNonNegNum); } UInt32 sizeOfT = Marshal.AlignedSizeOf(); @@ -577,7 +577,7 @@ namespace System.IO // only check position and ask for fewer Ts if count is too big if (position >= _capacity) { - throw new ArgumentOutOfRangeException(nameof(position), Environment.GetResourceString("ArgumentOutOfRange_PositionLessThanCapacityRequired")); + throw new ArgumentOutOfRangeException(nameof(position), SR.ArgumentOutOfRange_PositionLessThanCapacityRequired); } int n = count; @@ -903,17 +903,17 @@ namespace System.IO { if (position < 0) { - throw new ArgumentOutOfRangeException(nameof(position), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(position), SR.ArgumentOutOfRange_NeedNonNegNum); } Contract.EndContractBlock(); if (!_isOpen) { - throw new ObjectDisposedException("UnmanagedMemoryAccessor", Environment.GetResourceString("ObjectDisposed_ViewAccessorClosed")); + throw new ObjectDisposedException("UnmanagedMemoryAccessor", SR.ObjectDisposed_ViewAccessorClosed); } if (!CanWrite) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_Writing")); + throw new NotSupportedException(SR.NotSupported_Writing); } UInt32 sizeOfT = Marshal.SizeOfType(typeof(T)); @@ -921,11 +921,11 @@ namespace System.IO { if (position >= _capacity) { - throw new ArgumentOutOfRangeException(nameof(position), Environment.GetResourceString("ArgumentOutOfRange_PositionLessThanCapacityRequired")); + throw new ArgumentOutOfRangeException(nameof(position), SR.ArgumentOutOfRange_PositionLessThanCapacityRequired); } else { - throw new ArgumentException(Environment.GetResourceString("Argument_NotEnoughBytesToWrite", typeof(T).FullName), nameof(position)); + throw new ArgumentException(SR.Format(SR.Argument_NotEnoughBytesToWrite, typeof (T).FullName), nameof(position)); } } @@ -943,33 +943,33 @@ namespace System.IO } if (offset < 0) { - throw new ArgumentOutOfRangeException(nameof(offset), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(offset), 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 - offset < count) { - throw new ArgumentException(Environment.GetResourceString("Argument_OffsetAndLengthOutOfBounds")); + throw new ArgumentException(SR.Argument_OffsetAndLengthOutOfBounds); } if (position < 0) { - throw new ArgumentOutOfRangeException(nameof(position), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(position), SR.ArgumentOutOfRange_NeedNonNegNum); } if (position >= Capacity) { - throw new ArgumentOutOfRangeException(nameof(position), Environment.GetResourceString("ArgumentOutOfRange_PositionLessThanCapacityRequired")); + throw new ArgumentOutOfRangeException(nameof(position), SR.ArgumentOutOfRange_PositionLessThanCapacityRequired); } Contract.EndContractBlock(); if (!_isOpen) { - throw new ObjectDisposedException("UnmanagedMemoryAccessor", Environment.GetResourceString("ObjectDisposed_ViewAccessorClosed")); + throw new ObjectDisposedException("UnmanagedMemoryAccessor", SR.ObjectDisposed_ViewAccessorClosed); } if (!CanWrite) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_Writing")); + throw new NotSupportedException(SR.NotSupported_Writing); } _buffer.WriteArray((UInt64)(_offset + position), array, offset, count); @@ -1031,26 +1031,26 @@ namespace System.IO { if (!_isOpen) { - throw new ObjectDisposedException("UnmanagedMemoryAccessor", Environment.GetResourceString("ObjectDisposed_ViewAccessorClosed")); + throw new ObjectDisposedException("UnmanagedMemoryAccessor", SR.ObjectDisposed_ViewAccessorClosed); } if (!CanRead) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_Reading")); + throw new NotSupportedException(SR.NotSupported_Reading); } if (position < 0) { - throw new ArgumentOutOfRangeException(nameof(position), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(position), SR.ArgumentOutOfRange_NeedNonNegNum); } Contract.EndContractBlock(); if (position > _capacity - sizeOfType) { if (position >= _capacity) { - throw new ArgumentOutOfRangeException(nameof(position), Environment.GetResourceString("ArgumentOutOfRange_PositionLessThanCapacityRequired")); + throw new ArgumentOutOfRangeException(nameof(position), SR.ArgumentOutOfRange_PositionLessThanCapacityRequired); } else { - throw new ArgumentException(Environment.GetResourceString("Argument_NotEnoughBytesToRead"), nameof(position)); + throw new ArgumentException(SR.Argument_NotEnoughBytesToRead, nameof(position)); } } } @@ -1059,26 +1059,26 @@ namespace System.IO { if (!_isOpen) { - throw new ObjectDisposedException("UnmanagedMemoryAccessor", Environment.GetResourceString("ObjectDisposed_ViewAccessorClosed")); + throw new ObjectDisposedException("UnmanagedMemoryAccessor", SR.ObjectDisposed_ViewAccessorClosed); } if (!CanWrite) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_Writing")); + throw new NotSupportedException(SR.NotSupported_Writing); } if (position < 0) { - throw new ArgumentOutOfRangeException(nameof(position), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(position), SR.ArgumentOutOfRange_NeedNonNegNum); } Contract.EndContractBlock(); if (position > _capacity - sizeOfType) { if (position >= _capacity) { - throw new ArgumentOutOfRangeException(nameof(position), Environment.GetResourceString("ArgumentOutOfRange_PositionLessThanCapacityRequired")); + throw new ArgumentOutOfRangeException(nameof(position), SR.ArgumentOutOfRange_PositionLessThanCapacityRequired); } else { - throw new ArgumentException(Environment.GetResourceString("Argument_NotEnoughBytesToWrite", nameof(Byte)), nameof(position)); + throw new ArgumentException(SR.Format(SR.Argument_NotEnoughBytesToWrite, nameof(Byte)), nameof(position)); } } } diff --git a/src/mscorlib/src/System/IO/UnmanagedMemoryStream.cs b/src/mscorlib/src/System/IO/UnmanagedMemoryStream.cs index 086c19b..f21fe47 100644 --- a/src/mscorlib/src/System/IO/UnmanagedMemoryStream.cs +++ b/src/mscorlib/src/System/IO/UnmanagedMemoryStream.cs @@ -126,15 +126,15 @@ namespace System.IO } if (offset < 0) { - throw new ArgumentOutOfRangeException(nameof(offset), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum); } if (length < 0) { - throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_NeedNonNegNum); } if (buffer.ByteLength < (ulong)(offset + length)) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidSafeBufferOffLen")); + throw new ArgumentException(SR.Argument_InvalidSafeBufferOffLen); } if (access < FileAccess.Read || access > FileAccess.ReadWrite) { @@ -144,7 +144,7 @@ namespace System.IO if (_isOpen) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CalledTwice")); + throw new InvalidOperationException(SR.InvalidOperation_CalledTwice); } // check for wraparound @@ -157,7 +157,7 @@ namespace System.IO buffer.AcquirePointer(ref pointer); if ((pointer + offset + length) < pointer) { - throw new ArgumentException(Environment.GetResourceString("ArgumentOutOfRange_UnmanagedMemStreamWrapAround")); + throw new ArgumentException(SR.ArgumentOutOfRange_UnmanagedMemStreamWrapAround); } } finally @@ -195,17 +195,17 @@ namespace System.IO if (pointer == null) throw new ArgumentNullException(nameof(pointer)); if (length < 0 || capacity < 0) - throw new ArgumentOutOfRangeException((length < 0) ? nameof(length) : nameof(capacity), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException((length < 0) ? nameof(length) : nameof(capacity), SR.ArgumentOutOfRange_NeedNonNegNum); if (length > capacity) - throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_LengthGreaterThanCapacity")); + throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_LengthGreaterThanCapacity); Contract.EndContractBlock(); // Check for wraparound. if (((byte*)((long)pointer + capacity)) < pointer) - throw new ArgumentOutOfRangeException(nameof(capacity), Environment.GetResourceString("ArgumentOutOfRange_UnmanagedMemStreamWrapAround")); + throw new ArgumentOutOfRangeException(nameof(capacity), SR.ArgumentOutOfRange_UnmanagedMemStreamWrapAround); if (access < FileAccess.Read || access > FileAccess.ReadWrite) - throw new ArgumentOutOfRangeException(nameof(access), Environment.GetResourceString("ArgumentOutOfRange_Enum")); + throw new ArgumentOutOfRangeException(nameof(access), SR.ArgumentOutOfRange_Enum); if (_isOpen) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CalledTwice")); + throw new InvalidOperationException(SR.InvalidOperation_CalledTwice); _mem = pointer; _offset = 0; @@ -295,7 +295,7 @@ namespace System.IO set { if (value < 0) - throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); if (!CanSeek) __Error.StreamIsClosed(); @@ -303,7 +303,7 @@ namespace System.IO unsafe { // On 32 bit machines, ensure we don't wrap around. if (value > (long) Int32.MaxValue || _mem + value < _mem) - throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_StreamLength")); + throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_StreamLength); } #endif Interlocked.Exchange(ref _position, value); @@ -317,13 +317,13 @@ namespace System.IO { if (_buffer != null) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_UmsSafeBuffer")); + throw new NotSupportedException(SR.NotSupported_UmsSafeBuffer); } // Use a temp to avoid a race long pos = Interlocked.Read(ref _position); if (pos > _capacity) - throw new IndexOutOfRangeException(Environment.GetResourceString("IndexOutOfRange_UMSPosition")); + throw new IndexOutOfRangeException(SR.IndexOutOfRange_UMSPosition); byte* ptr = _mem + pos; if (!_isOpen) __Error.StreamIsClosed(); return ptr; @@ -331,15 +331,15 @@ namespace System.IO set { if (_buffer != null) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_UmsSafeBuffer")); + throw new NotSupportedException(SR.NotSupported_UmsSafeBuffer); if (!_isOpen) __Error.StreamIsClosed(); // Note: subtracting pointers returns an Int64. Working around // to avoid hitting compiler warning CS0652 on this line. if (new IntPtr(value - _mem).ToInt64() > UnmanagedMemStreamMaxLength) - throw new ArgumentOutOfRangeException("offset", Environment.GetResourceString("ArgumentOutOfRange_UnmanagedMemStreamLength")); + throw new ArgumentOutOfRangeException("offset", SR.ArgumentOutOfRange_UnmanagedMemStreamLength); if (value < _mem) - throw new IOException(Environment.GetResourceString("IO.IO_SeekBeforeBegin")); + throw new IOException(SR.IO_SeekBeforeBegin); Interlocked.Exchange(ref _position, value - _mem); } @@ -350,7 +350,7 @@ namespace System.IO get { if (_buffer != null) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_UmsSafeBuffer")); + throw new NotSupportedException(SR.NotSupported_UmsSafeBuffer); return _mem; } @@ -359,13 +359,13 @@ namespace System.IO public override int Read([In, Out] byte[] buffer, int offset, int count) { if (buffer == null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); if (offset < 0) - throw new ArgumentOutOfRangeException(nameof(offset), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum); if (count < 0) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); if (buffer.Length - offset < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); // Keep this in sync with contract validation in ReadAsync if (!_isOpen) __Error.StreamIsClosed(); @@ -421,13 +421,13 @@ namespace System.IO public override Task ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) { if (buffer == null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); if (offset < 0) - throw new ArgumentOutOfRangeException(nameof(offset), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum); if (count < 0) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); if (buffer.Length - offset < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); // contract validation copied from Read(...) if (cancellationToken.IsCancellationRequested) @@ -491,31 +491,31 @@ namespace System.IO { if (!_isOpen) __Error.StreamIsClosed(); if (offset > UnmanagedMemStreamMaxLength) - throw new ArgumentOutOfRangeException(nameof(offset), Environment.GetResourceString("ArgumentOutOfRange_UnmanagedMemStreamLength")); + throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_UnmanagedMemStreamLength); switch (loc) { case SeekOrigin.Begin: if (offset < 0) - throw new IOException(Environment.GetResourceString("IO.IO_SeekBeforeBegin")); + throw new IOException(SR.IO_SeekBeforeBegin); Interlocked.Exchange(ref _position, offset); break; case SeekOrigin.Current: long pos = Interlocked.Read(ref _position); if (offset + pos < 0) - throw new IOException(Environment.GetResourceString("IO.IO_SeekBeforeBegin")); + throw new IOException(SR.IO_SeekBeforeBegin); Interlocked.Exchange(ref _position, offset + pos); break; case SeekOrigin.End: long len = Interlocked.Read(ref _length); if (len + offset < 0) - throw new IOException(Environment.GetResourceString("IO.IO_SeekBeforeBegin")); + throw new IOException(SR.IO_SeekBeforeBegin); Interlocked.Exchange(ref _position, len + offset); break; default: - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidSeekOrigin")); + throw new ArgumentException(SR.Argument_InvalidSeekOrigin); } long finalPos = Interlocked.Read(ref _position); @@ -526,15 +526,15 @@ namespace System.IO public override void SetLength(long value) { if (value < 0) - throw new ArgumentOutOfRangeException("length", Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException("length", SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); if (_buffer != null) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_UmsSafeBuffer")); + throw new NotSupportedException(SR.NotSupported_UmsSafeBuffer); if (!_isOpen) __Error.StreamIsClosed(); if (!CanWrite) __Error.WriteNotSupported(); if (value > _capacity) - throw new IOException(Environment.GetResourceString("IO.IO_FixedCapacity")); + throw new IOException(SR.IO_FixedCapacity); long pos = Interlocked.Read(ref _position); long len = Interlocked.Read(ref _length); @@ -555,13 +555,13 @@ namespace System.IO public override void Write(byte[] buffer, int offset, int count) { if (buffer == null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); if (offset < 0) - throw new ArgumentOutOfRangeException(nameof(offset), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum); if (count < 0) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); if (buffer.Length - offset < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); // Keep contract validation in sync with WriteAsync(..) if (!_isOpen) __Error.StreamIsClosed(); @@ -572,11 +572,11 @@ namespace System.IO long n = pos + count; // Check for overflow if (n < 0) - throw new IOException(Environment.GetResourceString("IO.IO_StreamTooLong")); + throw new IOException(SR.IO_StreamTooLong); if (n > _capacity) { - throw new NotSupportedException(Environment.GetResourceString("IO.IO_FixedCapacity")); + throw new NotSupportedException(SR.IO_FixedCapacity); } if (_buffer == null) @@ -607,7 +607,7 @@ namespace System.IO long bytesLeft = _capacity - pos; if (bytesLeft < count) { - throw new ArgumentException(Environment.GetResourceString("Arg_BufferTooSmall")); + throw new ArgumentException(SR.Arg_BufferTooSmall); } byte* pointer = null; @@ -638,13 +638,13 @@ namespace System.IO public override Task WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) { if (buffer == null) - throw new ArgumentNullException(nameof(buffer), Environment.GetResourceString("ArgumentNull_Buffer")); + throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); if (offset < 0) - throw new ArgumentOutOfRangeException(nameof(offset), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum); if (count < 0) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); if (buffer.Length - offset < count) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidOffLen")); + throw new ArgumentException(SR.Argument_InvalidOffLen); Contract.EndContractBlock(); // contract validation copied from Write(..) if (cancellationToken.IsCancellationRequested) @@ -675,10 +675,10 @@ namespace System.IO { // Check for overflow if (n < 0) - throw new IOException(Environment.GetResourceString("IO.IO_StreamTooLong")); + throw new IOException(SR.IO_StreamTooLong); if (n > _capacity) - throw new NotSupportedException(Environment.GetResourceString("IO.IO_FixedCapacity")); + throw new NotSupportedException(SR.IO_FixedCapacity); // Check to see whether we are now expanding the stream and must // zero any memory in the middle. diff --git a/src/mscorlib/src/System/IO/UnmanagedMemoryStreamWrapper.cs b/src/mscorlib/src/System/IO/UnmanagedMemoryStreamWrapper.cs index 04d5be3..86e4707 100644 --- a/src/mscorlib/src/System/IO/UnmanagedMemoryStreamWrapper.cs +++ b/src/mscorlib/src/System/IO/UnmanagedMemoryStreamWrapper.cs @@ -70,7 +70,7 @@ namespace System.IO public override byte[] GetBuffer() { - throw new UnauthorizedAccessException(Environment.GetResourceString("UnauthorizedAccess_MemStreamBuffer")); + throw new UnauthorizedAccessException(SR.UnauthorizedAccess_MemStreamBuffer); } public override bool TryGetBuffer(out ArraySegment buffer) @@ -88,7 +88,7 @@ namespace System.IO [SuppressMessage("Microsoft.Contracts", "CC1055")] // Skip extra error checking to avoid *potential* AppCompat problems. set { - throw new IOException(Environment.GetResourceString("IO.IO_FixedCapacity")); + throw new IOException(SR.IO_FixedCapacity); } } @@ -151,7 +151,7 @@ namespace System.IO public unsafe override void WriteTo(Stream stream) { if (stream == null) - throw new ArgumentNullException(nameof(stream), Environment.GetResourceString("ArgumentNull_Stream")); + throw new ArgumentNullException(nameof(stream), SR.ArgumentNull_Stream); Contract.EndContractBlock(); if (!_unmanagedStream._isOpen) __Error.StreamIsClosed(); @@ -178,19 +178,19 @@ namespace System.IO throw new ArgumentNullException(nameof(destination)); if (bufferSize <= 0) - throw new ArgumentOutOfRangeException(nameof(bufferSize), Environment.GetResourceString("ArgumentOutOfRange_NeedPosNum")); + throw new ArgumentOutOfRangeException(nameof(bufferSize), SR.ArgumentOutOfRange_NeedPosNum); if (!CanRead && !CanWrite) - throw new ObjectDisposedException(null, Environment.GetResourceString("ObjectDisposed_StreamClosed")); + throw new ObjectDisposedException(null, SR.ObjectDisposed_StreamClosed); if (!destination.CanRead && !destination.CanWrite) - throw new ObjectDisposedException(nameof(destination), Environment.GetResourceString("ObjectDisposed_StreamClosed")); + throw new ObjectDisposedException(nameof(destination), SR.ObjectDisposed_StreamClosed); if (!CanRead) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_UnreadableStream")); + throw new NotSupportedException(SR.NotSupported_UnreadableStream); if (!destination.CanWrite) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_UnwritableStream")); + throw new NotSupportedException(SR.NotSupported_UnwritableStream); Contract.EndContractBlock(); diff --git a/src/mscorlib/src/System/IO/__Error.cs b/src/mscorlib/src/System/IO/__Error.cs index 14c8eb9..70f8326 100644 --- a/src/mscorlib/src/System/IO/__Error.cs +++ b/src/mscorlib/src/System/IO/__Error.cs @@ -30,49 +30,49 @@ namespace System.IO { internal static void EndOfFile() { - throw new EndOfStreamException(Environment.GetResourceString("IO.EOF_ReadBeyondEOF")); + throw new EndOfStreamException(SR.IO_EOF_ReadBeyondEOF); } internal static void FileNotOpen() { - throw new ObjectDisposedException(null, Environment.GetResourceString("ObjectDisposed_FileClosed")); + throw new ObjectDisposedException(null, SR.ObjectDisposed_FileClosed); } internal static void StreamIsClosed() { - throw new ObjectDisposedException(null, Environment.GetResourceString("ObjectDisposed_StreamClosed")); + throw new ObjectDisposedException(null, SR.ObjectDisposed_StreamClosed); } internal static void MemoryStreamNotExpandable() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_MemStreamNotExpandable")); + throw new NotSupportedException(SR.NotSupported_MemStreamNotExpandable); } internal static void ReaderClosed() { - throw new ObjectDisposedException(null, Environment.GetResourceString("ObjectDisposed_ReaderClosed")); + throw new ObjectDisposedException(null, SR.ObjectDisposed_ReaderClosed); } internal static void ReadNotSupported() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_UnreadableStream")); + throw new NotSupportedException(SR.NotSupported_UnreadableStream); } internal static void WrongAsyncResult() { - throw new ArgumentException(Environment.GetResourceString("Arg_WrongAsyncResult")); + throw new ArgumentException(SR.Arg_WrongAsyncResult); } internal static void EndReadCalledTwice() { // Should ideally be InvalidOperationExc but we can't maitain parity with Stream and FileStream without some work - throw new ArgumentException(Environment.GetResourceString("InvalidOperation_EndReadCalledMultiple")); + throw new ArgumentException(SR.InvalidOperation_EndReadCalledMultiple); } internal static void EndWriteCalledTwice() { // Should ideally be InvalidOperationExc but we can't maintain parity with Stream and FileStream without some work - throw new ArgumentException(Environment.GetResourceString("InvalidOperation_EndWriteCalledMultiple")); + throw new ArgumentException(SR.InvalidOperation_EndWriteCalledMultiple); } // Given a possible fully qualified path, ensure that we have path @@ -124,7 +124,7 @@ namespace System.IO if (!safeToReturn) { if (PathInternal.IsDirectorySeparator(path[path.Length - 1])) - path = Environment.GetResourceString("IO.IO_NoPermissionToDirectoryName"); + path = SR.IO_NoPermissionToDirectoryName; else path = Path.GetFileName(path); } @@ -153,46 +153,46 @@ namespace System.IO { case Win32Native.ERROR_FILE_NOT_FOUND: if (str.Length == 0) - throw new FileNotFoundException(Environment.GetResourceString("IO.FileNotFound")); + throw new FileNotFoundException(SR.IO_FileNotFound); else - throw new FileNotFoundException(Environment.GetResourceString("IO.FileNotFound_FileName", str), str); + throw new FileNotFoundException(SR.Format(SR.IO_FileNotFound_FileName, str), str); case Win32Native.ERROR_PATH_NOT_FOUND: if (str.Length == 0) - throw new DirectoryNotFoundException(Environment.GetResourceString("IO.PathNotFound_NoPathName")); + throw new DirectoryNotFoundException(SR.IO_PathNotFound_NoPathName); else - throw new DirectoryNotFoundException(Environment.GetResourceString("IO.PathNotFound_Path", str)); + throw new DirectoryNotFoundException(SR.Format(SR.IO_PathNotFound_Path, str)); case Win32Native.ERROR_ACCESS_DENIED: if (str.Length == 0) - throw new UnauthorizedAccessException(Environment.GetResourceString("UnauthorizedAccess_IODenied_NoPathName")); + throw new UnauthorizedAccessException(SR.UnauthorizedAccess_IODenied_NoPathName); else - throw new UnauthorizedAccessException(Environment.GetResourceString("UnauthorizedAccess_IODenied_Path", str)); + throw new UnauthorizedAccessException(SR.Format(SR.UnauthorizedAccess_IODenied_Path, str)); case Win32Native.ERROR_ALREADY_EXISTS: if (str.Length == 0) goto default; - throw new IOException(Environment.GetResourceString("IO.IO_AlreadyExists_Name", str), Win32Native.MakeHRFromErrorCode(errorCode), maybeFullPath); + throw new IOException(SR.Format(SR.IO_AlreadyExists_Name, str), Win32Native.MakeHRFromErrorCode(errorCode), maybeFullPath); case Win32Native.ERROR_FILENAME_EXCED_RANGE: - throw new PathTooLongException(Environment.GetResourceString("IO.PathTooLong")); + throw new PathTooLongException(SR.IO_PathTooLong); case Win32Native.ERROR_INVALID_DRIVE: - throw new DriveNotFoundException(Environment.GetResourceString("IO.DriveNotFound_Drive", str)); + throw new DriveNotFoundException(SR.Format(SR.IO_DriveNotFound_Drive, str)); case Win32Native.ERROR_INVALID_PARAMETER: throw new IOException(Win32Native.GetMessage(errorCode), Win32Native.MakeHRFromErrorCode(errorCode), maybeFullPath); case Win32Native.ERROR_SHARING_VIOLATION: if (str.Length == 0) - throw new IOException(Environment.GetResourceString("IO.IO_SharingViolation_NoFileName"), Win32Native.MakeHRFromErrorCode(errorCode), maybeFullPath); + throw new IOException(SR.IO_SharingViolation_NoFileName, Win32Native.MakeHRFromErrorCode(errorCode), maybeFullPath); else - throw new IOException(Environment.GetResourceString("IO.IO_SharingViolation_File", str), Win32Native.MakeHRFromErrorCode(errorCode), maybeFullPath); + throw new IOException(SR.Format(SR.IO_SharingViolation_File, str), Win32Native.MakeHRFromErrorCode(errorCode), maybeFullPath); case Win32Native.ERROR_FILE_EXISTS: if (str.Length == 0) goto default; - throw new IOException(Environment.GetResourceString("IO.IO_FileExists_Name", str), Win32Native.MakeHRFromErrorCode(errorCode), maybeFullPath); + throw new IOException(SR.Format(SR.IO_FileExists_Name, str), Win32Native.MakeHRFromErrorCode(errorCode), maybeFullPath); case Win32Native.ERROR_OPERATION_ABORTED: throw new OperationCanceledException(); @@ -204,7 +204,7 @@ namespace System.IO internal static void WriteNotSupported() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_UnwritableStream")); + throw new NotSupportedException(SR.NotSupported_UnwritableStream); } // From WinError.h diff --git a/src/mscorlib/src/System/Int16.cs b/src/mscorlib/src/System/Int16.cs index 89b081b..e05ce44 100644 --- a/src/mscorlib/src/System/Int16.cs +++ b/src/mscorlib/src/System/Int16.cs @@ -48,7 +48,7 @@ namespace System return m_value - ((Int16)value).m_value; } - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeInt16")); + throw new ArgumentException(SR.Arg_MustBeInt16); } public int CompareTo(Int16 value) @@ -145,7 +145,7 @@ namespace System } catch (OverflowException e) { - throw new OverflowException(Environment.GetResourceString("Overflow_Int16"), e); + throw new OverflowException(SR.Overflow_Int16, e); } // We need this check here since we don't allow signs to specified in hex numbers. So we fixup the result @@ -154,12 +154,12 @@ namespace System { // We are parsing a hexadecimal number if ((i < 0) || (i > UInt16.MaxValue)) { - throw new OverflowException(Environment.GetResourceString("Overflow_Int16")); + throw new OverflowException(SR.Overflow_Int16); } return (short)i; } - if (i < MinValue || i > MaxValue) throw new OverflowException(Environment.GetResourceString("Overflow_Int16")); + if (i < MinValue || i > MaxValue) throw new OverflowException(SR.Overflow_Int16); return (short)i; } @@ -294,7 +294,7 @@ namespace System /// DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Int16", "DateTime")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Int16", "DateTime")); } /// diff --git a/src/mscorlib/src/System/Int32.cs b/src/mscorlib/src/System/Int32.cs index cbbd5f9..70a2a07 100644 --- a/src/mscorlib/src/System/Int32.cs +++ b/src/mscorlib/src/System/Int32.cs @@ -51,7 +51,7 @@ namespace System if (m_value > i) return 1; return 0; } - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeInt32")); + throw new ArgumentException(SR.Arg_MustBeInt32); } public int CompareTo(int value) @@ -256,7 +256,7 @@ namespace System /// DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Int32", "DateTime")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Int32", "DateTime")); } /// diff --git a/src/mscorlib/src/System/Int64.cs b/src/mscorlib/src/System/Int64.cs index 9e68c42..56d01a5 100644 --- a/src/mscorlib/src/System/Int64.cs +++ b/src/mscorlib/src/System/Int64.cs @@ -50,7 +50,7 @@ namespace System if (m_value > i) return 1; return 0; } - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeInt64")); + throw new ArgumentException(SR.Arg_MustBeInt64); } public int CompareTo(Int64 value) @@ -235,7 +235,7 @@ namespace System /// DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Int64", "DateTime")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Int64", "DateTime")); } /// diff --git a/src/mscorlib/src/System/IntPtr.cs b/src/mscorlib/src/System/IntPtr.cs index 17a2d38..28f1b1b 100644 --- a/src/mscorlib/src/System/IntPtr.cs +++ b/src/mscorlib/src/System/IntPtr.cs @@ -69,7 +69,7 @@ namespace System if (Size == 4 && (l > Int32.MaxValue || l < Int32.MinValue)) { - throw new ArgumentException(Environment.GetResourceString("Serialization_InvalidPtrValue")); + throw new ArgumentException(SR.Serialization_InvalidPtrValue); } m_value = (void*)l; diff --git a/src/mscorlib/src/System/Math.cs b/src/mscorlib/src/System/Math.cs index 4cdb794..6f7d731 100644 --- a/src/mscorlib/src/System/Math.cs +++ b/src/mscorlib/src/System/Math.cs @@ -113,7 +113,7 @@ namespace System public static double Round(double value, int digits) { if ((digits < 0) || (digits > maxRoundingDigits)) - throw new ArgumentOutOfRangeException(nameof(digits), Environment.GetResourceString("ArgumentOutOfRange_RoundingDigits")); + throw new ArgumentOutOfRangeException(nameof(digits), SR.ArgumentOutOfRange_RoundingDigits); Contract.EndContractBlock(); return InternalRound(value, digits, MidpointRounding.ToEven); } @@ -126,10 +126,10 @@ namespace System public static double Round(double value, int digits, MidpointRounding mode) { if ((digits < 0) || (digits > maxRoundingDigits)) - throw new ArgumentOutOfRangeException(nameof(digits), Environment.GetResourceString("ArgumentOutOfRange_RoundingDigits")); + throw new ArgumentOutOfRangeException(nameof(digits), SR.ArgumentOutOfRange_RoundingDigits); if (mode < MidpointRounding.ToEven || mode > MidpointRounding.AwayFromZero) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidEnumValue", mode, nameof(MidpointRounding)), nameof(mode)); + throw new ArgumentException(SR.Format(SR.Argument_InvalidEnumValue, mode, nameof(MidpointRounding)), nameof(mode)); } Contract.EndContractBlock(); return InternalRound(value, digits, mode); @@ -243,7 +243,7 @@ namespace System { Contract.Requires(value < 0, "AbsHelper should only be called for negative values! (workaround for JIT inlining)"); if (value == SByte.MinValue) - throw new OverflowException(Environment.GetResourceString("Overflow_NegateTwosCompNum")); + throw new OverflowException(SR.Overflow_NegateTwosCompNum); Contract.EndContractBlock(); return ((sbyte)(-value)); } @@ -260,7 +260,7 @@ namespace System { Contract.Requires(value < 0, "AbsHelper should only be called for negative values! (workaround for JIT inlining)"); if (value == Int16.MinValue) - throw new OverflowException(Environment.GetResourceString("Overflow_NegateTwosCompNum")); + throw new OverflowException(SR.Overflow_NegateTwosCompNum); Contract.EndContractBlock(); return (short)-value; } @@ -277,7 +277,7 @@ namespace System { Contract.Requires(value < 0, "AbsHelper should only be called for negative values! (workaround for JIT inlining)"); if (value == Int32.MinValue) - throw new OverflowException(Environment.GetResourceString("Overflow_NegateTwosCompNum")); + throw new OverflowException(SR.Overflow_NegateTwosCompNum); Contract.EndContractBlock(); return -value; } @@ -294,7 +294,7 @@ namespace System { Contract.Requires(value < 0, "AbsHelper should only be called for negative values! (workaround for JIT inlining)"); if (value == Int64.MinValue) - throw new OverflowException(Environment.GetResourceString("Overflow_NegateTwosCompNum")); + throw new OverflowException(SR.Overflow_NegateTwosCompNum); Contract.EndContractBlock(); return -value; } @@ -631,7 +631,7 @@ namespace System private static void ThrowMinMaxException(T min, T max) { - throw new ArgumentException(Environment.GetResourceString("Argument_MinMaxValue", min, max)); + throw new ArgumentException(SR.Format(SR.Argument_MinMaxValue, min, max)); } /*=====================================Log====================================== @@ -713,7 +713,7 @@ namespace System return 1; else if (value == 0) return 0; - throw new ArithmeticException(Environment.GetResourceString("Arithmetic_NaN")); + throw new ArithmeticException(SR.Arithmetic_NaN); } public static int Sign(double value) @@ -724,7 +724,7 @@ namespace System return 1; else if (value == 0) return 0; - throw new ArithmeticException(Environment.GetResourceString("Arithmetic_NaN")); + throw new ArithmeticException(SR.Arithmetic_NaN); } public static int Sign(Decimal value) diff --git a/src/mscorlib/src/System/MathF.cs b/src/mscorlib/src/System/MathF.cs index 2abac7b..60669a4 100644 --- a/src/mscorlib/src/System/MathF.cs +++ b/src/mscorlib/src/System/MathF.cs @@ -159,7 +159,7 @@ namespace System { if ((digits < 0) || (digits > maxRoundingDigits)) { - throw new ArgumentOutOfRangeException(nameof(digits), Environment.GetResourceString("ArgumentOutOfRange_RoundingDigits")); + throw new ArgumentOutOfRangeException(nameof(digits), SR.ArgumentOutOfRange_RoundingDigits); } Contract.EndContractBlock(); @@ -170,12 +170,12 @@ namespace System { if ((digits < 0) || (digits > maxRoundingDigits)) { - throw new ArgumentOutOfRangeException(nameof(digits), Environment.GetResourceString("ArgumentOutOfRange_RoundingDigits")); + throw new ArgumentOutOfRangeException(nameof(digits), SR.ArgumentOutOfRange_RoundingDigits); } if (mode < MidpointRounding.ToEven || mode > MidpointRounding.AwayFromZero) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidEnumx", mode, nameof(MidpointRounding)), nameof(mode)); + throw new ArgumentException(SR.Format(SR.Argument_InvalidEnum, mode, nameof(MidpointRounding)), nameof(mode)); } Contract.EndContractBlock(); @@ -186,7 +186,7 @@ namespace System { if (mode < MidpointRounding.ToEven || mode > MidpointRounding.AwayFromZero) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidEnumx", mode, nameof(MidpointRounding)), nameof(mode)); + throw new ArgumentException(SR.Format(SR.Argument_InvalidEnum, mode, nameof(MidpointRounding)), nameof(mode)); } Contract.EndContractBlock(); diff --git a/src/mscorlib/src/System/MissingFieldException.cs b/src/mscorlib/src/System/MissingFieldException.cs index 15d1a68..65a9726 100644 --- a/src/mscorlib/src/System/MissingFieldException.cs +++ b/src/mscorlib/src/System/MissingFieldException.cs @@ -22,7 +22,7 @@ namespace System public class MissingFieldException : MissingMemberException, ISerializable { public MissingFieldException() - : base(Environment.GetResourceString("Arg_MissingFieldException")) + : base(SR.Arg_MissingFieldException) { SetErrorCode(__HResults.COR_E_MISSINGFIELD); } @@ -54,9 +54,7 @@ namespace System else { // do any desired fixups to classname here. - return Environment.GetResourceString("MissingField_Name", - (Signature != null ? FormatSignature(Signature) + " " : "") + - ClassName + "." + MemberName); + return SR.Format(SR.MissingField_Name, (Signature != null ? FormatSignature(Signature) + " " : "") + ClassName + "." + MemberName); } } } diff --git a/src/mscorlib/src/System/MissingMemberException.cs b/src/mscorlib/src/System/MissingMemberException.cs index be5ac83..d40aa53 100644 --- a/src/mscorlib/src/System/MissingMemberException.cs +++ b/src/mscorlib/src/System/MissingMemberException.cs @@ -26,7 +26,7 @@ namespace System public class MissingMemberException : MemberAccessException, ISerializable { public MissingMemberException() - : base(Environment.GetResourceString("Arg_MissingMemberException")) + : base(SR.Arg_MissingMemberException) { SetErrorCode(__HResults.COR_E_MISSINGMEMBER); } @@ -61,9 +61,7 @@ namespace System else { // do any desired fixups to classname here. - return Environment.GetResourceString("MissingMember_Name", - ClassName + "." + MemberName + - (Signature != null ? " " + FormatSignature(Signature) : "")); + return SR.Format(SR.MissingMember_Name, ClassName + "." + MemberName + (Signature != null ? " " + FormatSignature(Signature) : "")); } } } diff --git a/src/mscorlib/src/System/MissingMethodException.cs b/src/mscorlib/src/System/MissingMethodException.cs index 81b2f61..c17ab8e 100644 --- a/src/mscorlib/src/System/MissingMethodException.cs +++ b/src/mscorlib/src/System/MissingMethodException.cs @@ -24,7 +24,7 @@ namespace System public class MissingMethodException : MissingMemberException, ISerializable { public MissingMethodException() - : base(Environment.GetResourceString("Arg_MissingMethodException")) + : base(SR.Arg_MissingMethodException) { SetErrorCode(__HResults.COR_E_MISSINGMETHOD); } @@ -56,9 +56,7 @@ namespace System else { // do any desired fixups to classname here. - return Environment.GetResourceString("MissingMethod_Name", - ClassName + "." + MemberName + - (Signature != null ? " " + FormatSignature(Signature) : "")); + return SR.Format(SR.MissingMethod_Name, ClassName + "." + MemberName + (Signature != null ? " " + FormatSignature(Signature) : "")); } } } diff --git a/src/mscorlib/src/System/MulticastDelegate.cs b/src/mscorlib/src/System/MulticastDelegate.cs index 6d4d288..440c9a6 100644 --- a/src/mscorlib/src/System/MulticastDelegate.cs +++ b/src/mscorlib/src/System/MulticastDelegate.cs @@ -59,11 +59,11 @@ namespace System // One can only create delegates on RuntimeMethodInfo and DynamicMethod. // If it is not a RuntimeMethodInfo (must be a DynamicMethod) or if it is an unmanaged function pointer, throw if (!(method is RuntimeMethodInfo) || IsUnmanagedFunctionPtr()) - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidDelegateType")); + throw new SerializationException(SR.Serialization_InvalidDelegateType); // We can't deal with secure delegates either. if (!InvocationListLogicallyNull() && !_invocationCount.IsNull() && !_methodPtrAux.IsNull()) - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidDelegateType")); + throw new SerializationException(SR.Serialization_InvalidDelegateType); DelegateSerializationHolder.GetDelegateSerializationInfo(info, this.GetType(), Target, method, targetIndex); } @@ -91,7 +91,7 @@ namespace System } // if nothing was serialized it is a delegate over a DynamicMethod, so just throw if (nextDe == null) - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidDelegateType")); + throw new SerializationException(SR.Serialization_InvalidDelegateType); } } @@ -266,7 +266,7 @@ namespace System // Verify that the types are the same... if (!InternalEqualTypes(this, follow)) - throw new ArgumentException(Environment.GetResourceString("Arg_DlgtTypeMis")); + throw new ArgumentException(SR.Arg_DlgtTypeMis); MulticastDelegate dFollow = (MulticastDelegate)follow; Object[] resultList; @@ -592,7 +592,7 @@ namespace System [System.Diagnostics.DebuggerNonUserCode] private void ThrowNullThisInDelegateToInstance() { - throw new ArgumentException(Environment.GetResourceString("Arg_DlgtNullInst")); + throw new ArgumentException(SR.Arg_DlgtNullInst); } [System.Diagnostics.DebuggerNonUserCode] diff --git a/src/mscorlib/src/System/Number.cs b/src/mscorlib/src/System/Number.cs index d7a1bc1..b30d4e6 100644 --- a/src/mscorlib/src/System/Number.cs +++ b/src/mscorlib/src/System/Number.cs @@ -676,7 +676,7 @@ namespace System if (!NumberBufferToDecimal(number.PackForNative(), ref result)) { - throw new OverflowException(Environment.GetResourceString("Overflow_Decimal")); + throw new OverflowException(SR.Overflow_Decimal); } return result; } @@ -710,12 +710,12 @@ namespace System { return Double.NaN; } - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); } if (!NumberBufferToDouble(number.PackForNative(), ref d)) { - throw new OverflowException(Environment.GetResourceString("Overflow_Double")); + throw new OverflowException(SR.Overflow_Double); } return d; @@ -733,14 +733,14 @@ namespace System { if (!HexNumberToInt32(ref number, ref i)) { - throw new OverflowException(Environment.GetResourceString("Overflow_Int32")); + throw new OverflowException(SR.Overflow_Int32); } } else { if (!NumberToInt32(ref number, ref i)) { - throw new OverflowException(Environment.GetResourceString("Overflow_Int32")); + throw new OverflowException(SR.Overflow_Int32); } } return i; @@ -758,14 +758,14 @@ namespace System { if (!HexNumberToInt64(ref number, ref i)) { - throw new OverflowException(Environment.GetResourceString("Overflow_Int64")); + throw new OverflowException(SR.Overflow_Int64); } } else { if (!NumberToInt64(ref number, ref i)) { - throw new OverflowException(Environment.GetResourceString("Overflow_Int64")); + throw new OverflowException(SR.Overflow_Int64); } } return i; @@ -1014,17 +1014,17 @@ namespace System { return Single.NaN; } - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); } if (!NumberBufferToDouble(number.PackForNative(), ref d)) { - throw new OverflowException(Environment.GetResourceString("Overflow_Single")); + throw new OverflowException(SR.Overflow_Single); } Single castSingle = (Single)d; if (Single.IsInfinity(castSingle)) { - throw new OverflowException(Environment.GetResourceString("Overflow_Single")); + throw new OverflowException(SR.Overflow_Single); } return castSingle; } @@ -1041,14 +1041,14 @@ namespace System { if (!HexNumberToUInt32(ref number, ref i)) { - throw new OverflowException(Environment.GetResourceString("Overflow_UInt32")); + throw new OverflowException(SR.Overflow_UInt32); } } else { if (!NumberToUInt32(ref number, ref i)) { - throw new OverflowException(Environment.GetResourceString("Overflow_UInt32")); + throw new OverflowException(SR.Overflow_UInt32); } } @@ -1066,14 +1066,14 @@ namespace System { if (!HexNumberToUInt64(ref number, ref i)) { - throw new OverflowException(Environment.GetResourceString("Overflow_UInt64")); + throw new OverflowException(SR.Overflow_UInt64); } } else { if (!NumberToUInt64(ref number, ref i)) { - throw new OverflowException(Environment.GetResourceString("Overflow_UInt64")); + throw new OverflowException(SR.Overflow_UInt64); } } return i; @@ -1093,7 +1093,7 @@ namespace System if (!ParseNumber(ref p, options, ref number, null, info, parseDecimal) || (p - stringPointer < str.Length && !TrailingZeros(str, (int)(p - stringPointer)))) { - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); } } } diff --git a/src/mscorlib/src/System/Object.cs b/src/mscorlib/src/System/Object.cs index 643e1d9..3c30442 100644 --- a/src/mscorlib/src/System/Object.cs +++ b/src/mscorlib/src/System/Object.cs @@ -127,7 +127,7 @@ namespace System FieldInfo fldInfo = GetFieldInfo(typeName, fieldName); if (fldInfo.IsInitOnly) - throw new FieldAccessException(Environment.GetResourceString("FieldAccess_InitOnly")); + throw new FieldAccessException(SR.FieldAccess_InitOnly); // Make sure that the value is compatible with the type // of field diff --git a/src/mscorlib/src/System/OleAutBinder.cs b/src/mscorlib/src/System/OleAutBinder.cs index fafaa8d..1db61bb 100644 --- a/src/mscorlib/src/System/OleAutBinder.cs +++ b/src/mscorlib/src/System/OleAutBinder.cs @@ -85,7 +85,7 @@ namespace System Console.Write("Exception thrown: "); Console.WriteLine(e); #endif - throw new COMException(Environment.GetResourceString("Interop.COM_TypeMismatch"), unchecked((int)0x80020005)); + throw new COMException(SR.Interop_COM_TypeMismatch, unchecked((int)0x80020005)); } } } diff --git a/src/mscorlib/src/System/OperatingSystem.cs b/src/mscorlib/src/System/OperatingSystem.cs index d8f78d7..5eb1253 100644 --- a/src/mscorlib/src/System/OperatingSystem.cs +++ b/src/mscorlib/src/System/OperatingSystem.cs @@ -35,7 +35,7 @@ namespace System if (platform < PlatformID.Win32S || platform > PlatformID.MacOSX) { throw new ArgumentException( - Environment.GetResourceString("Arg_EnumIllegalVal", (int)platform), + SR.Format(SR.Arg_EnumIllegalVal, (int)platform), nameof(platform)); } @@ -69,7 +69,7 @@ namespace System if (_version == null) { - throw new SerializationException(Environment.GetResourceString("Serialization_MissField", "_version")); + throw new SerializationException(SR.Format(SR.Serialization_MissField, "_version")); } } diff --git a/src/mscorlib/src/System/OperationCanceledException.cs b/src/mscorlib/src/System/OperationCanceledException.cs index 371e1c0..1afd59b 100644 --- a/src/mscorlib/src/System/OperationCanceledException.cs +++ b/src/mscorlib/src/System/OperationCanceledException.cs @@ -30,7 +30,7 @@ namespace System } public OperationCanceledException() - : base(Environment.GetResourceString("OperationCanceled")) + : base(SR.OperationCanceled) { SetErrorCode(__HResults.COR_E_OPERATIONCANCELED); } diff --git a/src/mscorlib/src/System/Random.cs b/src/mscorlib/src/System/Random.cs index 507c233..a81a4f4 100644 --- a/src/mscorlib/src/System/Random.cs +++ b/src/mscorlib/src/System/Random.cs @@ -212,7 +212,7 @@ namespace System { if (minValue > maxValue) { - throw new ArgumentOutOfRangeException(nameof(minValue), Environment.GetResourceString("Argument_MinMaxValue", nameof(minValue), nameof(maxValue))); + throw new ArgumentOutOfRangeException(nameof(minValue), SR.Format(SR.Argument_MinMaxValue, nameof(minValue), nameof(maxValue))); } Contract.EndContractBlock(); @@ -237,7 +237,7 @@ namespace System { if (maxValue < 0) { - throw new ArgumentOutOfRangeException(nameof(maxValue), Environment.GetResourceString("ArgumentOutOfRange_MustBePositive", nameof(maxValue))); + throw new ArgumentOutOfRangeException(nameof(maxValue), SR.Format(SR.ArgumentOutOfRange_MustBePositive, nameof(maxValue))); } Contract.EndContractBlock(); return (int)(Sample() * maxValue); diff --git a/src/mscorlib/src/System/Reflection/AmbiguousMatchException.cs b/src/mscorlib/src/System/Reflection/AmbiguousMatchException.cs index 36091d0..11abf8d 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 86f7f42..82966db 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 202bd07..a1b9034 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 c12187d..0c8271b 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 83ef541..7f88e0c 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 2ff87a0..6d9cb0d 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() != 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 a2fb2b6..529ba54 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 185d204..3ca9b2e 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 cbc7345..cf5bd11 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 ec725ac..b592053 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 953b39a..ef4d1ca 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 aae90c2..55aa5c5 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 ae28212..d0e9d34 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 4538988..dd5ffa9 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 fe32417..4021410 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 4216507..c04c3c8 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 ee4c68e..7388258 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 ad5cc70..2d0a9b4 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 13ae4ee..d92d822 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() != 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() != 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() != 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 c0af6ba..4f1b8eb 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 da087dc..6dbcba2 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 eb5df8c..fd1a8e7 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 d82e271..4c4cd15 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 bfe9ce0..16848b4 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 b4cba17..bfd2c96 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 to TypeBuilderInstantiation G. 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 ==> TypeBuilderInstantiation G 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 ==> TypeBuilderInstantiation G 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() != 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 06d8384..6d46362 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 6c9bc81..78238c0 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 e9515b1..bcda341 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 d3333df..dc1d19b 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 43c5556..8e5b657 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 994cdc6..2ec6abd 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 d59205d..a487f68 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 384b2dd..3afd396 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 b245b54..275e4f8 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 652831c..70abf75 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 91e205e..600676a 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 908b795..4dca8de 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 856e952..20d6e63 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 5322047..1cca9e1 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 069927e..c2601ae 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 8d82e26..ba356e2 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 cc1beb7..cab7a4a 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 a2530e2..73298d3 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 2b663a8..4e77e8f 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 5fb2e92..77a56b4 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 5726081..fe4ffbf 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 326b571..38c5b7d 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 3e2bce4..5e315f9 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); } diff --git a/src/mscorlib/src/System/Resources/FileBasedResourceGroveler.cs b/src/mscorlib/src/System/Resources/FileBasedResourceGroveler.cs index da4ee81..e1bbd28 100644 --- a/src/mscorlib/src/System/Resources/FileBasedResourceGroveler.cs +++ b/src/mscorlib/src/System/Resources/FileBasedResourceGroveler.cs @@ -62,7 +62,7 @@ namespace System.Resources { // We really don't think this should happen - we always // expect the neutral locale's resources to be present. - throw new MissingManifestResourceException(Environment.GetResourceString("MissingManifestResource_NoNeutralDisk") + Environment.NewLine + "baseName: " + _mediator.BaseNameField + " locationInfo: " + (_mediator.LocationInfo == null ? "" : _mediator.LocationInfo.FullName) + " fileName: " + _mediator.GetResourceFileName(culture)); + throw new MissingManifestResourceException(SR.MissingManifestResource_NoNeutralDisk + Environment.NewLine + "baseName: " + _mediator.BaseNameField + " locationInfo: " + (_mediator.LocationInfo == null ? "" : _mediator.LocationInfo.FullName) + " fileName: " + _mediator.GetResourceFileName(culture)); } } } @@ -142,7 +142,7 @@ namespace System.Resources } catch (MissingMethodException e) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ResMgrBadResSet_Type", _mediator.UserResourceSet.AssemblyQualifiedName), e); + throw new InvalidOperationException(SR.Format(SR.InvalidOperation_ResMgrBadResSet_Type, _mediator.UserResourceSet.AssemblyQualifiedName), e); } } } diff --git a/src/mscorlib/src/System/Resources/LooselyLinkedResourceReference.cs b/src/mscorlib/src/System/Resources/LooselyLinkedResourceReference.cs index 9287ae4..3179df0 100644 --- a/src/mscorlib/src/System/Resources/LooselyLinkedResourceReference.cs +++ b/src/mscorlib/src/System/Resources/LooselyLinkedResourceReference.cs @@ -39,9 +39,9 @@ namespace System.Resources { if (typeName == null) throw new ArgumentNullException(nameof(typeName)); if (looselyLinkedResourceName.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(looselyLinkedResourceName)); + throw new ArgumentException(SR.Argument_EmptyName, nameof(looselyLinkedResourceName)); if (typeName.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(typeName)); + throw new ArgumentException(SR.Argument_EmptyName, nameof(typeName)); Contract.EndContractBlock(); _manifestResourceName = looselyLinkedResourceName; @@ -64,7 +64,7 @@ namespace System.Resources { Stream data = assembly.GetManifestResourceStream(_manifestResourceName); if (data == null) - throw new MissingManifestResourceException(Environment.GetResourceString("MissingManifestResource_LooselyLinked", _manifestResourceName, assembly.FullName)); + throw new MissingManifestResourceException(SR.Format(SR.MissingManifestResource_LooselyLinked, _manifestResourceName, assembly.FullName)); Type type = Type.GetType(_typeName, true); diff --git a/src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs b/src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs index 3ef0066..0e9666b 100644 --- a/src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs +++ b/src/mscorlib/src/System/Resources/ManifestBasedResourceGroveler.cs @@ -159,7 +159,7 @@ namespace System.Resources { if ((UltimateResourceFallbackLocation)fallback < UltimateResourceFallbackLocation.MainAssembly || (UltimateResourceFallbackLocation)fallback > UltimateResourceFallbackLocation.Satellite) { - throw new ArgumentException(Environment.GetResourceString("Arg_InvalidNeutralResourcesLanguage_FallbackLoc", fallback)); + throw new ArgumentException(SR.Format(SR.Arg_InvalidNeutralResourcesLanguage_FallbackLoc, fallback)); } fallbackLocation = (UltimateResourceFallbackLocation)fallback; } @@ -185,7 +185,7 @@ namespace System.Resources return CultureInfo.InvariantCulture; } - throw new ArgumentException(Environment.GetResourceString("Arg_InvalidNeutralResourcesLanguage_Asm_Culture", a.ToString(), cultureName), e); + throw new ArgumentException(SR.Format(SR.Arg_InvalidNeutralResourcesLanguage_Asm_Culture, a.ToString(), cultureName), e); } } @@ -238,7 +238,7 @@ namespace System.Resources // resMgrHeaderVersion is older than this ResMgr version. // We should add in backwards compatibility support here. - throw new NotSupportedException(Environment.GetResourceString("NotSupported_ObsoleteResourcesFile", _mediator.MainAssembly.GetSimpleName())); + throw new NotSupportedException(SR.Format(SR.NotSupported_ObsoleteResourcesFile, _mediator.MainAssembly.GetSimpleName())); } store.Position = startPos; @@ -334,7 +334,7 @@ namespace System.Resources } catch (MissingMethodException e) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ResMgrBadResSet_Type", _mediator.UserResourceSet.AssemblyQualifiedName), e); + throw new InvalidOperationException(SR.Format(SR.InvalidOperation_ResMgrBadResSet_Type, _mediator.UserResourceSet.AssemblyQualifiedName), e); } } } @@ -394,7 +394,7 @@ namespace System.Resources } else { - throw new MissingManifestResourceException(Environment.GetResourceString("MissingManifestResource_MultipleBlobs", givenName, satellite.ToString())); + throw new MissingManifestResourceException(SR.Format(SR.MissingManifestResource_MultipleBlobs, givenName, satellite.ToString())); } } } @@ -521,7 +521,7 @@ namespace System.Resources { missingCultureName = ""; } - throw new MissingSatelliteAssemblyException(Environment.GetResourceString("MissingSatelliteAssembly_Culture_Name", _mediator.NeutralResourcesCulture, satAssemName), missingCultureName); + throw new MissingSatelliteAssemblyException(SR.Format(SR.MissingSatelliteAssembly_Culture_Name, _mediator.NeutralResourcesCulture, satAssemName), missingCultureName); } private void HandleResourceStreamMissing(String fileName) @@ -542,7 +542,7 @@ namespace System.Resources if (_mediator.LocationInfo != null && _mediator.LocationInfo.Namespace != null) resName = _mediator.LocationInfo.Namespace + Type.Delimiter; resName += fileName; - throw new MissingManifestResourceException(Environment.GetResourceString("MissingManifestResource_NoNeutralAsm", resName, _mediator.MainAssembly.GetSimpleName())); + throw new MissingManifestResourceException(SR.Format(SR.MissingManifestResource_NoNeutralAsm, resName, _mediator.MainAssembly.GetSimpleName())); } [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] diff --git a/src/mscorlib/src/System/Resources/MissingManifestResourceException.cs b/src/mscorlib/src/System/Resources/MissingManifestResourceException.cs index 9401806..fd3c5b9 100644 --- a/src/mscorlib/src/System/Resources/MissingManifestResourceException.cs +++ b/src/mscorlib/src/System/Resources/MissingManifestResourceException.cs @@ -22,7 +22,7 @@ namespace System.Resources public class MissingManifestResourceException : SystemException { public MissingManifestResourceException() - : base(Environment.GetResourceString("Arg_MissingManifestResourceException")) + : base(SR.Arg_MissingManifestResourceException) { SetErrorCode(System.__HResults.COR_E_MISSINGMANIFESTRESOURCE); } diff --git a/src/mscorlib/src/System/Resources/MissingSatelliteAssemblyException.cs b/src/mscorlib/src/System/Resources/MissingSatelliteAssemblyException.cs index f1f1494..5f927f4 100644 --- a/src/mscorlib/src/System/Resources/MissingSatelliteAssemblyException.cs +++ b/src/mscorlib/src/System/Resources/MissingSatelliteAssemblyException.cs @@ -26,7 +26,7 @@ namespace System.Resources private String _cultureName; public MissingSatelliteAssemblyException() - : base(Environment.GetResourceString("MissingSatelliteAssembly_Default")) + : base(SR.MissingSatelliteAssembly_Default) { SetErrorCode(System.__HResults.COR_E_MISSINGSATELLITEASSEMBLY); } diff --git a/src/mscorlib/src/System/Resources/NeutralResourcesLanguageAttribute.cs b/src/mscorlib/src/System/Resources/NeutralResourcesLanguageAttribute.cs index 83fb51d..d124389 100644 --- a/src/mscorlib/src/System/Resources/NeutralResourcesLanguageAttribute.cs +++ b/src/mscorlib/src/System/Resources/NeutralResourcesLanguageAttribute.cs @@ -47,7 +47,7 @@ namespace System.Resources if (cultureName == null) throw new ArgumentNullException(nameof(cultureName)); if (!Enum.IsDefined(typeof(UltimateResourceFallbackLocation), location)) - throw new ArgumentException(Environment.GetResourceString("Arg_InvalidNeutralResourcesLanguage_FallbackLoc", location)); + throw new ArgumentException(SR.Format(SR.Arg_InvalidNeutralResourcesLanguage_FallbackLoc, location)); Contract.EndContractBlock(); _culture = cultureName; diff --git a/src/mscorlib/src/System/Resources/ResourceManager.cs b/src/mscorlib/src/System/Resources/ResourceManager.cs index c60e822..993efdd 100644 --- a/src/mscorlib/src/System/Resources/ResourceManager.cs +++ b/src/mscorlib/src/System/Resources/ResourceManager.cs @@ -310,7 +310,7 @@ namespace System.Resources Contract.EndContractBlock(); if (!(assembly is RuntimeAssembly)) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeAssembly")); + throw new ArgumentException(SR.Argument_MustBeRuntimeAssembly); MainAssembly = assembly; BaseNameField = baseName; @@ -340,13 +340,13 @@ namespace System.Resources Contract.EndContractBlock(); if (!(assembly is RuntimeAssembly)) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeAssembly")); + throw new ArgumentException(SR.Argument_MustBeRuntimeAssembly); MainAssembly = assembly; BaseNameField = baseName; if (usingResourceSet != null && (usingResourceSet != _minResourceSet) && !(usingResourceSet.IsSubclassOf(_minResourceSet))) - throw new ArgumentException(Environment.GetResourceString("Arg_ResMgrNotResSet"), nameof(usingResourceSet)); + throw new ArgumentException(SR.Arg_ResMgrNotResSet, nameof(usingResourceSet)); _userResourceSet = usingResourceSet; CommonAssemblyInit(); @@ -367,7 +367,7 @@ namespace System.Resources Contract.EndContractBlock(); if (!(resourceSource is RuntimeType)) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType")); + throw new ArgumentException(SR.Argument_MustBeRuntimeType); _locationInfo = resourceSource; MainAssembly = _locationInfo.Assembly; @@ -758,7 +758,7 @@ namespace System.Resources // Ensure that the assembly reference is not null if (a == null) { - throw new ArgumentNullException(nameof(a), Environment.GetResourceString("ArgumentNull_Assembly")); + throw new ArgumentNullException(nameof(a), SR.ArgumentNull_Assembly); } Contract.EndContractBlock(); @@ -1120,9 +1120,9 @@ namespace System.Resources // Always throw if we did not fully succeed in initializing the WinRT Resource Manager. if (_PRIExceptionInfo != null && _PRIExceptionInfo._PackageSimpleName != null && _PRIExceptionInfo._ResWFile != null) - throw new MissingManifestResourceException(Environment.GetResourceString("MissingManifestResource_ResWFileNotLoaded", _PRIExceptionInfo._ResWFile, _PRIExceptionInfo._PackageSimpleName)); + throw new MissingManifestResourceException(SR.Format(SR.MissingManifestResource_ResWFileNotLoaded, _PRIExceptionInfo._ResWFile, _PRIExceptionInfo._PackageSimpleName)); - throw new MissingManifestResourceException(Environment.GetResourceString("MissingManifestResource_NoPRIresources")); + throw new MissingManifestResourceException(SR.MissingManifestResource_NoPRIresources); } // Throws WinRT hresults. @@ -1299,7 +1299,7 @@ namespace System.Resources Object obj = GetObject(name, culture, false); UnmanagedMemoryStream ums = obj as UnmanagedMemoryStream; if (ums == null && obj != null) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ResourceNotStream_Name", name)); + throw new InvalidOperationException(SR.Format(SR.InvalidOperation_ResourceNotStream_Name, name)); return ums; } diff --git a/src/mscorlib/src/System/Resources/ResourceReader.cs b/src/mscorlib/src/System/Resources/ResourceReader.cs index 49795d8..9734343 100644 --- a/src/mscorlib/src/System/Resources/ResourceReader.cs +++ b/src/mscorlib/src/System/Resources/ResourceReader.cs @@ -133,7 +133,7 @@ namespace System.Resources if (stream == null) throw new ArgumentNullException(nameof(stream)); if (!stream.CanRead) - throw new ArgumentException(Environment.GetResourceString("Argument_StreamNotReadable")); + throw new ArgumentException(SR.Argument_StreamNotReadable); Contract.EndContractBlock(); _resCache = new Dictionary(FastResourceComparer.Default); @@ -211,7 +211,7 @@ namespace System.Resources int stringLength = _store.Read7BitEncodedInt(); if (stringLength < 0) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_NegativeStringLength")); + throw new BadImageFormatException(SR.BadImageFormat_NegativeStringLength); } _store.BaseStream.Seek(stringLength, SeekOrigin.Current); } @@ -239,7 +239,7 @@ namespace System.Resources r = ReadUnalignedI4(&_namePositionsPtr[index]); if (r < 0 || r > _dataSectionOffset - _nameSectionOffset) { - throw new FormatException(Environment.GetResourceString("BadImageFormat_ResourcesNameInvalidOffset", r)); + throw new FormatException(SR.Format(SR.BadImageFormat_ResourcesNameInvalidOffset, r)); } return r; } @@ -252,7 +252,7 @@ namespace System.Resources public IDictionaryEnumerator GetEnumerator() { if (_resCache == null) - throw new InvalidOperationException(Environment.GetResourceString("ResourceReaderIsClosed")); + throw new InvalidOperationException(SR.ResourceReaderIsClosed); return new ResourceEnumerator(this); } @@ -341,7 +341,7 @@ namespace System.Resources int dataPos = _store.ReadInt32(); if (dataPos < 0 || dataPos >= _store.BaseStream.Length - _dataSectionOffset) { - throw new FormatException(Environment.GetResourceString("BadImageFormat_ResourcesDataInvalidOffset", dataPos)); + throw new FormatException(SR.Format(SR.BadImageFormat_ResourcesDataInvalidOffset, dataPos)); } return dataPos; } @@ -361,7 +361,7 @@ namespace System.Resources int byteLen = _store.Read7BitEncodedInt(); if (byteLen < 0) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_NegativeStringLength")); + throw new BadImageFormatException(SR.BadImageFormat_NegativeStringLength); } if (_ums != null) { @@ -370,7 +370,7 @@ namespace System.Resources _ums.Seek(byteLen, SeekOrigin.Current); if (_ums.Position > _ums.Length) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesNameTooLong")); + throw new BadImageFormatException(SR.BadImageFormat_ResourcesNameTooLong); } // On 64-bit machines, these char*'s may be misaligned. Use a @@ -387,7 +387,7 @@ namespace System.Resources { int n = _store.Read(bytes, byteLen - numBytesToRead, numBytesToRead); if (n == 0) - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourceNameCorrupted")); + throw new BadImageFormatException(SR.BadImageFormat_ResourceNameCorrupted); numBytesToRead -= n; } return FastResourceComparer.CompareOrdinal(bytes, byteLen / 2, name) == 0; @@ -410,13 +410,13 @@ namespace System.Resources byteLen = _store.Read7BitEncodedInt(); if (byteLen < 0) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_NegativeStringLength")); + throw new BadImageFormatException(SR.BadImageFormat_NegativeStringLength); } if (_ums != null) { if (_ums.Position > _ums.Length - byteLen) - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesIndexTooLong", index)); + throw new BadImageFormatException(SR.Format(SR.BadImageFormat_ResourcesIndexTooLong, index)); String s = null; char* charPtr = (char*)_ums.PositionPointer; @@ -438,7 +438,7 @@ namespace System.Resources dataOffset = _store.ReadInt32(); if (dataOffset < 0 || dataOffset >= _store.BaseStream.Length - _dataSectionOffset) { - throw new FormatException(Environment.GetResourceString("BadImageFormat_ResourcesDataInvalidOffset", dataOffset)); + throw new FormatException(SR.Format(SR.BadImageFormat_ResourcesDataInvalidOffset, dataOffset)); } return s; } @@ -452,13 +452,13 @@ namespace System.Resources { int n = _store.Read(bytes, byteLen - count, count); if (n == 0) - throw new EndOfStreamException(Environment.GetResourceString("BadImageFormat_ResourceNameCorrupted_NameIndex", index)); + throw new EndOfStreamException(SR.Format(SR.BadImageFormat_ResourceNameCorrupted_NameIndex, index)); count -= n; } dataOffset = _store.ReadInt32(); if (dataOffset < 0 || dataOffset >= _store.BaseStream.Length - _dataSectionOffset) { - throw new FormatException(Environment.GetResourceString("BadImageFormat_ResourcesDataInvalidOffset", dataOffset)); + throw new FormatException(SR.Format(SR.BadImageFormat_ResourcesDataInvalidOffset, dataOffset)); } } return Encoding.Unicode.GetString(bytes, 0, byteLen); @@ -479,7 +479,7 @@ namespace System.Resources int dataPos = _store.ReadInt32(); if (dataPos < 0 || dataPos >= _store.BaseStream.Length - _dataSectionOffset) { - throw new FormatException(Environment.GetResourceString("BadImageFormat_ResourcesDataInvalidOffset", dataPos)); + throw new FormatException(SR.Format(SR.BadImageFormat_ResourcesDataInvalidOffset, dataPos)); } BCLDebug.Log("RESMGRFILEFORMAT", "GetValueForNameIndex: dataPos: " + dataPos); ResourceTypeCode junk; @@ -505,7 +505,7 @@ namespace System.Resources if (typeIndex == -1) return null; if (FindType(typeIndex) != typeof(String)) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ResourceNotString_Type", FindType(typeIndex).FullName)); + throw new InvalidOperationException(SR.Format(SR.InvalidOperation_ResourceNotString_Type, FindType(typeIndex).FullName)); s = _store.ReadString(); } else @@ -518,7 +518,7 @@ namespace System.Resources typeString = typeCode.ToString(); else typeString = FindType(typeCode - ResourceTypeCode.StartOfUserTypes).FullName; - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ResourceNotString_Type", typeString)); + throw new InvalidOperationException(SR.Format(SR.InvalidOperation_ResourceNotString_Type, typeString)); } if (typeCode == ResourceTypeCode.String) // ignore Null s = _store.ReadString(); @@ -564,11 +564,11 @@ namespace System.Resources } catch (EndOfStreamException eof) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_TypeMismatch"), eof); + throw new BadImageFormatException(SR.BadImageFormat_TypeMismatch, eof); } catch (ArgumentOutOfRangeException e) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_TypeMismatch"), e); + throw new BadImageFormatException(SR.BadImageFormat_TypeMismatch, e); } } @@ -623,7 +623,7 @@ namespace System.Resources } else { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_ResourceObjectSerialization")); + throw new NotSupportedException(SR.NotSupported_ResourceObjectSerialization); } } @@ -640,11 +640,11 @@ namespace System.Resources } catch (EndOfStreamException eof) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_TypeMismatch"), eof); + throw new BadImageFormatException(SR.BadImageFormat_TypeMismatch, eof); } catch (ArgumentOutOfRangeException e) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_TypeMismatch"), e); + throw new BadImageFormatException(SR.BadImageFormat_TypeMismatch, e); } } @@ -717,21 +717,21 @@ namespace System.Resources int len = _store.ReadInt32(); if (len < 0) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourceDataLengthInvalid", len)); + throw new BadImageFormatException(SR.Format(SR.BadImageFormat_ResourceDataLengthInvalid, len)); } if (_ums == null) { if (len > _store.BaseStream.Length) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourceDataLengthInvalid", len)); + throw new BadImageFormatException(SR.Format(SR.BadImageFormat_ResourceDataLengthInvalid, len)); } return _store.ReadBytes(len); } if (len > _ums.Length - _ums.Position) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourceDataLengthInvalid", len)); + throw new BadImageFormatException(SR.Format(SR.BadImageFormat_ResourceDataLengthInvalid, len)); } byte[] bytes = new byte[len]; @@ -745,7 +745,7 @@ namespace System.Resources int len = _store.ReadInt32(); if (len < 0) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourceDataLengthInvalid", len)); + throw new BadImageFormatException(SR.Format(SR.BadImageFormat_ResourceDataLengthInvalid, len)); } if (_ums == null) { @@ -757,7 +757,7 @@ namespace System.Resources // make sure we don't create an UnmanagedMemoryStream that is longer than the resource stream. if (len > _ums.Length - _ums.Position) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourceDataLengthInvalid", len)); + throw new BadImageFormatException(SR.Format(SR.BadImageFormat_ResourceDataLengthInvalid, len)); } // For the case that we've memory mapped in the .resources @@ -771,13 +771,13 @@ namespace System.Resources default: if (typeCode < ResourceTypeCode.StartOfUserTypes) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_TypeMismatch")); + throw new BadImageFormatException(SR.BadImageFormat_TypeMismatch); } break; } // Normal serialized objects - throw new NotSupportedException(Environment.GetResourceString("NotSupported_ResourceObjectSerialization")); + throw new NotSupportedException(SR.NotSupported_ResourceObjectSerialization); } @@ -797,11 +797,11 @@ namespace System.Resources } catch (EndOfStreamException eof) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted"), eof); + throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted, eof); } catch (IndexOutOfRangeException e) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted"), e); + throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted, e); } } @@ -811,7 +811,7 @@ namespace System.Resources // Check for magic number int magicNum = _store.ReadInt32(); if (magicNum != ResourceManager.MagicNumber) - throw new ArgumentException(Environment.GetResourceString("Resources_StreamNotValid")); + throw new ArgumentException(SR.Resources_StreamNotValid); // Assuming this is ResourceManager header V1 or greater, hopefully // after the version number there is a number of bytes to skip // to bypass the rest of the ResMgr header. For V2 or greater, we @@ -820,7 +820,7 @@ namespace System.Resources int numBytesToSkip = _store.ReadInt32(); if (numBytesToSkip < 0 || resMgrHeaderVersion < 0) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted")); + throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted); } if (resMgrHeaderVersion > 1) { @@ -839,7 +839,7 @@ namespace System.Resources AssemblyName mscorlib = new AssemblyName(ResourceManager.MscorlibName); if (!ResourceManager.CompareNames(readerType, ResourceManager.ResReaderTypeName, mscorlib)) - throw new NotSupportedException(Environment.GetResourceString("NotSupported_WrongResourceReader_Type", readerType)); + throw new NotSupportedException(SR.Format(SR.NotSupported_WrongResourceReader_Type, readerType)); // Skip over type name for a suitable ResourceSet SkipString(); @@ -849,7 +849,7 @@ namespace System.Resources // Do file version check int version = _store.ReadInt32(); if (version != RuntimeResourceSet.Version && version != 1) - throw new ArgumentException(Environment.GetResourceString("Arg_ResourceFileUnsupportedVersion", RuntimeResourceSet.Version, version)); + throw new ArgumentException(SR.Format(SR.Arg_ResourceFileUnsupportedVersion, RuntimeResourceSet.Version, version)); _version = version; #if RESOURCE_FILE_FORMAT_DEBUG @@ -875,7 +875,7 @@ namespace System.Resources _numResources = _store.ReadInt32(); if (_numResources < 0) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted")); + throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted); } BCLDebug.Log("RESMGRFILEFORMAT", "ReadResources: Expecting " + _numResources + " resources."); #if RESOURCE_FILE_FORMAT_DEBUG @@ -888,7 +888,7 @@ namespace System.Resources int numTypes = _store.ReadInt32(); if (numTypes < 0) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted")); + throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted); } _typeTable = new RuntimeType[numTypes]; _typeNamePositions = new int[numTypes]; @@ -942,7 +942,7 @@ namespace System.Resources int seekPos = unchecked(4 * _numResources); if (seekPos < 0) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted")); + throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted); } unsafe { @@ -969,7 +969,7 @@ namespace System.Resources int namePosition = _store.ReadInt32(); if (namePosition < 0) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted")); + throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted); } _namePositions[i] = namePosition; @@ -980,7 +980,7 @@ namespace System.Resources int seekPos = unchecked(4 * _numResources); if (seekPos < 0) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted")); + throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted); } unsafe { @@ -996,7 +996,7 @@ namespace System.Resources _dataSectionOffset = _store.ReadInt32(); if (_dataSectionOffset < 0) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted")); + throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted); } // Store current location as start of name section @@ -1005,7 +1005,7 @@ namespace System.Resources // _nameSectionOffset should be <= _dataSectionOffset; if not, it's corrupt if (_dataSectionOffset < _nameSectionOffset) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_ResourcesHeaderCorrupted")); + throw new BadImageFormatException(SR.BadImageFormat_ResourcesHeaderCorrupted); } BCLDebug.Log("RESMGRFILEFORMAT", String.Format(CultureInfo.InvariantCulture, "ReadResources: _nameOffset = 0x{0:x} _dataOffset = 0x{1:x}", _nameSectionOffset, _dataSectionOffset)); @@ -1018,7 +1018,7 @@ namespace System.Resources { if (typeIndex < 0 || typeIndex >= _typeTable.Length) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_InvalidType")); + throw new BadImageFormatException(SR.BadImageFormat_InvalidType); } if (_typeTable[typeIndex] == null) { @@ -1041,7 +1041,7 @@ namespace System.Resources // getting to Type.GetType -- this is costly with v1 resource formats. catch (FileNotFoundException) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_ResourceObjectSerialization")); + throw new NotSupportedException(SR.NotSupported_ResourceObjectSerialization); } finally { @@ -1059,7 +1059,7 @@ namespace System.Resources throw new ArgumentNullException(nameof(resourceName)); Contract.EndContractBlock(); if (_resCache == null) - throw new InvalidOperationException(Environment.GetResourceString("ResourceReaderIsClosed")); + throw new InvalidOperationException(SR.ResourceReaderIsClosed); // Get the type information from the data section. Also, // sort all of the data section's indexes to compute length of @@ -1069,7 +1069,7 @@ namespace System.Resources int dataPos = FindPosForResource(resourceName); if (dataPos == -1) { - throw new ArgumentException(Environment.GetResourceString("Arg_ResourceNameNotExist", resourceName)); + throw new ArgumentException(SR.Format(SR.Arg_ResourceNameNotExist, resourceName)); } lock (this) @@ -1082,14 +1082,14 @@ namespace System.Resources int numBytesToSkip = _store.Read7BitEncodedInt(); if (numBytesToSkip < 0) { - throw new FormatException(Environment.GetResourceString("BadImageFormat_ResourcesNameInvalidOffset", numBytesToSkip)); + throw new FormatException(SR.Format(SR.BadImageFormat_ResourcesNameInvalidOffset, numBytesToSkip)); } _store.BaseStream.Position += numBytesToSkip; int dPos = _store.ReadInt32(); if (dPos < 0 || dPos >= _store.BaseStream.Length - _dataSectionOffset) { - throw new FormatException(Environment.GetResourceString("BadImageFormat_ResourcesDataInvalidOffset", dPos)); + throw new FormatException(SR.Format(SR.BadImageFormat_ResourcesDataInvalidOffset, dPos)); } sortedDataPositions[i] = dPos; } @@ -1106,7 +1106,7 @@ namespace System.Resources ResourceTypeCode typeCode = (ResourceTypeCode)_store.Read7BitEncodedInt(); if (typeCode < 0 || typeCode >= ResourceTypeCode.StartOfUserTypes + _typeTable.Length) { - throw new BadImageFormatException(Environment.GetResourceString("BadImageFormat_InvalidType")); + throw new BadImageFormatException(SR.BadImageFormat_InvalidType); } resourceType = TypeNameFromTypeCode(typeCode); @@ -1115,7 +1115,7 @@ namespace System.Resources len -= (int)(_store.BaseStream.Position - (_dataSectionOffset + dataPos)); byte[] bytes = _store.ReadBytes(len); if (bytes.Length != len) - throw new FormatException(Environment.GetResourceString("BadImageFormat_ResourceNameCorrupted")); + throw new FormatException(SR.BadImageFormat_ResourceNameCorrupted); resourceData = bytes; } } @@ -1181,9 +1181,9 @@ namespace System.Resources { get { - if (_currentName == ENUM_DONE) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumEnded)); - if (!_currentIsValid) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumNotStarted)); - if (_reader._resCache == null) throw new InvalidOperationException(Environment.GetResourceString("ResourceReaderIsClosed")); + if (_currentName == ENUM_DONE) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumEnded)); + if (!_currentIsValid) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumNotStarted)); + if (_reader._resCache == null) throw new InvalidOperationException(SR.ResourceReaderIsClosed); return _reader.AllocateStringForNameIndex(_currentName, out _dataPosition); } @@ -1210,9 +1210,9 @@ namespace System.Resources { get { - if (_currentName == ENUM_DONE) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumEnded)); - if (!_currentIsValid) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumNotStarted)); - if (_reader._resCache == null) throw new InvalidOperationException(Environment.GetResourceString("ResourceReaderIsClosed")); + if (_currentName == ENUM_DONE) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumEnded)); + if (!_currentIsValid) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumNotStarted)); + if (_reader._resCache == null) throw new InvalidOperationException(SR.ResourceReaderIsClosed); String key; Object value = null; @@ -1248,9 +1248,9 @@ namespace System.Resources { get { - if (_currentName == ENUM_DONE) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumEnded)); - if (!_currentIsValid) throw new InvalidOperationException(Environment.GetResourceString(ResId.InvalidOperation_EnumNotStarted)); - if (_reader._resCache == null) throw new InvalidOperationException(Environment.GetResourceString("ResourceReaderIsClosed")); + if (_currentName == ENUM_DONE) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumEnded)); + if (!_currentIsValid) throw new InvalidOperationException(SR.GetResourceString(ResId.InvalidOperation_EnumNotStarted)); + if (_reader._resCache == null) throw new InvalidOperationException(SR.ResourceReaderIsClosed); // Consider using _resCache here, eventually, if // this proves to be an interesting perf scenario. @@ -1262,7 +1262,7 @@ namespace System.Resources public void Reset() { - if (_reader._resCache == null) throw new InvalidOperationException(Environment.GetResourceString("ResourceReaderIsClosed")); + if (_reader._resCache == null) throw new InvalidOperationException(SR.ResourceReaderIsClosed); _currentIsValid = false; _currentName = ENUM_NOT_STARTED; } diff --git a/src/mscorlib/src/System/Resources/ResourceSet.cs b/src/mscorlib/src/System/Resources/ResourceSet.cs index 0fac0a9..24f9184 100644 --- a/src/mscorlib/src/System/Resources/ResourceSet.cs +++ b/src/mscorlib/src/System/Resources/ResourceSet.cs @@ -196,7 +196,7 @@ namespace System.Resources { Hashtable copyOfTable = Table; // Avoid a race with Dispose if (copyOfTable == null) - throw new ObjectDisposedException(null, Environment.GetResourceString("ObjectDisposed_ResourceSet")); + throw new ObjectDisposedException(null, SR.ObjectDisposed_ResourceSet); return copyOfTable.GetEnumerator(); } @@ -211,7 +211,7 @@ namespace System.Resources } catch (InvalidCastException) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ResourceNotString_Name", name)); + throw new InvalidOperationException(SR.Format(SR.InvalidOperation_ResourceNotString_Name, name)); } } @@ -228,7 +228,7 @@ namespace System.Resources } catch (InvalidCastException) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ResourceNotString_Name", name)); + throw new InvalidOperationException(SR.Format(SR.InvalidOperation_ResourceNotString_Name, name)); } // case-sensitive lookup succeeded @@ -245,7 +245,7 @@ namespace System.Resources } catch (InvalidCastException) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ResourceNotString_Name", name)); + throw new InvalidOperationException(SR.Format(SR.InvalidOperation_ResourceNotString_Name, name)); } } @@ -293,7 +293,7 @@ namespace System.Resources Hashtable copyOfTable = Table; // Avoid a race with Dispose if (copyOfTable == null) - throw new ObjectDisposedException(null, Environment.GetResourceString("ObjectDisposed_ResourceSet")); + throw new ObjectDisposedException(null, SR.ObjectDisposed_ResourceSet); return copyOfTable[name]; } @@ -303,7 +303,7 @@ namespace System.Resources Hashtable copyOfTable = Table; // Avoid a race with Dispose if (copyOfTable == null) - throw new ObjectDisposedException(null, Environment.GetResourceString("ObjectDisposed_ResourceSet")); + throw new ObjectDisposedException(null, SR.ObjectDisposed_ResourceSet); Hashtable caseTable = _caseInsensitiveTable; // Avoid a race condition with Close if (caseTable == null) diff --git a/src/mscorlib/src/System/Resources/RuntimeResourceSet.cs b/src/mscorlib/src/System/Resources/RuntimeResourceSet.cs index 202fe50..e9c038a 100644 --- a/src/mscorlib/src/System/Resources/RuntimeResourceSet.cs +++ b/src/mscorlib/src/System/Resources/RuntimeResourceSet.cs @@ -259,7 +259,7 @@ namespace System.Resources { IResourceReader copyOfReader = Reader; if (copyOfReader == null || _resCache == null) - throw new ObjectDisposedException(null, Environment.GetResourceString("ObjectDisposed_ResourceSet")); + throw new ObjectDisposedException(null, SR.ObjectDisposed_ResourceSet); return copyOfReader.GetEnumerator(); } @@ -292,7 +292,7 @@ namespace System.Resources if (key == null) throw new ArgumentNullException(nameof(key)); if (Reader == null || _resCache == null) - throw new ObjectDisposedException(null, Environment.GetResourceString("ObjectDisposed_ResourceSet")); + throw new ObjectDisposedException(null, SR.ObjectDisposed_ResourceSet); Contract.EndContractBlock(); Object value = null; @@ -301,7 +301,7 @@ namespace System.Resources lock (Reader) { if (Reader == null) - throw new ObjectDisposedException(null, Environment.GetResourceString("ObjectDisposed_ResourceSet")); + throw new ObjectDisposedException(null, SR.ObjectDisposed_ResourceSet); if (_defaultReader != null) { diff --git a/src/mscorlib/src/System/RtType.cs b/src/mscorlib/src/System/RtType.cs index 9a3d9ab..5489945 100644 --- a/src/mscorlib/src/System/RtType.cs +++ b/src/mscorlib/src/System/RtType.cs @@ -1832,7 +1832,7 @@ namespace System if (!loaderAssuredCompatible) throw new ArgumentException(String.Format( - CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_ResolveMethodHandle"), + CultureInfo.CurrentCulture, SR.Argument_ResolveMethodHandle, reflectedType.ToString(), declaredType.ToString())); } // Action is assignable from, but not a subclass of Action. @@ -1860,7 +1860,7 @@ namespace System { // ignoring instantiation is the ReflectedType is not a subtype of the DeclaringType throw new ArgumentException(String.Format( - CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_ResolveMethodHandle"), + CultureInfo.CurrentCulture, SR.Argument_ResolveMethodHandle, reflectedType.ToString(), declaredType.ToString())); } @@ -1882,7 +1882,7 @@ namespace System { // declaredType is not Array, not generic, and not assignable from reflectedType throw new ArgumentException(String.Format( - CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_ResolveMethodHandle"), + CultureInfo.CurrentCulture, SR.Argument_ResolveMethodHandle, reflectedType.ToString(), declaredType.ToString())); } } @@ -1950,7 +1950,7 @@ namespace System !RuntimeTypeHandle.CompareCanonicalHandles(declaredType, reflectedType)) { throw new ArgumentException(String.Format( - CultureInfo.CurrentCulture, Environment.GetResourceString("Argument_ResolveFieldHandle"), + CultureInfo.CurrentCulture, SR.Argument_ResolveFieldHandle, reflectedType.ToString(), declaredType.ToString())); } @@ -1984,7 +1984,7 @@ namespace System { if (type.IsPointer || type.IsByRef || type == typeof(void)) throw new ArgumentException( - Environment.GetResourceString("Argument_NeverValidGenericArgument", type.ToString())); + SR.Format(SR.Argument_NeverValidGenericArgument, type.ToString())); } @@ -2004,7 +2004,7 @@ namespace System if (genericArguments.Length != genericParamters.Length) throw new ArgumentException( - Environment.GetResourceString("Argument_NotEnoughGenArguments", genericArguments.Length, genericParamters.Length)); + SR.Format(SR.Argument_NotEnoughGenArguments, genericArguments.Length, genericParamters.Length)); } internal static void ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Exception e) @@ -2041,8 +2041,7 @@ namespace System typeContext, methodContext, genericArgument.GetTypeHandleInternal().GetTypeChecked())) { throw new ArgumentException( - Environment.GetResourceString("Argument_GenConstraintViolation", - i.ToString(CultureInfo.CurrentCulture), genericArgument.ToString(), definition.ToString(), genericParameter.ToString()), e); + SR.Format(SR.Argument_GenConstraintViolation, i.ToString(CultureInfo.CurrentCulture), genericArgument.ToString(), definition.ToString(), genericParameter.ToString()), e); } } } @@ -2731,7 +2730,7 @@ namespace System public override InterfaceMapping GetInterfaceMap(Type ifaceType) { if (IsGenericParameter) - throw new InvalidOperationException(Environment.GetResourceString("Arg_GenericParameter")); + throw new InvalidOperationException(SR.Arg_GenericParameter); if ((object)ifaceType == null) throw new ArgumentNullException(nameof(ifaceType)); @@ -2740,7 +2739,7 @@ namespace System RuntimeType ifaceRtType = ifaceType as RuntimeType; if (ifaceRtType == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeType"), nameof(ifaceType)); + throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(ifaceType)); RuntimeTypeHandle ifaceRtTypeHandle = ifaceRtType.GetTypeHandleInternal(); @@ -2751,7 +2750,7 @@ namespace System // SZArrays implement the methods on IList`1, IEnumerable`1, and ICollection`1 with // SZArrayHelper and some runtime magic. We don't have accurate interface maps for them. if (IsSZArray && ifaceType.IsGenericType) - throw new ArgumentException(Environment.GetResourceString("Argument_ArrayGetInterfaceMap")); + throw new ArgumentException(SR.Argument_ArrayGetInterfaceMap); int ifaceInstanceMethodCount = RuntimeTypeHandle.GetNumVirtuals(ifaceRtType); @@ -2813,7 +2812,7 @@ namespace System MethodInfo methodInfo = candidates[j]; if (!System.DefaultBinder.CompareMethodSigAndName(methodInfo, firstCandidate)) { - throw new AmbiguousMatchException(Environment.GetResourceString("Arg_AmbiguousMatchException")); + throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException); } } @@ -2886,7 +2885,7 @@ namespace System { if ((object)returnType == null) // if we are here we have no args or property type to select over and we have more than one property with that name - throw new AmbiguousMatchException(Environment.GetResourceString("Arg_AmbiguousMatchException")); + throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException); } } @@ -2920,7 +2919,7 @@ namespace System if ((bindingAttr & eventInfo.BindingFlags) == eventInfo.BindingFlags) { if (match != null) - throw new AmbiguousMatchException(Environment.GetResourceString("Arg_AmbiguousMatchException")); + throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException); match = eventInfo; } @@ -2952,7 +2951,7 @@ namespace System if (match != null) { if (Object.ReferenceEquals(fieldInfo.DeclaringType, match.DeclaringType)) - throw new AmbiguousMatchException(Environment.GetResourceString("Arg_AmbiguousMatchException")); + throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException); if ((match.DeclaringType.IsInterface == true) && (fieldInfo.DeclaringType.IsInterface == true)) multipleStaticFieldMatches = true; @@ -2964,7 +2963,7 @@ namespace System } if (multipleStaticFieldMatches && match.DeclaringType.IsInterface) - throw new AmbiguousMatchException(Environment.GetResourceString("Arg_AmbiguousMatchException")); + throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException); return match; } @@ -2996,7 +2995,7 @@ namespace System if (RuntimeType.FilterApplyType(iface, bindingAttr, name, false, ns)) { if (match != null) - throw new AmbiguousMatchException(Environment.GetResourceString("Arg_AmbiguousMatchException")); + throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException); match = iface; } @@ -3027,7 +3026,7 @@ namespace System if (RuntimeType.FilterApplyType(nestedType, bindingAttr, name, false, ns)) { if (match != null) - throw new AmbiguousMatchException(Environment.GetResourceString("Arg_AmbiguousMatchException")); + throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException); match = nestedType; } @@ -3231,7 +3230,7 @@ namespace System get { if (!IsGenericParameter) - throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericParameter")); + throw new InvalidOperationException(SR.Arg_NotGenericParameter); Contract.EndContractBlock(); IRuntimeMethodInfo declaringMethod = RuntimeTypeHandle.GetDeclaringMethod(this); @@ -3516,7 +3515,7 @@ namespace System get { if (!IsGenericParameter) - throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericParameter")); + throw new InvalidOperationException(SR.Arg_NotGenericParameter); Contract.EndContractBlock(); GenericParameterAttributes attributes; @@ -3558,7 +3557,7 @@ namespace System public override int GetArrayRank() { if (!IsArrayImpl()) - throw new ArgumentException(Environment.GetResourceString("Argument_HasToBeArrayClass")); + throw new ArgumentException(SR.Argument_HasToBeArrayClass); return RuntimeTypeHandle.GetArrayRank(this); } @@ -3573,7 +3572,7 @@ namespace System public override string[] GetEnumNames() { if (!IsEnum) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), "enumType"); + throw new ArgumentException(SR.Arg_MustBeEnum, "enumType"); Contract.EndContractBlock(); String[] ret = Enum.InternalGetNames(this); @@ -3589,7 +3588,7 @@ namespace System public override Array GetEnumValues() { if (!IsEnum) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), "enumType"); + throw new ArgumentException(SR.Arg_MustBeEnum, "enumType"); Contract.EndContractBlock(); // Get all of the values @@ -3610,7 +3609,7 @@ namespace System public override Type GetEnumUnderlyingType() { if (!IsEnum) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), "enumType"); + throw new ArgumentException(SR.Arg_MustBeEnum, "enumType"); Contract.EndContractBlock(); return Enum.InternalGetUnderlyingType(this); @@ -3629,7 +3628,7 @@ namespace System if (valueType.IsEnum) { if (!valueType.IsEquivalentTo(this)) - throw new ArgumentException(Environment.GetResourceString("Arg_EnumAndObjectMustBeSameType", valueType.ToString(), this.ToString())); + throw new ArgumentException(SR.Format(SR.Arg_EnumAndObjectMustBeSameType, valueType.ToString(), this.ToString())); valueType = (RuntimeType)valueType.GetEnumUnderlyingType(); } @@ -3650,7 +3649,7 @@ namespace System { RuntimeType underlyingType = Enum.InternalGetUnderlyingType(this); if (underlyingType != valueType) - throw new ArgumentException(Environment.GetResourceString("Arg_EnumUnderlyingTypeAndObjectMustBeSameType", valueType.ToString(), underlyingType.ToString())); + throw new ArgumentException(SR.Format(SR.Arg_EnumUnderlyingTypeAndObjectMustBeSameType, valueType.ToString(), underlyingType.ToString())); ulong[] ulValues = Enum.InternalGetValues(this); ulong ulValue = Enum.ToUInt64(value); @@ -3659,7 +3658,7 @@ namespace System } else { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_UnknownEnumType")); + throw new InvalidOperationException(SR.InvalidOperation_UnknownEnumType); } } @@ -3672,7 +3671,7 @@ namespace System Type valueType = value.GetType(); if (!(valueType.IsEnum || IsIntegerType(valueType))) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnumBaseTypeOrEnum"), nameof(value)); + throw new ArgumentException(SR.Arg_MustBeEnumBaseTypeOrEnum, nameof(value)); ulong ulValue = Enum.ToUInt64(value); @@ -3706,10 +3705,10 @@ namespace System if (!IsGenericTypeDefinition) throw new InvalidOperationException( - Environment.GetResourceString("Arg_NotGenericTypeDefinition", this)); + SR.Format(SR.Arg_NotGenericTypeDefinition, this)); if (GetGenericArguments().Length != instantiation.Length) - throw new ArgumentException(Environment.GetResourceString("Argument_GenericArgsCount"), nameof(instantiation)); + throw new ArgumentException(SR.Argument_GenericArgsCount, nameof(instantiation)); for (int i = 0; i < instantiation.Length; i++) { @@ -3764,7 +3763,7 @@ namespace System get { if (!IsGenericParameter) - throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericParameter")); + throw new InvalidOperationException(SR.Arg_NotGenericParameter); Contract.EndContractBlock(); return new RuntimeTypeHandle(this).GetGenericVariableIndex(); @@ -3774,7 +3773,7 @@ namespace System public override Type GetGenericTypeDefinition() { if (!IsGenericType) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotGenericType")); + throw new InvalidOperationException(SR.InvalidOperation_NotGenericType); Contract.EndContractBlock(); return RuntimeTypeHandle.GetGenericTypeDefinition(this); @@ -3798,7 +3797,7 @@ namespace System public override Type[] GetGenericParameterConstraints() { if (!IsGenericParameter) - throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericParameter")); + throw new InvalidOperationException(SR.Arg_NotGenericParameter); Contract.EndContractBlock(); Type[] constraints = new RuntimeTypeHandle(this).GetConstraints(); @@ -3914,7 +3913,7 @@ namespace System } if ((invokeAttr & BindingFlags.ExactBinding) == BindingFlags.ExactBinding) - throw new ArgumentException(String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Arg_ObjObjEx"), value.GetType(), this)); + throw new ArgumentException(String.Format(CultureInfo.CurrentUICulture, SR.Arg_ObjObjEx, value.GetType(), this)); return TryChangeType(value, binder, culture, needsSpecialCast); } @@ -3955,7 +3954,7 @@ namespace System } } - throw new ArgumentException(String.Format(CultureInfo.CurrentUICulture, Environment.GetResourceString("Arg_ObjObjEx"), value.GetType(), this)); + throw new ArgumentException(String.Format(CultureInfo.CurrentUICulture, SR.Arg_ObjObjEx, value.GetType(), this)); } // GetDefaultMembers @@ -3986,13 +3985,13 @@ namespace System Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) { if (IsGenericParameter) - throw new InvalidOperationException(Environment.GetResourceString("Arg_GenericParameter")); + throw new InvalidOperationException(SR.Arg_GenericParameter); Contract.EndContractBlock(); #region Preconditions if ((bindingFlags & InvocationMask) == 0) // "Must specify binding flags describing the invoke operation required." - throw new ArgumentException(Environment.GetResourceString("Arg_NoAccessSpec"), nameof(bindingFlags)); + throw new ArgumentException(SR.Arg_NoAccessSpec, nameof(bindingFlags)); // Provide a default binding mask if none is provided if ((bindingFlags & MemberBindingMask) == 0) @@ -4010,13 +4009,13 @@ namespace System { if (namedParams.Length > providedArgs.Length) // "Named parameter array can not be bigger than argument array." - throw new ArgumentException(Environment.GetResourceString("Arg_NamedParamTooBig"), nameof(namedParams)); + throw new ArgumentException(SR.Arg_NamedParamTooBig, nameof(namedParams)); } else { if (namedParams.Length != 0) // "Named parameter array can not be bigger than argument array." - throw new ArgumentException(Environment.GetResourceString("Arg_NamedParamTooBig"), nameof(namedParams)); + throw new ArgumentException(SR.Arg_NamedParamTooBig, nameof(namedParams)); } } #endregion @@ -4027,22 +4026,22 @@ namespace System { #region Preconditions if ((bindingFlags & ClassicBindingMask) == 0) - throw new ArgumentException(Environment.GetResourceString("Arg_COMAccess"), nameof(bindingFlags)); + throw new ArgumentException(SR.Arg_COMAccess, nameof(bindingFlags)); if ((bindingFlags & BindingFlags.GetProperty) != 0 && (bindingFlags & ClassicBindingMask & ~(BindingFlags.GetProperty | BindingFlags.InvokeMethod)) != 0) - throw new ArgumentException(Environment.GetResourceString("Arg_PropSetGet"), nameof(bindingFlags)); + throw new ArgumentException(SR.Arg_PropSetGet, nameof(bindingFlags)); if ((bindingFlags & BindingFlags.InvokeMethod) != 0 && (bindingFlags & ClassicBindingMask & ~(BindingFlags.GetProperty | BindingFlags.InvokeMethod)) != 0) - throw new ArgumentException(Environment.GetResourceString("Arg_PropSetInvoke"), nameof(bindingFlags)); + throw new ArgumentException(SR.Arg_PropSetInvoke, nameof(bindingFlags)); if ((bindingFlags & BindingFlags.SetProperty) != 0 && (bindingFlags & ClassicBindingMask & ~BindingFlags.SetProperty) != 0) - throw new ArgumentException(Environment.GetResourceString("Arg_COMPropSetPut"), nameof(bindingFlags)); + throw new ArgumentException(SR.Arg_COMPropSetPut, nameof(bindingFlags)); if ((bindingFlags & BindingFlags.PutDispProperty) != 0 && (bindingFlags & ClassicBindingMask & ~BindingFlags.PutDispProperty) != 0) - throw new ArgumentException(Environment.GetResourceString("Arg_COMPropSetPut"), nameof(bindingFlags)); + throw new ArgumentException(SR.Arg_COMPropSetPut, nameof(bindingFlags)); if ((bindingFlags & BindingFlags.PutRefDispProperty) != 0 && (bindingFlags & ClassicBindingMask & ~BindingFlags.PutRefDispProperty) != 0) - throw new ArgumentException(Environment.GetResourceString("Arg_COMPropSetPut"), nameof(bindingFlags)); + throw new ArgumentException(SR.Arg_COMPropSetPut, nameof(bindingFlags)); #endregion { @@ -4065,7 +4064,7 @@ namespace System #region Check that any named paramters are not null if (namedParams != null && Array.IndexOf(namedParams, null) != -1) // "Named parameter value must not be null." - throw new ArgumentException(Environment.GetResourceString("Arg_NamedParamNull"), nameof(namedParams)); + throw new ArgumentException(SR.Arg_NamedParamNull, nameof(namedParams)); #endregion int argCnt = (providedArgs != null) ? providedArgs.Length : 0; @@ -4082,7 +4081,7 @@ namespace System { if ((bindingFlags & BindingFlags.CreateInstance) != 0 && (bindingFlags & BinderNonCreateInstance) != 0) // "Can not specify both CreateInstance and another access type." - throw new ArgumentException(Environment.GetResourceString("Arg_CreatInstAccess"), nameof(bindingFlags)); + throw new ArgumentException(SR.Arg_CreatInstAccess, nameof(bindingFlags)); return Activator.CreateInstance(this, bindingFlags, binder, providedArgs, culture); } @@ -4119,11 +4118,11 @@ namespace System { if (IsSetField) // "Can not specify both Get and Set on a field." - throw new ArgumentException(Environment.GetResourceString("Arg_FldSetGet"), nameof(bindingFlags)); + throw new ArgumentException(SR.Arg_FldSetGet, nameof(bindingFlags)); if ((bindingFlags & BindingFlags.SetProperty) != 0) // "Can not specify both GetField and SetProperty." - throw new ArgumentException(Environment.GetResourceString("Arg_FldGetPropSet"), nameof(bindingFlags)); + throw new ArgumentException(SR.Arg_FldGetPropSet, nameof(bindingFlags)); } else { @@ -4134,11 +4133,11 @@ namespace System if ((bindingFlags & BindingFlags.GetProperty) != 0) // "Can not specify both SetField and GetProperty." - throw new ArgumentException(Environment.GetResourceString("Arg_FldSetPropGet"), nameof(bindingFlags)); + throw new ArgumentException(SR.Arg_FldSetPropGet, nameof(bindingFlags)); if ((bindingFlags & BindingFlags.InvokeMethod) != 0) // "Can not specify Set on a Field and Invoke on a method." - throw new ArgumentException(Environment.GetResourceString("Arg_FldSetInvoke"), nameof(bindingFlags)); + throw new ArgumentException(SR.Arg_FldSetInvoke, nameof(bindingFlags)); } #endregion @@ -4187,7 +4186,7 @@ namespace System } catch (InvalidCastException) { - throw new ArgumentException(Environment.GetResourceString("Arg_IndexMustBeInt")); + throw new ArgumentException(SR.Arg_IndexMustBeInt); } } @@ -4212,7 +4211,7 @@ namespace System { #region Get the field value if (argCnt != 0) - throw new ArgumentException(Environment.GetResourceString("Arg_FldGetArgErr"), nameof(bindingFlags)); + throw new ArgumentException(SR.Arg_FldGetArgErr, nameof(bindingFlags)); return selFld.GetValue(target); #endregion @@ -4221,7 +4220,7 @@ namespace System { #region Set the field Value if (argCnt != 1) - throw new ArgumentException(Environment.GetResourceString("Arg_FldSetArgErr"), nameof(bindingFlags)); + throw new ArgumentException(SR.Arg_FldSetArgErr, nameof(bindingFlags)); selFld.SetValue(target, providedArgs[0], bindingFlags, binder, culture); @@ -4272,7 +4271,7 @@ namespace System Debug.Assert(!IsSetField); if (isSetProperty) - throw new ArgumentException(Environment.GetResourceString("Arg_PropSetGet"), nameof(bindingFlags)); + throw new ArgumentException(SR.Arg_PropSetGet, nameof(bindingFlags)); } else { @@ -4281,7 +4280,7 @@ namespace System Debug.Assert(!IsGetField); if ((bindingFlags & BindingFlags.InvokeMethod) != 0) - throw new ArgumentException(Environment.GetResourceString("Arg_PropSetInvoke"), nameof(bindingFlags)); + throw new ArgumentException(SR.Arg_PropSetInvoke, nameof(bindingFlags)); } #endregion } @@ -4486,7 +4485,7 @@ namespace System 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); } @@ -4500,7 +4499,7 @@ namespace System 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); } @@ -4603,20 +4602,20 @@ namespace System private void CreateInstanceCheckThis() { if (this is ReflectionOnlyType) - throw new ArgumentException(Environment.GetResourceString("Arg_ReflectionOnlyInvoke")); + throw new ArgumentException(SR.Arg_ReflectionOnlyInvoke); if (ContainsGenericParameters) throw new ArgumentException( - Environment.GetResourceString("Acc_CreateGenericEx", this)); + SR.Format(SR.Acc_CreateGenericEx, this)); Contract.EndContractBlock(); Type elementType = this.GetRootElementType(); if (Object.ReferenceEquals(elementType, typeof(ArgIterator))) - throw new NotSupportedException(Environment.GetResourceString("Acc_CreateArgIterator")); + throw new NotSupportedException(SR.Acc_CreateArgIterator); if (Object.ReferenceEquals(elementType, typeof(void))) - throw new NotSupportedException(Environment.GetResourceString("Acc_CreateVoid")); + throw new NotSupportedException(SR.Acc_CreateVoid); } internal Object CreateInstanceImpl( @@ -4670,7 +4669,7 @@ namespace System if (cons == null) { - throw new MissingMethodException(Environment.GetResourceString("MissingConstructor_Name", FullName)); + throw new MissingMethodException(SR.Format(SR.MissingConstructor_Name, FullName)); } MethodBase invokeMethod; @@ -4684,7 +4683,7 @@ namespace System if (invokeMethod == null) { - throw new MissingMethodException(Environment.GetResourceString("MissingConstructor_Name", FullName)); + throw new MissingMethodException(SR.Format(SR.MissingConstructor_Name, FullName)); } if (invokeMethod.GetParametersNoCopy().Length == 0) @@ -4694,7 +4693,7 @@ namespace System Debug.Assert((invokeMethod.CallingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs); throw new NotSupportedException(String.Format(CultureInfo.CurrentCulture, - Environment.GetResourceString("NotSupported_CallToVarArg"))); + SR.NotSupported_CallToVarArg)); } // fast path?? @@ -4834,7 +4833,7 @@ namespace System internal Object CreateInstanceDefaultCtor(bool publicOnly, bool skipCheckThis, bool fillCache, ref StackCrawlMark stackMark) { if (GetType() == typeof(ReflectionOnlyType)) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAllowedInReflectionOnly")); + throw new InvalidOperationException(SR.InvalidOperation_NotAllowedInReflectionOnly); ActivatorCache activatorCache = s_ActivatorCache; if (activatorCache != null) @@ -4847,7 +4846,7 @@ namespace System if (ace.m_ctor != null && (ace.m_ctorAttributes & MethodAttributes.MemberAccessMask) != MethodAttributes.Public) { - throw new MissingMethodException(Environment.GetResourceString("Arg_NoDefCTor")); + throw new MissingMethodException(SR.Arg_NoDefCTor); } } @@ -4944,7 +4943,7 @@ namespace System { get { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NotAllowedInReflectionOnly")); + throw new InvalidOperationException(SR.InvalidOperation_NotAllowedInReflectionOnly); } } } diff --git a/src/mscorlib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs b/src/mscorlib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs index eed21cf..9e4673b 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 abb5a8f..dc27a65 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 70b94182..d986ea9 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 4666611..9e87b21 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 8343071..993a24f 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 82a0f09..f8fcfb5 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 51c379f..4b43682 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 ff96aef..73be2c5 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 8aea9b2..323a9a6 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 304f369..9e813d9 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 4cf2140..dcb9e24 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 b7fb686..5e26352 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 8ce8bb2..6e64418 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 142389e..306d889 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 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 8240e29..4634ea8 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 ad64e5e..96bbdd7 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 d541cf4..2ec2f9e 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 7fb3e4e..aba25e9 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 2d0e9a7..3509205 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(this); diff --git a/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToListAdapter.cs b/src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToListAdapter.cs index d6e50f5..539b802 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 8fd3043..aa0f3ba 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(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(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(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(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(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 0e9140f..4549a40 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(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 fe1ecff..63565a3 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 9f33b2f..2a34aba 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 mapping in dictionary) @@ -53,12 +53,12 @@ namespace System.Runtime.InteropServices.WindowsRuntime void ICollection.Add(TKey item) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_KeyCollectionSet")); + throw new NotSupportedException(SR.NotSupported_KeyCollectionSet); } void ICollection.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.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 b1a4042..bb54d49 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 d599d24..083b0ff 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 mapping in dictionary) @@ -57,12 +57,12 @@ namespace System.Runtime.InteropServices.WindowsRuntime void ICollection.Add(TValue item) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_ValueCollectionSet")); + throw new NotSupportedException(SR.NotSupported_ValueCollectionSet); } void ICollection.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.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 03b17d9..974da48 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 55f8a1e..e06364d 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 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 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 2fac36b..73daf87 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 b902ded..5dce7df 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 6010eec..5f12322 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(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 0503b72..fc02bed 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 8373885..87330e2 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 _this = JitHelpers.UnsafeCast>(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 cace204..12b13ac 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 f11260e..6b6c171 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() > 0) - throw new ArgumentException(Environment.GetResourceString("Argument_IndexOutOfArrayBounds")); + throw new ArgumentException(SR.Argument_IndexOutOfArrayBounds); if (array.Length - arrayIndex < Count()) - 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>(_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 a8a13c6..224a266 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(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 a3715da..5d50954 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 898f1a6..3065b83 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() > 0) - throw new ArgumentException(Environment.GetResourceString("Argument_IndexOutOfArrayBounds")); + throw new ArgumentException(SR.Argument_IndexOutOfArrayBounds); if (array.Length - arrayIndex < Count()) - 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(_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 3e33248..56e62a2 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 6b7785d..84c12f8 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 00dad37..0b7ba10 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 b772a22..0f28d3b 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 3f21425..0da4773 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 2785942..f9f87bc 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 17a2602..16d41d3 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 0db38b6..5f07c3a 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 435ca27..be9f4ae 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 65db0e9..7f2d275 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 d024361..7fc3ce2 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 Byte.MaxValue) { - throw new OverflowException(Environment.GetResourceString("Overflow_SByte")); + throw new OverflowException(SR.Overflow_SByte); } return (sbyte)i; } - if (i < MinValue || i > MaxValue) throw new OverflowException(Environment.GetResourceString("Overflow_SByte")); + if (i < MinValue || i > MaxValue) throw new OverflowException(SR.Overflow_SByte); return (sbyte)i; } @@ -303,7 +303,7 @@ namespace System /// DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "SByte", "DateTime")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "SByte", "DateTime")); } /// diff --git a/src/mscorlib/src/System/Security/Util/URLString.cs b/src/mscorlib/src/System/Security/Util/URLString.cs index d694acb..33aac6f 100644 --- a/src/mscorlib/src/System/Security/Util/URLString.cs +++ b/src/mscorlib/src/System/Security/Util/URLString.cs @@ -131,7 +131,7 @@ namespace System.Security.Util PathInternal.MaxLongPath)) #endif { - throw new PathTooLongException(Environment.GetResourceString("IO.PathTooLong")); + throw new PathTooLongException(SR.IO_PathTooLong); } } } diff --git a/src/mscorlib/src/System/Security/VerificationException.cs b/src/mscorlib/src/System/Security/VerificationException.cs index d07b76f..6f70dcd 100644 --- a/src/mscorlib/src/System/Security/VerificationException.cs +++ b/src/mscorlib/src/System/Security/VerificationException.cs @@ -14,7 +14,7 @@ namespace System.Security public class VerificationException : SystemException { public VerificationException() - : base(Environment.GetResourceString("Verification_Exception")) + : base(SR.Verification_Exception) { SetErrorCode(__HResults.COR_E_VERIFICATION); } diff --git a/src/mscorlib/src/System/Single.cs b/src/mscorlib/src/System/Single.cs index f3ed5b8..4fb6ae0 100644 --- a/src/mscorlib/src/System/Single.cs +++ b/src/mscorlib/src/System/Single.cs @@ -98,7 +98,7 @@ namespace System else // f is NaN. return 1; } - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeSingle")); + throw new ArgumentException(SR.Arg_MustBeSingle); } @@ -306,7 +306,7 @@ namespace System /// char IConvertible.ToChar(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Single", "Char")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Single", "Char")); } /// @@ -378,7 +378,7 @@ namespace System /// DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "Single", "DateTime")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Single", "DateTime")); } /// diff --git a/src/mscorlib/src/System/String.Comparison.cs b/src/mscorlib/src/System/String.Comparison.cs index bc78000..c2c3a87 100644 --- a/src/mscorlib/src/System/String.Comparison.cs +++ b/src/mscorlib/src/System/String.Comparison.cs @@ -386,7 +386,7 @@ namespace System // Single comparison to check if comparisonType is within [CurrentCulture .. OrdinalIgnoreCase] if ((uint)(comparisonType - StringComparison.CurrentCulture) > (uint)(StringComparison.OrdinalIgnoreCase - StringComparison.CurrentCulture)) { - throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"), nameof(comparisonType)); + throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType)); } Contract.EndContractBlock(); @@ -439,7 +439,7 @@ namespace System return CompareInfo.CompareOrdinalIgnoreCase(strA, 0, strA.Length, strB, 0, strB.Length); default: - throw new NotSupportedException(Environment.GetResourceString("NotSupported_StringComparison")); + throw new NotSupportedException(SR.NotSupported_StringComparison); } } @@ -572,7 +572,7 @@ namespace System { if (comparisonType < StringComparison.CurrentCulture || comparisonType > StringComparison.OrdinalIgnoreCase) { - throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"), nameof(comparisonType)); + throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType)); } Contract.EndContractBlock(); @@ -589,19 +589,19 @@ namespace System if (length < 0) { - throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_NegativeLength")); + throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_NegativeLength); } if (indexA < 0 || indexB < 0) { string paramName = indexA < 0 ? nameof(indexA) : nameof(indexB); - throw new ArgumentOutOfRangeException(paramName, Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(paramName, SR.ArgumentOutOfRange_Index); } if (strA.Length - indexA < 0 || strB.Length - indexB < 0) { string paramName = strA.Length - indexA < 0 ? nameof(indexA) : nameof(indexB); - throw new ArgumentOutOfRangeException(paramName, Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(paramName, SR.ArgumentOutOfRange_Index); } if (length == 0 || (object.ReferenceEquals(strA, strB) && indexA == indexB)) @@ -633,7 +633,7 @@ namespace System return (CompareInfo.CompareOrdinalIgnoreCase(strA, indexA, lengthA, strB, indexB, lengthB)); default: - throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison")); + throw new ArgumentException(SR.NotSupported_StringComparison); } } @@ -689,13 +689,13 @@ namespace System if (length < 0) { - throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_NegativeCount")); + throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_NegativeCount); } if (indexA < 0 || indexB < 0) { string paramName = indexA < 0 ? nameof(indexA) : nameof(indexB); - throw new ArgumentOutOfRangeException(paramName, Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(paramName, SR.ArgumentOutOfRange_Index); } int lengthA = Math.Min(length, strA.Length - indexA); @@ -704,7 +704,7 @@ namespace System if (lengthA < 0 || lengthB < 0) { string paramName = lengthA < 0 ? nameof(indexA) : nameof(indexB); - throw new ArgumentOutOfRangeException(paramName, Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(paramName, SR.ArgumentOutOfRange_Index); } if (length == 0 || (object.ReferenceEquals(strA, strB) && indexA == indexB)) @@ -731,7 +731,7 @@ namespace System if (other == null) { - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeString")); + throw new ArgumentException(SR.Arg_MustBeString); } return CompareTo(other); // will call the string-based overload @@ -766,7 +766,7 @@ namespace System if (comparisonType < StringComparison.CurrentCulture || comparisonType > StringComparison.OrdinalIgnoreCase) { - throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"), nameof(comparisonType)); + throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType)); } Contract.EndContractBlock(); @@ -800,7 +800,7 @@ namespace System case StringComparison.OrdinalIgnoreCase: return this.Length < value.Length ? false : (CompareInfo.CompareOrdinalIgnoreCase(this, this.Length - value.Length, value.Length, value, 0, value.Length) == 0); default: - throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"), nameof(comparisonType)); + throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType)); } } @@ -874,7 +874,7 @@ namespace System public bool Equals(String value, StringComparison comparisonType) { if (comparisonType < StringComparison.CurrentCulture || comparisonType > StringComparison.OrdinalIgnoreCase) - throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"), nameof(comparisonType)); + throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType)); Contract.EndContractBlock(); if ((Object)this == (Object)value) @@ -919,7 +919,7 @@ namespace System return (CompareInfo.CompareOrdinalIgnoreCase(this, 0, this.Length, value, 0, value.Length) == 0); default: - throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"), nameof(comparisonType)); + throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType)); } } @@ -945,7 +945,7 @@ namespace System public static bool Equals(String a, String b, StringComparison comparisonType) { if (comparisonType < StringComparison.CurrentCulture || comparisonType > StringComparison.OrdinalIgnoreCase) - throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"), nameof(comparisonType)); + throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType)); Contract.EndContractBlock(); if ((Object)a == (Object)b) @@ -994,7 +994,7 @@ namespace System } default: - throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"), nameof(comparisonType)); + throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType)); } } @@ -1123,7 +1123,7 @@ namespace System if (comparisonType < StringComparison.CurrentCulture || comparisonType > StringComparison.OrdinalIgnoreCase) { - throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"), nameof(comparisonType)); + throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType)); } Contract.EndContractBlock(); @@ -1169,7 +1169,7 @@ namespace System return (CompareInfo.CompareOrdinalIgnoreCase(this, 0, value.Length, value, 0, value.Length) == 0); default: - throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"), nameof(comparisonType)); + throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType)); } } diff --git a/src/mscorlib/src/System/String.Manipulation.cs b/src/mscorlib/src/System/String.Manipulation.cs index 90ec773..4a59ec4 100644 --- a/src/mscorlib/src/System/String.Manipulation.cs +++ b/src/mscorlib/src/System/String.Manipulation.cs @@ -763,15 +763,15 @@ namespace System } if (startIndex < 0) { - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_StartIndex")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_StartIndex); } if (count < 0) { - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NegativeCount")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NegativeCount); } if (startIndex > value.Length - count) { - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_IndexCountBuffer); } if (count <= 1) @@ -871,7 +871,7 @@ namespace System public String PadLeft(int totalWidth, char paddingChar) { if (totalWidth < 0) - throw new ArgumentOutOfRangeException(nameof(totalWidth), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(totalWidth), SR.ArgumentOutOfRange_NeedNonNegNum); int oldLength = Length; int count = totalWidth - oldLength; if (count <= 0) @@ -902,7 +902,7 @@ namespace System public String PadRight(int totalWidth, char paddingChar) { if (totalWidth < 0) - throw new ArgumentOutOfRangeException(nameof(totalWidth), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(totalWidth), SR.ArgumentOutOfRange_NeedNonNegNum); int oldLength = Length; int count = totalWidth - oldLength; if (count <= 0) @@ -927,13 +927,13 @@ namespace System { if (startIndex < 0) throw new ArgumentOutOfRangeException(nameof(startIndex), - Environment.GetResourceString("ArgumentOutOfRange_StartIndex")); + SR.ArgumentOutOfRange_StartIndex); if (count < 0) throw new ArgumentOutOfRangeException(nameof(count), - Environment.GetResourceString("ArgumentOutOfRange_NegativeCount")); + SR.ArgumentOutOfRange_NegativeCount); if (count > Length - startIndex) throw new ArgumentOutOfRangeException(nameof(count), - Environment.GetResourceString("ArgumentOutOfRange_IndexCount")); + SR.ArgumentOutOfRange_IndexCount); Contract.Ensures(Contract.Result() != null); Contract.Ensures(Contract.Result().Length == this.Length - count); Contract.EndContractBlock(); @@ -965,13 +965,13 @@ namespace System if (startIndex < 0) { throw new ArgumentOutOfRangeException(nameof(startIndex), - Environment.GetResourceString("ArgumentOutOfRange_StartIndex")); + SR.ArgumentOutOfRange_StartIndex); } if (startIndex >= Length) { throw new ArgumentOutOfRangeException(nameof(startIndex), - Environment.GetResourceString("ArgumentOutOfRange_StartIndexLessThanLength")); + SR.ArgumentOutOfRange_StartIndexLessThanLength); } Contract.Ensures(Contract.Result() != null); @@ -1014,7 +1014,7 @@ namespace System return ReplaceCore(oldValue, newValue, CultureInfo.InvariantCulture, CompareOptions.OrdinalIgnoreCase); default: - throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"), nameof(comparisonType)); + throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType)); } } @@ -1223,10 +1223,10 @@ namespace System { if (count < 0) throw new ArgumentOutOfRangeException(nameof(count), - Environment.GetResourceString("ArgumentOutOfRange_NegativeCount")); + SR.ArgumentOutOfRange_NegativeCount); if (options < StringSplitOptions.None || options > StringSplitOptions.RemoveEmptyEntries) - throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", options)); + throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, options)); Contract.Ensures(Contract.Result() != null); Contract.EndContractBlock(); @@ -1290,12 +1290,12 @@ namespace System if (count < 0) { throw new ArgumentOutOfRangeException(nameof(count), - Environment.GetResourceString("ArgumentOutOfRange_NegativeCount")); + SR.ArgumentOutOfRange_NegativeCount); } if (options < StringSplitOptions.None || options > StringSplitOptions.RemoveEmptyEntries) { - throw new ArgumentException(Environment.GetResourceString("Arg_EnumIllegalVal", (int)options)); + throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, (int)options)); } Contract.EndContractBlock(); @@ -1591,22 +1591,22 @@ namespace System //Bounds Checking. if (startIndex < 0) { - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_StartIndex")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_StartIndex); } if (startIndex > Length) { - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_StartIndexLargerThanLength")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_StartIndexLargerThanLength); } if (length < 0) { - throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_NegativeLength")); + throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_NegativeLength); } if (startIndex > Length - length) { - throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_IndexLength")); + throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_IndexLength); } Contract.EndContractBlock(); diff --git a/src/mscorlib/src/System/String.Searching.cs b/src/mscorlib/src/System/String.Searching.cs index 426bf21..411a45c 100644 --- a/src/mscorlib/src/System/String.Searching.cs +++ b/src/mscorlib/src/System/String.Searching.cs @@ -35,10 +35,10 @@ namespace System public unsafe int IndexOf(char value, int startIndex, int count) { if (startIndex < 0 || startIndex > Length) - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index); if (count < 0 || count > Length - startIndex) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_Count")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_Count); fixed (char* pChars = &m_firstChar) { @@ -124,12 +124,12 @@ namespace System { if (startIndex < 0 || startIndex > this.Length) { - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index); } if (count < 0 || count > this.Length - startIndex) { - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_Count")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_Count); } Contract.EndContractBlock(); @@ -156,10 +156,10 @@ namespace System throw new ArgumentNullException(nameof(value)); if (startIndex < 0 || startIndex > this.Length) - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index); if (count < 0 || startIndex > this.Length - count) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_Count")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_Count); Contract.EndContractBlock(); switch (comparisonType) @@ -186,7 +186,7 @@ namespace System return TextInfo.IndexOfStringOrdinalIgnoreCase(this, value, startIndex, count); default: - throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"), nameof(comparisonType)); + throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType)); } } @@ -214,10 +214,10 @@ namespace System return -1; if (startIndex < 0 || startIndex >= Length) - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index); if (count < 0 || count - 1 > startIndex) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_Count")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_Count); fixed (char* pChars = &m_firstChar) { @@ -300,7 +300,7 @@ namespace System { if (count < 0) { - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_Count")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_Count); } Contract.EndContractBlock(); @@ -332,7 +332,7 @@ namespace System // Now after handling empty strings, make sure we're not out of range if (startIndex < 0 || startIndex > this.Length) - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index); // Make sure that we allow startIndex == this.Length if (startIndex == this.Length) @@ -348,7 +348,7 @@ namespace System // 2nd half of this also catches when startIndex == MAXINT, so MAXINT - 0 + 1 == -1, which is < 0. if (count < 0 || startIndex - count + 1 < 0) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_Count")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_Count); switch (comparisonType) @@ -373,7 +373,7 @@ namespace System else return TextInfo.LastIndexOfStringOrdinalIgnoreCase(this, value, startIndex, count); default: - throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"), nameof(comparisonType)); + throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType)); } } } diff --git a/src/mscorlib/src/System/String.cs b/src/mscorlib/src/System/String.cs index eb4d792..2c1d97e 100644 --- a/src/mscorlib/src/System/String.cs +++ b/src/mscorlib/src/System/String.cs @@ -118,13 +118,13 @@ namespace System if (destination == null) throw new ArgumentNullException(nameof(destination)); if (count < 0) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NegativeCount")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NegativeCount); if (sourceIndex < 0) - throw new ArgumentOutOfRangeException(nameof(sourceIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_Index); if (count > Length - sourceIndex) - throw new ArgumentOutOfRangeException(nameof(sourceIndex), Environment.GetResourceString("ArgumentOutOfRange_IndexCount")); + throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_IndexCount); if (destinationIndex > destination.Length - count || destinationIndex < 0) - throw new ArgumentOutOfRangeException(nameof(destinationIndex), Environment.GetResourceString("ArgumentOutOfRange_IndexCount")); + throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_IndexCount); Contract.EndContractBlock(); // Note: fixed does not like empty arrays @@ -159,9 +159,9 @@ namespace System { // Range check everything. if (startIndex < 0 || startIndex > Length || startIndex > Length - length) - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index); if (length < 0) - throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_Index); Contract.EndContractBlock(); if (length > 0) @@ -232,13 +232,13 @@ namespace System return new String(value, startIndex, length); // default to ANSI if (length < 0) - throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_NeedNonNegNum); if (startIndex < 0) - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_StartIndex")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_StartIndex); if ((value + startIndex) < value) { // overflow check - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_PartialWCHAR")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_PartialWCHAR); } byte[] b = new byte[length]; @@ -252,7 +252,7 @@ namespace System // If we got a NullReferencException. It means the pointer or // the index is out of range throw new ArgumentOutOfRangeException(nameof(value), - Environment.GetResourceString("ArgumentOutOfRange_PartialWCHAR")); + SR.ArgumentOutOfRange_PartialWCHAR); } return enc.GetString(b); @@ -332,7 +332,7 @@ namespace System if (0 != DefaultCharUsed) { - throw new ArgumentException(Environment.GetResourceString("Interop_Marshal_Unmappable_Char")); + throw new ArgumentException(SR.Interop_Marshal_Unmappable_Char); } pbNativeBuffer[nb] = 0; @@ -428,13 +428,13 @@ namespace System throw new ArgumentNullException(nameof(value)); if (startIndex < 0) - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_StartIndex")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_StartIndex); if (length < 0) - throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_NegativeLength")); + throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_NegativeLength); if (startIndex > value.Length - length) - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index); Contract.EndContractBlock(); if (length > 0) @@ -498,7 +498,7 @@ namespace System else if (count == 0) return String.Empty; else - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_MustBeNonNegNum", nameof(count))); + throw new ArgumentOutOfRangeException(nameof(count), SR.Format(SR.ArgumentOutOfRange_MustBeNonNegNum, nameof(count))); } private static unsafe int wcslen(char* ptr) @@ -602,7 +602,7 @@ namespace System #if !FEATURE_PAL if (ptr < (char*)64000) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeStringPtrNotAtom")); + throw new ArgumentException(SR.Arg_MustBeStringPtrNotAtom); #endif // FEATURE_PAL Debug.Assert(this == null, "this == null"); // this is the string constructor, we allocate it @@ -620,7 +620,7 @@ namespace System } catch (NullReferenceException) { - throw new ArgumentOutOfRangeException(nameof(ptr), Environment.GetResourceString("ArgumentOutOfRange_PartialWCHAR")); + throw new ArgumentOutOfRangeException(nameof(ptr), SR.ArgumentOutOfRange_PartialWCHAR); } } @@ -628,12 +628,12 @@ namespace System { if (length < 0) { - throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_NegativeLength")); + throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_NegativeLength); } if (startIndex < 0) { - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_StartIndex")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_StartIndex); } Contract.EndContractBlock(); Debug.Assert(this == null, "this == null"); // this is the string constructor, we allocate it @@ -642,7 +642,7 @@ namespace System if (pFrom < ptr) { // This means that the pointer operation has had an overflow - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_PartialWCHAR")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_PartialWCHAR); } if (length == 0) @@ -658,7 +658,7 @@ namespace System } catch (NullReferenceException) { - throw new ArgumentOutOfRangeException(nameof(ptr), Environment.GetResourceString("ArgumentOutOfRange_PartialWCHAR")); + throw new ArgumentOutOfRangeException(nameof(ptr), SR.ArgumentOutOfRange_PartialWCHAR); } } diff --git a/src/mscorlib/src/System/StringComparer.cs b/src/mscorlib/src/System/StringComparer.cs index 19d2e9a..42b35fc 100644 --- a/src/mscorlib/src/System/StringComparer.cs +++ b/src/mscorlib/src/System/StringComparer.cs @@ -93,7 +93,7 @@ namespace System case StringComparison.OrdinalIgnoreCase: return OrdinalIgnoreCase; default: - throw new ArgumentException(Environment.GetResourceString("NotSupported_StringComparison"), nameof(comparisonType)); + throw new ArgumentException(SR.NotSupported_StringComparison, nameof(comparisonType)); } } @@ -131,7 +131,7 @@ namespace System return ia.CompareTo(y); } - throw new ArgumentException(Environment.GetResourceString("Argument_ImplementIComparable")); + throw new ArgumentException(SR.Argument_ImplementIComparable); } diff --git a/src/mscorlib/src/System/StubHelpers.cs b/src/mscorlib/src/System/StubHelpers.cs index 7497cbf..f584ece 100644 --- a/src/mscorlib/src/System/StubHelpers.cs +++ b/src/mscorlib/src/System/StubHelpers.cs @@ -532,7 +532,7 @@ namespace System.StubHelpers internal static unsafe IntPtr ConvertToNative(string managed) { if (!Environment.IsWinRTSupported) - throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_WinRT")); + throw new PlatformNotSupportedException(SR.PlatformNotSupported_WinRT); if (managed == null) throw new ArgumentNullException(); // We don't have enough information to get the argument name @@ -552,7 +552,7 @@ namespace System.StubHelpers [Out] HSTRING_HEADER* hstringHeader) { if (!Environment.IsWinRTSupported) - throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_WinRT")); + throw new PlatformNotSupportedException(SR.PlatformNotSupported_WinRT); if (managed == null) throw new ArgumentNullException(); // We don't have enough information to get the argument name @@ -571,7 +571,7 @@ namespace System.StubHelpers { if (!Environment.IsWinRTSupported) { - throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_WinRT")); + throw new PlatformNotSupportedException(SR.PlatformNotSupported_WinRT); } return WindowsRuntimeMarshal.HStringToString(hstring); @@ -1003,7 +1003,7 @@ namespace System.StubHelpers } default: - throw new ArgumentException(Environment.GetResourceString("Arg_NDirectBadObject")); + throw new ArgumentException(SR.Arg_NDirectBadObject); } // marshal the object as C-style array (UnmanagedType.LPArray) @@ -1170,7 +1170,7 @@ namespace System.StubHelpers return IntPtr.Zero; if (pManagedHome is ArrayWithOffset) - throw new ArgumentException(Environment.GetResourceString("Arg_MarshalAsAnyRestriction")); + throw new ArgumentException(SR.Arg_MarshalAsAnyRestriction); IntPtr pNativeHome; @@ -1202,7 +1202,7 @@ namespace System.StubHelpers else { // this type is not supported for AsAny marshaling - throw new ArgumentException(Environment.GetResourceString("Arg_NDirectBadObject")); + throw new ArgumentException(SR.Arg_NDirectBadObject); } } @@ -1328,7 +1328,7 @@ namespace System.StubHelpers { if (!Environment.IsWinRTSupported) { - throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_WinRT")); + throw new PlatformNotSupportedException(SR.PlatformNotSupported_WinRT); } string typeName; @@ -1336,7 +1336,7 @@ namespace System.StubHelpers { if (managedType.GetType() != typeof(System.RuntimeType)) { // The type should be exactly System.RuntimeType (and not its child System.ReflectionOnlyType, or other System.Type children) - throw new ArgumentException(Environment.GetResourceString("Argument_WinRTSystemRuntimeType", managedType.GetType().ToString())); + throw new ArgumentException(SR.Format(SR.Argument_WinRTSystemRuntimeType, managedType.GetType().ToString())); } bool isPrimitive; @@ -1371,7 +1371,7 @@ namespace System.StubHelpers { if (!Environment.IsWinRTSupported) { - throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_WinRT")); + throw new PlatformNotSupportedException(SR.PlatformNotSupported_WinRT); } string typeName = WindowsRuntimeMarshal.HStringToString(pNativeType->typeName); @@ -1392,7 +1392,7 @@ namespace System.StubHelpers // TypeSource must match if (isPrimitive != (pNativeType->typeKind == TypeKind.Primitive)) - throw new ArgumentException(Environment.GetResourceString("Argument_Unexpected_TypeSource")); + throw new ArgumentException(SR.Argument_Unexpected_TypeSource); } } @@ -1414,7 +1414,7 @@ namespace System.StubHelpers { if (!Environment.IsWinRTSupported) { - throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_WinRT")); + throw new PlatformNotSupportedException(SR.PlatformNotSupported_WinRT); } if (ex == null) @@ -1429,7 +1429,7 @@ namespace System.StubHelpers if (!Environment.IsWinRTSupported) { - throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_WinRT")); + throw new PlatformNotSupportedException(SR.PlatformNotSupported_WinRT); } Exception e = null; @@ -1722,7 +1722,7 @@ namespace System.StubHelpers { if (length > 0x7ffffff0) { - throw new MarshalDirectiveException(Environment.GetResourceString("Marshaler_StringTooLong")); + throw new MarshalDirectiveException(SR.Marshaler_StringTooLong); } } diff --git a/src/mscorlib/src/System/Text/ASCIIEncoding.cs b/src/mscorlib/src/System/Text/ASCIIEncoding.cs index a3107eb..f42a1c4 100644 --- a/src/mscorlib/src/System/Text/ASCIIEncoding.cs +++ b/src/mscorlib/src/System/Text/ASCIIEncoding.cs @@ -178,8 +178,7 @@ namespace System.Text // We always need the fallback buffer in get bytes so we can flush any remaining ones if necessary fallbackBuffer = encoder.FallbackBuffer; if (fallbackBuffer.Remaining > 0 && encoder.m_throwOnOverflow) - throw new ArgumentException(Environment.GetResourceString("Argument_EncoderFallbackNotEmpty", - this.EncodingName, encoder.Fallback.GetType())); + throw new ArgumentException(SR.Format(SR.Argument_EncoderFallbackNotEmpty, this.EncodingName, encoder.Fallback.GetType())); // Set our internal fallback interesting things. fallbackBuffer.InternalInitialize(chars, charEnd, encoder, false); @@ -319,8 +318,7 @@ namespace System.Text // We always need the fallback buffer in get bytes so we can flush any remaining ones if necessary fallbackBuffer = encoder.FallbackBuffer; if (fallbackBuffer.Remaining > 0 && encoder.m_throwOnOverflow) - throw new ArgumentException(Environment.GetResourceString("Argument_EncoderFallbackNotEmpty", - this.EncodingName, encoder.Fallback.GetType())); + throw new ArgumentException(SR.Format(SR.Argument_EncoderFallbackNotEmpty, this.EncodingName, encoder.Fallback.GetType())); // Set our internal fallback interesting things. fallbackBuffer.InternalInitialize(charStart, charEnd, encoder, true); @@ -714,7 +712,7 @@ namespace System.Text { if (charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Characters would be # of characters + 1 in case high surrogate is ? * max fallback @@ -726,7 +724,7 @@ namespace System.Text // 1 to 1 for most characters. Only surrogates with fallbacks have less. if (byteCount > 0x7fffffff) - throw new ArgumentOutOfRangeException(nameof(charCount), Environment.GetResourceString("ArgumentOutOfRange_GetByteCountOverflow")); + throw new ArgumentOutOfRangeException(nameof(charCount), SR.ArgumentOutOfRange_GetByteCountOverflow); return (int)byteCount; } @@ -735,7 +733,7 @@ namespace System.Text { if (byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Just return length, SBCS stay the same length because they don't map to surrogate @@ -746,7 +744,7 @@ namespace System.Text charCount *= DecoderFallback.MaxCharCount; if (charCount > 0x7fffffff) - throw new ArgumentOutOfRangeException(nameof(byteCount), Environment.GetResourceString("ArgumentOutOfRange_GetCharCountOverflow")); + throw new ArgumentOutOfRangeException(nameof(byteCount), SR.ArgumentOutOfRange_GetCharCountOverflow); return (int)charCount; } diff --git a/src/mscorlib/src/System/Text/Decoder.cs b/src/mscorlib/src/System/Text/Decoder.cs index e8b9128..a52c9ba 100644 --- a/src/mscorlib/src/System/Text/Decoder.cs +++ b/src/mscorlib/src/System/Text/Decoder.cs @@ -55,7 +55,7 @@ namespace System.Text // Can't change fallback if buffer is wrong if (m_fallbackBuffer != null && m_fallbackBuffer.Remaining > 0) throw new ArgumentException( - Environment.GetResourceString("Argument_FallbackBufferNotEmpty"), nameof(value)); + SR.Argument_FallbackBufferNotEmpty, nameof(value)); m_fallback = value; m_fallbackBuffer = null; @@ -127,11 +127,11 @@ namespace System.Text // Validate input parameters if (bytes == null) throw new ArgumentNullException(nameof(bytes), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (count < 0) throw new ArgumentOutOfRangeException(nameof(count), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); byte[] arrbyte = new byte[count]; @@ -191,11 +191,11 @@ namespace System.Text // Validate input parameters if (chars == null || bytes == null) throw new ArgumentNullException(chars == null ? nameof(chars) : nameof(bytes), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (byteCount < 0 || charCount < 0) throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount) : nameof(charCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Get the byte array to convert @@ -249,23 +249,23 @@ namespace System.Text // Validate parameters if (bytes == null || chars == null) throw new ArgumentNullException((bytes == null ? nameof(bytes) : nameof(chars)), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (byteIndex < 0 || byteCount < 0) throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex) : nameof(byteCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); if (charIndex < 0 || charCount < 0) throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - byteIndex < byteCount) throw new ArgumentOutOfRangeException(nameof(bytes), - Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer")); + SR.ArgumentOutOfRange_IndexCountBuffer); if (chars.Length - charIndex < charCount) throw new ArgumentOutOfRangeException(nameof(chars), - Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer")); + SR.ArgumentOutOfRange_IndexCountBuffer); Contract.EndContractBlock(); bytesUsed = byteCount; @@ -287,7 +287,7 @@ namespace System.Text } // Oops, we didn't have anything, we'll have to throw an overflow - throw new ArgumentException(Environment.GetResourceString("Argument_ConversionOverflow")); + throw new ArgumentException(SR.Argument_ConversionOverflow); } // This is the version that uses *. @@ -306,11 +306,11 @@ namespace System.Text // Validate input parameters if (chars == null || bytes == null) throw new ArgumentNullException(chars == null ? nameof(chars) : nameof(bytes), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (byteCount < 0 || charCount < 0) throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount) : nameof(charCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Get ready to do it @@ -333,7 +333,7 @@ namespace System.Text } // Oops, we didn't have anything, we'll have to throw an overflow - throw new ArgumentException(Environment.GetResourceString("Argument_ConversionOverflow")); + throw new ArgumentException(SR.Argument_ConversionOverflow); } } } diff --git a/src/mscorlib/src/System/Text/DecoderExceptionFallback.cs b/src/mscorlib/src/System/Text/DecoderExceptionFallback.cs index b709dcd..e319e15 100644 --- a/src/mscorlib/src/System/Text/DecoderExceptionFallback.cs +++ b/src/mscorlib/src/System/Text/DecoderExceptionFallback.cs @@ -94,8 +94,7 @@ namespace System.Text // Known index throw new DecoderFallbackException( - Environment.GetResourceString("Argument_InvalidCodePageBytesIndex", - strBytes, index), bytesUnknown, index); + SR.Format(SR.Argument_InvalidCodePageBytesIndex, strBytes, index), bytesUnknown, index); } } @@ -107,7 +106,7 @@ namespace System.Text private int index = 0; public DecoderFallbackException() - : base(Environment.GetResourceString("Arg_ArgumentException")) + : base(SR.Arg_ArgumentException) { SetErrorCode(__HResults.COR_E_ARGUMENT); } diff --git a/src/mscorlib/src/System/Text/DecoderFallback.cs b/src/mscorlib/src/System/Text/DecoderFallback.cs index e7b57bd..9311cda 100644 --- a/src/mscorlib/src/System/Text/DecoderFallback.cs +++ b/src/mscorlib/src/System/Text/DecoderFallback.cs @@ -160,14 +160,14 @@ namespace System.Text { // High Surrogate if (bHighSurrogate) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex")); + throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex); bHighSurrogate = true; } else { // Low surrogate if (bHighSurrogate == false) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex")); + throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex); bHighSurrogate = false; } } @@ -183,7 +183,7 @@ namespace System.Text // Need to make sure that bHighSurrogate isn't true if (bHighSurrogate) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex")); + throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex); // Now we aren't going to be false, so its OK to update chars chars = charTemp; @@ -220,14 +220,14 @@ namespace System.Text { // High Surrogate if (bHighSurrogate) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex")); + throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex); bHighSurrogate = true; } else { // Low surrogate if (bHighSurrogate == false) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex")); + throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex); bHighSurrogate = false; } } @@ -237,7 +237,7 @@ namespace System.Text // Need to make sure that bHighSurrogate isn't true if (bHighSurrogate) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex")); + throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex); return count; } @@ -264,8 +264,7 @@ namespace System.Text // Throw it, using our complete bytes throw new ArgumentException( - Environment.GetResourceString("Argument_RecursiveFallbackBytes", - strBytes.ToString()), nameof(bytesUnknown)); + SR.Format(SR.Argument_RecursiveFallbackBytes, strBytes.ToString()), nameof(bytesUnknown)); } } } diff --git a/src/mscorlib/src/System/Text/DecoderNLS.cs b/src/mscorlib/src/System/Text/DecoderNLS.cs index c2f5e47..6fcfc79 100644 --- a/src/mscorlib/src/System/Text/DecoderNLS.cs +++ b/src/mscorlib/src/System/Text/DecoderNLS.cs @@ -38,7 +38,7 @@ namespace System.Text throw new NotSupportedException( String.Format( System.Globalization.CultureInfo.CurrentCulture, - Environment.GetResourceString("NotSupported_TypeCannotDeserialized"), this.GetType())); + SR.NotSupported_TypeCannotDeserialized, this.GetType())); } // ISerializable implementation. called during serialization. @@ -81,15 +81,15 @@ namespace System.Text // Validate Parameters if (bytes == null) throw new ArgumentNullException(nameof(bytes), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (index < 0 || count < 0) throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - index < count) throw new ArgumentOutOfRangeException(nameof(bytes), - Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer")); + SR.ArgumentOutOfRange_IndexCountBuffer); Contract.EndContractBlock(); @@ -107,11 +107,11 @@ namespace System.Text // Validate parameters if (bytes == null) throw new ArgumentNullException(nameof(bytes), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (count < 0) throw new ArgumentOutOfRangeException(nameof(count), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Remember the flush @@ -134,19 +134,19 @@ namespace System.Text // Validate Parameters if (bytes == null || chars == null) throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (byteIndex < 0 || byteCount < 0) throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex) : nameof(byteCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - byteIndex < byteCount) throw new ArgumentOutOfRangeException(nameof(bytes), - Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer")); + SR.ArgumentOutOfRange_IndexCountBuffer); if (charIndex < 0 || charIndex > chars.Length) throw new ArgumentOutOfRangeException(nameof(charIndex), - Environment.GetResourceString("ArgumentOutOfRange_Index")); + SR.ArgumentOutOfRange_Index); Contract.EndContractBlock(); @@ -172,11 +172,11 @@ namespace System.Text // Validate parameters if (chars == null || bytes == null) throw new ArgumentNullException((chars == null ? nameof(chars) : nameof(bytes)), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (byteCount < 0 || charCount < 0) throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount) : nameof(charCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Remember our flush @@ -196,23 +196,23 @@ namespace System.Text // Validate parameters if (bytes == null || chars == null) throw new ArgumentNullException((bytes == null ? nameof(bytes) : nameof(chars)), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (byteIndex < 0 || byteCount < 0) throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex) : nameof(byteCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); if (charIndex < 0 || charCount < 0) throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - byteIndex < byteCount) throw new ArgumentOutOfRangeException(nameof(bytes), - Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer")); + SR.ArgumentOutOfRange_IndexCountBuffer); if (chars.Length - charIndex < charCount) throw new ArgumentOutOfRangeException(nameof(chars), - Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer")); + SR.ArgumentOutOfRange_IndexCountBuffer); Contract.EndContractBlock(); @@ -242,11 +242,11 @@ namespace System.Text // Validate input parameters if (chars == null || bytes == null) throw new ArgumentNullException(chars == null ? nameof(chars) : nameof(bytes), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (byteCount < 0 || charCount < 0) throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount) : nameof(charCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // We don't want to throw diff --git a/src/mscorlib/src/System/Text/DecoderReplacementFallback.cs b/src/mscorlib/src/System/Text/DecoderReplacementFallback.cs index 8147da5..b274691 100644 --- a/src/mscorlib/src/System/Text/DecoderReplacementFallback.cs +++ b/src/mscorlib/src/System/Text/DecoderReplacementFallback.cs @@ -59,7 +59,7 @@ namespace System.Text break; } if (bFoundHigh) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex", nameof(replacement))); + throw new ArgumentException(SR.Format(SR.Argument_InvalidCharSequenceNoIndex, nameof(replacement))); strDefault = replacement; } diff --git a/src/mscorlib/src/System/Text/Encoder.cs b/src/mscorlib/src/System/Text/Encoder.cs index 9ec8231..82eb2ad 100644 --- a/src/mscorlib/src/System/Text/Encoder.cs +++ b/src/mscorlib/src/System/Text/Encoder.cs @@ -55,7 +55,7 @@ namespace System.Text // Can't change fallback if buffer is wrong if (m_fallbackBuffer != null && m_fallbackBuffer.Remaining > 0) throw new ArgumentException( - Environment.GetResourceString("Argument_FallbackBufferNotEmpty"), nameof(value)); + SR.Argument_FallbackBufferNotEmpty, nameof(value)); m_fallback = value; m_fallbackBuffer = null; @@ -124,11 +124,11 @@ namespace System.Text // Validate input parameters if (chars == null) throw new ArgumentNullException(nameof(chars), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (count < 0) throw new ArgumentOutOfRangeException(nameof(count), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); char[] arrChar = new char[count]; @@ -185,11 +185,11 @@ namespace System.Text // Validate input parameters if (bytes == null || chars == null) throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Get the char array to convert @@ -242,23 +242,23 @@ namespace System.Text // Validate parameters if (chars == null || bytes == null) throw new ArgumentNullException((chars == null ? nameof(chars) : nameof(bytes)), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); if (byteIndex < 0 || byteCount < 0) throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex) : nameof(byteCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - charIndex < charCount) throw new ArgumentOutOfRangeException(nameof(chars), - Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer")); + SR.ArgumentOutOfRange_IndexCountBuffer); if (bytes.Length - byteIndex < byteCount) throw new ArgumentOutOfRangeException(nameof(bytes), - Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer")); + SR.ArgumentOutOfRange_IndexCountBuffer); Contract.EndContractBlock(); charsUsed = charCount; @@ -282,7 +282,7 @@ namespace System.Text } // Oops, we didn't have anything, we'll have to throw an overflow - throw new ArgumentException(Environment.GetResourceString("Argument_ConversionOverflow")); + throw new ArgumentException(SR.Argument_ConversionOverflow); } // Same thing, but using pointers @@ -300,10 +300,10 @@ namespace System.Text // Validate input parameters if (bytes == null || chars == null) throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Get ready to do it @@ -326,7 +326,7 @@ namespace System.Text } // Oops, we didn't have anything, we'll have to throw an overflow - throw new ArgumentException(Environment.GetResourceString("Argument_ConversionOverflow")); + throw new ArgumentException(SR.Argument_ConversionOverflow); } } } diff --git a/src/mscorlib/src/System/Text/EncoderBestFitFallback.cs b/src/mscorlib/src/System/Text/EncoderBestFitFallback.cs index 89e4f51..eb31655 100644 --- a/src/mscorlib/src/System/Text/EncoderBestFitFallback.cs +++ b/src/mscorlib/src/System/Text/EncoderBestFitFallback.cs @@ -120,13 +120,11 @@ namespace System.Text // Double check input surrogate pair if (!Char.IsHighSurrogate(charUnknownHigh)) throw new ArgumentOutOfRangeException(nameof(charUnknownHigh), - Environment.GetResourceString("ArgumentOutOfRange_Range", - 0xD800, 0xDBFF)); + SR.Format(SR.ArgumentOutOfRange_Range, 0xD800, 0xDBFF)); if (!Char.IsLowSurrogate(charUnknownLow)) throw new ArgumentOutOfRangeException(nameof(charUnknownLow), - Environment.GetResourceString("ArgumentOutOfRange_Range", - 0xDC00, 0xDFFF)); + SR.Format(SR.ArgumentOutOfRange_Range, 0xDC00, 0xDFFF)); Contract.EndContractBlock(); // If we had a buffer already we're being recursive, throw, it's probably at the suspect diff --git a/src/mscorlib/src/System/Text/EncoderExceptionFallback.cs b/src/mscorlib/src/System/Text/EncoderExceptionFallback.cs index b64e19e..251b4b4 100644 --- a/src/mscorlib/src/System/Text/EncoderExceptionFallback.cs +++ b/src/mscorlib/src/System/Text/EncoderExceptionFallback.cs @@ -54,8 +54,7 @@ namespace System.Text { // Fall back our char throw new EncoderFallbackException( - Environment.GetResourceString("Argument_InvalidCodePageConversionIndex", - (int)charUnknown, index), charUnknown, index); + SR.Format(SR.Argument_InvalidCodePageConversionIndex, (int)charUnknown, index), charUnknown, index); } public override bool Fallback(char charUnknownHigh, char charUnknownLow, int index) @@ -63,14 +62,12 @@ namespace System.Text if (!Char.IsHighSurrogate(charUnknownHigh)) { throw new ArgumentOutOfRangeException(nameof(charUnknownHigh), - Environment.GetResourceString("ArgumentOutOfRange_Range", - 0xD800, 0xDBFF)); + SR.Format(SR.ArgumentOutOfRange_Range, 0xD800, 0xDBFF)); } if (!Char.IsLowSurrogate(charUnknownLow)) { throw new ArgumentOutOfRangeException(nameof(charUnknownLow), - Environment.GetResourceString("ArgumentOutOfRange_Range", - 0xDC00, 0xDFFF)); + SR.Format(SR.ArgumentOutOfRange_Range, 0xDC00, 0xDFFF)); } Contract.EndContractBlock(); @@ -78,8 +75,7 @@ namespace System.Text // Fall back our char throw new EncoderFallbackException( - Environment.GetResourceString("Argument_InvalidCodePageConversionIndex", - iTemp, index), charUnknownHigh, charUnknownLow, index); + SR.Format(SR.Argument_InvalidCodePageConversionIndex, iTemp, index), charUnknownHigh, charUnknownLow, index); } public override char GetNextChar() @@ -112,7 +108,7 @@ namespace System.Text private int index; public EncoderFallbackException() - : base(Environment.GetResourceString("Arg_ArgumentException")) + : base(SR.Arg_ArgumentException) { SetErrorCode(__HResults.COR_E_ARGUMENT); } @@ -146,14 +142,12 @@ namespace System.Text if (!Char.IsHighSurrogate(charUnknownHigh)) { throw new ArgumentOutOfRangeException(nameof(charUnknownHigh), - Environment.GetResourceString("ArgumentOutOfRange_Range", - 0xD800, 0xDBFF)); + SR.Format(SR.ArgumentOutOfRange_Range, 0xD800, 0xDBFF)); } if (!Char.IsLowSurrogate(charUnknownLow)) { throw new ArgumentOutOfRangeException(nameof(CharUnknownLow), - Environment.GetResourceString("ArgumentOutOfRange_Range", - 0xDC00, 0xDFFF)); + SR.Format(SR.ArgumentOutOfRange_Range, 0xDC00, 0xDFFF)); } Contract.EndContractBlock(); diff --git a/src/mscorlib/src/System/Text/EncoderFallback.cs b/src/mscorlib/src/System/Text/EncoderFallback.cs index 2d1ee52..410b6f5 100644 --- a/src/mscorlib/src/System/Text/EncoderFallback.cs +++ b/src/mscorlib/src/System/Text/EncoderFallback.cs @@ -224,8 +224,7 @@ namespace System.Text { // Throw it, using our complete character throw new ArgumentException( - Environment.GetResourceString("Argument_RecursiveFallback", - charRecursive), "chars"); + SR.Format(SR.Argument_RecursiveFallback, charRecursive), "chars"); } } } diff --git a/src/mscorlib/src/System/Text/EncoderNLS.cs b/src/mscorlib/src/System/Text/EncoderNLS.cs index 2ba9097..99a26ca 100644 --- a/src/mscorlib/src/System/Text/EncoderNLS.cs +++ b/src/mscorlib/src/System/Text/EncoderNLS.cs @@ -41,7 +41,7 @@ namespace System.Text throw new NotSupportedException( String.Format( System.Globalization.CultureInfo.CurrentCulture, - Environment.GetResourceString("NotSupported_TypeCannotDeserialized"), this.GetType())); + SR.NotSupported_TypeCannotDeserialized, this.GetType())); } // ISerializable implementation. called during serialization. @@ -81,15 +81,15 @@ namespace System.Text // Validate input parameters if (chars == null) throw new ArgumentNullException(nameof(chars), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (index < 0 || count < 0) throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - index < count) throw new ArgumentOutOfRangeException(nameof(chars), - Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer")); + SR.ArgumentOutOfRange_IndexCountBuffer); Contract.EndContractBlock(); // Avoid empty input problem @@ -110,11 +110,11 @@ namespace System.Text // Validate input parameters if (chars == null) throw new ArgumentNullException(nameof(chars), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (count < 0) throw new ArgumentOutOfRangeException(nameof(count), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); this.m_mustFlush = flush; @@ -128,19 +128,19 @@ namespace System.Text // Validate parameters if (chars == null || bytes == null) throw new ArgumentNullException((chars == null ? nameof(chars) : nameof(bytes)), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - charIndex < charCount) throw new ArgumentOutOfRangeException(nameof(chars), - Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer")); + SR.ArgumentOutOfRange_IndexCountBuffer); if (byteIndex < 0 || byteIndex > bytes.Length) throw new ArgumentOutOfRangeException(nameof(byteIndex), - Environment.GetResourceString("ArgumentOutOfRange_Index")); + SR.ArgumentOutOfRange_Index); Contract.EndContractBlock(); if (chars.Length == 0) @@ -164,11 +164,11 @@ namespace System.Text // Validate parameters if (chars == null || bytes == null) throw new ArgumentNullException((chars == null ? nameof(chars) : nameof(bytes)), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (byteCount < 0 || charCount < 0) throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount) : nameof(charCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); this.m_mustFlush = flush; @@ -185,23 +185,23 @@ namespace System.Text // Validate parameters if (chars == null || bytes == null) throw new ArgumentNullException((chars == null ? nameof(chars) : nameof(bytes)), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); if (byteIndex < 0 || byteCount < 0) throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex) : nameof(byteCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - charIndex < charCount) throw new ArgumentOutOfRangeException(nameof(chars), - Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer")); + SR.ArgumentOutOfRange_IndexCountBuffer); if (bytes.Length - byteIndex < byteCount) throw new ArgumentOutOfRangeException(nameof(bytes), - Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer")); + SR.ArgumentOutOfRange_IndexCountBuffer); Contract.EndContractBlock(); @@ -231,10 +231,10 @@ namespace System.Text // Validate input parameters if (bytes == null || chars == null) throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // We don't want to throw diff --git a/src/mscorlib/src/System/Text/EncoderReplacementFallback.cs b/src/mscorlib/src/System/Text/EncoderReplacementFallback.cs index 0b8abb3..65b807c 100644 --- a/src/mscorlib/src/System/Text/EncoderReplacementFallback.cs +++ b/src/mscorlib/src/System/Text/EncoderReplacementFallback.cs @@ -61,7 +61,7 @@ namespace System.Text break; } if (bFoundHigh) - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex", nameof(replacement))); + throw new ArgumentException(SR.Format(SR.Argument_InvalidCharSequenceNoIndex, nameof(replacement))); strDefault = replacement; } @@ -149,13 +149,11 @@ namespace System.Text // Double check input surrogate pair if (!Char.IsHighSurrogate(charUnknownHigh)) throw new ArgumentOutOfRangeException(nameof(charUnknownHigh), - Environment.GetResourceString("ArgumentOutOfRange_Range", - 0xD800, 0xDBFF)); + SR.Format(SR.ArgumentOutOfRange_Range, 0xD800, 0xDBFF)); if (!Char.IsLowSurrogate(charUnknownLow)) throw new ArgumentOutOfRangeException(nameof(charUnknownLow), - Environment.GetResourceString("ArgumentOutOfRange_Range", - 0xDC00, 0xDFFF)); + SR.Format(SR.ArgumentOutOfRange_Range, 0xDC00, 0xDFFF)); Contract.EndContractBlock(); // If we had a buffer already we're being recursive, throw, it's probably at the suspect diff --git a/src/mscorlib/src/System/Text/Encoding.cs b/src/mscorlib/src/System/Text/Encoding.cs index 57e54fd..a7a9158 100644 --- a/src/mscorlib/src/System/Text/Encoding.cs +++ b/src/mscorlib/src/System/Text/Encoding.cs @@ -362,12 +362,12 @@ namespace System.Text if (srcEncoding == null || dstEncoding == null) { throw new ArgumentNullException((srcEncoding == null ? nameof(srcEncoding) : nameof(dstEncoding)), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); } if (bytes == null) { throw new ArgumentNullException(nameof(bytes), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); } Contract.Ensures(Contract.Result() != null); @@ -397,8 +397,7 @@ namespace System.Text if (codepage < 0 || codepage > 65535) { throw new ArgumentOutOfRangeException( - nameof(codepage), Environment.GetResourceString("ArgumentOutOfRange_Range", - 0, 65535)); + nameof(codepage), SR.Format(SR.ArgumentOutOfRange_Range, 0, 65535)); } Contract.EndContractBlock(); @@ -423,15 +422,14 @@ namespace System.Text case CodePageNoMac: // 2 CP_MACCP case CodePageNoThread: // 3 CP_THREAD_ACP case CodePageNoSymbol: // 42 CP_SYMBOL - throw new ArgumentException(Environment.GetResourceString( - "Argument_CodepageNotSupported", codepage), nameof(codepage)); + throw new ArgumentException(SR.Format(SR.Argument_CodepageNotSupported, codepage), nameof(codepage)); } // Is it a valid code page? if (EncodingTable.GetCodePageDataItem(codepage) == null) { throw new NotSupportedException( - Environment.GetResourceString("NotSupported_NoCodepageData", codepage)); + SR.Format(SR.NotSupported_NoCodepageData, codepage)); } return UTF8; @@ -514,7 +512,7 @@ namespace System.Text if (dataItem == null) { throw new NotSupportedException( - Environment.GetResourceString("NotSupported_NoCodepageData", m_codePage)); + SR.Format(SR.NotSupported_NoCodepageData, m_codePage)); } } } @@ -540,7 +538,7 @@ namespace System.Text { get { - return Environment.GetResourceString("Globalization.cp_" + m_codePage.ToString()); + return SR.GetResourceString("Globalization.cp_" + m_codePage.ToString()); } } @@ -668,7 +666,7 @@ namespace System.Text set { if (this.IsReadOnly) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ReadOnly")); + throw new InvalidOperationException(SR.InvalidOperation_ReadOnly); if (value == null) throw new ArgumentNullException(nameof(value)); @@ -689,7 +687,7 @@ namespace System.Text set { if (this.IsReadOnly) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ReadOnly")); + throw new InvalidOperationException(SR.InvalidOperation_ReadOnly); if (value == null) throw new ArgumentNullException(nameof(value)); @@ -739,7 +737,7 @@ namespace System.Text if (chars == null) { throw new ArgumentNullException(nameof(chars), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); } Contract.EndContractBlock(); @@ -770,16 +768,16 @@ namespace System.Text { if (s == null) throw new ArgumentNullException(nameof(s), - Environment.GetResourceString("ArgumentNull_String")); + SR.ArgumentNull_String); if (index < 0) throw new ArgumentOutOfRangeException(nameof(index), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); if (count < 0) throw new ArgumentOutOfRangeException(nameof(count), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); if (index > s.Length - count) throw new ArgumentOutOfRangeException(nameof(index), - Environment.GetResourceString("ArgumentOutOfRange_IndexCount")); + SR.ArgumentOutOfRange_IndexCount); Contract.EndContractBlock(); unsafe @@ -802,11 +800,11 @@ namespace System.Text // Validate input parameters if (chars == null) throw new ArgumentNullException(nameof(chars), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (count < 0) throw new ArgumentOutOfRangeException(nameof(count), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); char[] arrChar = new char[count]; @@ -837,7 +835,7 @@ namespace System.Text if (chars == null) { throw new ArgumentNullException(nameof(chars), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); } Contract.EndContractBlock(); return GetBytes(chars, 0, chars.Length); @@ -874,7 +872,7 @@ namespace System.Text { if (s == null) throw new ArgumentNullException(nameof(s), - Environment.GetResourceString("ArgumentNull_String")); + SR.ArgumentNull_String); Contract.EndContractBlock(); int byteCount = GetByteCount(s); @@ -892,16 +890,16 @@ namespace System.Text { if (s == null) throw new ArgumentNullException(nameof(s), - Environment.GetResourceString("ArgumentNull_String")); + SR.ArgumentNull_String); if (index < 0) throw new ArgumentOutOfRangeException(nameof(index), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); if (count < 0) throw new ArgumentOutOfRangeException(nameof(count), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); if (index > s.Length - count) throw new ArgumentOutOfRangeException(nameof(index), - Environment.GetResourceString("ArgumentOutOfRange_IndexCount")); + SR.ArgumentOutOfRange_IndexCount); Contract.EndContractBlock(); unsafe @@ -964,11 +962,11 @@ namespace System.Text // Validate input parameters if (bytes == null || chars == null) throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Get the char array to convert @@ -1010,7 +1008,7 @@ namespace System.Text if (bytes == null) { throw new ArgumentNullException(nameof(bytes), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); } Contract.EndContractBlock(); return GetCharCount(bytes, 0, bytes.Length); @@ -1031,11 +1029,11 @@ namespace System.Text // Validate input parameters if (bytes == null) throw new ArgumentNullException(nameof(bytes), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (count < 0) throw new ArgumentOutOfRangeException(nameof(count), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); byte[] arrbyte = new byte[count]; @@ -1063,7 +1061,7 @@ namespace System.Text if (bytes == null) { throw new ArgumentNullException(nameof(bytes), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); } Contract.EndContractBlock(); return GetChars(bytes, 0, bytes.Length); @@ -1118,11 +1116,11 @@ namespace System.Text // Validate input parameters if (chars == null || bytes == null) throw new ArgumentNullException(chars == null ? nameof(chars) : nameof(bytes), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); if (byteCount < 0 || charCount < 0) throw new ArgumentOutOfRangeException((byteCount < 0 ? nameof(byteCount) : nameof(charCount)), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Get the byte array to convert @@ -1169,10 +1167,10 @@ namespace System.Text public unsafe string GetString(byte* bytes, int byteCount) { if (bytes == null) - throw new ArgumentNullException(nameof(bytes), Environment.GetResourceString("ArgumentNull_Array")); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (byteCount < 0) - throw new ArgumentOutOfRangeException(nameof(byteCount), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(byteCount), SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); return String.CreateStringFromEncoding(bytes, byteCount, this); @@ -1297,7 +1295,7 @@ namespace System.Text { if (bytes == null) throw new ArgumentNullException(nameof(bytes), - Environment.GetResourceString("ArgumentNull_Array")); + SR.ArgumentNull_Array); Contract.EndContractBlock(); return GetString(bytes, 0, bytes.Length); @@ -1385,8 +1383,7 @@ namespace System.Text // Special message to include fallback type in case fallback's GetMaxCharCount is broken // This happens if user has implimented an encoder fallback with a broken GetMaxCharCount throw new ArgumentException( - Environment.GetResourceString("Argument_EncodingConversionOverflowBytes", - EncodingName, EncoderFallback.GetType()), "bytes"); + SR.Format(SR.Argument_EncodingConversionOverflowBytes, EncodingName, EncoderFallback.GetType()), "bytes"); } internal void ThrowBytesOverflow(EncoderNLS encoder, bool nothingEncoded) @@ -1409,8 +1406,7 @@ namespace System.Text // Special message to include fallback type in case fallback's GetMaxCharCount is broken // This happens if user has implimented a decoder fallback with a broken GetMaxCharCount throw new ArgumentException( - Environment.GetResourceString("Argument_EncodingConversionOverflowChars", - EncodingName, DecoderFallback.GetType()), "chars"); + SR.Format(SR.Argument_EncodingConversionOverflowChars, EncodingName, DecoderFallback.GetType()), "chars"); } internal void ThrowCharsOverflow(DecoderNLS decoder, bool nothingDecoded) @@ -1847,8 +1843,7 @@ namespace System.Text // If we're not converting we must not have data in our fallback buffer if (encoder.m_throwOnOverflow && encoder.InternalHasFallbackBuffer && this.fallbackBuffer.Remaining > 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EncoderFallbackNotEmpty", - encoder.Encoding.EncodingName, encoder.Fallback.GetType())); + throw new ArgumentException(SR.Format(SR.Argument_EncoderFallbackNotEmpty, encoder.Encoding.EncodingName, encoder.Fallback.GetType())); } fallbackBuffer.InternalInitialize(chars, charEnd, encoder, bytes != null); } diff --git a/src/mscorlib/src/System/Text/EncodingForwarder.cs b/src/mscorlib/src/System/Text/EncodingForwarder.cs index 1198045..db7dda3 100644 --- a/src/mscorlib/src/System/Text/EncodingForwarder.cs +++ b/src/mscorlib/src/System/Text/EncodingForwarder.cs @@ -39,15 +39,15 @@ namespace System.Text Debug.Assert(encoding != null); // this parameter should only be affected internally, so just do a debug check here if (chars == null) { - throw new ArgumentNullException(nameof(chars), Environment.GetResourceString("ArgumentNull_Array")); + throw new ArgumentNullException(nameof(chars), SR.ArgumentNull_Array); } if (index < 0 || count < 0) { - throw new ArgumentOutOfRangeException(index < 0 ? nameof(index) : nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(index < 0 ? nameof(index) : nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); } if (chars.Length - index < count) { - throw new ArgumentOutOfRangeException(nameof(chars), Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer")); + throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); } Contract.EndContractBlock(); @@ -88,11 +88,11 @@ namespace System.Text Debug.Assert(encoding != null); if (chars == null) { - throw new ArgumentNullException(nameof(chars), Environment.GetResourceString("ArgumentNull_Array")); + throw new ArgumentNullException(nameof(chars), SR.ArgumentNull_Array); } if (count < 0) { - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); } Contract.EndContractBlock(); @@ -106,21 +106,21 @@ namespace System.Text if (s == null || bytes == null) { string stringName = encoding is ASCIIEncoding ? "chars" : nameof(s); // ASCIIEncoding calls the first parameter chars - throw new ArgumentNullException(s == null ? stringName : nameof(bytes), Environment.GetResourceString("ArgumentNull_Array")); + throw new ArgumentNullException(s == null ? stringName : nameof(bytes), SR.ArgumentNull_Array); } if (charIndex < 0 || charCount < 0) { - throw new ArgumentOutOfRangeException(charIndex < 0 ? nameof(charIndex) : nameof(charCount), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(charIndex < 0 ? nameof(charIndex) : nameof(charCount), SR.ArgumentOutOfRange_NeedNonNegNum); } if (s.Length - charIndex < charCount) { string stringName = encoding is ASCIIEncoding ? "chars" : nameof(s); // ASCIIEncoding calls the first parameter chars // Duplicate the above check since we don't want the overhead of a type check on the general path - throw new ArgumentOutOfRangeException(stringName, Environment.GetResourceString("ArgumentOutOfRange_IndexCount")); + throw new ArgumentOutOfRangeException(stringName, SR.ArgumentOutOfRange_IndexCount); } if (byteIndex < 0 || byteIndex > bytes.Length) { - throw new ArgumentOutOfRangeException(nameof(byteIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.ArgumentOutOfRange_Index); } Contract.EndContractBlock(); @@ -141,19 +141,19 @@ namespace System.Text Debug.Assert(encoding != null); if (chars == null || bytes == null) { - throw new ArgumentNullException(chars == null ? nameof(chars) : nameof(bytes), Environment.GetResourceString("ArgumentNull_Array")); + throw new ArgumentNullException(chars == null ? nameof(chars) : nameof(bytes), SR.ArgumentNull_Array); } if (charIndex < 0 || charCount < 0) { - throw new ArgumentOutOfRangeException(charIndex < 0 ? nameof(charIndex) : nameof(charCount), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(charIndex < 0 ? nameof(charIndex) : nameof(charCount), SR.ArgumentOutOfRange_NeedNonNegNum); } if (chars.Length - charIndex < charCount) { - throw new ArgumentOutOfRangeException(nameof(chars), Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer")); + throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); } if (byteIndex < 0 || byteIndex > bytes.Length) { - throw new ArgumentOutOfRangeException(nameof(byteIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.ArgumentOutOfRange_Index); } Contract.EndContractBlock(); @@ -181,11 +181,11 @@ namespace System.Text Debug.Assert(encoding != null); if (bytes == null || chars == null) { - throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), Environment.GetResourceString("ArgumentNull_Array")); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); } if (charCount < 0 || byteCount < 0) { - throw new ArgumentOutOfRangeException(charCount < 0 ? nameof(charCount) : nameof(byteCount), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(charCount < 0 ? nameof(charCount) : nameof(byteCount), SR.ArgumentOutOfRange_NeedNonNegNum); } Contract.EndContractBlock(); @@ -197,15 +197,15 @@ namespace System.Text Debug.Assert(encoding != null); if (bytes == null) { - throw new ArgumentNullException(nameof(bytes), Environment.GetResourceString("ArgumentNull_Array")); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); } if (index < 0 || count < 0) { - throw new ArgumentOutOfRangeException(index < 0 ? nameof(index) : nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(index < 0 ? nameof(index) : nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); } if (bytes.Length - index < count) { - throw new ArgumentOutOfRangeException(nameof(bytes), Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer")); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); } Contract.EndContractBlock(); @@ -223,11 +223,11 @@ namespace System.Text Debug.Assert(encoding != null); if (bytes == null) { - throw new ArgumentNullException(nameof(bytes), Environment.GetResourceString("ArgumentNull_Array")); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); } if (count < 0) { - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); } Contract.EndContractBlock(); @@ -239,19 +239,19 @@ namespace System.Text Debug.Assert(encoding != null); if (bytes == null || chars == null) { - throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), Environment.GetResourceString("ArgumentNull_Array")); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); } if (byteIndex < 0 || byteCount < 0) { - throw new ArgumentOutOfRangeException(byteIndex < 0 ? nameof(byteIndex) : nameof(byteCount), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(byteIndex < 0 ? nameof(byteIndex) : nameof(byteCount), SR.ArgumentOutOfRange_NeedNonNegNum); } if (bytes.Length - byteIndex < byteCount) { - throw new ArgumentOutOfRangeException(nameof(bytes), Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer")); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); } if (charIndex < 0 || charIndex > chars.Length) { - throw new ArgumentOutOfRangeException(nameof(charIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(charIndex), SR.ArgumentOutOfRange_Index); } Contract.EndContractBlock(); @@ -277,11 +277,11 @@ namespace System.Text Debug.Assert(encoding != null); if (bytes == null || chars == null) { - throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), Environment.GetResourceString("ArgumentNull_Array")); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); } if (charCount < 0 || byteCount < 0) { - throw new ArgumentOutOfRangeException(charCount < 0 ? nameof(charCount) : nameof(byteCount), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(charCount < 0 ? nameof(charCount) : nameof(byteCount), SR.ArgumentOutOfRange_NeedNonNegNum); } Contract.EndContractBlock(); @@ -293,7 +293,7 @@ namespace System.Text Debug.Assert(encoding != null); if (bytes == null) { - throw new ArgumentNullException(nameof(bytes), Environment.GetResourceString("ArgumentNull_Array")); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); } if (index < 0 || count < 0) { @@ -301,11 +301,11 @@ namespace System.Text bool ascii = encoding is ASCIIEncoding; string indexName = ascii ? "byteIndex" : nameof(index); string countName = ascii ? "byteCount" : nameof(count); - throw new ArgumentOutOfRangeException(index < 0 ? indexName : countName, Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(index < 0 ? indexName : countName, SR.ArgumentOutOfRange_NeedNonNegNum); } if (bytes.Length - index < count) { - throw new ArgumentOutOfRangeException(nameof(bytes), Environment.GetResourceString("ArgumentOutOfRange_IndexCountBuffer")); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); } Contract.EndContractBlock(); diff --git a/src/mscorlib/src/System/Text/Latin1Encoding.cs b/src/mscorlib/src/System/Text/Latin1Encoding.cs index 7742f7c..e456b85 100644 --- a/src/mscorlib/src/System/Text/Latin1Encoding.cs +++ b/src/mscorlib/src/System/Text/Latin1Encoding.cs @@ -452,7 +452,7 @@ namespace System.Text { if (charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Characters would be # of characters + 1 in case high surrogate is ? * max fallback @@ -464,7 +464,7 @@ namespace System.Text // 1 to 1 for most characters. Only surrogates with fallbacks have less. if (byteCount > 0x7fffffff) - throw new ArgumentOutOfRangeException(nameof(charCount), Environment.GetResourceString("ArgumentOutOfRange_GetByteCountOverflow")); + throw new ArgumentOutOfRangeException(nameof(charCount), SR.ArgumentOutOfRange_GetByteCountOverflow); return (int)byteCount; } @@ -472,7 +472,7 @@ namespace System.Text { if (byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Just return length, SBCS stay the same length because they don't map to surrogate @@ -483,7 +483,7 @@ namespace System.Text charCount *= DecoderFallback.MaxCharCount; if (charCount > 0x7fffffff) - throw new ArgumentOutOfRangeException(nameof(byteCount), Environment.GetResourceString("ArgumentOutOfRange_GetCharCountOverflow")); + throw new ArgumentOutOfRangeException(nameof(byteCount), SR.ArgumentOutOfRange_GetCharCountOverflow); return (int)charCount; } diff --git a/src/mscorlib/src/System/Text/Normalization.Unix.cs b/src/mscorlib/src/System/Text/Normalization.Unix.cs index 8b1d790..2a10d06 100644 --- a/src/mscorlib/src/System/Text/Normalization.Unix.cs +++ b/src/mscorlib/src/System/Text/Normalization.Unix.cs @@ -25,7 +25,7 @@ namespace System.Text if (ret == -1) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex"), nameof(strInput)); + throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex, nameof(strInput)); } return ret == 1; @@ -50,7 +50,7 @@ namespace System.Text if (realLen == -1) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex"), nameof(strInput)); + throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex, nameof(strInput)); } if (realLen <= buf.Length) @@ -61,7 +61,7 @@ namespace System.Text buf = new char[realLen]; } - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex"), nameof(strInput)); + throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex, nameof(strInput)); } // ----------------------------- @@ -78,12 +78,12 @@ namespace System.Text if (normalizationForm != NormalizationForm.FormC && normalizationForm != NormalizationForm.FormD && normalizationForm != NormalizationForm.FormKC && normalizationForm != NormalizationForm.FormKD) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidNormalizationForm"), nameof(normalizationForm)); + throw new ArgumentException(SR.Argument_InvalidNormalizationForm, nameof(normalizationForm)); } if (HasInvalidUnicodeSequence(strInput)) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex"), nameof(strInput)); + throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex, nameof(strInput)); } } diff --git a/src/mscorlib/src/System/Text/Normalization.Windows.cs b/src/mscorlib/src/System/Text/Normalization.Windows.cs index e3890b1..389dba7 100644 --- a/src/mscorlib/src/System/Text/Normalization.Windows.cs +++ b/src/mscorlib/src/System/Text/Normalization.Windows.cs @@ -45,7 +45,7 @@ namespace System.Text throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex, nameof(strInput)); case Interop.Errors.ERROR_NOT_ENOUGH_MEMORY: - throw new OutOfMemoryException(SR.Arg_OutOfMemoryException); + throw new OutOfMemoryException(); default: throw new InvalidOperationException(SR.Format(SR.UnknownError_Num, lastError)); @@ -83,7 +83,7 @@ namespace System.Text // a trivial math function... // Can't really be Out of Memory, but just in case: if (lastError == Interop.Errors.ERROR_NOT_ENOUGH_MEMORY) - throw new OutOfMemoryException(SR.Arg_OutOfMemoryException); + throw new OutOfMemoryException(); // Who knows what happened? Not us! throw new InvalidOperationException(SR.Format(SR.UnknownError_Num, lastError)); @@ -123,7 +123,7 @@ namespace System.Text throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex, nameof(strInput)); case Interop.Errors.ERROR_NOT_ENOUGH_MEMORY: - throw new OutOfMemoryException(SR.Arg_OutOfMemoryException); + throw new OutOfMemoryException(); default: // We shouldn't get here... diff --git a/src/mscorlib/src/System/Text/StringBuilder.cs b/src/mscorlib/src/System/Text/StringBuilder.cs index 0cb0db0..6fb104d 100644 --- a/src/mscorlib/src/System/Text/StringBuilder.cs +++ b/src/mscorlib/src/System/Text/StringBuilder.cs @@ -127,16 +127,16 @@ namespace System.Text if (capacity < 0) { throw new ArgumentOutOfRangeException(nameof(capacity), - Environment.GetResourceString("ArgumentOutOfRange_MustBePositive", nameof(capacity))); + SR.Format(SR.ArgumentOutOfRange_MustBePositive, nameof(capacity))); } if (length < 0) { throw new ArgumentOutOfRangeException(nameof(length), - Environment.GetResourceString("ArgumentOutOfRange_MustBeNonNegNum", nameof(length))); + SR.Format(SR.ArgumentOutOfRange_MustBeNonNegNum, nameof(length))); } if (startIndex < 0) { - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_StartIndex")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_StartIndex); } Contract.EndContractBlock(); @@ -146,7 +146,7 @@ namespace System.Text } if (startIndex > value.Length - length) { - throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_IndexLength")); + throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_IndexLength); } m_MaxCapacity = Int32.MaxValue; if (capacity == 0) @@ -172,16 +172,16 @@ namespace System.Text { if (capacity > maxCapacity) { - throw new ArgumentOutOfRangeException(nameof(capacity), Environment.GetResourceString("ArgumentOutOfRange_Capacity")); + throw new ArgumentOutOfRangeException(nameof(capacity), SR.ArgumentOutOfRange_Capacity); } if (maxCapacity < 1) { - throw new ArgumentOutOfRangeException(nameof(maxCapacity), Environment.GetResourceString("ArgumentOutOfRange_SmallMaxCapacity")); + throw new ArgumentOutOfRangeException(nameof(maxCapacity), SR.ArgumentOutOfRange_SmallMaxCapacity); } if (capacity < 0) { throw new ArgumentOutOfRangeException(nameof(capacity), - Environment.GetResourceString("ArgumentOutOfRange_MustBePositive", nameof(capacity))); + SR.Format(SR.ArgumentOutOfRange_MustBePositive, nameof(capacity))); } Contract.EndContractBlock(); @@ -234,7 +234,7 @@ namespace System.Text } if (persistedMaxCapacity < 1 || persistedString.Length > persistedMaxCapacity) { - throw new SerializationException(Environment.GetResourceString("Serialization_StringBuilderMaxCapacity")); + throw new SerializationException(SR.Serialization_StringBuilderMaxCapacity); } if (!capacityPresent) @@ -252,7 +252,7 @@ namespace System.Text } if (persistedCapacity < 0 || persistedCapacity < persistedString.Length || persistedCapacity > persistedMaxCapacity) { - throw new SerializationException(Environment.GetResourceString("Serialization_StringBuilderCapacity")); + throw new SerializationException(SR.Serialization_StringBuilderCapacity); } // Assign @@ -315,15 +315,15 @@ namespace System.Text { if (value < 0) { - throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_NegativeCapacity")); + throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_NegativeCapacity); } if (value > MaxCapacity) { - throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_Capacity")); + throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_Capacity); } if (value < Length) { - throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_SmallCapacity")); + throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_SmallCapacity); } Contract.EndContractBlock(); @@ -351,7 +351,7 @@ namespace System.Text { if (capacity < 0) { - throw new ArgumentOutOfRangeException(nameof(capacity), Environment.GetResourceString("ArgumentOutOfRange_NegativeCapacity")); + throw new ArgumentOutOfRangeException(nameof(capacity), SR.ArgumentOutOfRange_NegativeCapacity); } Contract.EndContractBlock(); @@ -392,7 +392,7 @@ namespace System.Text } else { - throw new ArgumentOutOfRangeException(nameof(chunkLength), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(chunkLength), SR.ArgumentOutOfRange_Index); } } chunk = chunk.m_ChunkPrevious; @@ -412,19 +412,19 @@ namespace System.Text int currentLength = this.Length; if (startIndex < 0) { - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_StartIndex")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_StartIndex); } if (startIndex > currentLength) { - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_StartIndexLargerThanLength")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_StartIndexLargerThanLength); } if (length < 0) { - throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_NegativeLength")); + throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_NegativeLength); } if (startIndex > (currentLength - length)) { - throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_IndexLength")); + throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_IndexLength); } VerifyClassInvariant(); @@ -469,7 +469,7 @@ namespace System.Text } else { - throw new ArgumentOutOfRangeException(nameof(chunkCount), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(chunkCount), SR.ArgumentOutOfRange_Index); } } } @@ -504,12 +504,12 @@ namespace System.Text //If the new length is less than 0 or greater than our Maximum capacity, bail. if (value < 0) { - throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_NegativeLength")); + throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_NegativeLength); } if (value > MaxCapacity) { - throw new ArgumentOutOfRangeException(nameof(value), Environment.GetResourceString("ArgumentOutOfRange_SmallCapacity")); + throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_SmallCapacity); } Contract.EndContractBlock(); @@ -584,13 +584,13 @@ namespace System.Text if (indexInBlock >= 0) { if (indexInBlock >= chunk.m_ChunkLength) - throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index); chunk.m_ChunkChars[indexInBlock] = value; return; } chunk = chunk.m_ChunkPrevious; if (chunk == null) - throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index); } } } @@ -600,7 +600,7 @@ namespace System.Text { if (repeatCount < 0) { - throw new ArgumentOutOfRangeException(nameof(repeatCount), Environment.GetResourceString("ArgumentOutOfRange_NegativeCount")); + throw new ArgumentOutOfRangeException(nameof(repeatCount), SR.ArgumentOutOfRange_NegativeCount); } Contract.Ensures(Contract.Result() != null); Contract.EndContractBlock(); @@ -615,7 +615,7 @@ namespace System.Text int newLength = Length + repeatCount; if (newLength > m_MaxCapacity || newLength < repeatCount) { - throw new ArgumentOutOfRangeException(nameof(repeatCount), Environment.GetResourceString("ArgumentOutOfRange_LengthGreaterThanCapacity")); + throw new ArgumentOutOfRangeException(nameof(repeatCount), SR.ArgumentOutOfRange_LengthGreaterThanCapacity); } int idx = m_ChunkLength; @@ -644,11 +644,11 @@ namespace System.Text { if (startIndex < 0) { - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_GenericPositive")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_GenericPositive); } if (charCount < 0) { - throw new ArgumentOutOfRangeException(nameof(charCount), Environment.GetResourceString("ArgumentOutOfRange_GenericPositive")); + throw new ArgumentOutOfRangeException(nameof(charCount), SR.ArgumentOutOfRange_GenericPositive); } Contract.Ensures(Contract.Result() != null); Contract.EndContractBlock(); @@ -663,7 +663,7 @@ namespace System.Text } if (charCount > value.Length - startIndex) { - throw new ArgumentOutOfRangeException(nameof(charCount), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(charCount), SR.ArgumentOutOfRange_Index); } if (charCount == 0) @@ -745,12 +745,12 @@ namespace System.Text { if (startIndex < 0) { - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index); } if (count < 0) { - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_GenericPositive")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_GenericPositive); } Contract.Ensures(Contract.Result() != null); @@ -772,7 +772,7 @@ namespace System.Text if (startIndex > value.Length - count) { - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index); } unsafe @@ -808,28 +808,28 @@ namespace System.Text if (count < 0) { - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("Arg_NegativeArgCount")); + throw new ArgumentOutOfRangeException(nameof(count), SR.Arg_NegativeArgCount); } if (destinationIndex < 0) { throw new ArgumentOutOfRangeException(nameof(destinationIndex), - Environment.GetResourceString("ArgumentOutOfRange_MustBeNonNegNum", nameof(destinationIndex))); + SR.Format(SR.ArgumentOutOfRange_MustBeNonNegNum, nameof(destinationIndex))); } if (destinationIndex > destination.Length - count) { - throw new ArgumentException(Environment.GetResourceString("ArgumentOutOfRange_OffsetOut")); + throw new ArgumentException(SR.ArgumentOutOfRange_OffsetOut); } if ((uint)sourceIndex > (uint)Length) { - throw new ArgumentOutOfRangeException(nameof(sourceIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_Index); } if (sourceIndex > Length - count) { - throw new ArgumentException(Environment.GetResourceString("Arg_LongerThanSrcString")); + throw new ArgumentException(SR.Arg_LongerThanSrcString); } Contract.EndContractBlock(); @@ -873,7 +873,7 @@ namespace System.Text { if (count < 0) { - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); } Contract.Ensures(Contract.Result() != null); Contract.EndContractBlock(); @@ -882,7 +882,7 @@ namespace System.Text int currentLength = Length; if ((uint)index > (uint)currentLength) { - throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index); } //If value is null, empty or count is 0, do nothing. This is ECMA standard. @@ -926,17 +926,17 @@ namespace System.Text { if (length < 0) { - throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_NegativeLength")); + throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_NegativeLength); } if (startIndex < 0) { - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_StartIndex")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_StartIndex); } if (length > Length - startIndex) { - throw new ArgumentOutOfRangeException(nameof(length), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(length), SR.ArgumentOutOfRange_Index); } Contract.Ensures(Contract.Result() != null); Contract.EndContractBlock(); @@ -1200,7 +1200,7 @@ namespace System.Text { if ((uint)index > (uint)Length) { - throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index); } Contract.Ensures(Contract.Result() != null); Contract.EndContractBlock(); @@ -1285,7 +1285,7 @@ namespace System.Text { if ((uint)index > (uint)Length) { - throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index); } Contract.Ensures(Contract.Result() != null); Contract.EndContractBlock(); @@ -1306,7 +1306,7 @@ namespace System.Text int currentLength = Length; if ((uint)index > (uint)currentLength) { - throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index); } //If they passed in a null char array, just jump out quickly. @@ -1316,23 +1316,23 @@ namespace System.Text { return this; } - throw new ArgumentNullException(nameof(value), Environment.GetResourceString("ArgumentNull_String")); + throw new ArgumentNullException(nameof(value), SR.ArgumentNull_String); } //Range check the array. if (startIndex < 0) { - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_StartIndex")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_StartIndex); } if (charCount < 0) { - throw new ArgumentOutOfRangeException(nameof(charCount), Environment.GetResourceString("ArgumentOutOfRange_GenericPositive")); + throw new ArgumentOutOfRangeException(nameof(charCount), SR.ArgumentOutOfRange_GenericPositive); } if (startIndex > value.Length - charCount) { - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index); } if (charCount > 0) @@ -1510,7 +1510,7 @@ namespace System.Text private static void FormatError() { - throw new FormatException(Environment.GetResourceString("Format_InvalidString")); + throw new FormatException(SR.Format_InvalidString); } // undocumented exclusive limits on the range for Argument Hole Index and Argument Hole Alignment. @@ -1597,7 +1597,7 @@ namespace System.Text } while (ch >= '0' && ch <= '9' && index < Index_Limit); // If value of index is not within the range of the arguments passed in then error (Index out of range) - if (index >= args.Length) throw new FormatException(Environment.GetResourceString("Format_IndexOutOfRange")); + if (index >= args.Length) throw new FormatException(SR.Format_IndexOutOfRange); // Consume optional whitespace. while (pos < len && (ch = format[pos]) == ' ') pos++; @@ -1817,11 +1817,11 @@ namespace System.Text int currentLength = Length; if ((uint)startIndex > (uint)currentLength) { - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index); } if (count < 0 || startIndex > currentLength - count) { - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_Index); } if (oldValue == null) { @@ -1829,7 +1829,7 @@ namespace System.Text } if (oldValue.Length == 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(oldValue)); + throw new ArgumentException(SR.Argument_EmptyName, nameof(oldValue)); } if (newValue == null) @@ -1906,12 +1906,12 @@ namespace System.Text int currentLength = Length; if ((uint)startIndex > (uint)currentLength) { - throw new ArgumentOutOfRangeException(nameof(startIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(startIndex), SR.ArgumentOutOfRange_Index); } if (count < 0 || startIndex > currentLength - count) { - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_Index); } int endIndex = startIndex + count; @@ -1947,7 +1947,7 @@ namespace System.Text // We don't check null value as this case will throw null reference exception anyway if (valueCount < 0) { - throw new ArgumentOutOfRangeException(nameof(valueCount), Environment.GetResourceString("ArgumentOutOfRange_NegativeCount")); + throw new ArgumentOutOfRangeException(nameof(valueCount), SR.ArgumentOutOfRange_NegativeCount); } // this is where we can check if the valueCount will put us over m_MaxCapacity @@ -1955,7 +1955,7 @@ namespace System.Text int newLength = Length + valueCount; if (newLength > m_MaxCapacity || newLength < valueCount) { - throw new ArgumentOutOfRangeException(nameof(valueCount), Environment.GetResourceString("ArgumentOutOfRange_LengthGreaterThanCapacity")); + throw new ArgumentOutOfRangeException(nameof(valueCount), SR.ArgumentOutOfRange_LengthGreaterThanCapacity); } // This case is so common we want to optimize for it heavily. @@ -1995,7 +1995,7 @@ namespace System.Text { if ((uint)index > (uint)Length) { - throw new ArgumentOutOfRangeException(nameof(index), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index); } if (valueCount > 0) @@ -2143,7 +2143,7 @@ namespace System.Text } else { - throw new ArgumentOutOfRangeException(nameof(destinationIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(destinationIndex), SR.ArgumentOutOfRange_Index); } } } @@ -2161,7 +2161,7 @@ namespace System.Text } else { - throw new ArgumentOutOfRangeException(nameof(sourceIndex), Environment.GetResourceString("ArgumentOutOfRange_Index")); + throw new ArgumentOutOfRangeException(nameof(sourceIndex), SR.ArgumentOutOfRange_Index); } } } @@ -2258,7 +2258,7 @@ namespace System.Text VerifyClassInvariant(); if ((minBlockCharCount + Length) > m_MaxCapacity || minBlockCharCount + Length < minBlockCharCount) - throw new ArgumentOutOfRangeException("requiredLength", Environment.GetResourceString("ArgumentOutOfRange_SmallCapacity")); + throw new ArgumentOutOfRangeException("requiredLength", SR.ArgumentOutOfRange_SmallCapacity); // Compute the length of the new block we need // We make the new chunk at least big enough for the current need (minBlockCharCount) @@ -2317,7 +2317,7 @@ namespace System.Text Debug.Assert(count > 0, "Count must be strictly positive"); Debug.Assert(index >= 0, "Index can't be negative"); if (count + Length > m_MaxCapacity || count + Length < count) - throw new ArgumentOutOfRangeException("requiredLength", Environment.GetResourceString("ArgumentOutOfRange_SmallCapacity")); + throw new ArgumentOutOfRangeException("requiredLength", SR.ArgumentOutOfRange_SmallCapacity); chunk = this; while (chunk.m_ChunkOffset > index) diff --git a/src/mscorlib/src/System/Text/UTF32Encoding.cs b/src/mscorlib/src/System/Text/UTF32Encoding.cs index 0e5f1f4..37defe3 100644 --- a/src/mscorlib/src/System/Text/UTF32Encoding.cs +++ b/src/mscorlib/src/System/Text/UTF32Encoding.cs @@ -202,8 +202,7 @@ namespace System.Text // We mustn't have left over fallback data when counting if (fallbackBuffer.Remaining > 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EncoderFallbackNotEmpty", - this.EncodingName, encoder.Fallback.GetType())); + throw new ArgumentException(SR.Format(SR.Argument_EncoderFallbackNotEmpty, this.EncodingName, encoder.Fallback.GetType())); } else { @@ -301,8 +300,7 @@ namespace System.Text // Check for overflows. if (byteCount < 0) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString( - "ArgumentOutOfRange_GetByteCountOverflow")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_GetByteCountOverflow); // Shouldn't have anything in fallback buffer for GetByteCount // (don't have to check m_throwOnOverflow for count) @@ -339,8 +337,7 @@ namespace System.Text // We mustn't have left over fallback data when not converting if (encoder.m_throwOnOverflow && fallbackBuffer.Remaining > 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EncoderFallbackNotEmpty", - this.EncodingName, encoder.Fallback.GetType())); + throw new ArgumentException(SR.Format(SR.Argument_EncoderFallbackNotEmpty, this.EncodingName, encoder.Fallback.GetType())); } else { @@ -647,7 +644,7 @@ namespace System.Text // Check for overflows. if (charCount < 0) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_GetByteCountOverflow")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_GetByteCountOverflow); // Shouldn't have anything in fallback buffer for GetCharCount // (don't have to check m_throwOnOverflow for chars or count) @@ -907,7 +904,7 @@ namespace System.Text { if (charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Characters would be # of characters + 1 in case left over high surrogate is ? * max fallback @@ -920,7 +917,7 @@ namespace System.Text byteCount *= 4; if (byteCount > 0x7fffffff) - throw new ArgumentOutOfRangeException(nameof(charCount), Environment.GetResourceString("ArgumentOutOfRange_GetByteCountOverflow")); + throw new ArgumentOutOfRangeException(nameof(charCount), SR.ArgumentOutOfRange_GetByteCountOverflow); return (int)byteCount; } @@ -930,7 +927,7 @@ namespace System.Text { if (byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // A supplementary character becomes 2 surrogate characters, so 4 input bytes becomes 2 chars, @@ -950,7 +947,7 @@ namespace System.Text } if (charCount > 0x7fffffff) - throw new ArgumentOutOfRangeException(nameof(byteCount), Environment.GetResourceString("ArgumentOutOfRange_GetCharCountOverflow")); + throw new ArgumentOutOfRangeException(nameof(byteCount), SR.ArgumentOutOfRange_GetCharCountOverflow); return (int)charCount; } diff --git a/src/mscorlib/src/System/Text/UTF7Encoding.cs b/src/mscorlib/src/System/Text/UTF7Encoding.cs index abe6fd1..3a470a9 100644 --- a/src/mscorlib/src/System/Text/UTF7Encoding.cs +++ b/src/mscorlib/src/System/Text/UTF7Encoding.cs @@ -581,7 +581,7 @@ namespace System.Text { if (charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Suppose that every char can not be direct-encoded, we know that @@ -604,7 +604,7 @@ namespace System.Text // check for overflow if (byteCount > 0x7fffffff) - throw new ArgumentOutOfRangeException(nameof(charCount), Environment.GetResourceString("ArgumentOutOfRange_GetByteCountOverflow")); + throw new ArgumentOutOfRangeException(nameof(charCount), SR.ArgumentOutOfRange_GetByteCountOverflow); return (int)byteCount; } @@ -614,7 +614,7 @@ namespace System.Text { if (byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Worst case is 1 char per byte. Minimum 1 for left over bits in case decoder is being flushed @@ -869,7 +869,7 @@ namespace System.Text Debug.Assert(iCount < 0, "[DecoderUTF7FallbackBuffer.InternalFallback] Can't have recursive fallbacks"); if (bytes.Length != 1) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidCharSequenceNoIndex")); + throw new ArgumentException(SR.Argument_InvalidCharSequenceNoIndex); } // Can't fallback a byte 0, so return for that case, 1 otherwise. diff --git a/src/mscorlib/src/System/Text/UTF8Encoding.cs b/src/mscorlib/src/System/Text/UTF8Encoding.cs index cd0319d..997aa90 100644 --- a/src/mscorlib/src/System/Text/UTF8Encoding.cs +++ b/src/mscorlib/src/System/Text/UTF8Encoding.cs @@ -231,8 +231,7 @@ namespace System.Text { fallbackBuffer = encoder.FallbackBuffer; if (fallbackBuffer.Remaining > 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EncoderFallbackNotEmpty", - this.EncodingName, encoder.Fallback.GetType())); + throw new ArgumentException(SR.Format(SR.Argument_EncoderFallbackNotEmpty, this.EncodingName, encoder.Fallback.GetType())); // Set our internal fallback interesting things. fallbackBuffer.InternalInitialize(chars, pEnd, encoder, false); @@ -582,7 +581,7 @@ namespace System.Text if (byteCount < 0) { throw new ArgumentException( - Environment.GetResourceString("Argument_ConversionOverflow")); + SR.Argument_ConversionOverflow); } #endif @@ -649,8 +648,7 @@ namespace System.Text // We always need the fallback buffer in get bytes so we can flush any remaining ones if necessary fallbackBuffer = encoder.FallbackBuffer; if (fallbackBuffer.Remaining > 0 && encoder.m_throwOnOverflow) - throw new ArgumentException(Environment.GetResourceString("Argument_EncoderFallbackNotEmpty", - this.EncodingName, encoder.Fallback.GetType())); + throw new ArgumentException(SR.Format(SR.Argument_EncoderFallbackNotEmpty, this.EncodingName, encoder.Fallback.GetType())); // Set our internal fallback interesting things. fallbackBuffer.InternalInitialize(chars, pEnd, encoder, true); @@ -2237,7 +2235,7 @@ namespace System.Text { if (charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Characters would be # of characters + 1 in case left over high surrogate is ? * max fallback @@ -2250,7 +2248,7 @@ namespace System.Text byteCount *= 3; if (byteCount > 0x7fffffff) - throw new ArgumentOutOfRangeException(nameof(charCount), Environment.GetResourceString("ArgumentOutOfRange_GetByteCountOverflow")); + throw new ArgumentOutOfRangeException(nameof(charCount), SR.ArgumentOutOfRange_GetByteCountOverflow); return (int)byteCount; } @@ -2260,7 +2258,7 @@ namespace System.Text { if (byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Figure out our length, 1 char per input byte + 1 char if 1st byte is last byte of 4 byte surrogate pair @@ -2274,7 +2272,7 @@ namespace System.Text } if (charCount > 0x7fffffff) - throw new ArgumentOutOfRangeException(nameof(byteCount), Environment.GetResourceString("ArgumentOutOfRange_GetCharCountOverflow")); + throw new ArgumentOutOfRangeException(nameof(byteCount), SR.ArgumentOutOfRange_GetCharCountOverflow); return (int)charCount; } diff --git a/src/mscorlib/src/System/Text/UnicodeEncoding.cs b/src/mscorlib/src/System/Text/UnicodeEncoding.cs index 16d2413..07de4c8 100644 --- a/src/mscorlib/src/System/Text/UnicodeEncoding.cs +++ b/src/mscorlib/src/System/Text/UnicodeEncoding.cs @@ -189,7 +189,7 @@ namespace System.Text // (If they were all invalid chars, this would actually be wrong, // but that's a ridiculously large # so we're not concerned about that case) if (byteCount < 0) - throw new ArgumentOutOfRangeException(nameof(count), Environment.GetResourceString("ArgumentOutOfRange_GetByteCountOverflow")); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_GetByteCountOverflow); char* charStart = chars; char* charEnd = chars + count; @@ -219,8 +219,7 @@ namespace System.Text { fallbackBuffer = encoder.FallbackBuffer; if (fallbackBuffer.Remaining > 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EncoderFallbackNotEmpty", - this.EncodingName, encoder.Fallback.GetType())); + throw new ArgumentException(SR.Format(SR.Argument_EncoderFallbackNotEmpty, this.EncodingName, encoder.Fallback.GetType())); // Set our internal fallback interesting things. fallbackBuffer.InternalInitialize(charStart, charEnd, encoder, false); @@ -443,8 +442,7 @@ namespace System.Text { // Throw it, using our complete character throw new ArgumentException( - Environment.GetResourceString("Argument_RecursiveFallback", - charLeftOver), nameof(chars)); + SR.Format(SR.Argument_RecursiveFallback, charLeftOver), nameof(chars)); } else { @@ -511,8 +509,7 @@ namespace System.Text // We always need the fallback buffer in get bytes so we can flush any remaining ones if necessary fallbackBuffer = encoder.FallbackBuffer; if (fallbackBuffer.Remaining > 0 && encoder.m_throwOnOverflow) - throw new ArgumentException(Environment.GetResourceString("Argument_EncoderFallbackNotEmpty", - this.EncodingName, encoder.Fallback.GetType())); + throw new ArgumentException(SR.Format(SR.Argument_EncoderFallbackNotEmpty, this.EncodingName, encoder.Fallback.GetType())); // Set our internal fallback interesting things. fallbackBuffer.InternalInitialize(charStart, charEnd, encoder, false); @@ -853,8 +850,7 @@ namespace System.Text { // Throw it, using our complete character throw new ArgumentException( - Environment.GetResourceString("Argument_RecursiveFallback", - charLeftOver), nameof(chars)); + SR.Format(SR.Argument_RecursiveFallback, charLeftOver), nameof(chars)); } else { @@ -1712,7 +1708,7 @@ namespace System.Text { if (charCount < 0) throw new ArgumentOutOfRangeException(nameof(charCount), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // Characters would be # of characters + 1 in case left over high surrogate is ? * max fallback @@ -1725,7 +1721,7 @@ namespace System.Text byteCount <<= 1; if (byteCount > 0x7fffffff) - throw new ArgumentOutOfRangeException(nameof(charCount), Environment.GetResourceString("ArgumentOutOfRange_GetByteCountOverflow")); + throw new ArgumentOutOfRangeException(nameof(charCount), SR.ArgumentOutOfRange_GetByteCountOverflow); return (int)byteCount; } @@ -1735,7 +1731,7 @@ namespace System.Text { if (byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount), - Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); // long because byteCount could be biggest int. @@ -1749,7 +1745,7 @@ namespace System.Text charCount *= DecoderFallback.MaxCharCount; if (charCount > 0x7fffffff) - throw new ArgumentOutOfRangeException(nameof(byteCount), Environment.GetResourceString("ArgumentOutOfRange_GetCharCountOverflow")); + throw new ArgumentOutOfRangeException(nameof(byteCount), SR.ArgumentOutOfRange_GetCharCountOverflow); return (int)charCount; } diff --git a/src/mscorlib/src/System/Threading/AbandonedMutexException.cs b/src/mscorlib/src/System/Threading/AbandonedMutexException.cs index b39cb20..bbc1a67 100644 --- a/src/mscorlib/src/System/Threading/AbandonedMutexException.cs +++ b/src/mscorlib/src/System/Threading/AbandonedMutexException.cs @@ -25,7 +25,7 @@ namespace System.Threading private Mutex m_Mutex = null; public AbandonedMutexException() - : base(Environment.GetResourceString("Threading.AbandonedMutexException")) + : base(SR.Threading_AbandonedMutexException) { SetErrorCode(__HResults.COR_E_ABANDONEDMUTEX); } @@ -43,7 +43,7 @@ namespace System.Threading } public AbandonedMutexException(int location, WaitHandle handle) - : base(Environment.GetResourceString("Threading.AbandonedMutexException")) + : base(SR.Threading_AbandonedMutexException) { SetErrorCode(__HResults.COR_E_ABANDONEDMUTEX); SetupException(location, handle); diff --git a/src/mscorlib/src/System/Threading/CancellationToken.cs b/src/mscorlib/src/System/Threading/CancellationToken.cs index 4d82120..8bddfc9 100644 --- a/src/mscorlib/src/System/Threading/CancellationToken.cs +++ b/src/mscorlib/src/System/Threading/CancellationToken.cs @@ -469,12 +469,12 @@ namespace System.Threading // Throws an OCE; separated out to enable better inlining of ThrowIfCancellationRequested private void ThrowOperationCanceledException() { - throw new OperationCanceledException(Environment.GetResourceString("OperationCanceled"), this); + throw new OperationCanceledException(SR.OperationCanceled, this); } private static void ThrowObjectDisposedException() { - throw new ObjectDisposedException(null, Environment.GetResourceString("CancellationToken_SourceDisposed")); + throw new ObjectDisposedException(null, SR.CancellationToken_SourceDisposed); } // ----------------------------------- diff --git a/src/mscorlib/src/System/Threading/CancellationTokenSource.cs b/src/mscorlib/src/System/Threading/CancellationTokenSource.cs index eef3a15..3f4aaaa 100644 --- a/src/mscorlib/src/System/Threading/CancellationTokenSource.cs +++ b/src/mscorlib/src/System/Threading/CancellationTokenSource.cs @@ -600,7 +600,7 @@ namespace System.Threading // separation enables inlining of ThrowIfDisposed private static void ThrowObjectDisposedException() { - throw new ObjectDisposedException(null, Environment.GetResourceString("CancellationTokenSource_Disposed")); + throw new ObjectDisposedException(null, SR.CancellationTokenSource_Disposed); } /// @@ -891,7 +891,7 @@ namespace System.Threading switch (tokens.Length) { case 0: - throw new ArgumentException(Environment.GetResourceString("CancellationToken_CreateLinkedToken_TokensIsEmpty")); + throw new ArgumentException(SR.CancellationToken_CreateLinkedToken_TokensIsEmpty); case 1: return CreateLinkedTokenSource(tokens[0]); case 2: diff --git a/src/mscorlib/src/System/Threading/EventWaitHandle.cs b/src/mscorlib/src/System/Threading/EventWaitHandle.cs index 034c4b0..611d9de 100644 --- a/src/mscorlib/src/System/Threading/EventWaitHandle.cs +++ b/src/mscorlib/src/System/Threading/EventWaitHandle.cs @@ -46,11 +46,11 @@ namespace System.Threading if (name != null) { #if PLATFORM_UNIX - throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_NamedSynchronizationPrimitives")); + throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); #else if (System.IO.Path.MaxPath < name.Length) { - throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", Path.MaxPath), nameof(name)); + throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, Path.MaxPath), nameof(name)); } #endif } @@ -67,7 +67,7 @@ namespace System.Threading break; default: - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag", name)); + throw new ArgumentException(SR.Format(SR.Argument_InvalidFlag, name)); }; if (_handle.IsInvalid) @@ -76,7 +76,7 @@ namespace System.Threading _handle.SetHandleAsInvalid(); if (null != name && 0 != name.Length && Win32Native.ERROR_INVALID_HANDLE == errorCode) - throw new WaitHandleCannotBeOpenedException(Environment.GetResourceString("Threading.WaitHandleCannotBeOpenedException_InvalidHandle", name)); + throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); __Error.WinIOError(errorCode, name); } @@ -93,11 +93,11 @@ namespace System.Threading if (name != null) { #if PLATFORM_UNIX - throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_NamedSynchronizationPrimitives")); + throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); #else if (System.IO.Path.MaxPath < name.Length) { - throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", Path.MaxPath), nameof(name)); + throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, Path.MaxPath), nameof(name)); } #endif } @@ -116,7 +116,7 @@ namespace System.Threading break; default: - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag", name)); + throw new ArgumentException(SR.Format(SR.Argument_InvalidFlag, name)); }; _handle = Win32Native.CreateEvent(secAttrs, isManualReset, initialState, name); @@ -126,7 +126,7 @@ namespace System.Threading { _handle.SetHandleAsInvalid(); if (null != name && 0 != name.Length && Win32Native.ERROR_INVALID_HANDLE == errorCode) - throw new WaitHandleCannotBeOpenedException(Environment.GetResourceString("Threading.WaitHandleCannotBeOpenedException_InvalidHandle", name)); + throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); __Error.WinIOError(errorCode, name); } @@ -153,7 +153,7 @@ namespace System.Threading throw new WaitHandleCannotBeOpenedException(); case OpenExistingResult.NameInvalid: - throw new WaitHandleCannotBeOpenedException(Environment.GetResourceString("Threading.WaitHandleCannotBeOpenedException_InvalidHandle", name)); + throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); case OpenExistingResult.PathNotFound: __Error.WinIOError(Win32Native.ERROR_PATH_NOT_FOUND, ""); @@ -172,21 +172,21 @@ namespace System.Threading private static OpenExistingResult OpenExistingWorker(string name, EventWaitHandleRights rights, out EventWaitHandle result) { #if PLATFORM_UNIX - throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_NamedSynchronizationPrimitives")); + throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); #else if (name == null) { - throw new ArgumentNullException(nameof(name), Environment.GetResourceString("ArgumentNull_WithParamName")); + throw new ArgumentNullException(nameof(name), SR.ArgumentNull_WithParamName); } if (name.Length == 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name)); + throw new ArgumentException(SR.Argument_EmptyName, nameof(name)); } if (null != name && System.IO.Path.MaxPath < name.Length) { - throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", Path.MaxPath), nameof(name)); + throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, Path.MaxPath), nameof(name)); } Contract.EndContractBlock(); diff --git a/src/mscorlib/src/System/Threading/ExecutionContext.cs b/src/mscorlib/src/System/Threading/ExecutionContext.cs index 1e9e9b4..ec125ad 100644 --- a/src/mscorlib/src/System/Threading/ExecutionContext.cs +++ b/src/mscorlib/src/System/Threading/ExecutionContext.cs @@ -117,7 +117,7 @@ namespace System.Threading ExecutionContext executionContext = currentThread.ExecutionContext ?? Default; if (executionContext.m_isFlowSuppressed) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotSupressFlowMultipleTimes")); + throw new InvalidOperationException(SR.InvalidOperation_CannotSupressFlowMultipleTimes); } Contract.EndContractBlock(); @@ -134,7 +134,7 @@ namespace System.Threading ExecutionContext executionContext = currentThread.ExecutionContext; if (executionContext == null || !executionContext.m_isFlowSuppressed) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotRestoreUnsupressedFlow")); + throw new InvalidOperationException(SR.InvalidOperation_CannotRestoreUnsupressedFlow); } Contract.EndContractBlock(); @@ -151,7 +151,7 @@ namespace System.Threading public static void Run(ExecutionContext executionContext, ContextCallback callback, Object state) { if (executionContext == null) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NullContext")); + throw new InvalidOperationException(SR.InvalidOperation_NullContext); Thread currentThread = Thread.CurrentThread; ExecutionContextSwitcher ecsw = default(ExecutionContextSwitcher); @@ -238,7 +238,7 @@ namespace System.Threading catch (Exception ex) { Environment.FailFast( - Environment.GetResourceString("ExecutionContext_ExceptionInAsyncLocalNotification"), + SR.ExecutionContext_ExceptionInAsyncLocalNotification, ex); } } @@ -319,11 +319,11 @@ namespace System.Threading { if (_thread == null) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotUseAFCMultiple")); + throw new InvalidOperationException(SR.InvalidOperation_CannotUseAFCMultiple); } if (Thread.CurrentThread != _thread) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotUseAFCOtherThread")); + throw new InvalidOperationException(SR.InvalidOperation_CannotUseAFCOtherThread); } // An async flow control cannot be undone when a different execution context is applied. The desktop framework @@ -338,7 +338,7 @@ namespace System.Threading // flow is suppressed. if (!ExecutionContext.IsFlowSuppressed()) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_AsyncFlowCtrlCtxMismatch")); + throw new InvalidOperationException(SR.InvalidOperation_AsyncFlowCtrlCtxMismatch); } Contract.EndContractBlock(); diff --git a/src/mscorlib/src/System/Threading/LazyInitializer.cs b/src/mscorlib/src/System/Threading/LazyInitializer.cs index 6c84caa..e264a8f 100644 --- a/src/mscorlib/src/System/Threading/LazyInitializer.cs +++ b/src/mscorlib/src/System/Threading/LazyInitializer.cs @@ -128,7 +128,7 @@ namespace System.Threading T value = valueFactory(); if (value == null) { - throw new InvalidOperationException(Environment.GetResourceString("Lazy_StaticInit_InvalidOperation")); + throw new InvalidOperationException(SR.Lazy_StaticInit_InvalidOperation); } Interlocked.CompareExchange(ref target, value, null); @@ -257,7 +257,7 @@ namespace System.Threading Volatile.Write(ref target, valueFactory()); if (target == null) { - throw new InvalidOperationException(Environment.GetResourceString("Lazy_StaticInit_InvalidOperation")); + throw new InvalidOperationException(SR.Lazy_StaticInit_InvalidOperation); } } } @@ -279,7 +279,7 @@ namespace System.Threading } catch (MissingMethodException) { - throw new MissingMemberException(Environment.GetResourceString("Lazy_CreateValue_NoParameterlessCtorForT")); + throw new MissingMemberException(SR.Lazy_CreateValue_NoParameterlessCtorForT); } } } diff --git a/src/mscorlib/src/System/Threading/ManualResetEventSlim.cs b/src/mscorlib/src/System/Threading/ManualResetEventSlim.cs index c0bdbce..402a76c 100644 --- a/src/mscorlib/src/System/Threading/ManualResetEventSlim.cs +++ b/src/mscorlib/src/System/Threading/ManualResetEventSlim.cs @@ -163,7 +163,7 @@ namespace System.Threading // it is possible for the max number of waiters to be exceeded via user-code, hence we use a real exception here. if (value >= NumWaitersState_MaxValue) - throw new InvalidOperationException(String.Format(Environment.GetResourceString("ManualResetEventSlim_ctor_TooManyWaiters"), NumWaitersState_MaxValue)); + throw new InvalidOperationException(String.Format(SR.ManualResetEventSlim_ctor_TooManyWaiters, NumWaitersState_MaxValue)); UpdateStateAtomically(value << NumWaitersState_ShiftCount, NumWaitersState_BitMask); } @@ -218,7 +218,7 @@ namespace System.Threading { throw new ArgumentOutOfRangeException( nameof(spinCount), - String.Format(Environment.GetResourceString("ManualResetEventSlim_ctor_SpinCountOutOfRange"), SpinCountState_MaxValue)); + String.Format(SR.ManualResetEventSlim_ctor_SpinCountOutOfRange, SpinCountState_MaxValue)); } // We will suppress default spin because the user specified a count. @@ -717,7 +717,7 @@ namespace System.Threading private void ThrowIfDisposed() { if ((m_combinedState & Dispose_BitMask) != 0) - throw new ObjectDisposedException(Environment.GetResourceString("ManualResetEventSlim_Disposed")); + throw new ObjectDisposedException(SR.ManualResetEventSlim_Disposed); } /// diff --git a/src/mscorlib/src/System/Threading/Monitor.cs b/src/mscorlib/src/System/Threading/Monitor.cs index 8cebe64..3ace333 100644 --- a/src/mscorlib/src/System/Threading/Monitor.cs +++ b/src/mscorlib/src/System/Threading/Monitor.cs @@ -57,7 +57,7 @@ namespace System.Threading private static void ThrowLockTakenException() { - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeFalse"), "lockTaken"); + throw new ArgumentException(SR.Argument_MustBeFalse, "lockTaken"); } [MethodImplAttribute(MethodImplOptions.InternalCall)] @@ -122,7 +122,7 @@ namespace System.Threading { long tm = (long)timeout.TotalMilliseconds; if (tm < -1 || tm > (long)Int32.MaxValue) - throw new ArgumentOutOfRangeException(nameof(timeout), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); return (int)tm; } diff --git a/src/mscorlib/src/System/Threading/Mutex.cs b/src/mscorlib/src/System/Threading/Mutex.cs index cac423f..5e77e35 100644 --- a/src/mscorlib/src/System/Threading/Mutex.cs +++ b/src/mscorlib/src/System/Threading/Mutex.cs @@ -50,7 +50,7 @@ namespace System.Threading #if !PLATFORM_UNIX if (name != null && System.IO.Path.MaxPath < name.Length) { - throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", Path.MaxPath), nameof(name)); + throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, Path.MaxPath), nameof(name)); } #endif Contract.EndContractBlock(); @@ -128,11 +128,11 @@ namespace System.Threading #if PLATFORM_UNIX case Win32Native.ERROR_FILENAME_EXCED_RANGE: // On Unix, length validation is done by CoreCLR's PAL after converting to utf-8 - throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", Interop.Sys.MaxName), "name"); + throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, Interop.Sys.MaxName), "name"); #endif case Win32Native.ERROR_INVALID_HANDLE: - throw new WaitHandleCannotBeOpenedException(Environment.GetResourceString("Threading.WaitHandleCannotBeOpenedException_InvalidHandle", m_name)); + throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, m_name)); } } __Error.WinIOError(errorCode, m_name); @@ -210,7 +210,7 @@ namespace System.Threading throw new WaitHandleCannotBeOpenedException(); case OpenExistingResult.NameInvalid: - throw new WaitHandleCannotBeOpenedException(Environment.GetResourceString("Threading.WaitHandleCannotBeOpenedException_InvalidHandle", name)); + throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); case OpenExistingResult.PathNotFound: __Error.WinIOError(Win32Native.ERROR_PATH_NOT_FOUND, name); @@ -230,17 +230,17 @@ namespace System.Threading { if (name == null) { - throw new ArgumentNullException(nameof(name), Environment.GetResourceString("ArgumentNull_WithParamName")); + throw new ArgumentNullException(nameof(name), SR.ArgumentNull_WithParamName); } if (name.Length == 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name)); + throw new ArgumentException(SR.Argument_EmptyName, nameof(name)); } #if !PLATFORM_UNIX if (System.IO.Path.MaxPath < name.Length) { - throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", Path.MaxPath), nameof(name)); + throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, Path.MaxPath), nameof(name)); } #endif Contract.EndContractBlock(); @@ -262,7 +262,7 @@ namespace System.Threading if (name != null && errorCode == Win32Native.ERROR_FILENAME_EXCED_RANGE) { // On Unix, length validation is done by CoreCLR's PAL after converting to utf-8 - throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", Interop.Sys.MaxName), nameof(name)); + throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, Interop.Sys.MaxName), nameof(name)); } #endif @@ -291,7 +291,7 @@ namespace System.Threading } else { - throw new ApplicationException(Environment.GetResourceString("Arg_SynchronizationLockException")); + throw new ApplicationException(SR.Arg_SynchronizationLockException); } } diff --git a/src/mscorlib/src/System/Threading/Overlapped.cs b/src/mscorlib/src/System/Threading/Overlapped.cs index 8712c12..64ae76d 100644 --- a/src/mscorlib/src/System/Threading/Overlapped.cs +++ b/src/mscorlib/src/System/Threading/Overlapped.cs @@ -166,7 +166,7 @@ namespace System.Threading { if (!m_pinSelf.IsNull()) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_Overlapped_Pack")); + throw new InvalidOperationException(SR.InvalidOperation_Overlapped_Pack); } if (iocb != null) @@ -198,7 +198,7 @@ namespace System.Threading { if (!m_pinSelf.IsNull()) { - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_Overlapped_Pack")); + throw new InvalidOperationException(SR.InvalidOperation_Overlapped_Pack); } m_userObject = userData; if (m_userObject != null) diff --git a/src/mscorlib/src/System/Threading/Semaphore.cs b/src/mscorlib/src/System/Threading/Semaphore.cs index 1eac4aa..ae353cc 100644 --- a/src/mscorlib/src/System/Threading/Semaphore.cs +++ b/src/mscorlib/src/System/Threading/Semaphore.cs @@ -20,17 +20,17 @@ namespace System.Threading { if (initialCount < 0) { - throw new ArgumentOutOfRangeException(nameof(initialCount), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(initialCount), SR.ArgumentOutOfRange_NeedNonNegNum); } if (maximumCount < 1) { - throw new ArgumentOutOfRangeException(nameof(maximumCount), Environment.GetResourceString("ArgumentOutOfRange_NeedPosNum")); + throw new ArgumentOutOfRangeException(nameof(maximumCount), SR.ArgumentOutOfRange_NeedPosNum); } if (initialCount > maximumCount) { - throw new ArgumentException(Environment.GetResourceString("Argument_SemaphoreInitialMaximum")); + throw new ArgumentException(SR.Argument_SemaphoreInitialMaximum); } SafeWaitHandle myHandle = CreateSemaphone(initialCount, maximumCount, name); @@ -41,7 +41,7 @@ namespace System.Threading if (null != name && 0 != name.Length && Win32Native.ERROR_INVALID_HANDLE == errorCode) throw new WaitHandleCannotBeOpenedException( - Environment.GetResourceString("Threading.WaitHandleCannotBeOpenedException_InvalidHandle", name)); + SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); __Error.WinIOError(); } @@ -52,17 +52,17 @@ namespace System.Threading { if (initialCount < 0) { - throw new ArgumentOutOfRangeException(nameof(initialCount), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(initialCount), SR.ArgumentOutOfRange_NeedNonNegNum); } if (maximumCount < 1) { - throw new ArgumentOutOfRangeException(nameof(maximumCount), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(maximumCount), SR.ArgumentOutOfRange_NeedNonNegNum); } if (initialCount > maximumCount) { - throw new ArgumentException(Environment.GetResourceString("Argument_SemaphoreInitialMaximum")); + throw new ArgumentException(SR.Argument_SemaphoreInitialMaximum); } SafeWaitHandle myHandle = CreateSemaphone(initialCount, maximumCount, name); @@ -72,7 +72,7 @@ namespace System.Threading { if (null != name && 0 != name.Length && Win32Native.ERROR_INVALID_HANDLE == errorCode) throw new WaitHandleCannotBeOpenedException( - Environment.GetResourceString("Threading.WaitHandleCannotBeOpenedException_InvalidHandle", name)); + SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); __Error.WinIOError(); } createdNew = errorCode != Win32Native.ERROR_ALREADY_EXISTS; @@ -89,10 +89,10 @@ namespace System.Threading if (name != null) { #if PLATFORM_UNIX - throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_NamedSynchronizationPrimitives")); + throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); #else if (name.Length > Path.MaxPath) - throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", Path.MaxPath), nameof(name)); + throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, Path.MaxPath), nameof(name)); #endif } @@ -111,7 +111,7 @@ namespace System.Threading case OpenExistingResult.NameNotFound: throw new WaitHandleCannotBeOpenedException(); case OpenExistingResult.NameInvalid: - throw new WaitHandleCannotBeOpenedException(Environment.GetResourceString("Threading.WaitHandleCannotBeOpenedException_InvalidHandle", name)); + throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); case OpenExistingResult.PathNotFound: throw new IOException(Win32Native.GetMessage(Win32Native.ERROR_PATH_NOT_FOUND)); default: @@ -127,14 +127,14 @@ namespace System.Threading private static OpenExistingResult OpenExistingWorker(string name, out Semaphore result) { #if PLATFORM_UNIX - throw new PlatformNotSupportedException(Environment.GetResourceString("PlatformNotSupported_NamedSynchronizationPrimitives")); + throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); #else if (name == null) - throw new ArgumentNullException(nameof(name), Environment.GetResourceString("ArgumentNull_WithParamName")); + throw new ArgumentNullException(nameof(name), SR.ArgumentNull_WithParamName); if (name.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), nameof(name)); + throw new ArgumentException(SR.Argument_EmptyName, nameof(name)); if (name.Length > Path.MaxPath) - throw new ArgumentException(Environment.GetResourceString("Argument_WaitHandleNameTooLong", Path.MaxPath), nameof(name)); + throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, Path.MaxPath), nameof(name)); const int SYNCHRONIZE = 0x00100000; const int SEMAPHORE_MODIFY_STATE = 0x00000002; @@ -173,7 +173,7 @@ namespace System.Threading { if (releaseCount < 1) { - throw new ArgumentOutOfRangeException(nameof(releaseCount), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(releaseCount), SR.ArgumentOutOfRange_NeedNonNegNum); } //If ReleaseSempahore returns false when the specified value would cause diff --git a/src/mscorlib/src/System/Threading/SemaphoreFullException.cs b/src/mscorlib/src/System/Threading/SemaphoreFullException.cs index ca01dba..bbcc226 100644 --- a/src/mscorlib/src/System/Threading/SemaphoreFullException.cs +++ b/src/mscorlib/src/System/Threading/SemaphoreFullException.cs @@ -12,7 +12,7 @@ namespace System.Threading [ComVisibleAttribute(false)] public class SemaphoreFullException : SystemException { - public SemaphoreFullException() : base(Environment.GetResourceString("Threading_SemaphoreFullException")) + public SemaphoreFullException() : base(SR.Threading_SemaphoreFullException) { } diff --git a/src/mscorlib/src/System/Threading/SemaphoreSlim.cs b/src/mscorlib/src/System/Threading/SemaphoreSlim.cs index 7be7d2f..98bbc53 100644 --- a/src/mscorlib/src/System/Threading/SemaphoreSlim.cs +++ b/src/mscorlib/src/System/Threading/SemaphoreSlim.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. @@ -916,7 +916,7 @@ namespace System.Threading /// The key string private static string GetResourceString(string str) { - return Environment.GetResourceString(str); + return SR.GetResourceString(str); } #endregion } diff --git a/src/mscorlib/src/System/Threading/SpinWait.cs b/src/mscorlib/src/System/Threading/SpinWait.cs index e5bd3c7..ae490e8 100644 --- a/src/mscorlib/src/System/Threading/SpinWait.cs +++ b/src/mscorlib/src/System/Threading/SpinWait.cs @@ -51,7 +51,7 @@ namespace System.Threading /// /// /// encapsulates common spinning logic. On single-processor machines, yields are - /// always used instead of busy waits, and on computers with Intel™ processors employing Hyper-Threading™ + /// always used instead of busy waits, and on computers with Intel� processors employing Hyper-Threading� /// technology, it helps to prevent hardware thread starvation. SpinWait encapsulates a good mixture of /// spinning and true yielding. /// @@ -214,7 +214,7 @@ namespace System.Threading if (totalMilliseconds < -1 || totalMilliseconds > Int32.MaxValue) { throw new System.ArgumentOutOfRangeException( - nameof(timeout), timeout, Environment.GetResourceString("SpinWait_SpinUntil_TimeoutWrong")); + nameof(timeout), timeout, SR.SpinWait_SpinUntil_TimeoutWrong); } // Call wait with the timeout milliseconds @@ -236,11 +236,11 @@ namespace System.Threading if (millisecondsTimeout < Timeout.Infinite) { throw new ArgumentOutOfRangeException( - nameof(millisecondsTimeout), millisecondsTimeout, Environment.GetResourceString("SpinWait_SpinUntil_TimeoutWrong")); + nameof(millisecondsTimeout), millisecondsTimeout, SR.SpinWait_SpinUntil_TimeoutWrong); } if (condition == null) { - throw new ArgumentNullException(nameof(condition), Environment.GetResourceString("SpinWait_SpinUntil_ArgumentNull")); + throw new ArgumentNullException(nameof(condition), SR.SpinWait_SpinUntil_ArgumentNull); } uint startTime = 0; if (millisecondsTimeout != 0 && millisecondsTimeout != Timeout.Infinite) diff --git a/src/mscorlib/src/System/Threading/SynchronizationLockException.cs b/src/mscorlib/src/System/Threading/SynchronizationLockException.cs index 1f7a284..a3b8cb4 100644 --- a/src/mscorlib/src/System/Threading/SynchronizationLockException.cs +++ b/src/mscorlib/src/System/Threading/SynchronizationLockException.cs @@ -23,7 +23,7 @@ namespace System.Threading public class SynchronizationLockException : SystemException { public SynchronizationLockException() - : base(Environment.GetResourceString("Arg_SynchronizationLockException")) + : base(SR.Arg_SynchronizationLockException) { SetErrorCode(__HResults.COR_E_SYNCHRONIZATIONLOCK); } diff --git a/src/mscorlib/src/System/Threading/Tasks/TaskCanceledException.cs b/src/mscorlib/src/System/Threading/Tasks/TaskCanceledException.cs index 890a9c8..d7690d4 100644 --- a/src/mscorlib/src/System/Threading/Tasks/TaskCanceledException.cs +++ b/src/mscorlib/src/System/Threading/Tasks/TaskCanceledException.cs @@ -28,7 +28,7 @@ namespace System.Threading.Tasks /// /// Initializes a new instance of the class. /// - public TaskCanceledException() : base(Environment.GetResourceString("TaskCanceledException_ctor_DefaultMessage")) + public TaskCanceledException() : base(SR.TaskCanceledException_ctor_DefaultMessage) { } @@ -58,7 +58,7 @@ namespace System.Threading.Tasks /// /// A task that has been canceled. public TaskCanceledException(Task task) : - base(Environment.GetResourceString("TaskCanceledException_ctor_DefaultMessage"), task != null ? task.CancellationToken : new CancellationToken()) + base(SR.TaskCanceledException_ctor_DefaultMessage, task != null ? task.CancellationToken : new CancellationToken()) { m_canceledTask = task; } diff --git a/src/mscorlib/src/System/Threading/Tasks/TaskExceptionHolder.cs b/src/mscorlib/src/System/Threading/Tasks/TaskExceptionHolder.cs index 2ff127d..1385d90 100644 --- a/src/mscorlib/src/System/Threading/Tasks/TaskExceptionHolder.cs +++ b/src/mscorlib/src/System/Threading/Tasks/TaskExceptionHolder.cs @@ -127,7 +127,7 @@ namespace System.Threading.Tasks // First, publish the unobserved exception and allow users to observe it AggregateException exceptionToThrow = new AggregateException( - Environment.GetResourceString("TaskExceptionHolder_UnhandledException"), + SR.TaskExceptionHolder_UnhandledException, m_faultExceptions); UnobservedTaskExceptionEventArgs ueea = new UnobservedTaskExceptionEventArgs(exceptionToThrow); TaskScheduler.PublishUnobservedTaskException(m_task, ueea); @@ -276,7 +276,7 @@ namespace System.Threading.Tasks // Anything else is a programming error else { - throw new ArgumentException(Environment.GetResourceString("TaskExceptionHolder_UnknownExceptionType"), nameof(exceptionObject)); + throw new ArgumentException(SR.TaskExceptionHolder_UnknownExceptionType, nameof(exceptionObject)); } } } diff --git a/src/mscorlib/src/System/Threading/Tasks/TaskFactory.cs b/src/mscorlib/src/System/Threading/Tasks/TaskFactory.cs index fd6c721..9f6f505 100644 --- a/src/mscorlib/src/System/Threading/Tasks/TaskFactory.cs +++ b/src/mscorlib/src/System/Threading/Tasks/TaskFactory.cs @@ -1518,9 +1518,9 @@ namespace System.Threading.Tasks { // Options detected here cause exceptions in FromAsync methods that take beginMethod as a parameter if ((creationOptions & TaskCreationOptions.LongRunning) != 0) - throw new ArgumentOutOfRangeException(nameof(creationOptions), Environment.GetResourceString("Task_FromAsync_LongRunning")); + throw new ArgumentOutOfRangeException(nameof(creationOptions), SR.Task_FromAsync_LongRunning); if ((creationOptions & TaskCreationOptions.PreferFairness) != 0) - throw new ArgumentOutOfRangeException(nameof(creationOptions), Environment.GetResourceString("Task_FromAsync_PreferFairness")); + throw new ArgumentOutOfRangeException(nameof(creationOptions), SR.Task_FromAsync_PreferFairness); } // Check for general validity of options @@ -2382,7 +2382,7 @@ namespace System.Threading.Tasks for (int i = 0; i < numTasks; i++) { var task = tasks[i]; - if (task == null) throw new ArgumentException(Environment.GetResourceString("Task_MultiTaskContinuation_NullTask"), nameof(tasks)); + if (task == null) throw new ArgumentException(SR.Task_MultiTaskContinuation_NullTask, nameof(tasks)); if (checkArgsOnly) continue; @@ -3008,7 +3008,7 @@ namespace System.Threading.Tasks if (tasks == null) throw new ArgumentNullException(nameof(tasks)); if (tasks.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Task_MultiTaskContinuation_EmptyTaskList"), nameof(tasks)); + throw new ArgumentException(SR.Task_MultiTaskContinuation_EmptyTaskList, nameof(tasks)); Contract.EndContractBlock(); Task[] tasksCopy = new Task[tasks.Length]; @@ -3017,7 +3017,7 @@ namespace System.Threading.Tasks tasksCopy[i] = tasks[i]; if (tasksCopy[i] == null) - throw new ArgumentException(Environment.GetResourceString("Task_MultiTaskContinuation_NullTask"), nameof(tasks)); + throw new ArgumentException(SR.Task_MultiTaskContinuation_NullTask, nameof(tasks)); } return tasksCopy; @@ -3028,7 +3028,7 @@ namespace System.Threading.Tasks if (tasks == null) throw new ArgumentNullException(nameof(tasks)); if (tasks.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Task_MultiTaskContinuation_EmptyTaskList"), nameof(tasks)); + throw new ArgumentException(SR.Task_MultiTaskContinuation_EmptyTaskList, nameof(tasks)); Contract.EndContractBlock(); Task[] tasksCopy = new Task[tasks.Length]; @@ -3037,7 +3037,7 @@ namespace System.Threading.Tasks tasksCopy[i] = tasks[i]; if (tasksCopy[i] == null) - throw new ArgumentException(Environment.GetResourceString("Task_MultiTaskContinuation_NullTask"), nameof(tasks)); + throw new ArgumentException(SR.Task_MultiTaskContinuation_NullTask, nameof(tasks)); } return tasksCopy; @@ -3056,7 +3056,7 @@ namespace System.Threading.Tasks const TaskContinuationOptions illegalMask = TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.LongRunning; if ((continuationOptions & illegalMask) == illegalMask) { - throw new ArgumentOutOfRangeException(nameof(continuationOptions), Environment.GetResourceString("Task_ContinueWith_ESandLR")); + throw new ArgumentOutOfRangeException(nameof(continuationOptions), SR.Task_ContinueWith_ESandLR); } // Check that no nonsensical options are specified. @@ -3075,7 +3075,7 @@ namespace System.Threading.Tasks // Check that no "fire" options are specified. if ((continuationOptions & NotOnAny) != 0) - throw new ArgumentOutOfRangeException(nameof(continuationOptions), Environment.GetResourceString("Task_MultiTaskContinuation_FireOptions")); + throw new ArgumentOutOfRangeException(nameof(continuationOptions), SR.Task_MultiTaskContinuation_FireOptions); Contract.EndContractBlock(); } } diff --git a/src/mscorlib/src/System/Threading/Tasks/TaskScheduler.cs b/src/mscorlib/src/System/Threading/Tasks/TaskScheduler.cs index 94d3f11..45d398f 100644 --- a/src/mscorlib/src/System/Threading/Tasks/TaskScheduler.cs +++ b/src/mscorlib/src/System/Threading/Tasks/TaskScheduler.cs @@ -218,7 +218,7 @@ namespace System.Threading.Tasks // Otherwise the scheduler is buggy if (bInlined && !(task.IsDelegateInvoked || task.IsCanceled)) { - throw new InvalidOperationException(Environment.GetResourceString("TaskScheduler_InconsistentStateAfterTryExecuteTaskInline")); + throw new InvalidOperationException(SR.TaskScheduler_InconsistentStateAfterTryExecuteTaskInline); } return bInlined; @@ -443,7 +443,7 @@ namespace System.Threading.Tasks { if (task.ExecutingTaskScheduler != this) { - throw new InvalidOperationException(Environment.GetResourceString("TaskScheduler_ExecuteTask_WrongTaskScheduler")); + throw new InvalidOperationException(SR.TaskScheduler_ExecuteTask_WrongTaskScheduler); } return task.ExecuteEntry(); @@ -594,13 +594,13 @@ namespace System.Threading.Tasks m_taskScheduler = scheduler; } - // returns the scheduler’s Id + // returns the scheduler�s Id public Int32 Id { get { return m_taskScheduler.Id; } } - // returns the scheduler’s GetScheduledTasks + // returns the scheduler�s GetScheduledTasks public IEnumerable ScheduledTasks { get { return m_taskScheduler.GetScheduledTasks(); } @@ -631,7 +631,7 @@ namespace System.Threading.Tasks // make sure we have a synccontext to work with if (synContext == null) { - throw new InvalidOperationException(Environment.GetResourceString("TaskScheduler_FromCurrentSynchronizationContext_NoCurrent")); + throw new InvalidOperationException(SR.TaskScheduler_FromCurrentSynchronizationContext_NoCurrent); } m_synchronizationContext = synContext; diff --git a/src/mscorlib/src/System/Threading/Tasks/TaskSchedulerException.cs b/src/mscorlib/src/System/Threading/Tasks/TaskSchedulerException.cs index 3726a5e..148b630 100644 --- a/src/mscorlib/src/System/Threading/Tasks/TaskSchedulerException.cs +++ b/src/mscorlib/src/System/Threading/Tasks/TaskSchedulerException.cs @@ -26,7 +26,7 @@ namespace System.Threading.Tasks /// /// Initializes a new instance of the class. /// - public TaskSchedulerException() : base(Environment.GetResourceString("TaskSchedulerException_ctor_DefaultMessage")) // + public TaskSchedulerException() : base(SR.TaskSchedulerException_ctor_DefaultMessage) // { } @@ -46,7 +46,7 @@ namespace System.Threading.Tasks /// /// The exception that is the cause of the current exception. public TaskSchedulerException(Exception innerException) - : base(Environment.GetResourceString("TaskSchedulerException_ctor_DefaultMessage"), innerException) + : base(SR.TaskSchedulerException_ctor_DefaultMessage, innerException) { } diff --git a/src/mscorlib/src/System/Threading/Tasks/future.cs b/src/mscorlib/src/System/Threading/Tasks/future.cs index 147456a..26c2388 100644 --- a/src/mscorlib/src/System/Threading/Tasks/future.cs +++ b/src/mscorlib/src/System/Threading/Tasks/future.cs @@ -374,7 +374,7 @@ namespace System.Threading.Tasks { get { - return IsRanToCompletion ? "" + m_result : Environment.GetResourceString("TaskT_DebuggerNoResult"); + return IsRanToCompletion ? "" + m_result : SR.TaskT_DebuggerNoResult; } } diff --git a/src/mscorlib/src/System/Threading/Thread.cs b/src/mscorlib/src/System/Threading/Thread.cs index d57389f..6908b17 100644 --- a/src/mscorlib/src/System/Threading/Thread.cs +++ b/src/mscorlib/src/System/Threading/Thread.cs @@ -172,7 +172,7 @@ namespace System.Threading throw new ArgumentNullException(nameof(start)); } if (0 > maxStackSize) - throw new ArgumentOutOfRangeException(nameof(maxStackSize), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(maxStackSize), SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); SetStartHelper((Delegate)start, maxStackSize); } @@ -193,7 +193,7 @@ namespace System.Threading throw new ArgumentNullException(nameof(start)); } if (0 > maxStackSize) - throw new ArgumentOutOfRangeException(nameof(maxStackSize), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); + throw new ArgumentOutOfRangeException(nameof(maxStackSize), SR.ArgumentOutOfRange_NeedNonNegNum); Contract.EndContractBlock(); SetStartHelper((Delegate)start, maxStackSize); } @@ -218,7 +218,7 @@ namespace System.Threading // There are ways how to create an unitialized objects through remoting, etc. Avoid AVing in the EE by throwing a nice // exception here. if (thread.IsNull()) - throw new ArgumentException(null, Environment.GetResourceString("Argument_InvalidHandle")); + throw new ArgumentException(null, SR.Argument_InvalidHandle); return new ThreadHandle(thread); } @@ -248,7 +248,7 @@ namespace System.Threading //We expect the thread to be setup with a ParameterizedThreadStart // if this constructor is called. //If we got here then that wasn't the case - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_ThreadWrongThreadStart")); + throw new InvalidOperationException(SR.InvalidOperation_ThreadWrongThreadStart); } m_ThreadStartArg = parameter; StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; @@ -322,7 +322,7 @@ namespace System.Threading { long tm = (long)timeout.TotalMilliseconds; if (tm < -1 || tm > (long)Int32.MaxValue) - throw new ArgumentOutOfRangeException(nameof(timeout), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); Sleep((int)tm); } @@ -538,7 +538,7 @@ namespace System.Threading lock (this) { if (m_Name != null) - throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_WriteOnce")); + throw new InvalidOperationException(SR.InvalidOperation_WriteOnce); m_Name = value; InformThreadNameChange(GetNativeHandle(), value, (value != null) ? value.Length : 0); diff --git a/src/mscorlib/src/System/Threading/ThreadLocal.cs b/src/mscorlib/src/System/Threading/ThreadLocal.cs index 67407e7..64b8a60 100644 --- a/src/mscorlib/src/System/Threading/ThreadLocal.cs +++ b/src/mscorlib/src/System/Threading/ThreadLocal.cs @@ -323,7 +323,7 @@ namespace System.Threading int id = ~m_idComplement; if (id < 0) { - throw new ObjectDisposedException(Environment.GetResourceString("ThreadLocal_Disposed")); + throw new ObjectDisposedException(SR.ThreadLocal_Disposed); } Debugger.NotifyOfCrossThreadDependency(); @@ -340,7 +340,7 @@ namespace System.Threading if (IsValueCreated) { - throw new InvalidOperationException(Environment.GetResourceString("ThreadLocal_Value_RecursiveCallsToValue")); + throw new InvalidOperationException(SR.ThreadLocal_Value_RecursiveCallsToValue); } } @@ -356,7 +356,7 @@ namespace System.Threading // If the object has been disposed, id will be -1. if (id < 0) { - throw new ObjectDisposedException(Environment.GetResourceString("ThreadLocal_Disposed")); + throw new ObjectDisposedException(SR.ThreadLocal_Disposed); } // If a slot array has not been created on this thread yet, create it. @@ -394,7 +394,7 @@ namespace System.Threading if (!m_initialized) { - throw new ObjectDisposedException(Environment.GetResourceString("ThreadLocal_Disposed")); + throw new ObjectDisposedException(SR.ThreadLocal_Disposed); } slot.Value = value; @@ -416,7 +416,7 @@ namespace System.Threading // Dispose also executes under a lock. if (!m_initialized) { - throw new ObjectDisposedException(Environment.GetResourceString("ThreadLocal_Disposed")); + throw new ObjectDisposedException(SR.ThreadLocal_Disposed); } LinkedSlot firstRealNode = m_linkedSlot.Next; @@ -454,11 +454,11 @@ namespace System.Threading { if (!m_trackAllValues) { - throw new InvalidOperationException(Environment.GetResourceString("ThreadLocal_ValuesNotAvailable")); + throw new InvalidOperationException(SR.ThreadLocal_ValuesNotAvailable); } var list = GetValuesAsList(); // returns null if disposed - if (list == null) throw new ObjectDisposedException(Environment.GetResourceString("ThreadLocal_Disposed")); + if (list == null) throw new ObjectDisposedException(SR.ThreadLocal_Disposed); return list; } } @@ -511,7 +511,7 @@ namespace System.Threading int id = ~m_idComplement; if (id < 0) { - throw new ObjectDisposedException(Environment.GetResourceString("ThreadLocal_Disposed")); + throw new ObjectDisposedException(SR.ThreadLocal_Disposed); } LinkedSlotVolatile[] slotArray = ts_slotArray; diff --git a/src/mscorlib/src/System/Threading/ThreadPool.cs b/src/mscorlib/src/System/Threading/ThreadPool.cs index 7dbb957..0084050 100644 --- a/src/mscorlib/src/System/Threading/ThreadPool.cs +++ b/src/mscorlib/src/System/Threading/ThreadPool.cs @@ -805,8 +805,8 @@ namespace System.Threading // This will result in a "leak" of sorts (since the handle will not be cleaned up) // but the process is exiting anyway. // - // During AD-unload, we don’t finalize live objects until all threads have been - // aborted out of the AD. Since these locked regions are CERs, we won’t abort them + // During AD-unload, we don�t finalize live objects until all threads have been + // aborted out of the AD. Since these locked regions are CERs, we won�t abort them // while the lock is held. So there should be no leak on AD-unload. // if (Interlocked.CompareExchange(ref m_lock, 1, 0) == 0) @@ -1184,7 +1184,7 @@ namespace System.Threading ) { if (millisecondsTimeOutInterval < -1) - throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); Contract.EndContractBlock(); StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, true); @@ -1200,7 +1200,7 @@ namespace System.Threading ) { if (millisecondsTimeOutInterval < -1) - throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); Contract.EndContractBlock(); StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, false); @@ -1216,7 +1216,7 @@ namespace System.Threading ) { if (millisecondsTimeOutInterval < -1) - throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); Contract.EndContractBlock(); StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, true); @@ -1232,7 +1232,7 @@ namespace System.Threading ) { if (millisecondsTimeOutInterval < -1) - throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); Contract.EndContractBlock(); StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, false); @@ -1249,9 +1249,9 @@ namespace System.Threading { long tm = (long)timeout.TotalMilliseconds; if (tm < -1) - throw new ArgumentOutOfRangeException(nameof(timeout), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); if (tm > (long)Int32.MaxValue) - throw new ArgumentOutOfRangeException(nameof(timeout), Environment.GetResourceString("ArgumentOutOfRange_LessEqualToIntegerMaxVal")); + throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_LessEqualToIntegerMaxVal); StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)tm, executeOnlyOnce, ref stackMark, true); } @@ -1267,9 +1267,9 @@ namespace System.Threading { long tm = (long)timeout.TotalMilliseconds; if (tm < -1) - throw new ArgumentOutOfRangeException(nameof(timeout), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); if (tm > (long)Int32.MaxValue) - throw new ArgumentOutOfRangeException(nameof(timeout), Environment.GetResourceString("ArgumentOutOfRange_LessEqualToIntegerMaxVal")); + throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_LessEqualToIntegerMaxVal); StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)tm, executeOnlyOnce, ref stackMark, false); } diff --git a/src/mscorlib/src/System/Threading/ThreadStartException.cs b/src/mscorlib/src/System/Threading/ThreadStartException.cs index 5b5ee82..27a0d57 100644 --- a/src/mscorlib/src/System/Threading/ThreadStartException.cs +++ b/src/mscorlib/src/System/Threading/ThreadStartException.cs @@ -14,13 +14,13 @@ namespace System.Threading public sealed class ThreadStartException : SystemException { private ThreadStartException() - : base(Environment.GetResourceString("Arg_ThreadStartException")) + : base(SR.Arg_ThreadStartException) { SetErrorCode(__HResults.COR_E_THREADSTART); } private ThreadStartException(Exception reason) - : base(Environment.GetResourceString("Arg_ThreadStartException"), reason) + : base(SR.Arg_ThreadStartException, reason) { SetErrorCode(__HResults.COR_E_THREADSTART); } diff --git a/src/mscorlib/src/System/Threading/ThreadStateException.cs b/src/mscorlib/src/System/Threading/ThreadStateException.cs index 0df4416..9e1cc1d 100644 --- a/src/mscorlib/src/System/Threading/ThreadStateException.cs +++ b/src/mscorlib/src/System/Threading/ThreadStateException.cs @@ -22,7 +22,7 @@ namespace System.Threading public class ThreadStateException : SystemException { public ThreadStateException() - : base(Environment.GetResourceString("Arg_ThreadStateException")) + : base(SR.Arg_ThreadStateException) { SetErrorCode(__HResults.COR_E_THREADSTATE); } diff --git a/src/mscorlib/src/System/Threading/Timer.cs b/src/mscorlib/src/System/Threading/Timer.cs index 666fe70..960f815 100644 --- a/src/mscorlib/src/System/Threading/Timer.cs +++ b/src/mscorlib/src/System/Threading/Timer.cs @@ -455,7 +455,7 @@ namespace System.Threading lock (TimerQueue.Instance) { if (m_canceled) - throw new ObjectDisposedException(null, Environment.GetResourceString("ObjectDisposed_Generic")); + throw new ObjectDisposedException(null, SR.ObjectDisposed_Generic); // prevent ThreadAbort while updating state try { } @@ -666,9 +666,9 @@ namespace System.Threading int period) { if (dueTime < -1) - throw new ArgumentOutOfRangeException(nameof(dueTime), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(dueTime), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); if (period < -1) - throw new ArgumentOutOfRangeException(nameof(period), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(period), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); Contract.EndContractBlock(); TimerSetup(callback, state, (UInt32)dueTime, (UInt32)period); @@ -681,15 +681,15 @@ namespace System.Threading { long dueTm = (long)dueTime.TotalMilliseconds; if (dueTm < -1) - throw new ArgumentOutOfRangeException(nameof(dueTm), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(dueTm), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); if (dueTm > MAX_SUPPORTED_TIMEOUT) - throw new ArgumentOutOfRangeException(nameof(dueTm), Environment.GetResourceString("ArgumentOutOfRange_TimeoutTooLarge")); + throw new ArgumentOutOfRangeException(nameof(dueTm), SR.ArgumentOutOfRange_TimeoutTooLarge); long periodTm = (long)period.TotalMilliseconds; if (periodTm < -1) - throw new ArgumentOutOfRangeException(nameof(periodTm), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(periodTm), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); if (periodTm > MAX_SUPPORTED_TIMEOUT) - throw new ArgumentOutOfRangeException(nameof(periodTm), Environment.GetResourceString("ArgumentOutOfRange_PeriodTooLarge")); + throw new ArgumentOutOfRangeException(nameof(periodTm), SR.ArgumentOutOfRange_PeriodTooLarge); TimerSetup(callback, state, (UInt32)dueTm, (UInt32)periodTm); } @@ -709,13 +709,13 @@ namespace System.Threading long period) { if (dueTime < -1) - throw new ArgumentOutOfRangeException(nameof(dueTime), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(dueTime), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); if (period < -1) - throw new ArgumentOutOfRangeException(nameof(period), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(period), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); if (dueTime > MAX_SUPPORTED_TIMEOUT) - throw new ArgumentOutOfRangeException(nameof(dueTime), Environment.GetResourceString("ArgumentOutOfRange_TimeoutTooLarge")); + throw new ArgumentOutOfRangeException(nameof(dueTime), SR.ArgumentOutOfRange_TimeoutTooLarge); if (period > MAX_SUPPORTED_TIMEOUT) - throw new ArgumentOutOfRangeException(nameof(period), Environment.GetResourceString("ArgumentOutOfRange_PeriodTooLarge")); + throw new ArgumentOutOfRangeException(nameof(period), SR.ArgumentOutOfRange_PeriodTooLarge); Contract.EndContractBlock(); TimerSetup(callback, state, (UInt32)dueTime, (UInt32)period); } @@ -745,9 +745,9 @@ namespace System.Threading public bool Change(int dueTime, int period) { if (dueTime < -1) - throw new ArgumentOutOfRangeException(nameof(dueTime), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(dueTime), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); if (period < -1) - throw new ArgumentOutOfRangeException(nameof(period), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(period), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); Contract.EndContractBlock(); return m_timer.m_timer.Change((UInt32)dueTime, (UInt32)period); @@ -767,13 +767,13 @@ namespace System.Threading public bool Change(long dueTime, long period) { if (dueTime < -1) - throw new ArgumentOutOfRangeException(nameof(dueTime), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(dueTime), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); if (period < -1) - throw new ArgumentOutOfRangeException(nameof(period), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(period), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); if (dueTime > MAX_SUPPORTED_TIMEOUT) - throw new ArgumentOutOfRangeException(nameof(dueTime), Environment.GetResourceString("ArgumentOutOfRange_TimeoutTooLarge")); + throw new ArgumentOutOfRangeException(nameof(dueTime), SR.ArgumentOutOfRange_TimeoutTooLarge); if (period > MAX_SUPPORTED_TIMEOUT) - throw new ArgumentOutOfRangeException(nameof(period), Environment.GetResourceString("ArgumentOutOfRange_PeriodTooLarge")); + throw new ArgumentOutOfRangeException(nameof(period), SR.ArgumentOutOfRange_PeriodTooLarge); Contract.EndContractBlock(); return m_timer.m_timer.Change((UInt32)dueTime, (UInt32)period); diff --git a/src/mscorlib/src/System/Threading/WaitHandle.cs b/src/mscorlib/src/System/Threading/WaitHandle.cs index 7ffd4b8..50b277f 100644 --- a/src/mscorlib/src/System/Threading/WaitHandle.cs +++ b/src/mscorlib/src/System/Threading/WaitHandle.cs @@ -153,7 +153,7 @@ namespace System.Threading { if (millisecondsTimeout < -1) { - throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); } Contract.EndContractBlock(); return WaitOne((long)millisecondsTimeout, exitContext); @@ -164,7 +164,7 @@ namespace System.Threading long tm = (long)timeout.TotalMilliseconds; if (-1 > tm || (long)Int32.MaxValue < tm) { - throw new ArgumentOutOfRangeException(nameof(timeout), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); } return WaitOne(tm, exitContext); } @@ -195,7 +195,7 @@ namespace System.Threading { if (waitableSafeHandle == null) { - throw new ObjectDisposedException(null, Environment.GetResourceString("ObjectDisposed_Generic")); + throw new ObjectDisposedException(null, SR.ObjectDisposed_Generic); } Contract.EndContractBlock(); int ret = WaitOneNative(waitableSafeHandle, (uint)millisecondsTimeout, hasThreadAffinity, exitContext); @@ -216,7 +216,7 @@ namespace System.Threading // This is required to support the Wait which FAS needs (otherwise recursive dependency comes in) if (safeWaitHandle == null) { - throw new ObjectDisposedException(null, Environment.GetResourceString("ObjectDisposed_Generic")); + throw new ObjectDisposedException(null, SR.ObjectDisposed_Generic); } Contract.EndContractBlock(); @@ -248,7 +248,7 @@ namespace System.Threading { if (waitHandles == null) { - throw new ArgumentNullException(nameof(waitHandles), Environment.GetResourceString("ArgumentNull_Waithandles")); + throw new ArgumentNullException(nameof(waitHandles), SR.ArgumentNull_Waithandles); } if (waitHandles.Length == 0) { @@ -261,15 +261,15 @@ namespace System.Threading // in CoreCLR, and ArgumentNullException in the desktop CLR. This is ugly, but so is breaking // user code. // - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyWaithandleArray")); + throw new ArgumentException(SR.Argument_EmptyWaithandleArray); } if (waitHandles.Length > MAX_WAITHANDLES) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_MaxWaitHandles")); + throw new NotSupportedException(SR.NotSupported_MaxWaitHandles); } if (-1 > millisecondsTimeout) { - throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); } Contract.EndContractBlock(); WaitHandle[] internalWaitHandles = new WaitHandle[waitHandles.Length]; @@ -278,7 +278,7 @@ namespace System.Threading WaitHandle waitHandle = waitHandles[i]; if (waitHandle == null) - throw new ArgumentNullException("waitHandles[" + i + "]", Environment.GetResourceString("ArgumentNull_ArrayElement")); + throw new ArgumentNullException("waitHandles[" + i + "]", SR.ArgumentNull_ArrayElement); internalWaitHandles[i] = waitHandle; } @@ -312,7 +312,7 @@ namespace System.Threading long tm = (long)timeout.TotalMilliseconds; if (-1 > tm || (long)Int32.MaxValue < tm) { - throw new ArgumentOutOfRangeException(nameof(timeout), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); } return WaitAll(waitHandles, (int)tm, exitContext); } @@ -350,19 +350,19 @@ namespace System.Threading { if (waitHandles == null) { - throw new ArgumentNullException(nameof(waitHandles), Environment.GetResourceString("ArgumentNull_Waithandles")); + throw new ArgumentNullException(nameof(waitHandles), SR.ArgumentNull_Waithandles); } if (waitHandles.Length == 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_EmptyWaithandleArray")); + throw new ArgumentException(SR.Argument_EmptyWaithandleArray); } if (MAX_WAITHANDLES < waitHandles.Length) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_MaxWaitHandles")); + throw new NotSupportedException(SR.NotSupported_MaxWaitHandles); } if (-1 > millisecondsTimeout) { - throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); } Contract.EndContractBlock(); WaitHandle[] internalWaitHandles = new WaitHandle[waitHandles.Length]; @@ -371,7 +371,7 @@ namespace System.Threading WaitHandle waitHandle = waitHandles[i]; if (waitHandle == null) - throw new ArgumentNullException("waitHandles[" + i + "]", Environment.GetResourceString("ArgumentNull_ArrayElement")); + throw new ArgumentNullException("waitHandles[" + i + "]", SR.ArgumentNull_ArrayElement); internalWaitHandles[i] = waitHandle; } @@ -409,7 +409,7 @@ namespace System.Threading long tm = (long)timeout.TotalMilliseconds; if (-1 > tm || (long)Int32.MaxValue < tm) { - throw new ArgumentOutOfRangeException(nameof(timeout), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); } return WaitAny(waitHandles, (int)tm, exitContext); } @@ -466,7 +466,7 @@ namespace System.Threading long tm = (long)timeout.TotalMilliseconds; if (-1 > tm || (long)Int32.MaxValue < tm) { - throw new ArgumentOutOfRangeException(nameof(timeout), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); } return SignalAndWait(toSignal, toWaitOn, (int)tm, exitContext); #endif @@ -492,7 +492,7 @@ namespace System.Threading } if (-1 > millisecondsTimeout) { - throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout), Environment.GetResourceString("ArgumentOutOfRange_NeedNonNegOrNegative1")); + throw new ArgumentOutOfRangeException(nameof(millisecondsTimeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); } Contract.EndContractBlock(); @@ -507,7 +507,7 @@ namespace System.Threading if (ERROR_TOO_MANY_POSTS == ret) { - throw new InvalidOperationException(Environment.GetResourceString("Threading.WaitHandleTooManyPosts")); + throw new InvalidOperationException(SR.Threading_WaitHandleTooManyPosts); } //Object was signaled diff --git a/src/mscorlib/src/System/Threading/WaitHandleCannotBeOpenedException.cs b/src/mscorlib/src/System/Threading/WaitHandleCannotBeOpenedException.cs index acdb19c..7bc6e28 100644 --- a/src/mscorlib/src/System/Threading/WaitHandleCannotBeOpenedException.cs +++ b/src/mscorlib/src/System/Threading/WaitHandleCannotBeOpenedException.cs @@ -15,7 +15,7 @@ namespace System.Threading public class WaitHandleCannotBeOpenedException : ApplicationException { - public WaitHandleCannotBeOpenedException() : base(Environment.GetResourceString("Threading.WaitHandleCannotBeOpenedException")) + public WaitHandleCannotBeOpenedException() : base(SR.Threading_WaitHandleCannotBeOpenedException) { SetErrorCode(__HResults.COR_E_WAITHANDLECANNOTBEOPENED); } diff --git a/src/mscorlib/src/System/ThrowHelper.cs b/src/mscorlib/src/System/ThrowHelper.cs index 978e47a..b6af3a8 100644 --- a/src/mscorlib/src/System/ThrowHelper.cs +++ b/src/mscorlib/src/System/ThrowHelper.cs @@ -9,7 +9,7 @@ // The old way to throw an exception generates quite a lot IL code and assembly code. // Following is an example: // C# source -// throw new ArgumentNullException(nameof(key), Environment.GetResourceString("ArgumentNull_Key")); +// throw new ArgumentNullException(nameof(key), SR.ArgumentNull_Key); // IL code: // IL_0003: ldstr "key" // IL_0008: ldstr "ArgumentNull_Key" @@ -52,7 +52,7 @@ namespace System internal static void ThrowInvalidTypeWithPointersNotSupported(Type targetType) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidTypeWithPointersNotSupported", targetType)); + throw new ArgumentException(SR.Format(SR.Argument_InvalidTypeWithPointersNotSupported, targetType)); } internal static void ThrowIndexOutOfRangeException() @@ -67,17 +67,17 @@ namespace System internal static void ThrowArgumentException_DestinationTooShort() { - throw new ArgumentException(Environment.GetResourceString("Argument_DestinationTooShort")); + throw new ArgumentException(SR.Argument_DestinationTooShort); } internal static void ThrowNotSupportedException_CannotCallEqualsOnSpan() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_CannotCallEqualsOnSpan")); + throw new NotSupportedException(SR.NotSupported_CannotCallEqualsOnSpan); } internal static void ThrowNotSupportedException_CannotCallGetHashCodeOnSpan() { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_CannotCallGetHashCodeOnSpan")); + throw new NotSupportedException(SR.NotSupported_CannotCallGetHashCodeOnSpan); } internal static void ThrowArgumentOutOfRange_IndexException() @@ -122,7 +122,7 @@ namespace System private static ArgumentException GetAddingDuplicateWithKeyArgumentException(object key) { - return new ArgumentException(Environment.GetResourceString("Argument_AddingDuplicateWithKey", key)); + return new ArgumentException(SR.Format(SR.Argument_AddingDuplicateWithKey, key)); } internal static void ThrowAddingDuplicateWithKeyArgumentException(object key) @@ -290,12 +290,12 @@ namespace System private static ArgumentException GetWrongKeyTypeArgumentException(object key, Type targetType) { - return new ArgumentException(Environment.GetResourceString("Arg_WrongType", key, targetType), nameof(key)); + return new ArgumentException(SR.Format(SR.Arg_WrongType, key, targetType), nameof(key)); } private static ArgumentException GetWrongValueTypeArgumentException(object value, Type targetType) { - return new ArgumentException(Environment.GetResourceString("Arg_WrongType", value, targetType), nameof(value)); + return new ArgumentException(SR.Format(SR.Arg_WrongType, value, targetType), nameof(value)); } internal static ArgumentOutOfRangeException GetArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource) @@ -341,7 +341,7 @@ namespace System Debug.Assert(Enum.IsDefined(typeof(ExceptionResource), resource), "The enum value is not defined, please check the ExceptionResource Enum."); - return Environment.GetResourceString(resource.ToString()); + return SR.GetResourceString(resource.ToString()); } } diff --git a/src/mscorlib/src/System/TimeSpan.cs b/src/mscorlib/src/System/TimeSpan.cs index cd7b454..35be47f 100644 --- a/src/mscorlib/src/System/TimeSpan.cs +++ b/src/mscorlib/src/System/TimeSpan.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. @@ -93,7 +93,7 @@ namespace System { Int64 totalMilliSeconds = ((Int64)days * 3600 * 24 + (Int64)hours * 3600 + (Int64)minutes * 60 + seconds) * 1000 + milliseconds; if (totalMilliSeconds > MaxMilliSeconds || totalMilliSeconds < MinMilliSeconds) - throw new ArgumentOutOfRangeException(null, Environment.GetResourceString("Overflow_TimeSpanTooLong")); + throw new ArgumentOutOfRangeException(null, SR.Overflow_TimeSpanTooLong); _ticks = (long)totalMilliSeconds * TicksPerMillisecond; } @@ -169,7 +169,7 @@ namespace System // sign was opposite. // >> 63 gives the sign bit (either 64 1's or 64 0's). if ((_ticks >> 63 == ts._ticks >> 63) && (_ticks >> 63 != result >> 63)) - throw new OverflowException(Environment.GetResourceString("Overflow_TimeSpanTooLong")); + throw new OverflowException(SR.Overflow_TimeSpanTooLong); return new TimeSpan(result); } @@ -189,7 +189,7 @@ namespace System { if (value == null) return 1; if (!(value is TimeSpan)) - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeTimeSpan")); + throw new ArgumentException(SR.Arg_MustBeTimeSpan); long t = ((TimeSpan)value)._ticks; if (_ticks > t) return 1; if (_ticks < t) return -1; @@ -212,7 +212,7 @@ namespace System public TimeSpan Duration() { if (Ticks == TimeSpan.MinValue.Ticks) - throw new OverflowException(Environment.GetResourceString("Overflow_Duration")); + throw new OverflowException(SR.Overflow_Duration); Contract.EndContractBlock(); return new TimeSpan(_ticks >= 0 ? _ticks : -_ticks); } @@ -249,12 +249,12 @@ namespace System private static TimeSpan Interval(double value, int scale) { if (Double.IsNaN(value)) - throw new ArgumentException(Environment.GetResourceString("Arg_CannotBeNaN")); + throw new ArgumentException(SR.Arg_CannotBeNaN); Contract.EndContractBlock(); double tmp = value * scale; double millis = tmp + (value >= 0 ? 0.5 : -0.5); if ((millis > Int64.MaxValue / TicksPerMillisecond) || (millis < Int64.MinValue / TicksPerMillisecond)) - throw new OverflowException(Environment.GetResourceString("Overflow_TimeSpanTooLong")); + throw new OverflowException(SR.Overflow_TimeSpanTooLong); return new TimeSpan((long)millis * TicksPerMillisecond); } @@ -271,7 +271,7 @@ namespace System public TimeSpan Negate() { if (Ticks == TimeSpan.MinValue.Ticks) - throw new OverflowException(Environment.GetResourceString("Overflow_NegateTwosCompNum")); + throw new OverflowException(SR.Overflow_NegateTwosCompNum); Contract.EndContractBlock(); return new TimeSpan(-_ticks); } @@ -288,7 +288,7 @@ namespace System // sign was opposite from the first argument's sign. // >> 63 gives the sign bit (either 64 1's or 64 0's). if ((_ticks >> 63 != ts._ticks >> 63) && (_ticks >> 63 != result >> 63)) - throw new OverflowException(Environment.GetResourceString("Overflow_TimeSpanTooLong")); + throw new OverflowException(SR.Overflow_TimeSpanTooLong); return new TimeSpan(result); } @@ -303,7 +303,7 @@ namespace System // which is less than 2^44, meaning we won't overflow totalSeconds. long totalSeconds = (long)hour * 3600 + (long)minute * 60 + (long)second; if (totalSeconds > MaxSeconds || totalSeconds < MinSeconds) - throw new ArgumentOutOfRangeException(null, Environment.GetResourceString("Overflow_TimeSpanTooLong")); + throw new ArgumentOutOfRangeException(null, SR.Overflow_TimeSpanTooLong); return totalSeconds * TicksPerSecond; } @@ -386,7 +386,7 @@ namespace System public static TimeSpan operator -(TimeSpan t) { if (t._ticks == TimeSpan.MinValue._ticks) - throw new OverflowException(Environment.GetResourceString("Overflow_NegateTwosCompNum")); + throw new OverflowException(SR.Overflow_NegateTwosCompNum); return new TimeSpan(-t._ticks); } @@ -409,7 +409,7 @@ namespace System { if (double.IsNaN(factor)) { - throw new ArgumentException(Environment.GetResourceString("Arg_CannotBeNaN"), nameof(factor)); + throw new ArgumentException(SR.Arg_CannotBeNaN, nameof(factor)); } // Rounding to the nearest tick is as close to the result we would have with unlimited @@ -417,7 +417,7 @@ namespace System double ticks = Math.Round(timeSpan.Ticks * factor); if (ticks > long.MaxValue | ticks < long.MinValue) { - throw new OverflowException(Environment.GetResourceString("Overflow_TimeSpanTooLong")); + throw new OverflowException(SR.Overflow_TimeSpanTooLong); } return FromTicks((long)ticks); @@ -429,13 +429,13 @@ namespace System { if (double.IsNaN(divisor)) { - throw new ArgumentException(Environment.GetResourceString("Arg_CannotBeNaN"), nameof(divisor)); + throw new ArgumentException(SR.Arg_CannotBeNaN, nameof(divisor)); } double ticks = Math.Round(timeSpan.Ticks / divisor); if (ticks > long.MaxValue | ticks < long.MinValue || double.IsNaN(ticks)) { - throw new OverflowException(Environment.GetResourceString("Overflow_TimeSpanTooLong")); + throw new OverflowException(SR.Overflow_TimeSpanTooLong); } return FromTicks((long)ticks); diff --git a/src/mscorlib/src/System/TimeZoneInfo.AdjustmentRule.cs b/src/mscorlib/src/System/TimeZoneInfo.AdjustmentRule.cs index 21238fb..c0c27ee 100644 --- a/src/mscorlib/src/System/TimeZoneInfo.AdjustmentRule.cs +++ b/src/mscorlib/src/System/TimeZoneInfo.AdjustmentRule.cs @@ -144,22 +144,22 @@ namespace System { if (dateStart.Kind != DateTimeKind.Unspecified && dateStart.Kind != DateTimeKind.Utc) { - throw new ArgumentException(Environment.GetResourceString("Argument_DateTimeKindMustBeUnspecifiedOrUtc"), nameof(dateStart)); + throw new ArgumentException(SR.Argument_DateTimeKindMustBeUnspecifiedOrUtc, nameof(dateStart)); } if (dateEnd.Kind != DateTimeKind.Unspecified && dateEnd.Kind != DateTimeKind.Utc) { - throw new ArgumentException(Environment.GetResourceString("Argument_DateTimeKindMustBeUnspecifiedOrUtc"), nameof(dateEnd)); + throw new ArgumentException(SR.Argument_DateTimeKindMustBeUnspecifiedOrUtc, nameof(dateEnd)); } if (daylightTransitionStart.Equals(daylightTransitionEnd) && !noDaylightTransitions) { - throw new ArgumentException(Environment.GetResourceString("Argument_TransitionTimesAreIdentical"), nameof(daylightTransitionEnd)); + throw new ArgumentException(SR.Argument_TransitionTimesAreIdentical, nameof(daylightTransitionEnd)); } if (dateStart > dateEnd) { - throw new ArgumentException(Environment.GetResourceString("Argument_OutOfOrderDateTimes"), nameof(dateStart)); + throw new ArgumentException(SR.Argument_OutOfOrderDateTimes, nameof(dateStart)); } // This cannot use UtcOffsetOutOfRange to account for the scenario where Samoa moved across the International Date Line, @@ -168,22 +168,22 @@ namespace System // to be -23 (what it takes to go from UTC+13 to UTC-10) if (daylightDelta.TotalHours < -23.0 || daylightDelta.TotalHours > 14.0) { - throw new ArgumentOutOfRangeException(nameof(daylightDelta), daylightDelta, Environment.GetResourceString("ArgumentOutOfRange_UtcOffset")); + throw new ArgumentOutOfRangeException(nameof(daylightDelta), daylightDelta, SR.ArgumentOutOfRange_UtcOffset); } if (daylightDelta.Ticks % TimeSpan.TicksPerMinute != 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_TimeSpanHasSeconds"), nameof(daylightDelta)); + throw new ArgumentException(SR.Argument_TimeSpanHasSeconds, nameof(daylightDelta)); } if (dateStart != DateTime.MinValue && dateStart.Kind == DateTimeKind.Unspecified && dateStart.TimeOfDay != TimeSpan.Zero) { - throw new ArgumentException(Environment.GetResourceString("Argument_DateTimeHasTimeOfDay"), nameof(dateStart)); + throw new ArgumentException(SR.Argument_DateTimeHasTimeOfDay, nameof(dateStart)); } if (dateEnd != DateTime.MaxValue && dateEnd.Kind == DateTimeKind.Unspecified && dateEnd.TimeOfDay != TimeSpan.Zero) { - throw new ArgumentException(Environment.GetResourceString("Argument_DateTimeHasTimeOfDay"), nameof(dateEnd)); + throw new ArgumentException(SR.Argument_DateTimeHasTimeOfDay, nameof(dateEnd)); } Contract.EndContractBlock(); } @@ -200,7 +200,7 @@ namespace System } catch (ArgumentException e) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData"), e); + throw new SerializationException(SR.Serialization_InvalidData, e); } } diff --git a/src/mscorlib/src/System/TimeZoneInfo.StringSerializer.cs b/src/mscorlib/src/System/TimeZoneInfo.StringSerializer.cs index 9c1d5c3..c52f730 100644 --- a/src/mscorlib/src/System/TimeZoneInfo.StringSerializer.cs +++ b/src/mscorlib/src/System/TimeZoneInfo.StringSerializer.cs @@ -112,11 +112,11 @@ namespace System } catch (ArgumentException ex) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData"), ex); + throw new SerializationException(SR.Serialization_InvalidData, ex); } catch (InvalidTimeZoneException ex) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData"), ex); + throw new SerializationException(SR.Serialization_InvalidData, ex); } } @@ -181,7 +181,7 @@ namespace System { if (c != Esc && c != Sep && c != Lhs && c != Rhs) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidEscapeSequence", c)); + throw new SerializationException(SR.Format(SR.Serialization_InvalidEscapeSequence, c)); } } @@ -194,7 +194,7 @@ namespace System { if (_currentTokenStartIndex < 0 || _currentTokenStartIndex >= _serializedText.Length) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } State tokenState = State.NotEscaped; @@ -236,7 +236,7 @@ namespace System case '\0': // invalid character - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); default: break; @@ -244,7 +244,7 @@ namespace System } } - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } /// @@ -258,11 +258,11 @@ namespace System // first verify the internal state of the object if (_state == State.EndOfLine) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } if (_currentTokenStartIndex < 0 || _currentTokenStartIndex >= _serializedText.Length) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } State tokenState = State.NotEscaped; StringBuilder token = StringBuilderCache.Acquire(InitialCapacityForString); @@ -286,11 +286,11 @@ namespace System case Lhs: // '[' is an unexpected character - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); case Rhs: // ']' is an unexpected character - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); case Sep: _currentTokenStartIndex = i + 1; @@ -306,7 +306,7 @@ namespace System case '\0': // invalid character - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); default: token.Append(_serializedText[i]); @@ -320,10 +320,10 @@ namespace System if (tokenState == State.Escaped) { // we are at the end of the serialized text but we are in an escaped state - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidEscapeSequence", string.Empty)); + throw new SerializationException(SR.Format(SR.Serialization_InvalidEscapeSequence, string.Empty)); } - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } /// @@ -335,7 +335,7 @@ namespace System DateTime time; if (!DateTime.TryParseExact(token, format, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None, out time)) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } return time; } @@ -352,7 +352,7 @@ namespace System } catch (ArgumentOutOfRangeException e) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData"), e); + throw new SerializationException(SR.Serialization_InvalidData, e); } } @@ -365,7 +365,7 @@ namespace System int value; if (!int.TryParse(token, NumberStyles.AllowLeadingSign /* "[sign]digits" */, CultureInfo.InvariantCulture, out value)) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } return value; } @@ -391,11 +391,11 @@ namespace System // the AdjustmentRule array must end with a separator if (_state == State.EndOfLine) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } if (_currentTokenStartIndex < 0 || _currentTokenStartIndex >= _serializedText.Length) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } return count != 0 ? rules.ToArray() : null; @@ -414,7 +414,7 @@ namespace System if (_currentTokenStartIndex < 0 || _currentTokenStartIndex >= _serializedText.Length) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } // check to see if the very first token we see is the separator @@ -426,7 +426,7 @@ namespace System // verify the current token is a left-hand-side marker ("[") if (_serializedText[_currentTokenStartIndex] != Lhs) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } _currentTokenStartIndex++; @@ -442,7 +442,7 @@ namespace System if (_state == State.EndOfLine || _currentTokenStartIndex >= _serializedText.Length) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } // Check if we have baseUtcOffsetDelta in the serialized string and then deserialize it @@ -460,7 +460,7 @@ namespace System if (_state == State.EndOfLine || _currentTokenStartIndex >= _serializedText.Length) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } if (_serializedText[_currentTokenStartIndex] != Rhs) @@ -486,7 +486,7 @@ namespace System } catch (ArgumentException e) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData"), e); + throw new SerializationException(SR.Serialization_InvalidData, e); } // finally set the state to either EndOfLine or StartOfToken for the next caller @@ -514,19 +514,19 @@ namespace System // // we are at the end of the line or we are starting at a "]" character // - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } if (_currentTokenStartIndex < 0 || _currentTokenStartIndex >= _serializedText.Length) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } // verify the current token is a left-hand-side marker ("[") if (_serializedText[_currentTokenStartIndex] != Lhs) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } _currentTokenStartIndex++; @@ -534,7 +534,7 @@ namespace System if (isFixedDate != 0 && isFixedDate != 1) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } TransitionTime transition; @@ -554,7 +554,7 @@ namespace System } catch (ArgumentException e) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData"), e); + throw new SerializationException(SR.Serialization_InvalidData, e); } } else @@ -568,7 +568,7 @@ namespace System } catch (ArgumentException e) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData"), e); + throw new SerializationException(SR.Serialization_InvalidData, e); } } @@ -576,7 +576,7 @@ namespace System if (_state == State.EndOfLine || _currentTokenStartIndex >= _serializedText.Length) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } if (_serializedText[_currentTokenStartIndex] != Rhs) @@ -606,7 +606,7 @@ namespace System if (!sepFound) { // we MUST end on a separator - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData")); + throw new SerializationException(SR.Serialization_InvalidData); } // finally set the state to either EndOfLine or StartOfToken for the next caller diff --git a/src/mscorlib/src/System/TimeZoneInfo.TransitionTime.cs b/src/mscorlib/src/System/TimeZoneInfo.TransitionTime.cs index 354d0ac..1e1d9d3 100644 --- a/src/mscorlib/src/System/TimeZoneInfo.TransitionTime.cs +++ b/src/mscorlib/src/System/TimeZoneInfo.TransitionTime.cs @@ -75,37 +75,37 @@ namespace System { if (timeOfDay.Kind != DateTimeKind.Unspecified) { - throw new ArgumentException(Environment.GetResourceString("Argument_DateTimeKindMustBeUnspecified"), nameof(timeOfDay)); + throw new ArgumentException(SR.Argument_DateTimeKindMustBeUnspecified, nameof(timeOfDay)); } // Month range 1-12 if (month < 1 || month > 12) { - throw new ArgumentOutOfRangeException(nameof(month), Environment.GetResourceString("ArgumentOutOfRange_MonthParam")); + throw new ArgumentOutOfRangeException(nameof(month), SR.ArgumentOutOfRange_MonthParam); } // Day range 1-31 if (day < 1 || day > 31) { - throw new ArgumentOutOfRangeException(nameof(day), Environment.GetResourceString("ArgumentOutOfRange_DayParam")); + throw new ArgumentOutOfRangeException(nameof(day), SR.ArgumentOutOfRange_DayParam); } // Week range 1-5 if (week < 1 || week > 5) { - throw new ArgumentOutOfRangeException(nameof(week), Environment.GetResourceString("ArgumentOutOfRange_Week")); + throw new ArgumentOutOfRangeException(nameof(week), SR.ArgumentOutOfRange_Week); } // DayOfWeek range 0-6 if ((int)dayOfWeek < 0 || (int)dayOfWeek > 6) { - throw new ArgumentOutOfRangeException(nameof(dayOfWeek), Environment.GetResourceString("ArgumentOutOfRange_DayOfWeek")); + throw new ArgumentOutOfRangeException(nameof(dayOfWeek), SR.ArgumentOutOfRange_DayOfWeek); } Contract.EndContractBlock(); if (timeOfDay.Year != 1 || timeOfDay.Month != 1 || timeOfDay.Day != 1 || (timeOfDay.Ticks % TimeSpan.TicksPerMillisecond != 0)) { - throw new ArgumentException(Environment.GetResourceString("Argument_DateTimeHasTicks"), nameof(timeOfDay)); + throw new ArgumentException(SR.Argument_DateTimeHasTicks, nameof(timeOfDay)); } } @@ -120,7 +120,7 @@ namespace System } catch (ArgumentException e) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData"), e); + throw new SerializationException(SR.Serialization_InvalidData, e); } } diff --git a/src/mscorlib/src/System/TimeZoneInfo.Unix.cs b/src/mscorlib/src/System/TimeZoneInfo.Unix.cs index 1ecf4d4..02baadc 100644 --- a/src/mscorlib/src/System/TimeZoneInfo.Unix.cs +++ b/src/mscorlib/src/System/TimeZoneInfo.Unix.cs @@ -219,7 +219,7 @@ namespace System } catch (IOException ex) { - e = new InvalidTimeZoneException(Environment.GetResourceString("InvalidTimeZone_InvalidFileData", id, timeZoneFilePath), ex); + e = new InvalidTimeZoneException(SR.Format(SR.InvalidTimeZone_InvalidFileData, id, timeZoneFilePath), ex); return TimeZoneInfoResult.InvalidTimeZoneException; } @@ -227,7 +227,7 @@ namespace System if (value == null) { - e = new InvalidTimeZoneException(Environment.GetResourceString("InvalidTimeZone_InvalidFileData", id, timeZoneFilePath)); + e = new InvalidTimeZoneException(SR.Format(SR.InvalidTimeZone_InvalidFileData, id, timeZoneFilePath)); return TimeZoneInfoResult.InvalidTimeZoneException; } @@ -571,7 +571,7 @@ namespace System } else if (id.Length == 0 || id.Contains("\0")) { - throw new TimeZoneNotFoundException(Environment.GetResourceString("TimeZoneNotFound_MissingData", id)); + throw new TimeZoneNotFoundException(SR.Format(SR.TimeZoneNotFound_MissingData, id)); } TimeZoneInfo value; @@ -598,11 +598,11 @@ namespace System } else if (result == TimeZoneInfoResult.SecurityException) { - throw new SecurityException(Environment.GetResourceString("Security_CannotReadFileData", id), e); + throw new SecurityException(SR.Format(SR.Security_CannotReadFileData, id), e); } else { - throw new TimeZoneNotFoundException(Environment.GetResourceString("TimeZoneNotFound_MissingData", id), e); + throw new TimeZoneNotFoundException(SR.Format(SR.TimeZoneNotFound_MissingData, id), e); } } @@ -926,7 +926,7 @@ namespace System return transitionTypes[0]; } - throw new InvalidTimeZoneException(Environment.GetResourceString("InvalidTimeZone_NoTTInfoStructures")); + throw new InvalidTimeZoneException(SR.InvalidTimeZone_NoTTInfoStructures); } /// @@ -1060,7 +1060,7 @@ namespace System DayOfWeek day; if (!TZif_ParseMDateRule(date, out month, out week, out day)) { - throw new InvalidTimeZoneException(Environment.GetResourceString("InvalidTimeZone_UnparseablePosixMDateString", date)); + throw new InvalidTimeZoneException(SR.Format(SR.InvalidTimeZone_UnparseablePosixMDateString, date)); } DateTime timeOfDay; @@ -1103,7 +1103,7 @@ namespace System // One of them *could* be supported if we relaxed the TransitionTime validation rules, and allowed // "IsFixedDateRule = true, Month = 0, Day = n" to mean the nth day of the year, picking one of the rules above - throw new InvalidTimeZoneException(Environment.GetResourceString("InvalidTimeZone_JulianDayNotSupported")); + throw new InvalidTimeZoneException(SR.InvalidTimeZone_JulianDayNotSupported); } } @@ -1425,7 +1425,7 @@ namespace System { if (data == null || data.Length < index + Length) { - throw new ArgumentException(Environment.GetResourceString("Argument_TimeZoneInfoInvalidTZif"), nameof(data)); + throw new ArgumentException(SR.Argument_TimeZoneInfoInvalidTZif, nameof(data)); } Contract.EndContractBlock(); UtcOffset = new TimeSpan(0, 0, TZif_ToInt32(data, index + 00)); @@ -1461,7 +1461,7 @@ namespace System if (Magic != 0x545A6966) { // 0x545A6966 = {0x54, 0x5A, 0x69, 0x66} = "TZif" - throw new ArgumentException(Environment.GetResourceString("Argument_TimeZoneInfoBadTZif"), nameof(data)); + throw new ArgumentException(SR.Argument_TimeZoneInfoBadTZif, nameof(data)); } byte version = data[index + 04]; diff --git a/src/mscorlib/src/System/TimeZoneInfo.Win32.cs b/src/mscorlib/src/System/TimeZoneInfo.Win32.cs index 09a926f..5107fee 100644 --- a/src/mscorlib/src/System/TimeZoneInfo.Win32.cs +++ b/src/mscorlib/src/System/TimeZoneInfo.Win32.cs @@ -348,7 +348,7 @@ namespace System } else if (id.Length == 0 || id.Length > MaxKeyLength || id.Contains("\0")) { - throw new TimeZoneNotFoundException(Environment.GetResourceString("TimeZoneNotFound_MissingData", id)); + throw new TimeZoneNotFoundException(SR.Format(SR.TimeZoneNotFound_MissingData, id)); } TimeZoneInfo value; @@ -369,15 +369,15 @@ namespace System } else if (result == TimeZoneInfoResult.InvalidTimeZoneException) { - throw new InvalidTimeZoneException(Environment.GetResourceString("InvalidTimeZone_InvalidRegistryData", id), e); + throw new InvalidTimeZoneException(SR.Format(SR.InvalidTimeZone_InvalidRegistryData, id), e); } else if (result == TimeZoneInfoResult.SecurityException) { - throw new SecurityException(Environment.GetResourceString("Security_CannotReadRegistryData", id), e); + throw new SecurityException(SR.Format(SR.Security_CannotReadRegistryData, id), e); } else { - throw new TimeZoneNotFoundException(Environment.GetResourceString("TimeZoneNotFound_MissingData", id), e); + throw new TimeZoneNotFoundException(SR.Format(SR.TimeZoneNotFound_MissingData, id), e); } } diff --git a/src/mscorlib/src/System/TimeZoneInfo.cs b/src/mscorlib/src/System/TimeZoneInfo.cs index 1f62879..c37d81b 100644 --- a/src/mscorlib/src/System/TimeZoneInfo.cs +++ b/src/mscorlib/src/System/TimeZoneInfo.cs @@ -164,7 +164,7 @@ namespace System { if (!SupportsDaylightSavingTime) { - throw new ArgumentException(Environment.GetResourceString("Argument_DateTimeOffsetIsNotAmbiguous"), nameof(dateTimeOffset)); + throw new ArgumentException(SR.Argument_DateTimeOffsetIsNotAmbiguous, nameof(dateTimeOffset)); } Contract.EndContractBlock(); @@ -180,7 +180,7 @@ namespace System if (!isAmbiguous) { - throw new ArgumentException(Environment.GetResourceString("Argument_DateTimeOffsetIsNotAmbiguous"), nameof(dateTimeOffset)); + throw new ArgumentException(SR.Argument_DateTimeOffsetIsNotAmbiguous, nameof(dateTimeOffset)); } // the passed in dateTime is ambiguous in this TimeZoneInfo instance @@ -210,7 +210,7 @@ namespace System { if (!SupportsDaylightSavingTime) { - throw new ArgumentException(Environment.GetResourceString("Argument_DateTimeIsNotAmbiguous"), nameof(dateTime)); + throw new ArgumentException(SR.Argument_DateTimeIsNotAmbiguous, nameof(dateTime)); } Contract.EndContractBlock(); @@ -240,7 +240,7 @@ namespace System if (!isAmbiguous) { - throw new ArgumentException(Environment.GetResourceString("Argument_DateTimeIsNotAmbiguous"), nameof(dateTime)); + throw new ArgumentException(SR.Argument_DateTimeIsNotAmbiguous, nameof(dateTime)); } // the passed in dateTime is ambiguous in this TimeZoneInfo instance @@ -649,7 +649,7 @@ namespace System DateTimeKind sourceKind = cachedData.GetCorrespondingKind(sourceTimeZone); if (((flags & TimeZoneInfoOptions.NoThrowOnInvalidTime) == 0) && (dateTime.Kind != DateTimeKind.Unspecified) && (dateTime.Kind != sourceKind)) { - throw new ArgumentException(Environment.GetResourceString("Argument_ConvertMismatch"), nameof(sourceTimeZone)); + throw new ArgumentException(SR.Argument_ConvertMismatch, nameof(sourceTimeZone)); } // @@ -675,7 +675,7 @@ namespace System // period that supports DST if (((flags & TimeZoneInfoOptions.NoThrowOnInvalidTime) == 0) && GetIsInvalidTime(dateTime, sourceRule, sourceDaylightTime)) { - throw new ArgumentException(Environment.GetResourceString("Argument_DateTimeIsInvalid"), nameof(dateTime)); + throw new ArgumentException(SR.Argument_DateTimeIsInvalid, nameof(dateTime)); } sourceIsDaylightSavings = GetIsDaylightSavings(dateTime, sourceRule, sourceDaylightTime, flags); @@ -767,7 +767,7 @@ namespace System } if (source.Length == 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidSerializedString", source), nameof(source)); + throw new ArgumentException(SR.Format(SR.Argument_InvalidSerializedString, source), nameof(source)); } Contract.EndContractBlock(); @@ -1001,16 +1001,16 @@ namespace System if (adjustmentRulesSupportDst != _supportsDaylightSavingTime) { - throw new SerializationException(Environment.GetResourceString("Serialization_CorruptField", "SupportsDaylightSavingTime")); + throw new SerializationException(SR.Format(SR.Serialization_CorruptField, "SupportsDaylightSavingTime")); } } catch (ArgumentException e) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData"), e); + throw new SerializationException(SR.Serialization_InvalidData, e); } catch (InvalidTimeZoneException e) { - throw new SerializationException(Environment.GetResourceString("Serialization_InvalidData"), e); + throw new SerializationException(SR.Serialization_InvalidData, e); } } @@ -1880,17 +1880,17 @@ namespace System if (id.Length == 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidId", id), nameof(id)); + throw new ArgumentException(SR.Format(SR.Argument_InvalidId, id), nameof(id)); } if (UtcOffsetOutOfRange(baseUtcOffset)) { - throw new ArgumentOutOfRangeException(nameof(baseUtcOffset), Environment.GetResourceString("ArgumentOutOfRange_UtcOffset")); + throw new ArgumentOutOfRangeException(nameof(baseUtcOffset), SR.ArgumentOutOfRange_UtcOffset); } if (baseUtcOffset.Ticks % TimeSpan.TicksPerMinute != 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_TimeSpanHasSeconds"), nameof(baseUtcOffset)); + throw new ArgumentException(SR.Argument_TimeSpanHasSeconds, nameof(baseUtcOffset)); } Contract.EndContractBlock(); @@ -1914,7 +1914,7 @@ namespace System if (current == null) { - throw new InvalidTimeZoneException(Environment.GetResourceString("Argument_AdjustmentRulesNoNulls")); + throw new InvalidTimeZoneException(SR.Argument_AdjustmentRulesNoNulls); } // FUTURE: check to see if this rule supports Daylight Saving Time @@ -1923,13 +1923,13 @@ namespace System if (UtcOffsetOutOfRange(baseUtcOffset + current.DaylightDelta)) { - throw new InvalidTimeZoneException(Environment.GetResourceString("ArgumentOutOfRange_UtcOffsetAndDaylightDelta")); + throw new InvalidTimeZoneException(SR.ArgumentOutOfRange_UtcOffsetAndDaylightDelta); } if (prev != null && current.DateStart <= prev.DateEnd) { // verify the rules are in chronological order and the DateStart/DateEnd do not overlap - throw new InvalidTimeZoneException(Environment.GetResourceString("Argument_AdjustmentRulesOutOfOrder")); + throw new InvalidTimeZoneException(SR.Argument_AdjustmentRulesOutOfOrder); } } } diff --git a/src/mscorlib/src/System/Tuple.cs b/src/mscorlib/src/System/Tuple.cs index 02894c2..a118df0 100644 --- a/src/mscorlib/src/System/Tuple.cs +++ b/src/mscorlib/src/System/Tuple.cs @@ -148,7 +148,7 @@ namespace System if (objTuple == null) { - throw new ArgumentException(Environment.GetResourceString("ArgumentException_TupleIncorrectType", this.GetType().ToString()), "other"); + throw new ArgumentException(SR.Format(SR.ArgumentException_TupleIncorrectType, this.GetType().ToString()), "other"); } return comparer.Compare(m_Item1, objTuple.m_Item1); @@ -250,7 +250,7 @@ namespace System if (objTuple == null) { - throw new ArgumentException(Environment.GetResourceString("ArgumentException_TupleIncorrectType", this.GetType().ToString()), "other"); + throw new ArgumentException(SR.Format(SR.ArgumentException_TupleIncorrectType, this.GetType().ToString()), "other"); } int c = 0; @@ -367,7 +367,7 @@ namespace System if (objTuple == null) { - throw new ArgumentException(Environment.GetResourceString("ArgumentException_TupleIncorrectType", this.GetType().ToString()), "other"); + throw new ArgumentException(SR.Format(SR.ArgumentException_TupleIncorrectType, this.GetType().ToString()), "other"); } int c = 0; @@ -495,7 +495,7 @@ namespace System if (objTuple == null) { - throw new ArgumentException(Environment.GetResourceString("ArgumentException_TupleIncorrectType", this.GetType().ToString()), "other"); + throw new ArgumentException(SR.Format(SR.ArgumentException_TupleIncorrectType, this.GetType().ToString()), "other"); } int c = 0; @@ -634,7 +634,7 @@ namespace System if (objTuple == null) { - throw new ArgumentException(Environment.GetResourceString("ArgumentException_TupleIncorrectType", this.GetType().ToString()), "other"); + throw new ArgumentException(SR.Format(SR.ArgumentException_TupleIncorrectType, this.GetType().ToString()), "other"); } int c = 0; @@ -784,7 +784,7 @@ namespace System if (objTuple == null) { - throw new ArgumentException(Environment.GetResourceString("ArgumentException_TupleIncorrectType", this.GetType().ToString()), "other"); + throw new ArgumentException(SR.Format(SR.ArgumentException_TupleIncorrectType, this.GetType().ToString()), "other"); } int c = 0; @@ -945,7 +945,7 @@ namespace System if (objTuple == null) { - throw new ArgumentException(Environment.GetResourceString("ArgumentException_TupleIncorrectType", this.GetType().ToString()), "other"); + throw new ArgumentException(SR.Format(SR.ArgumentException_TupleIncorrectType, this.GetType().ToString()), "other"); } int c = 0; @@ -1077,7 +1077,7 @@ namespace System { if (!(rest is ITupleInternal)) { - throw new ArgumentException(Environment.GetResourceString("ArgumentException_TupleLastArgumentNotATuple")); + throw new ArgumentException(SR.ArgumentException_TupleLastArgumentNotATuple); } m_Item1 = item1; @@ -1122,7 +1122,7 @@ namespace System if (objTuple == null) { - throw new ArgumentException(Environment.GetResourceString("ArgumentException_TupleIncorrectType", this.GetType().ToString()), "other"); + throw new ArgumentException(SR.Format(SR.ArgumentException_TupleIncorrectType, this.GetType().ToString()), "other"); } int c = 0; diff --git a/src/mscorlib/src/System/TypeLoadException.cs b/src/mscorlib/src/System/TypeLoadException.cs index 750e84f..c09d3e1 100644 --- a/src/mscorlib/src/System/TypeLoadException.cs +++ b/src/mscorlib/src/System/TypeLoadException.cs @@ -27,7 +27,7 @@ namespace System public class TypeLoadException : SystemException, ISerializable { public TypeLoadException() - : base(Environment.GetResourceString("Arg_TypeLoadException")) + : base(SR.Arg_TypeLoadException) { SetErrorCode(__HResults.COR_E_TYPELOAD); } @@ -59,14 +59,14 @@ namespace System { if ((ClassName == null) && (ResourceId == 0)) - _message = Environment.GetResourceString("Arg_TypeLoadException"); + _message = SR.Arg_TypeLoadException; else { if (AssemblyName == null) - AssemblyName = Environment.GetResourceString("IO_UnknownFileName"); + AssemblyName = SR.IO_UnknownFileName; if (ClassName == null) - ClassName = Environment.GetResourceString("IO_UnknownFileName"); + ClassName = SR.IO_UnknownFileName; String format = null; GetTypeLoadExceptionMessage(ResourceId, JitHelpers.GetStringHandleOnStack(ref format)); diff --git a/src/mscorlib/src/System/TypeNameParser.cs b/src/mscorlib/src/System/TypeNameParser.cs index 4dee3d4..f9d6089 100644 --- a/src/mscorlib/src/System/TypeNameParser.cs +++ b/src/mscorlib/src/System/TypeNameParser.cs @@ -74,7 +74,7 @@ namespace System if (typeName == null) throw new ArgumentNullException(nameof(typeName)); if (typeName.Length > 0 && typeName[0] == '\0') - throw new ArgumentException(Environment.GetResourceString("Format_StringZeroLength")); + throw new ArgumentException(SR.Format_StringZeroLength); Contract.EndContractBlock(); Type ret = null; @@ -143,7 +143,7 @@ namespace System { // This can only happen if the type name is an empty string or if the first char is '\0' if (throwOnError) - throw new TypeLoadException(Environment.GetResourceString("Arg_TypeLoadNullStr")); + throw new TypeLoadException(SR.Arg_TypeLoadNullStr); return null; } @@ -221,7 +221,7 @@ namespace System assembly = assemblyResolver(new AssemblyName(asmName)); if (assembly == null && throwOnError) { - throw new FileNotFoundException(Environment.GetResourceString("FileNotFound_ResolveAssembly", asmName)); + throw new FileNotFoundException(SR.Format(SR.FileNotFound_ResolveAssembly, asmName)); } } @@ -245,8 +245,8 @@ namespace System if (type == null && throwOnError) { string errorString = assembly == null ? - Environment.GetResourceString("TypeLoad_ResolveType", OuterMostTypeName) : - Environment.GetResourceString("TypeLoad_ResolveTypeFromAssembly", OuterMostTypeName, assembly.FullName); + SR.Format(SR.TypeLoad_ResolveType, OuterMostTypeName): + SR.Format(SR.TypeLoad_ResolveTypeFromAssembly, OuterMostTypeName, assembly.FullName); throw new TypeLoadException(errorString); } @@ -277,7 +277,7 @@ namespace System if (type == null) { if (throwOnError) - throw new TypeLoadException(Environment.GetResourceString("TypeLoad_ResolveNestedType", names[i], names[i - 1])); + throw new TypeLoadException(SR.Format(SR.TypeLoad_ResolveNestedType, names[i], names[i - 1])); else break; } diff --git a/src/mscorlib/src/System/TypeUnloadedException.cs b/src/mscorlib/src/System/TypeUnloadedException.cs index 841a281..d1d55d5 100644 --- a/src/mscorlib/src/System/TypeUnloadedException.cs +++ b/src/mscorlib/src/System/TypeUnloadedException.cs @@ -20,7 +20,7 @@ namespace System public class TypeUnloadedException : SystemException { public TypeUnloadedException() - : base(Environment.GetResourceString("Arg_TypeUnloadedException")) + : base(SR.Arg_TypeUnloadedException) { SetErrorCode(__HResults.COR_E_TYPEUNLOADED); } diff --git a/src/mscorlib/src/System/TypedReference.cs b/src/mscorlib/src/System/TypedReference.cs index eb5234e..ca65082 100644 --- a/src/mscorlib/src/System/TypedReference.cs +++ b/src/mscorlib/src/System/TypedReference.cs @@ -31,7 +31,7 @@ namespace System throw new ArgumentNullException(nameof(flds)); Contract.EndContractBlock(); if (flds.Length == 0) - throw new ArgumentException(Environment.GetResourceString("Arg_ArrayZeroError")); + throw new ArgumentException(SR.Arg_ArrayZeroError); IntPtr[] fields = new IntPtr[flds.Length]; // For proper handling of Nullable don't change GetType() to something like 'IsAssignableFrom' @@ -41,20 +41,20 @@ namespace System { RuntimeFieldInfo field = flds[i] as RuntimeFieldInfo; if (field == null) - throw new ArgumentException(Environment.GetResourceString("Argument_MustBeRuntimeFieldInfo")); + throw new ArgumentException(SR.Argument_MustBeRuntimeFieldInfo); if (field.IsInitOnly || field.IsStatic) - throw new ArgumentException(Environment.GetResourceString("Argument_TypedReferenceInvalidField")); + throw new ArgumentException(SR.Argument_TypedReferenceInvalidField); if (targetType != field.GetDeclaringTypeInternal() && !targetType.IsSubclassOf(field.GetDeclaringTypeInternal())) - throw new MissingMemberException(Environment.GetResourceString("MissingMemberTypeRef")); + throw new MissingMemberException(SR.MissingMemberTypeRef); RuntimeType fieldType = (RuntimeType)field.FieldType; if (fieldType.IsPrimitive) - throw new ArgumentException(Environment.GetResourceString("Arg_TypeRefPrimitve")); + throw new ArgumentException(SR.Arg_TypeRefPrimitve); if (i < (flds.Length - 1) && !fieldType.IsValueType) - throw new MissingMemberException(Environment.GetResourceString("MissingMemberNestErr")); + throw new MissingMemberException(SR.MissingMemberNestErr); fields[i] = field.FieldHandle.Value; targetType = fieldType; @@ -84,7 +84,7 @@ namespace System public override bool Equals(Object o) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_NYI")); + throw new NotSupportedException(SR.NotSupported_NYI); } public unsafe static Object ToObject(TypedReference value) diff --git a/src/mscorlib/src/System/UInt16.cs b/src/mscorlib/src/System/UInt16.cs index b9b5412..b6893c2 100644 --- a/src/mscorlib/src/System/UInt16.cs +++ b/src/mscorlib/src/System/UInt16.cs @@ -46,7 +46,7 @@ namespace System { return ((int)m_value - (int)(((UInt16)value).m_value)); } - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeUInt16")); + throw new ArgumentException(SR.Arg_MustBeUInt16); } public int CompareTo(UInt16 value) @@ -137,10 +137,10 @@ namespace System } catch (OverflowException e) { - throw new OverflowException(Environment.GetResourceString("Overflow_UInt16"), e); + throw new OverflowException(SR.Overflow_UInt16, e); } - if (i > MaxValue) throw new OverflowException(Environment.GetResourceString("Overflow_UInt16")); + if (i > MaxValue) throw new OverflowException(SR.Overflow_UInt16); return (ushort)i; } @@ -263,7 +263,7 @@ namespace System /// DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "UInt16", "DateTime")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "UInt16", "DateTime")); } /// diff --git a/src/mscorlib/src/System/UInt32.cs b/src/mscorlib/src/System/UInt32.cs index 503a136..f209b79 100644 --- a/src/mscorlib/src/System/UInt32.cs +++ b/src/mscorlib/src/System/UInt32.cs @@ -53,7 +53,7 @@ namespace System if (m_value > i) return 1; return 0; } - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeUInt32")); + throw new ArgumentException(SR.Arg_MustBeUInt32); } public int CompareTo(UInt32 value) @@ -241,7 +241,7 @@ namespace System /// DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "UInt32", "DateTime")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "UInt32", "DateTime")); } /// diff --git a/src/mscorlib/src/System/UInt64.cs b/src/mscorlib/src/System/UInt64.cs index f034d17..1f74940 100644 --- a/src/mscorlib/src/System/UInt64.cs +++ b/src/mscorlib/src/System/UInt64.cs @@ -50,7 +50,7 @@ namespace System if (m_value > i) return 1; return 0; } - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeUInt64")); + throw new ArgumentException(SR.Arg_MustBeUInt64); } public int CompareTo(UInt64 value) @@ -236,7 +236,7 @@ namespace System /// DateTime IConvertible.ToDateTime(IFormatProvider provider) { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_FromTo", "UInt64", "DateTime")); + throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "UInt64", "DateTime")); } /// diff --git a/src/mscorlib/src/System/UIntPtr.cs b/src/mscorlib/src/System/UIntPtr.cs index 09e61a3..09b7e51 100644 --- a/src/mscorlib/src/System/UIntPtr.cs +++ b/src/mscorlib/src/System/UIntPtr.cs @@ -57,7 +57,7 @@ namespace System if (Size == 4 && l > UInt32.MaxValue) { - throw new ArgumentException(Environment.GetResourceString("Serialization_InvalidPtrValue")); + throw new ArgumentException(SR.Serialization_InvalidPtrValue); } m_value = (void*)l; diff --git a/src/mscorlib/src/System/UnitySerializationHolder.cs b/src/mscorlib/src/System/UnitySerializationHolder.cs index 038b9b0..943e8ce 100644 --- a/src/mscorlib/src/System/UnitySerializationHolder.cs +++ b/src/mscorlib/src/System/UnitySerializationHolder.cs @@ -199,14 +199,14 @@ namespace System private void ThrowInsufficientInformation(string field) { throw new SerializationException( - Environment.GetResourceString("Serialization_InsufficientDeserializationState", field)); + SR.Format(SR.Serialization_InsufficientDeserializationState, field)); } #endregion #region ISerializable public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { - throw new NotSupportedException(Environment.GetResourceString("NotSupported_UnitySerHolder")); + throw new NotSupportedException(SR.NotSupported_UnitySerHolder); } #endregion @@ -292,7 +292,7 @@ namespace System if (namedModule == null) throw new SerializationException( - Environment.GetResourceString("Serialization_UnableToFindModule", m_data, m_assemblyName)); + SR.Format(SR.Serialization_UnableToFindModule, m_data, m_assemblyName)); return namedModule; } @@ -311,7 +311,7 @@ namespace System } default: - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidUnity")); + throw new ArgumentException(SR.Argument_InvalidUnity); } } #endregion diff --git a/src/mscorlib/src/System/ValueTuple.cs b/src/mscorlib/src/System/ValueTuple.cs index 0f0863a..abe119a 100644 --- a/src/mscorlib/src/System/ValueTuple.cs +++ b/src/mscorlib/src/System/ValueTuple.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. @@ -1956,7 +1956,7 @@ namespace System { if (!(rest is IValueTupleInternal)) { - throw new ArgumentException(SR.ArgumentException_ValueTupleLastArgumentNotATuple); + throw new ArgumentException(SR.ArgumentException_ValueTupleLastArgumentNotAValueTuple); } Item1 = item1; diff --git a/src/mscorlib/src/System/Variant.cs b/src/mscorlib/src/System/Variant.cs index 3036e5b..cae5bda 100644 --- a/src/mscorlib/src/System/Variant.cs +++ b/src/mscorlib/src/System/Variant.cs @@ -515,7 +515,7 @@ namespace System break; default: - throw new NotSupportedException(Environment.GetResourceString("NotSupported_UnknownTypeCode", ic.GetTypeCode())); + throw new NotSupportedException(SR.Format(SR.NotSupported_UnknownTypeCode, ic.GetTypeCode())); } } } @@ -561,12 +561,12 @@ namespace System } else { - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_CannotCoerceByRefVariant")); + throw new InvalidCastException(SR.InvalidCast_CannotCoerceByRefVariant); } break; default: - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_CannotCoerceByRefVariant")); + throw new InvalidCastException(SR.InvalidCast_CannotCoerceByRefVariant); } } else @@ -670,7 +670,7 @@ namespace System break; default: - throw new InvalidCastException(Environment.GetResourceString("InvalidCast_CannotCoerceByRefVariant")); + throw new InvalidCastException(SR.InvalidCast_CannotCoerceByRefVariant); } } } diff --git a/src/mscorlib/src/System/Version.cs b/src/mscorlib/src/System/Version.cs index 03d45af..9c31786 100644 --- a/src/mscorlib/src/System/Version.cs +++ b/src/mscorlib/src/System/Version.cs @@ -38,16 +38,16 @@ namespace System public Version(int major, int minor, int build, int revision) { if (major < 0) - throw new ArgumentOutOfRangeException(nameof(major), Environment.GetResourceString("ArgumentOutOfRange_Version")); + throw new ArgumentOutOfRangeException(nameof(major), SR.ArgumentOutOfRange_Version); if (minor < 0) - throw new ArgumentOutOfRangeException(nameof(minor), Environment.GetResourceString("ArgumentOutOfRange_Version")); + throw new ArgumentOutOfRangeException(nameof(minor), SR.ArgumentOutOfRange_Version); if (build < 0) - throw new ArgumentOutOfRangeException(nameof(build), Environment.GetResourceString("ArgumentOutOfRange_Version")); + throw new ArgumentOutOfRangeException(nameof(build), SR.ArgumentOutOfRange_Version); if (revision < 0) - throw new ArgumentOutOfRangeException(nameof(revision), Environment.GetResourceString("ArgumentOutOfRange_Version")); + throw new ArgumentOutOfRangeException(nameof(revision), SR.ArgumentOutOfRange_Version); Contract.EndContractBlock(); _Major = major; @@ -59,13 +59,13 @@ namespace System public Version(int major, int minor, int build) { if (major < 0) - throw new ArgumentOutOfRangeException(nameof(major), Environment.GetResourceString("ArgumentOutOfRange_Version")); + throw new ArgumentOutOfRangeException(nameof(major), SR.ArgumentOutOfRange_Version); if (minor < 0) - throw new ArgumentOutOfRangeException(nameof(minor), Environment.GetResourceString("ArgumentOutOfRange_Version")); + throw new ArgumentOutOfRangeException(nameof(minor), SR.ArgumentOutOfRange_Version); if (build < 0) - throw new ArgumentOutOfRangeException(nameof(build), Environment.GetResourceString("ArgumentOutOfRange_Version")); + throw new ArgumentOutOfRangeException(nameof(build), SR.ArgumentOutOfRange_Version); Contract.EndContractBlock(); @@ -77,10 +77,10 @@ namespace System public Version(int major, int minor) { if (major < 0) - throw new ArgumentOutOfRangeException(nameof(major), Environment.GetResourceString("ArgumentOutOfRange_Version")); + throw new ArgumentOutOfRangeException(nameof(major), SR.ArgumentOutOfRange_Version); if (minor < 0) - throw new ArgumentOutOfRangeException(nameof(minor), Environment.GetResourceString("ArgumentOutOfRange_Version")); + throw new ArgumentOutOfRangeException(nameof(minor), SR.ArgumentOutOfRange_Version); Contract.EndContractBlock(); _Major = major; @@ -158,7 +158,7 @@ namespace System Version v = version as Version; if (v == null) { - throw new ArgumentException(Environment.GetResourceString("Arg_MustBeVersion")); + throw new ArgumentException(SR.Arg_MustBeVersion); } return CompareTo(v); @@ -230,7 +230,7 @@ namespace System return StringBuilderCache.GetStringAndRelease(sb); default: if (_Build == -1) - throw new ArgumentException(Environment.GetResourceString("ArgumentOutOfRange_Bounds_Lower_Upper", "0", "2"), nameof(fieldCount)); + throw new ArgumentException(SR.Format(SR.ArgumentOutOfRange_Bounds_Lower_Upper, "0", "2"), nameof(fieldCount)); if (fieldCount == 3) { @@ -244,7 +244,7 @@ namespace System } if (_Revision == -1) - throw new ArgumentException(Environment.GetResourceString("ArgumentOutOfRange_Bounds_Lower_Upper", "0", "3"), nameof(fieldCount)); + throw new ArgumentException(SR.Format(SR.ArgumentOutOfRange_Bounds_Lower_Upper, "0", "3"), nameof(fieldCount)); if (fieldCount == 4) { @@ -259,7 +259,7 @@ namespace System return StringBuilderCache.GetStringAndRelease(sb); } - throw new ArgumentException(Environment.GetResourceString("ArgumentOutOfRange_Bounds_Lower_Upper", "0", "4"), nameof(fieldCount)); + throw new ArgumentException(SR.Format(SR.ArgumentOutOfRange_Bounds_Lower_Upper, "0", "4"), nameof(fieldCount)); } } @@ -476,9 +476,9 @@ namespace System case ParseFailureKind.ArgumentNullException: return new ArgumentNullException(m_argumentName); case ParseFailureKind.ArgumentException: - return new ArgumentException(Environment.GetResourceString("Arg_VersionString")); + return new ArgumentException(SR.Arg_VersionString); case ParseFailureKind.ArgumentOutOfRangeException: - return new ArgumentOutOfRangeException(m_exceptionArgument, Environment.GetResourceString("ArgumentOutOfRange_Version")); + return new ArgumentOutOfRangeException(m_exceptionArgument, SR.ArgumentOutOfRange_Version); case ParseFailureKind.FormatException: // Regenerate the FormatException as would be thrown by Int32.Parse() try @@ -494,10 +494,10 @@ namespace System return e; } Debug.Assert(false, "Int32.Parse() did not throw exception but TryParse failed: " + m_exceptionArgument); - return new FormatException(Environment.GetResourceString("Format_InvalidString")); + return new FormatException(SR.Format_InvalidString); default: Debug.Assert(false, "Unmatched case in Version.GetVersionParseException() for value: " + m_failure); - return new ArgumentException(Environment.GetResourceString("Arg_VersionString")); + return new ArgumentException(SR.Arg_VersionString); } } } -- 2.7.4