From f31097f14560b193e76a7b2e1e61af9870b5356b Mon Sep 17 00:00:00 2001 From: Ahson Khan Date: Mon, 21 May 2018 18:03:55 -0700 Subject: [PATCH] Code cleanup and formatting for System.Memory files. (#17451) * Fix IDE0034 C# expression can be simplified (use of default) * Remove unnecessary using statements * IDE0012 C# Name can be simplified. String -> string * IDE0041 C# Null check can be simplified * Fix code formatting (limited to Span/System.Memory files). * Address PR feedback - IDE0012 Name can be simplified (String -> string) * Add back the necessary using statements and fix typo * Fix comment typo and add necessary using statements --- src/System.Private.CoreLib/Common/System/SR.cs | 18 ++-- .../shared/System/ArgumentException.cs | 20 ++-- .../shared/System/ArraySegment.cs | 2 +- .../shared/System/Buffers/MemoryHandle.cs | 1 - .../shared/System/Buffers/MemoryManager.cs | 1 - .../Collections/Concurrent/ConcurrentQueue.cs | 6 +- .../shared/System/Convert.cs | 4 +- .../shared/System/DateTimeOffset.cs | 6 +- .../System/Diagnostics/Tracing/EventProvider.cs | 2 +- .../System/Diagnostics/Tracing/EventSource.cs | 6 +- .../System/Diagnostics/Tracing/StubEnvironment.cs | 4 +- .../Tracing/TraceLogging/EventPayload.cs | 2 +- .../Tracing/TraceLogging/PropertyValue.cs | 2 +- .../TraceLogging/TraceLoggingEventSource.cs | 10 +- .../shared/System/Globalization/Calendar.cs | 4 +- .../shared/System/Globalization/CalendarData.cs | 118 ++++++++++---------- .../Globalization/ChineseLunisolarCalendar.cs | 4 +- .../shared/System/Globalization/CompareInfo.cs | 8 +- .../Globalization/CultureNotFoundException.cs | 22 ++-- .../shared/System/Globalization/DateTimeFormat.cs | 46 ++++---- .../Globalization/DateTimeFormatInfoScanner.cs | 92 ++++++++-------- .../shared/System/Globalization/DateTimeParse.cs | 56 +++++----- .../Globalization/EastAsianLunisolarCalendar.cs | 2 +- .../System/Globalization/GregorianCalendar.cs | 16 +-- .../Globalization/GregorianCalendarHelper.cs | 22 ++-- .../shared/System/Globalization/HebrewCalendar.cs | 14 +-- .../System/Globalization/HijriCalendar.Win32.cs | 8 +- .../shared/System/Globalization/HijriCalendar.cs | 18 ++-- .../System/Globalization/JapaneseCalendar.cs | 16 +-- .../Globalization/JapaneseLunisolarCalendar.cs | 2 +- .../shared/System/Globalization/JulianCalendar.cs | 12 +-- .../shared/System/Globalization/KoreanCalendar.cs | 2 +- .../System/Globalization/NumberFormatInfo.cs | 86 +++++++-------- .../shared/System/Globalization/PersianCalendar.cs | 16 +-- .../shared/System/Globalization/RegionInfo.cs | 26 ++--- .../shared/System/Globalization/StringInfo.cs | 2 +- .../shared/System/Globalization/TaiwanCalendar.cs | 4 +- .../Globalization/TaiwanLunisolarCalendar.cs | 2 +- .../System/Globalization/ThaiBuddhistCalendar.cs | 2 +- .../shared/System/Globalization/TimeSpanParse.cs | 20 ++-- .../System/Globalization/UmAlQuraCalendar.cs | 14 +-- src/System.Private.CoreLib/shared/System/Guid.cs | 12 +-- .../shared/System/IO/FileStream.Windows.cs | 2 +- .../shared/System/IO/FileStream.cs | 4 +- .../shared/System/IO/MemoryStream.cs | 6 +- .../shared/System/IO/TextReader.cs | 4 +- .../shared/System/IO/TextWriter.cs | 4 +- .../shared/System/IO/UnmanagedMemoryStream.cs | 4 +- .../System/IO/UnmanagedMemoryStreamWrapper.cs | 6 +- src/System.Private.CoreLib/shared/System/Lazy.cs | 4 +- .../shared/System/MemoryDebugView.cs | 1 - .../shared/System/MemoryExtensions.cs | 1 + .../shared/System/ObjectDisposedException.cs | 18 ++-- .../shared/System/ReadOnlySpan.Fast.cs | 5 +- .../shared/System/ReadOnlySpan.cs | 2 +- .../Runtime/CompilerServices/YieldAwaitable.cs | 2 +- .../Runtime/InteropServices/ExternalException.cs | 2 +- .../Runtime/InteropServices/MemoryMarshal.Fast.cs | 2 - .../Runtime/InteropServices/MemoryMarshal.cs | 4 +- .../System/Runtime/InteropServices/SafeBuffer.cs | 2 +- .../shared/System/Span.Fast.cs | 5 +- src/System.Private.CoreLib/shared/System/Span.cs | 2 +- .../shared/System/SpanDebugView.cs | 4 +- .../shared/System/SpanHelpers.BinarySearch.cs | 2 +- .../shared/System/SpanHelpers.Byte.cs | 9 +- .../shared/System/SpanHelpers.T.cs | 14 ++- .../shared/System/SpanHelpers.cs | 31 +++--- .../shared/System/String.Searching.cs | 4 +- .../shared/System/Text/ASCIIEncoding.cs | 6 +- .../shared/System/Text/Encoding.cs | 26 ++--- .../shared/System/Text/EncodingNLS.cs | 6 +- .../shared/System/Text/StringBuilder.cs | 36 +++---- .../shared/System/Text/UTF32Encoding.cs | 6 +- .../shared/System/Text/UTF7Encoding.cs | 14 +-- .../shared/System/Text/UTF8Encoding.cs | 6 +- .../shared/System/Text/UnicodeEncoding.cs | 4 +- .../shared/System/Threading/AsyncLocal.cs | 6 +- .../Tasks/ConcurrentExclusiveSchedulerPair.cs | 4 +- .../System/Threading/Tasks/TaskCompletionSource.cs | 2 +- .../shared/System/TimeSpan.cs | 8 +- .../shared/System/TimeZoneInfo.AdjustmentRule.cs | 4 +- .../shared/System/TimeZoneInfo.Win32.cs | 2 +- .../shared/System/TypeInitializationException.cs | 12 +-- .../shared/System/ValueTuple.cs | 14 +-- .../shared/System/Version.cs | 8 +- .../src/Microsoft/Win32/RegistryKey.cs | 54 +++++----- .../System/AppContext/AppContextDefaultValues.cs | 10 +- src/System.Private.CoreLib/src/System/Array.cs | 8 +- .../Collections/Concurrent/ConcurrentDictionary.cs | 10 +- .../Collections/Concurrent/ConcurrentStack.cs | 6 +- .../src/System/Diagnostics/Contracts/Contracts.cs | 6 +- .../System/Diagnostics/Contracts/ContractsBCL.cs | 36 +++---- .../src/System/Diagnostics/Debug.Windows.cs | 4 +- .../src/System/Diagnostics/Stacktrace.cs | 24 ++--- src/System.Private.CoreLib/src/System/Enum.cs | 2 +- src/System.Private.CoreLib/src/System/GC.cs | 4 +- .../src/System/Globalization/CultureInfo.cs | 34 +++--- .../src/System/IO/BinaryReader.cs | 6 +- src/System.Private.CoreLib/src/System/IO/Stream.cs | 12 +-- src/System.Private.CoreLib/src/System/Internal.cs | 46 ++++---- src/System.Private.CoreLib/src/System/Object.cs | 10 +- .../src/System/Reflection/CustomAttribute.cs | 32 +++--- .../System/Reflection/Emit/DynamicILGenerator.cs | 10 +- .../src/System/Reflection/Emit/EnumBuilder.cs | 32 +++--- .../Reflection/Emit/GenericTypeParameterBuilder.cs | 28 ++--- .../src/System/Reflection/Emit/ModuleBuilder.cs | 108 +++++++++---------- .../System/Reflection/Emit/ModuleBuilderData.cs | 16 +-- .../src/System/Reflection/Emit/SymbolType.cs | 32 +++--- .../src/System/Reflection/Emit/TypeBuilder.cs | 120 ++++++++++----------- .../Reflection/Emit/TypeBuilderInstantiation.cs | 28 ++--- .../System/Reflection/ExceptionHandlingClause.cs | 6 +- .../src/System/Reflection/FieldInfo.CoreCLR.cs | 2 +- .../src/System/Reflection/MdConstant.cs | 4 +- .../src/System/Reflection/MdImport.cs | 18 ++-- .../src/System/Reflection/MethodBase.CoreCLR.cs | 4 +- .../src/System/Reflection/RtFieldInfo.cs | 8 +- .../src/System/Reflection/RuntimeAssembly.cs | 84 +++++++-------- .../System/Reflection/RuntimeConstructorInfo.cs | 10 +- .../src/System/Reflection/RuntimeModule.cs | 28 ++--- .../Resources/ManifestBasedResourceGroveler.cs | 36 +++---- .../src/System/Resources/ResourceManager.cs | 98 ++++++++--------- .../src/System/Resources/ResourceReader.cs | 44 ++++---- .../src/System/Resources/__FastResourceComparer.cs | 34 +++--- src/System.Private.CoreLib/src/System/RtType.cs | 90 ++++++++-------- .../Runtime/CompilerServices/AsyncMethodBuilder.cs | 18 ++-- .../CompilerServices/ConditionalWeakTable.cs | 6 +- .../System/Runtime/CompilerServices/TaskAwaiter.cs | 2 +- .../src/System/Runtime/InteropServices/Marshal.cs | 76 ++++++------- .../WindowsRuntime/ConstantSplittableMap.cs | 4 +- .../WindowsRuntime/CustomPropertyImpl.cs | 2 +- .../WindowsRuntime/EnumeratorToIteratorAdapter.cs | 2 +- .../IMapViewToIReadOnlyDictionaryAdapter.cs | 4 +- .../IReadOnlyListToIVectorViewAdapter.cs | 2 +- .../WindowsRuntime/ListToVectorAdapter.cs | 2 +- .../WindowsRuntime/MapToDictionaryAdapter.cs | 4 +- .../WindowsRuntime/WindowsRuntimeMarshal.cs | 4 +- .../WindowsRuntime/WindowsRuntimeMetadata.cs | 2 +- .../System/Runtime/Loader/AssemblyLoadContext.cs | 2 +- .../src/System/Runtime/MemoryFailPoint.cs | 6 +- .../src/System/StubHelpers.cs | 8 +- .../src/System/Text/EncodingTable.cs | 2 +- .../src/System/Threading/CancellationToken.cs | 4 +- .../Threading/CancellationTokenRegistration.cs | 2 +- .../System/Threading/CancellationTokenSource.cs | 2 +- .../ClrThreadPoolPreAllocatedOverlapped.cs | 2 +- .../src/System/Threading/ManualResetEventSlim.cs | 4 +- .../src/System/Threading/SemaphoreSlim.cs | 12 +-- .../System/Threading/Tasks/AsyncCausalityTracer.cs | 2 +- .../src/System/Threading/Tasks/FutureFactory.cs | 30 +++--- .../Threading/Tasks/ProducerConsumerQueues.cs | 6 +- .../src/System/Threading/Tasks/Task.cs | 90 ++++++++-------- .../src/System/Threading/Tasks/TaskContinuation.cs | 10 +- .../src/System/Threading/Tasks/TaskFactory.cs | 6 +- .../src/System/Threading/Tasks/future.cs | 38 +++---- .../src/System/Threading/ThreadLocal.cs | 6 +- .../src/System/TypeLoadException.cs | 4 +- 156 files changed, 1274 insertions(+), 1272 deletions(-) diff --git a/src/System.Private.CoreLib/Common/System/SR.cs b/src/System.Private.CoreLib/Common/System/SR.cs index 0b6db12..c94ad7f 100644 --- a/src/System.Private.CoreLib/Common/System/SR.cs +++ b/src/System.Private.CoreLib/Common/System/SR.cs @@ -30,7 +30,7 @@ namespace System // Needed for debugger integration internal static string GetResourceString(string resourceKey) { - return GetResourceString(resourceKey, String.Empty); + return GetResourceString(resourceKey, string.Empty); } internal static string GetResourceString(string resourceKey, string defaultString) @@ -155,10 +155,10 @@ namespace System { if (UsingResourceKeys()) { - return resourceFormat + String.Join(", ", args); + return resourceFormat + string.Join(", ", args); } - return String.Format(resourceFormat, args); + return string.Format(resourceFormat, args); } return resourceFormat; @@ -168,29 +168,29 @@ namespace System { if (UsingResourceKeys()) { - return String.Join(", ", resourceFormat, p1); + return string.Join(", ", resourceFormat, p1); } - return String.Format(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.Join(", ", resourceFormat, p1, p2); } - return String.Format(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.Join(", ", resourceFormat, p1, p2, p3); } - return String.Format(resourceFormat, p1, p2, p3); + return string.Format(resourceFormat, p1, p2, p3); } } } diff --git a/src/System.Private.CoreLib/shared/System/ArgumentException.cs b/src/System.Private.CoreLib/shared/System/ArgumentException.cs index 8a8fe3e..5a91806 100644 --- a/src/System.Private.CoreLib/shared/System/ArgumentException.cs +++ b/src/System.Private.CoreLib/shared/System/ArgumentException.cs @@ -23,7 +23,7 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class ArgumentException : SystemException { - private String _paramName; + private string _paramName; // Creates a new ArgumentException with its message // string set to the empty string. @@ -36,26 +36,26 @@ namespace System // Creates a new ArgumentException with its message // string set to message. // - public ArgumentException(String message) + public ArgumentException(string message) : base(message) { HResult = HResults.COR_E_ARGUMENT; } - public ArgumentException(String message, Exception innerException) + public ArgumentException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_ARGUMENT; } - public ArgumentException(String message, String paramName, Exception innerException) + public ArgumentException(string message, string paramName, Exception innerException) : base(message, innerException) { _paramName = paramName; HResult = HResults.COR_E_ARGUMENT; } - public ArgumentException(String message, String paramName) + public ArgumentException(string message, string paramName) : base(message) { _paramName = paramName; @@ -74,14 +74,14 @@ namespace System info.AddValue("ParamName", _paramName, typeof(string)); } - public override String Message + public override string Message { get { - String s = base.Message; - if (!String.IsNullOrEmpty(_paramName)) + string s = base.Message; + if (!string.IsNullOrEmpty(_paramName)) { - String resourceString = SR.Format(SR.Arg_ParamName_Name, _paramName); + string resourceString = SR.Format(SR.Arg_ParamName_Name, _paramName); return s + Environment.NewLine + resourceString; } else @@ -89,7 +89,7 @@ namespace System } } - public virtual String ParamName + public virtual string ParamName { get { return _paramName; } } diff --git a/src/System.Private.CoreLib/shared/System/ArraySegment.cs b/src/System.Private.CoreLib/shared/System/ArraySegment.cs index 3a13595..81cf770 100644 --- a/src/System.Private.CoreLib/shared/System/ArraySegment.cs +++ b/src/System.Private.CoreLib/shared/System/ArraySegment.cs @@ -289,7 +289,7 @@ namespace System bool ICollection.Remove(T item) { ThrowHelper.ThrowNotSupportedException(); - return default(bool); + return default; } #endregion diff --git a/src/System.Private.CoreLib/shared/System/Buffers/MemoryHandle.cs b/src/System.Private.CoreLib/shared/System/Buffers/MemoryHandle.cs index 231add1..b218534 100644 --- a/src/System.Private.CoreLib/shared/System/Buffers/MemoryHandle.cs +++ b/src/System.Private.CoreLib/shared/System/Buffers/MemoryHandle.cs @@ -2,7 +2,6 @@ // 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.Runtime; using System.Runtime.InteropServices; namespace System.Buffers diff --git a/src/System.Private.CoreLib/shared/System/Buffers/MemoryManager.cs b/src/System.Private.CoreLib/shared/System/Buffers/MemoryManager.cs index acba3d2..1b235b5 100644 --- a/src/System.Private.CoreLib/shared/System/Buffers/MemoryManager.cs +++ b/src/System.Private.CoreLib/shared/System/Buffers/MemoryManager.cs @@ -2,7 +2,6 @@ // 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.Runtime; using System.Runtime.CompilerServices; namespace System.Buffers diff --git a/src/System.Private.CoreLib/shared/System/Collections/Concurrent/ConcurrentQueue.cs b/src/System.Private.CoreLib/shared/System/Collections/Concurrent/ConcurrentQueue.cs index 32691bc..63880b0 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/Concurrent/ConcurrentQueue.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/Concurrent/ConcurrentQueue.cs @@ -175,7 +175,7 @@ namespace System.Collections.Concurrent /// cref="ICollection"/>. This property is not supported. /// /// The SyncRoot property is not supported. - object ICollection.SyncRoot { get { ThrowHelper.ThrowNotSupportedException(ExceptionResource.ConcurrentCollection_SyncRoot_NotSupported); return default(object); } } + object ICollection.SyncRoot { get { ThrowHelper.ThrowNotSupportedException(ExceptionResource.ConcurrentCollection_SyncRoot_NotSupported); return default; } } /// Returns an enumerator that iterates through a collection. /// An that can be used to iterate through the collection. @@ -713,7 +713,7 @@ namespace System.Collections.Concurrent // check and this check, another item could have arrived). if (head._nextSegment == null) { - item = default(T); + item = default; return false; } @@ -807,7 +807,7 @@ namespace System.Collections.Concurrent // and we'll traverse to that segment. } - result = default(T); + result = default; return false; } diff --git a/src/System.Private.CoreLib/shared/System/Convert.cs b/src/System.Private.CoreLib/shared/System/Convert.cs index 2162e7b..c72b540 100644 --- a/src/System.Private.CoreLib/shared/System/Convert.cs +++ b/src/System.Private.CoreLib/shared/System/Convert.cs @@ -316,7 +316,7 @@ namespace System public static Object ChangeType(Object value, Type conversionType, IFormatProvider provider) { - if (ReferenceEquals(conversionType, null)) + if (conversionType is null) { throw new ArgumentNullException(nameof(conversionType)); } @@ -2008,7 +2008,7 @@ namespace System IFormattable formattable = value as IFormattable; if (formattable != null) return formattable.ToString(null, provider); - return value == null ? String.Empty : value.ToString(); + return value == null ? string.Empty : value.ToString(); } public static string ToString(bool value) diff --git a/src/System.Private.CoreLib/shared/System/DateTimeOffset.cs b/src/System.Private.CoreLib/shared/System/DateTimeOffset.cs index 3c3f3f4..da5705c 100644 --- a/src/System.Private.CoreLib/shared/System/DateTimeOffset.cs +++ b/src/System.Private.CoreLib/shared/System/DateTimeOffset.cs @@ -806,7 +806,7 @@ namespace System styles = ValidateStyles(styles, nameof(styles)); if (input == null) { - result = default(DateTimeOffset); + result = default; return false; } @@ -835,7 +835,7 @@ namespace System styles = ValidateStyles(styles, nameof(styles)); if (input == null || format == null) { - result = default(DateTimeOffset); + result = default; return false; } @@ -866,7 +866,7 @@ namespace System styles = ValidateStyles(styles, nameof(styles)); if (input == null) { - result = default(DateTimeOffset); + result = default; return false; } diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventProvider.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventProvider.cs index c1e4298..d412e6b 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventProvider.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventProvider.cs @@ -959,7 +959,7 @@ namespace System.Diagnostics.Tracing List dataRefObj = new List(s_etwAPIMaxRefObjCount); EventData* userData = stackalloc EventData[2 * argCount]; for (int i = 0; i < 2 * argCount; i++) - userData[i] = default(EventData); + userData[i] = default; EventData* userDataPtr = (EventData*)userData; byte* dataBuffer = stackalloc byte[s_basicTypeAllocationBufferSize * 2 * argCount]; // Assume 16 chars for non-string argument byte* currentBuffer = dataBuffer; diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs index 1836a1f..cfe1d35 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs @@ -3168,7 +3168,7 @@ namespace System.Diagnostics.Tracing if ((flags & EventManifestOptions.Strict) != 0 && (manifest.Errors.Count > 0 || exception != null)) { - string msg = String.Empty; + string msg = string.Empty; if (manifest.Errors.Count > 0) { bool firstError = true; @@ -3550,7 +3550,7 @@ namespace System.Diagnostics.Tracing { #if (!ES_BUILD_PCL && !ES_BUILD_PN) // send message to debugger without delay - System.Diagnostics.Debugger.Log(0, null, String.Format("EventSource Error: {0}{1}", msg, Environment.NewLine)); + System.Diagnostics.Debugger.Log(0, null, string.Format("EventSource Error: {0}{1}", msg, Environment.NewLine)); #endif // Send it to all listeners. @@ -4231,7 +4231,7 @@ namespace System.Diagnostics.Tracing /// /// Gets the arguments for the callback. /// - public IDictionary Arguments { get; internal set; } + public IDictionary Arguments { get; internal set; } /// /// Enables the event that has the specified identifier. diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/StubEnvironment.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/StubEnvironment.cs index 1b3ca80..13de05a 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/StubEnvironment.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/StubEnvironment.cs @@ -30,10 +30,10 @@ namespace System.Diagnostics.Tracing.Internal if (fmt != null) return string.Format(fmt, args); - string sargs = String.Empty; + string sargs = string.Empty; foreach(var arg in args) { - if (sargs != String.Empty) + if (sargs != string.Empty) sargs += ", "; sargs += arg.ToString(); } diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs index 30a9411..3febe6f 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/EventPayload.cs @@ -144,7 +144,7 @@ namespace System.Diagnostics.Tracing position++; } - value = default(object); + value = default; return false; } diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs index ae60888..9ff7e83 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs @@ -87,7 +87,7 @@ namespace System.Diagnostics.Tracing private PropertyValue(object value) { _reference = value; - _scalar = default(Scalar); + _scalar = default; _scalarLength = 0; } diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs index ccdc8bf..1793a16 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs @@ -447,11 +447,11 @@ namespace System.Diagnostics.Tracing var scratch = stackalloc byte[eventTypes.scratchSize]; var descriptors = stackalloc EventData[eventTypes.dataCount + 3]; for(int i = 0; i < eventTypes.dataCount + 3; i++) - descriptors[i] = default(EventData); + descriptors[i] = default; var pins = stackalloc GCHandle[pinCount]; for (int i = 0; i < pinCount; i++) - pins[i] = default(GCHandle); + pins[i] = default; fixed (byte* pMetadata0 = this.providerMetadata, @@ -563,7 +563,7 @@ namespace System.Diagnostics.Tracing var descriptorsLength = eventTypes.dataCount + eventTypes.typeInfos.Length * 2 + 3; var descriptors = stackalloc EventData[descriptorsLength]; for(int i = 0; i < descriptorsLength; i++) - descriptors[i] = default(EventData); + descriptors[i] = default; fixed (byte* pMetadata0 = this.providerMetadata, @@ -632,11 +632,11 @@ namespace System.Diagnostics.Tracing var scratch = stackalloc byte[eventTypes.scratchSize]; var descriptors = stackalloc EventData[eventTypes.dataCount + 3]; for(int i=0; i maxValue.Ticks) { throw new ArgumentException( - String.Format(CultureInfo.InvariantCulture, SR.Format(SR.Argument_ResultCalendarRange, + string.Format(CultureInfo.InvariantCulture, SR.Format(SR.Argument_ResultCalendarRange, minValue, maxValue))); } } @@ -818,7 +818,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(millisecond), - String.Format( + string.Format( CultureInfo.InvariantCulture, SR.Format(SR.ArgumentOutOfRange_Range, 0, MillisPerSecond - 1))); } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CalendarData.cs b/src/System.Private.CoreLib/shared/System/Globalization/CalendarData.cs index ea70a1c..56ddf75 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/CalendarData.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/CalendarData.cs @@ -19,26 +19,26 @@ namespace System.Globalization internal const int MAX_CALENDARS = 23; // Identity - internal String sNativeName; // Calendar Name for the locale + internal string sNativeName; // Calendar Name for the locale // Formats - internal String[] saShortDates; // Short Data format, default first - internal String[] saYearMonths; // Year/Month Data format, default first - internal String[] saLongDates; // Long Data format, default first - internal String sMonthDay; // Month/Day format + internal string[] saShortDates; // Short Data format, default first + internal string[] saYearMonths; // Year/Month Data format, default first + internal string[] saLongDates; // Long Data format, default first + internal string sMonthDay; // Month/Day format // Calendar Parts Names - internal String[] saEraNames; // Names of Eras - internal String[] saAbbrevEraNames; // Abbreviated Era Names - internal String[] saAbbrevEnglishEraNames; // Abbreviated Era Names in English - internal String[] saDayNames; // Day Names, null to use locale data, starts on Sunday - internal String[] saAbbrevDayNames; // Abbrev Day Names, null to use locale data, starts on Sunday - internal String[] saSuperShortDayNames; // Super short Day of week names - internal String[] saMonthNames; // Month Names (13) - internal String[] saAbbrevMonthNames; // Abbrev Month Names (13) - internal String[] saMonthGenitiveNames; // Genitive Month Names (13) - internal String[] saAbbrevMonthGenitiveNames; // Genitive Abbrev Month Names (13) - internal String[] saLeapYearMonthNames; // Multiple strings for the month names in a leap year. + internal string[] saEraNames; // Names of Eras + internal string[] saAbbrevEraNames; // Abbreviated Era Names + internal string[] saAbbrevEnglishEraNames; // Abbreviated Era Names in English + internal string[] saDayNames; // Day Names, null to use locale data, starts on Sunday + internal string[] saAbbrevDayNames; // Abbrev Day Names, null to use locale data, starts on Sunday + internal string[] saSuperShortDayNames; // Super short Day of week names + internal string[] saMonthNames; // Month Names (13) + internal string[] saAbbrevMonthNames; // Abbrev Month Names (13) + internal string[] saMonthGenitiveNames; // Genitive Month Names (13) + internal string[] saAbbrevMonthGenitiveNames; // Genitive Abbrev Month Names (13) + internal string[] saLeapYearMonthNames; // Multiple strings for the month names in a leap year. // Integers at end to make marshaller happier internal int iTwoDigitYearMax = 2029; // Max 2 digit year (for Y2K bug data entry) @@ -69,22 +69,22 @@ namespace System.Globalization invariant.iCurrentEra = 1; // Current era # // Formats - invariant.saShortDates = new String[] { "MM/dd/yyyy", "yyyy-MM-dd" }; // short date format - invariant.saLongDates = new String[] { "dddd, dd MMMM yyyy" }; // long date format - invariant.saYearMonths = new String[] { "yyyy MMMM" }; // year month format + invariant.saShortDates = new string[] { "MM/dd/yyyy", "yyyy-MM-dd" }; // short date format + invariant.saLongDates = new string[] { "dddd, dd MMMM yyyy" }; // long date format + invariant.saYearMonths = new string[] { "yyyy MMMM" }; // year month format invariant.sMonthDay = "MMMM dd"; // Month day pattern // Calendar Parts Names - invariant.saEraNames = new String[] { "A.D." }; // Era names - invariant.saAbbrevEraNames = new String[] { "AD" }; // Abbreviated Era names - invariant.saAbbrevEnglishEraNames = new String[] { "AD" }; // Abbreviated era names in English - invariant.saDayNames = new String[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };// day names - invariant.saAbbrevDayNames = new String[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; // abbreviated day names - invariant.saSuperShortDayNames = new String[] { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; // The super short day names - invariant.saMonthNames = new String[] { "January", "February", "March", "April", "May", "June", - "July", "August", "September", "October", "November", "December", String.Empty}; // month names - invariant.saAbbrevMonthNames = new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", String.Empty}; // abbreviated month names + invariant.saEraNames = new string[] { "A.D." }; // Era names + invariant.saAbbrevEraNames = new string[] { "AD" }; // Abbreviated Era names + invariant.saAbbrevEnglishEraNames = new string[] { "AD" }; // Abbreviated era names in English + invariant.saDayNames = new string[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };// day names + invariant.saAbbrevDayNames = new string[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; // abbreviated day names + invariant.saSuperShortDayNames = new string[] { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; // The super short day names + invariant.saMonthNames = new string[] { "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December", string.Empty}; // month names + invariant.saAbbrevMonthNames = new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", string.Empty}; // abbreviated month names invariant.saMonthGenitiveNames = invariant.saMonthNames; // Genitive month names (same as month names for invariant) invariant.saAbbrevMonthGenitiveNames = invariant.saAbbrevMonthNames; // Abbreviated genitive month names (same as abbrev month names for invariant) invariant.saLeapYearMonthNames = invariant.saMonthNames; // leap year month names are unused in Gregorian English (invariant) @@ -97,7 +97,7 @@ namespace System.Globalization // // Get a bunch of data for a calendar // - internal CalendarData(String localeName, CalendarId calendarId, bool bUseUserOverrides) + internal CalendarData(string localeName, CalendarId calendarId, bool bUseUserOverrides) { this.bUseUserOverrides = bUseUserOverrides; @@ -109,7 +109,7 @@ namespace System.Globalization // Something failed, try invariant for missing parts // This is really not good, but we don't want the callers to crash. - if (this.sNativeName == null) this.sNativeName = String.Empty; // Calendar Name for the locale. + if (this.sNativeName == null) this.sNativeName = string.Empty; // Calendar Name for the locale. // Formats if (this.saShortDates == null) this.saShortDates = Invariant.saShortDates; // Short Data format, default first @@ -138,16 +138,16 @@ namespace System.Globalization } else { - this.sNativeName = String.Empty; + this.sNativeName = string.Empty; } } // Check for null genitive names (in case unmanaged side skips it for non-gregorian calendars, etc) - if (this.saMonthGenitiveNames == null || this.saMonthGenitiveNames.Length == 0 || String.IsNullOrEmpty(this.saMonthGenitiveNames[0])) + if (this.saMonthGenitiveNames == null || this.saMonthGenitiveNames.Length == 0 || string.IsNullOrEmpty(this.saMonthGenitiveNames[0])) this.saMonthGenitiveNames = this.saMonthNames; // Genitive month names (same as month names for invariant) - if (this.saAbbrevMonthGenitiveNames == null || this.saAbbrevMonthGenitiveNames.Length == 0 || String.IsNullOrEmpty(this.saAbbrevMonthGenitiveNames[0])) + if (this.saAbbrevMonthGenitiveNames == null || this.saAbbrevMonthGenitiveNames.Length == 0 || string.IsNullOrEmpty(this.saAbbrevMonthGenitiveNames[0])) this.saAbbrevMonthGenitiveNames = this.saAbbrevMonthNames; // Abbreviated genitive month names (same as abbrev month names for invariant) - if (this.saLeapYearMonthNames == null || this.saLeapYearMonthNames.Length == 0 || String.IsNullOrEmpty(this.saLeapYearMonthNames[0])) + if (this.saLeapYearMonthNames == null || this.saLeapYearMonthNames.Length == 0 || string.IsNullOrEmpty(this.saLeapYearMonthNames[0])) this.saLeapYearMonthNames = this.saMonthNames; InitializeEraNames(localeName, calendarId); @@ -162,7 +162,7 @@ namespace System.Globalization else { // For all others just use the an empty string (doesn't matter we'll never ask for it for other calendars) - this.saAbbrevEnglishEraNames = new String[] { "" }; + this.saAbbrevEnglishEraNames = new string[] { "" }; } // Japanese is the only thing with > 1 era. Its current era # is how many ever @@ -178,60 +178,60 @@ namespace System.Globalization // For Localized Gregorian we really expect the data from the OS. case CalendarId.GREGORIAN: // Fallback for CoreCLR < Win7 or culture.dll missing - if (this.saEraNames == null || this.saEraNames.Length == 0 || String.IsNullOrEmpty(this.saEraNames[0])) + if (this.saEraNames == null || this.saEraNames.Length == 0 || string.IsNullOrEmpty(this.saEraNames[0])) { - this.saEraNames = new String[] { "A.D." }; + this.saEraNames = new string[] { "A.D." }; } break; // The rest of the calendars have constant data, so we'll just use that case CalendarId.GREGORIAN_US: case CalendarId.JULIAN: - this.saEraNames = new String[] { "A.D." }; + this.saEraNames = new string[] { "A.D." }; break; case CalendarId.HEBREW: - this.saEraNames = new String[] { "C.E." }; + this.saEraNames = new string[] { "C.E." }; break; case CalendarId.HIJRI: case CalendarId.UMALQURA: if (localeName == "dv-MV") { // Special case for Divehi - this.saEraNames = new String[] { "\x0780\x07a8\x0796\x07b0\x0783\x07a9" }; + this.saEraNames = new string[] { "\x0780\x07a8\x0796\x07b0\x0783\x07a9" }; } else { - this.saEraNames = new String[] { "\x0628\x0639\x062F \x0627\x0644\x0647\x062C\x0631\x0629" }; + this.saEraNames = new string[] { "\x0628\x0639\x062F \x0627\x0644\x0647\x062C\x0631\x0629" }; } break; case CalendarId.GREGORIAN_ARABIC: case CalendarId.GREGORIAN_XLIT_ENGLISH: case CalendarId.GREGORIAN_XLIT_FRENCH: // These are all the same: - this.saEraNames = new String[] { "\x0645" }; + this.saEraNames = new string[] { "\x0645" }; break; case CalendarId.GREGORIAN_ME_FRENCH: - this.saEraNames = new String[] { "ap. J.-C." }; + this.saEraNames = new string[] { "ap. J.-C." }; break; case CalendarId.TAIWAN: if (SystemSupportsTaiwaneseCalendar()) { - this.saEraNames = new String[] { "\x4e2d\x83ef\x6c11\x570b" }; + this.saEraNames = new string[] { "\x4e2d\x83ef\x6c11\x570b" }; } else { - this.saEraNames = new String[] { String.Empty }; + this.saEraNames = new string[] { string.Empty }; } break; case CalendarId.KOREA: - this.saEraNames = new String[] { "\xb2e8\xae30" }; + this.saEraNames = new string[] { "\xb2e8\xae30" }; break; case CalendarId.THAI: - this.saEraNames = new String[] { "\x0e1e\x002e\x0e28\x002e" }; + this.saEraNames = new string[] { "\x0e1e\x002e\x0e28\x002e" }; break; case CalendarId.JAPAN: @@ -240,9 +240,9 @@ namespace System.Globalization break; case CalendarId.PERSIAN: - if (this.saEraNames == null || this.saEraNames.Length == 0 || String.IsNullOrEmpty(this.saEraNames[0])) + if (this.saEraNames == null || this.saEraNames.Length == 0 || string.IsNullOrEmpty(this.saEraNames[0])) { - this.saEraNames = new String[] { "\x0647\x002e\x0634" }; + this.saEraNames = new string[] { "\x0647\x002e\x0634" }; } break; @@ -261,16 +261,16 @@ namespace System.Globalization // For Localized Gregorian we really expect the data from the OS. case CalendarId.GREGORIAN: // Fallback for CoreCLR < Win7 or culture.dll missing - if (this.saAbbrevEraNames == null || this.saAbbrevEraNames.Length == 0 || String.IsNullOrEmpty(this.saAbbrevEraNames[0])) + if (this.saAbbrevEraNames == null || this.saAbbrevEraNames.Length == 0 || string.IsNullOrEmpty(this.saAbbrevEraNames[0])) { - this.saAbbrevEraNames = new String[] { "AD" }; + this.saAbbrevEraNames = new string[] { "AD" }; } break; // The rest of the calendars have constant data, so we'll just use that case CalendarId.GREGORIAN_US: case CalendarId.JULIAN: - this.saAbbrevEraNames = new String[] { "AD" }; + this.saAbbrevEraNames = new string[] { "AD" }; break; case CalendarId.JAPAN: case CalendarId.JAPANESELUNISOLAR: @@ -281,16 +281,16 @@ namespace System.Globalization if (localeName == "dv-MV") { // Special case for Divehi - this.saAbbrevEraNames = new String[] { "\x0780\x002e" }; + this.saAbbrevEraNames = new string[] { "\x0780\x002e" }; } else { - this.saAbbrevEraNames = new String[] { "\x0647\x0640" }; + this.saAbbrevEraNames = new string[] { "\x0647\x0640" }; } break; case CalendarId.TAIWAN: // Get era name and abbreviate it - this.saAbbrevEraNames = new String[1]; + this.saAbbrevEraNames = new string[1]; if (this.saEraNames[0].Length == 4) { this.saAbbrevEraNames[0] = this.saEraNames[0].Substring(2, 2); @@ -302,7 +302,7 @@ namespace System.Globalization break; case CalendarId.PERSIAN: - if (this.saAbbrevEraNames == null || this.saAbbrevEraNames.Length == 0 || String.IsNullOrEmpty(this.saAbbrevEraNames[0])) + if (this.saAbbrevEraNames == null || this.saAbbrevEraNames.Length == 0 || string.IsNullOrEmpty(this.saAbbrevEraNames[0])) { this.saAbbrevEraNames = this.saEraNames; } @@ -326,13 +326,13 @@ namespace System.Globalization // Get a culture name // TODO: Note that this doesn't handle the new calendars (lunisolar, etc) - String culture = CalendarIdToCultureName(calendarId); + string culture = CalendarIdToCultureName(calendarId); // Return our calendar return CultureInfo.GetCultureInfo(culture)._cultureData.GetCalendar(calendarId); } - private static String CalendarIdToCultureName(CalendarId calendarId) + private static string CalendarIdToCultureName(CalendarId calendarId) { switch (calendarId) { diff --git a/src/System.Private.CoreLib/shared/System/Globalization/ChineseLunisolarCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/ChineseLunisolarCalendar.cs index d2b52b9..a344923 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/ChineseLunisolarCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/ChineseLunisolarCalendar.cs @@ -315,7 +315,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( "year", - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, MIN_LUNISOLAR_YEAR, MAX_LUNISOLAR_YEAR)); } @@ -339,7 +339,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, MIN_LUNISOLAR_YEAR, MAX_LUNISOLAR_YEAR)); } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.cs b/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.cs index 788662b..ef01636 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.cs @@ -304,7 +304,7 @@ namespace System.Globalization { if (options == CompareOptions.OrdinalIgnoreCase) { - return String.Compare(string1, string2, StringComparison.OrdinalIgnoreCase); + return string.Compare(string1, string2, StringComparison.OrdinalIgnoreCase); } // Verify the options before we do any real comparison. @@ -315,7 +315,7 @@ namespace System.Globalization throw new ArgumentException(SR.Argument_CompareOptionOrdinal, nameof(options)); } - return String.CompareOrdinal(string1, string2); + return string.CompareOrdinal(string1, string2); } if ((options & ValidCompareMaskOffFlags) != 0) @@ -343,7 +343,7 @@ namespace System.Globalization if ((options & CompareOptions.IgnoreCase) != 0) return CompareOrdinalIgnoreCase(string1, string2); - return String.CompareOrdinal(string1, string2); + return string.CompareOrdinal(string1, string2); } return CompareString(string1.AsSpan(), string2.AsSpan(), options); @@ -449,7 +449,7 @@ namespace System.Globalization { if (options == CompareOptions.OrdinalIgnoreCase) { - int result = String.Compare(string1, offset1, string2, offset2, length1 < length2 ? length1 : length2, StringComparison.OrdinalIgnoreCase); + int result = string.Compare(string1, offset1, string2, offset2, length1 < length2 ? length1 : length2, StringComparison.OrdinalIgnoreCase); if ((length1 != length2) && result == 0) return (length1 > length2 ? 1 : -1); return (result); diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CultureNotFoundException.cs b/src/System.Private.CoreLib/shared/System/Globalization/CultureNotFoundException.cs index 10e8b1f..007aff7 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/CultureNotFoundException.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/CultureNotFoundException.cs @@ -18,28 +18,28 @@ namespace System.Globalization { } - public CultureNotFoundException(String message) + public CultureNotFoundException(string message) : base(message) { } - public CultureNotFoundException(String paramName, String message) + public CultureNotFoundException(string paramName, string message) : base(message, paramName) { } - public CultureNotFoundException(String message, Exception innerException) + public CultureNotFoundException(string message, Exception innerException) : base(message, innerException) { } - public CultureNotFoundException(String paramName, string invalidCultureName, String message) + public CultureNotFoundException(string paramName, string invalidCultureName, string message) : base(message, paramName) { _invalidCultureName = invalidCultureName; } - public CultureNotFoundException(String message, string invalidCultureName, Exception innerException) + public CultureNotFoundException(string message, string invalidCultureName, Exception innerException) : base(message, innerException) { _invalidCultureName = invalidCultureName; @@ -81,7 +81,7 @@ namespace System.Globalization get { return _invalidCultureName; } } - private static String DefaultMessage + private static string DefaultMessage { get { @@ -89,24 +89,24 @@ namespace System.Globalization } } - private String FormatedInvalidCultureId + private string FormatedInvalidCultureId { get { return InvalidCultureId != null ? - String.Format(CultureInfo.InvariantCulture, "{0} (0x{0:x4})", (int)InvalidCultureId) : + string.Format(CultureInfo.InvariantCulture, "{0} (0x{0:x4})", (int)InvalidCultureId) : InvalidCultureName; } } - public override String Message + public override string Message { get { - String s = base.Message; + string s = base.Message; if (_invalidCultureId != null || _invalidCultureName != null) { - String valueMessage = SR.Format(SR.Argument_CultureInvalidIdentifier, FormatedInvalidCultureId); + string valueMessage = SR.Format(SR.Argument_CultureInvalidIdentifier, FormatedInvalidCultureId); if (s == null) { return valueMessage; diff --git a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs index 092ad03..81e81d0 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs @@ -134,8 +134,8 @@ namespace System 's', 't', 'T', 'u', 'U', 'y', 'Y', }; - internal const String RoundtripFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK"; - internal const String RoundtripDateTimeUnfixed = "yyyy'-'MM'-'ddTHH':'mm':'ss zzz"; + internal const string RoundtripFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK"; + internal const string RoundtripDateTimeUnfixed = "yyyy'-'MM'-'ddTHH':'mm':'ss zzz"; private const int DEFAULT_ALL_DATETIMES_SIZE = 132; @@ -144,7 +144,7 @@ namespace System internal static readonly string[] InvariantAbbreviatedDayNames = InvariantFormatInfo.AbbreviatedDayNames; internal const string Gmt = "GMT"; - internal static String[] fixedNumberFormats = new String[] { + internal static string[] fixedNumberFormats = new string[] { "0", "00", "000", @@ -223,7 +223,7 @@ namespace System return (index - pos); } - private static String FormatDayOfWeek(int dayOfWeek, int repeat, DateTimeFormatInfo dtfi) + private static string FormatDayOfWeek(int dayOfWeek, int repeat, DateTimeFormatInfo dtfi) { Debug.Assert(dayOfWeek >= 0 && dayOfWeek <= 6, "dayOfWeek >= 0 && dayOfWeek <= 6"); if (repeat == 3) @@ -235,7 +235,7 @@ namespace System return (dtfi.GetDayName((DayOfWeek)dayOfWeek)); } - private static String FormatMonth(int month, int repeatCount, DateTimeFormatInfo dtfi) + private static string FormatMonth(int month, int repeatCount, DateTimeFormatInfo dtfi) { Debug.Assert(month >= 1 && month <= 12, "month >=1 && month <= 12"); if (repeatCount == 3) @@ -276,7 +276,7 @@ namespace System Therefore, if we are in a regular year, we have to increment the month name if moth is greater or eqaul to 7. */ - private static String FormatHebrewMonthName(DateTime time, int month, int repeatCount, DateTimeFormatInfo dtfi) + private static string FormatHebrewMonthName(DateTime time, int month, int repeatCount, DateTimeFormatInfo dtfi) { Debug.Assert(repeatCount != 3 || repeatCount != 4, "repeateCount should be 3 or 4"); if (dtfi.Calendar.IsLeapYear(dtfi.Calendar.GetYear(time))) @@ -347,7 +347,7 @@ namespace System { // Here we can't find the matching quote. throw new FormatException( - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.Format_BadQuote, quoteChar)); } @@ -669,7 +669,7 @@ namespace System } else { - String fmtPattern = "D" + tokenLen.ToString(); + string fmtPattern = "D" + tokenLen.ToString(); result.Append(year.ToString(fmtPattern, CultureInfo.InvariantCulture)); } } @@ -864,9 +864,9 @@ namespace System result.Append((char)('0' + (val % 10))); } - internal static String GetRealFormat(ReadOnlySpan format, DateTimeFormatInfo dtfi) + internal static string GetRealFormat(ReadOnlySpan format, DateTimeFormatInfo dtfi) { - String realFormat = null; + string realFormat = null; switch (format[0]) { @@ -931,7 +931,7 @@ namespace System // This method also convert the dateTime if necessary (e.g. when the format is in Universal time), // and change dtfi if necessary (e.g. when the format should use invariant culture). // - private static String ExpandPredefinedFormat(ReadOnlySpan format, ref DateTime dateTime, ref DateTimeFormatInfo dtfi, ref TimeSpan offset) + private static string ExpandPredefinedFormat(ReadOnlySpan format, ref DateTime dateTime, ref DateTimeFormatInfo dtfi, ref TimeSpan offset) { switch (format[0]) { @@ -988,12 +988,12 @@ namespace System return GetRealFormat(format, dtfi); } - internal static String Format(DateTime dateTime, String format, IFormatProvider provider) + internal static string Format(DateTime dateTime, string format, IFormatProvider provider) { return Format(dateTime, format, provider, NullOffset); } - internal static string Format(DateTime dateTime, String format, IFormatProvider provider, TimeSpan offset) + internal static string Format(DateTime dateTime, string format, IFormatProvider provider, TimeSpan offset) { if (format != null && format.Length == 1) { @@ -1313,11 +1313,11 @@ namespace System buffer[0] = (char)('0' + value); } - internal static String[] GetAllDateTimes(DateTime dateTime, char format, DateTimeFormatInfo dtfi) + internal static string[] GetAllDateTimes(DateTime dateTime, char format, DateTimeFormatInfo dtfi) { Debug.Assert(dtfi != null); - String[] allFormats = null; - String[] results = null; + string[] allFormats = null; + string[] results = null; switch (format) { @@ -1334,7 +1334,7 @@ namespace System case 'y': case 'Y': allFormats = dtfi.GetAllDateTimePatterns(format); - results = new String[allFormats.Length]; + results = new string[allFormats.Length]; for (int i = 0; i < allFormats.Length; i++) { results[i] = Format(dateTime, allFormats[i], dtfi); @@ -1343,7 +1343,7 @@ namespace System case 'U': DateTime universalTime = dateTime.ToUniversalTime(); allFormats = dtfi.GetAllDateTimePatterns(format); - results = new String[allFormats.Length]; + results = new string[allFormats.Length]; for (int i = 0; i < allFormats.Length; i++) { results[i] = Format(universalTime, allFormats[i], dtfi); @@ -1359,7 +1359,7 @@ namespace System case 'O': case 's': case 'u': - results = new String[] { Format(dateTime, new String(format, 1), dtfi) }; + results = new string[] { Format(dateTime, new string(format, 1), dtfi) }; break; default: throw new FormatException(SR.Format_InvalidString); @@ -1367,19 +1367,19 @@ namespace System return (results); } - internal static String[] GetAllDateTimes(DateTime dateTime, DateTimeFormatInfo dtfi) + internal static string[] GetAllDateTimes(DateTime dateTime, DateTimeFormatInfo dtfi) { - List results = new List(DEFAULT_ALL_DATETIMES_SIZE); + List results = new List(DEFAULT_ALL_DATETIMES_SIZE); for (int i = 0; i < allStandardFormats.Length; i++) { - String[] strings = GetAllDateTimes(dateTime, allStandardFormats[i], dtfi); + string[] strings = GetAllDateTimes(dateTime, allStandardFormats[i], dtfi); for (int j = 0; j < strings.Length; j++) { results.Add(strings[j]); } } - String[] value = new String[results.Count]; + string[] value = new string[results.Count]; results.CopyTo(0, value, 0, results.Count); return (value); } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfoScanner.cs b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfoScanner.cs index d3c3aac..d7e0abf 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfoScanner.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfoScanner.cs @@ -94,23 +94,23 @@ namespace System.Globalization internal const char IgnorableSymbolChar = '\xe001'; // Known CJK suffix - internal const String CJKYearSuff = "\u5e74"; - internal const String CJKMonthSuff = "\u6708"; - internal const String CJKDaySuff = "\u65e5"; + internal const string CJKYearSuff = "\u5e74"; + internal const string CJKMonthSuff = "\u6708"; + internal const string CJKDaySuff = "\u65e5"; - internal const String KoreanYearSuff = "\ub144"; - internal const String KoreanMonthSuff = "\uc6d4"; - internal const String KoreanDaySuff = "\uc77c"; + internal const string KoreanYearSuff = "\ub144"; + internal const string KoreanMonthSuff = "\uc6d4"; + internal const string KoreanDaySuff = "\uc77c"; - internal const String KoreanHourSuff = "\uc2dc"; - internal const String KoreanMinuteSuff = "\ubd84"; - internal const String KoreanSecondSuff = "\ucd08"; + internal const string KoreanHourSuff = "\uc2dc"; + internal const string KoreanMinuteSuff = "\ubd84"; + internal const string KoreanSecondSuff = "\ucd08"; - internal const String CJKHourSuff = "\u6642"; - internal const String ChineseHourSuff = "\u65f6"; + internal const string CJKHourSuff = "\u6642"; + internal const string ChineseHourSuff = "\u65f6"; - internal const String CJKMinuteSuff = "\u5206"; - internal const String CJKSecondSuff = "\u79d2"; + internal const string CJKMinuteSuff = "\u5206"; + internal const string CJKSecondSuff = "\u79d2"; // The collection fo date words & postfix. internal List m_dateWords = new List(); @@ -127,23 +127,23 @@ namespace System.Globalization // Add known words into the hash table. // Skip these special symbols. - temp.Add("/", String.Empty); - temp.Add("-", String.Empty); - temp.Add(".", String.Empty); + temp.Add("/", string.Empty); + temp.Add("-", string.Empty); + temp.Add(".", string.Empty); // Skip known CJK suffixes. - temp.Add(CJKYearSuff, String.Empty); - temp.Add(CJKMonthSuff, String.Empty); - temp.Add(CJKDaySuff, String.Empty); - temp.Add(KoreanYearSuff, String.Empty); - temp.Add(KoreanMonthSuff, String.Empty); - temp.Add(KoreanDaySuff, String.Empty); - temp.Add(KoreanHourSuff, String.Empty); - temp.Add(KoreanMinuteSuff, String.Empty); - temp.Add(KoreanSecondSuff, String.Empty); - temp.Add(CJKHourSuff, String.Empty); - temp.Add(ChineseHourSuff, String.Empty); - temp.Add(CJKMinuteSuff, String.Empty); - temp.Add(CJKSecondSuff, String.Empty); + temp.Add(CJKYearSuff, string.Empty); + temp.Add(CJKMonthSuff, string.Empty); + temp.Add(CJKDaySuff, string.Empty); + temp.Add(KoreanYearSuff, string.Empty); + temp.Add(KoreanMonthSuff, string.Empty); + temp.Add(KoreanDaySuff, string.Empty); + temp.Add(KoreanHourSuff, string.Empty); + temp.Add(KoreanMinuteSuff, string.Empty); + temp.Add(KoreanSecondSuff, string.Empty); + temp.Add(CJKHourSuff, string.Empty); + temp.Add(ChineseHourSuff, string.Empty); + temp.Add(CJKMinuteSuff, string.Empty); + temp.Add(CJKSecondSuff, string.Empty); s_knownWords = temp; } @@ -163,7 +163,7 @@ namespace System.Globalization // Note that the index can be pattern.Length if we reach the end of the string. // //////////////////////////////////////////////////////////////////////////// - internal static int SkipWhiteSpacesAndNonLetter(String pattern, int currentIndex) + internal static int SkipWhiteSpacesAndNonLetter(string pattern, int currentIndex) { while (currentIndex < pattern.Length) { @@ -211,7 +211,7 @@ namespace System.Globalization // word: The date word or postfix to be added. // //////////////////////////////////////////////////////////////////////////// - internal void AddDateWordOrPostfix(String formatPostfix, String str) + internal void AddDateWordOrPostfix(string formatPostfix, string str) { if (str.Length > 0) { @@ -221,7 +221,7 @@ namespace System.Globalization AddIgnorableSymbols("."); return; } - String words; + string words; if (KnownWords.TryGetValue(str, out words) == false) { if (m_dateWords == null) @@ -231,7 +231,7 @@ namespace System.Globalization if (formatPostfix == "MMMM") { // Add the word into the ArrayList as "\xfffe" + real month postfix. - String temp = MonthPostfixChar + str; + string temp = MonthPostfixChar + str; if (!m_dateWords.Contains(temp)) { m_dateWords.Add(temp); @@ -246,7 +246,7 @@ namespace System.Globalization if (str[str.Length - 1] == '.') { // Old version ignore the trialing dot in the date words. Support this as well. - String strWithoutDot = str.Substring(0, str.Length - 1); + string strWithoutDot = str.Substring(0, str.Length - 1); if (!m_dateWords.Contains(strWithoutDot)) { m_dateWords.Add(strWithoutDot); @@ -272,7 +272,7 @@ namespace System.Globalization // // //////////////////////////////////////////////////////////////////////////// - internal int AddDateWords(String pattern, int index, String formatPostfix) + internal int AddDateWords(string pattern, int index, string formatPostfix) { // Skip any whitespaces so we will start from a letter. int newIndex = SkipWhiteSpacesAndNonLetter(pattern, index); @@ -341,7 +341,7 @@ namespace System.Globalization // A simple helper to find the repeat count for a specified char. // //////////////////////////////////////////////////////////////////////////// - internal static int ScanRepeatChar(String pattern, char ch, int index, out int count) + internal static int ScanRepeatChar(string pattern, char ch, int index, out int count) { count = 1; while (++index < pattern.Length && pattern[index] == ch) @@ -367,7 +367,7 @@ namespace System.Globalization // //////////////////////////////////////////////////////////////////////////// - internal void AddIgnorableSymbols(String text) + internal void AddIgnorableSymbols(string text) { if (m_dateWords == null) { @@ -375,7 +375,7 @@ namespace System.Globalization m_dateWords = new List(); } // Add the ignorable symbol into the ArrayList. - String temp = IgnorableSymbolChar + text; + string temp = IgnorableSymbolChar + text; if (!m_dateWords.Contains(temp)) { m_dateWords.Add(temp); @@ -421,7 +421,7 @@ namespace System.Globalization // Windows style pattern uses '' for single quote, while .NET uses \' // //////////////////////////////////////////////////////////////////////////// - internal void ScanDateWord(String pattern) + internal void ScanDateWord(string pattern) { // Check if we have found all of the year/month/day pattern. _ymdFlags = FoundDatePattern.None; @@ -497,10 +497,10 @@ namespace System.Globalization // //////////////////////////////////////////////////////////////////////////// - internal String[] GetDateWordsOfDTFI(DateTimeFormatInfo dtfi) + internal string[] GetDateWordsOfDTFI(DateTimeFormatInfo dtfi) { // Enumarate all LongDatePatterns, and get the DateWords and scan for month postfix. - String[] datePatterns = dtfi.GetAllDateTimePatterns('D'); + string[] datePatterns = dtfi.GetAllDateTimePatterns('D'); int i; // Scan the long date patterns @@ -539,10 +539,10 @@ namespace System.Globalization ScanDateWord(datePatterns[i]); } - String[] result = null; + string[] result = null; if (m_dateWords != null && m_dateWords.Count > 0) { - result = new String[m_dateWords.Count]; + result = new string[m_dateWords.Count]; for (i = 0; i < m_dateWords.Count; i++) { result[i] = m_dateWords[i]; @@ -558,7 +558,7 @@ namespace System.Globalization // the format flag. // //////////////////////////////////////////////////////////////////////////// - internal static FORMATFLAGS GetFormatFlagGenitiveMonth(String[] monthNames, String[] genitveMonthNames, String[] abbrevMonthNames, String[] genetiveAbbrevMonthNames) + internal static FORMATFLAGS GetFormatFlagGenitiveMonth(string[] monthNames, string[] genitveMonthNames, string[] abbrevMonthNames, string[] genetiveAbbrevMonthNames) { // If we have different names in regular and genitive month names, use genitive month flag. return ((!EqualStringArrays(monthNames, genitveMonthNames) || !EqualStringArrays(abbrevMonthNames, genetiveAbbrevMonthNames)) @@ -570,7 +570,7 @@ namespace System.Globalization // Scan the month names to see if spaces are used or start with a digit, and return the format flag // //////////////////////////////////////////////////////////////////////////// - internal static FORMATFLAGS GetFormatFlagUseSpaceInMonthNames(String[] monthNames, String[] genitveMonthNames, String[] abbrevMonthNames, String[] genetiveAbbrevMonthNames) + internal static FORMATFLAGS GetFormatFlagUseSpaceInMonthNames(string[] monthNames, string[] genitveMonthNames, string[] abbrevMonthNames, string[] genetiveAbbrevMonthNames) { FORMATFLAGS formatFlags = 0; formatFlags |= (ArrayElementsBeginWithDigit(monthNames) || @@ -592,7 +592,7 @@ namespace System.Globalization // Scan the day names and set the correct format flag. // //////////////////////////////////////////////////////////////////////////// - internal static FORMATFLAGS GetFormatFlagUseSpaceInDayNames(String[] dayNames, String[] abbrevDayNames) + internal static FORMATFLAGS GetFormatFlagUseSpaceInDayNames(string[] dayNames, string[] abbrevDayNames) { return ((ArrayElementsHaveSpace(dayNames) || ArrayElementsHaveSpace(abbrevDayNames)) diff --git a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeParse.cs b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeParse.cs index 970d176..a6e2893 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeParse.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeParse.cs @@ -96,7 +96,7 @@ namespace System return DoStrictParse(s, format, style, dtfi, ref result); } - internal static DateTime ParseExactMultiple(ReadOnlySpan s, String[] formats, + internal static DateTime ParseExactMultiple(ReadOnlySpan s, string[] formats, DateTimeFormatInfo dtfi, DateTimeStyles style) { DateTimeResult result = new DateTimeResult(); // The buffer to store the parsing result. @@ -112,7 +112,7 @@ namespace System } - internal static DateTime ParseExactMultiple(ReadOnlySpan s, String[] formats, + internal static DateTime ParseExactMultiple(ReadOnlySpan s, string[] formats, DateTimeFormatInfo dtfi, DateTimeStyles style, out TimeSpan offset) { DateTimeResult result = new DateTimeResult(); // The buffer to store the parsing result. @@ -130,7 +130,7 @@ namespace System } } - internal static bool TryParseExactMultiple(ReadOnlySpan s, String[] formats, + internal static bool TryParseExactMultiple(ReadOnlySpan s, string[] formats, DateTimeFormatInfo dtfi, DateTimeStyles style, out DateTime result, out TimeSpan offset) { result = DateTime.MinValue; @@ -148,7 +148,7 @@ namespace System } - internal static bool TryParseExactMultiple(ReadOnlySpan s, String[] formats, + internal static bool TryParseExactMultiple(ReadOnlySpan s, string[] formats, DateTimeFormatInfo dtfi, DateTimeStyles style, out DateTime result) { result = DateTime.MinValue; @@ -162,7 +162,7 @@ namespace System return false; } - internal static bool TryParseExactMultiple(ReadOnlySpan s, String[] formats, + internal static bool TryParseExactMultiple(ReadOnlySpan s, string[] formats, DateTimeFormatInfo dtfi, DateTimeStyles style, ref DateTimeResult result) { if (formats == null) @@ -395,13 +395,13 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, }; // End NumEnd NumAmPm NumSpace NumDaySep NumTimesep MonthEnd MonthSpace MonthDSep NumDateSuff NumTimeSuff DayOfWeek YearSpace YearDateSep YearEnd TimeZone Era UTCMark - internal const String GMTName = "GMT"; - internal const String ZuluName = "Z"; + internal const string GMTName = "GMT"; + internal const string ZuluName = "Z"; // // Search from the index of str at str.Index to see if the target string exists in the str. // - private static bool MatchWord(ref __DTString str, String target) + private static bool MatchWord(ref __DTString str, string target) { if (target.Length > (str.Value.Length - str.Index)) { @@ -1247,7 +1247,7 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, // // Return 0 for YMD, 1 for MDY, 2 for DMY, otherwise -1. // - private static Boolean GetYearMonthDayOrder(String datePattern, DateTimeFormatInfo dtfi, out int order) + private static Boolean GetYearMonthDayOrder(string datePattern, DateTimeFormatInfo dtfi, out int order) { int yearOrder = -1; int monthOrder = -1; @@ -1345,7 +1345,7 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, // // Return 0 for YM, 1 for MY, otherwise -1. // - private static Boolean GetYearMonthOrder(String pattern, DateTimeFormatInfo dtfi, out int order) + private static Boolean GetYearMonthOrder(string pattern, DateTimeFormatInfo dtfi, out int order) { int yearOrder = -1; int monthOrder = -1; @@ -1411,7 +1411,7 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, // // Return 0 for MD, 1 for DM, otherwise -1. // - private static Boolean GetMonthDayOrder(String pattern, DateTimeFormatInfo dtfi, out int order) + private static Boolean GetMonthDayOrder(string pattern, DateTimeFormatInfo dtfi, out int order) { int monthOrder = -1; int dayOrder = -1; @@ -1859,7 +1859,7 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, int n1 = raw.GetNumber(0); int n2 = raw.GetNumber(1); - String pattern = dtfi.ShortDatePattern; + string pattern = dtfi.ShortDatePattern; // For compatibility, don't throw if we can't determine the order, but default to YMD instead int order; @@ -3315,7 +3315,7 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, int monthsInYear = (dtfi.GetMonthName(13).Length == 0 ? 12 : 13); for (int i = 1; i <= monthsInYear; i++) { - String searchStr = dtfi.GetAbbreviatedMonthName(i); + string searchStr = dtfi.GetAbbreviatedMonthName(i); int matchStrLen = searchStr.Length; if (dtfi.HasSpacesInMonthNames ? str.MatchSpecifiedWords(searchStr, false, ref matchStrLen) @@ -3373,7 +3373,7 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, int monthsInYear = (dtfi.GetMonthName(13).Length == 0 ? 12 : 13); for (int i = 1; i <= monthsInYear; i++) { - String searchStr = dtfi.GetMonthName(i); + string searchStr = dtfi.GetMonthName(i); int matchStrLen = searchStr.Length; if (dtfi.HasSpacesInMonthNames ? str.MatchSpecifiedWords(searchStr, false, ref matchStrLen) @@ -3438,7 +3438,7 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, { for (DayOfWeek i = DayOfWeek.Sunday; i <= DayOfWeek.Saturday; i++) { - String searchStr = dtfi.GetAbbreviatedDayName(i); + string searchStr = dtfi.GetAbbreviatedDayName(i); int matchStrLen = searchStr.Length; if (dtfi.HasSpacesInDayNames ? str.MatchSpecifiedWords(searchStr, false, ref matchStrLen) @@ -3477,7 +3477,7 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, { for (DayOfWeek i = DayOfWeek.Sunday; i <= DayOfWeek.Saturday; i++) { - String searchStr = dtfi.GetDayName(i); + string searchStr = dtfi.GetDayName(i); int matchStrLen = searchStr.Length; if (dtfi.HasSpacesInDayNames ? str.MatchSpecifiedWords(searchStr, false, ref matchStrLen) @@ -3517,7 +3517,7 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, { for (int i = 0; i < eras.Length; i++) { - String searchStr = dtfi.GetEraName(eras[i]); + string searchStr = dtfi.GetEraName(eras[i]); if (str.MatchSpecifiedWord(searchStr)) { str.Index += (searchStr.Length - 1); @@ -3560,7 +3560,7 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, if (str.GetNext()) { - String searchStr = dtfi.AMDesignator; + string searchStr = dtfi.AMDesignator; if (searchStr.Length > 0) { if (str.MatchSpecifiedWord(searchStr)) @@ -3774,7 +3774,7 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, // This method also set the dtfi according/parseInfo to some special pre-defined // formats. // - private static String ExpandPredefinedFormat(ReadOnlySpan format, ref DateTimeFormatInfo dtfi, ref ParsingInfo parseInfo, ref DateTimeResult result) + private static string ExpandPredefinedFormat(ReadOnlySpan format, ref DateTimeFormatInfo dtfi, ref ParsingInfo parseInfo, ref DateTimeResult result) { // // Check the format to see if we need to override the dtfi to be InvariantInfo, @@ -4201,7 +4201,7 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, // Some cultures uses space in the quoted string. E.g. Spanish has long date format as: // "dddd, dd' de 'MMMM' de 'yyyy". When inner spaces flag is set, we should skip whitespaces if there is space // in the quoted string. - String quotedStr = StringBuilderCache.GetStringAndRelease(enquotedString); + string quotedStr = StringBuilderCache.GetStringAndRelease(enquotedString); for (int i = 0; i < quotedStr.Length; i++) { @@ -4700,7 +4700,7 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, private static string Hex(string[] strs) { if (strs == null || strs.Length == 0) - return String.Empty; + return string.Empty; if (strs.Length == 1) return Hex(strs[0]); @@ -4713,7 +4713,7 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, StringBuilder buffer = new StringBuilder(); buffer.Append(Hex(strs[0])); curLineLength = buffer.Length; - String s; + string s; for (int i = 1; i < strs.Length - 1; i++) { @@ -4766,7 +4766,7 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, return buffer.ToString(); } // return an unicode escaped string form of char c - private static String Hex(char c) + private static string Hex(char c) { if (c <= '\x007f') return c.ToString(CultureInfo.InvariantCulture); @@ -5004,13 +5004,13 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, } [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal bool MatchSpecifiedWord(String target) => + internal bool MatchSpecifiedWord(string target) => Index + target.Length <= Length && m_info.Compare(Value.Slice(Index, target.Length), target, CompareOptions.IgnoreCase) == 0; private static readonly Char[] WhiteSpaceChecks = new Char[] { ' ', '\u00A0' }; - internal bool MatchSpecifiedWords(String target, bool checkWordBoundary, ref int matchLength) + internal bool MatchSpecifiedWords(string target, bool checkWordBoundary, ref int matchLength) { int valueRemaining = Value.Length - Index; matchLength = target.Length; @@ -5098,7 +5098,7 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, // If a match is found, true value is returned and Index is updated to the next character to be parsed. // Otherwise, Index is unchanged. // - internal bool Match(String str) + internal bool Match(string str) { if (++Index >= Length) { @@ -5147,12 +5147,12 @@ new DS[] { DS.ERROR, DS.TX_NNN, DS.TX_NNN, DS.TX_NNN, DS.ERROR, DS.ERROR, // maxMatchStrLen [in/out] the initailized maximum length. This parameter can be used to // find the longest match in two string arrays. // - internal int MatchLongestWords(String[] words, ref int maxMatchStrLen) + internal int MatchLongestWords(string[] words, ref int maxMatchStrLen) { int result = -1; for (int i = 0; i < words.Length; i++) { - String word = words[i]; + string word = words[i]; int matchLength = word.Length; if (MatchSpecifiedWords(word, false, ref matchLength)) { diff --git a/src/System.Private.CoreLib/shared/System/Globalization/EastAsianLunisolarCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/EastAsianLunisolarCalendar.cs index 358f4df..a29f8a1 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/EastAsianLunisolarCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/EastAsianLunisolarCalendar.cs @@ -162,7 +162,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( "time", - String.Format(CultureInfo.InvariantCulture, SR.ArgumentOutOfRange_CalendarRange, + string.Format(CultureInfo.InvariantCulture, SR.ArgumentOutOfRange_CalendarRange, MinSupportedDateTime, MaxSupportedDateTime)); } } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs index 94963a1..a018216 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs @@ -206,7 +206,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(months), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, -120000, @@ -317,7 +317,7 @@ namespace System.Globalization } throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, @@ -364,7 +364,7 @@ namespace System.Globalization } throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, @@ -451,7 +451,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, MaxYear)); } @@ -473,7 +473,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, MaxYear)); } @@ -501,7 +501,7 @@ namespace System.Globalization throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, MaxYear)); } @@ -551,7 +551,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( "year", - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 99, @@ -574,7 +574,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, MaxYear)); } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendarHelper.cs b/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendarHelper.cs index 2842bd3..26bb700 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendarHelper.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendarHelper.cs @@ -19,9 +19,9 @@ namespace System.Globalization // be affected by the DateTime.MinValue; internal int maxEraYear; // Max year value in this era. (== the year length of the era + 1) - internal String eraName; // The era name - internal String abbrevEraName; // Abbreviated Era Name - internal String englishEraName; // English era name + internal string eraName; // The era name + internal string abbrevEraName; // Abbreviated Era Name + internal string englishEraName; // English era name internal EraInfo(int era, int startYear, int startMonth, int startDay, int yearOffset, int minEraYear, int maxEraYear) { @@ -33,7 +33,7 @@ namespace System.Globalization } internal EraInfo(int era, int startYear, int startMonth, int startDay, int yearOffset, int minEraYear, int maxEraYear, - String eraName, String abbrevEraName, String englishEraName) + string eraName, string abbrevEraName, string englishEraName) { this.era = era; this.yearOffset = yearOffset; @@ -154,7 +154,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, m_EraInfo[i].minEraYear, @@ -297,7 +297,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(millisecond), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 0, @@ -315,7 +315,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( "time", - String.Format( + string.Format( CultureInfo.InvariantCulture, SR.ArgumentOutOfRange_CalendarRange, m_Cal.MinSupportedDateTime, @@ -346,7 +346,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(months), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, -120000, @@ -544,7 +544,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(day), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, @@ -583,7 +583,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(month), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, @@ -638,7 +638,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, m_minYear, m_maxYear)); } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/HebrewCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/HebrewCalendar.cs index 533d383..5174992 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/HebrewCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/HebrewCalendar.cs @@ -344,14 +344,14 @@ namespace System.Globalization ** We use a table for the Hebrew calendar calculation, so the year supported is limited. ============================================================================*/ - private static void CheckHebrewYearValue(int y, int era, String varName) + private static void CheckHebrewYearValue(int y, int era, string varName) { CheckEraRange(era); if (y > MaxHebrewYear || y < MinHebrewYear) { throw new ArgumentOutOfRangeException( varName, - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, MinHebrewYear, @@ -376,7 +376,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(month), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, @@ -402,7 +402,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(day), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, @@ -425,7 +425,7 @@ namespace System.Globalization throw new ArgumentOutOfRangeException( "time", // Print out the date in Gregorian using InvariantCulture since the DateTime is based on GreograinCalendar. - String.Format( + string.Format( CultureInfo.InvariantCulture, SR.ArgumentOutOfRange_CalendarRange, calendarMinValue, @@ -708,7 +708,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(months), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_AddValue)); } @@ -1104,7 +1104,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, MinHebrewYear, diff --git a/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.Win32.cs b/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.Win32.cs index 64a73fb..657163f 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.Win32.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.Win32.cs @@ -18,8 +18,8 @@ namespace System.Globalization return (_hijriAdvance); } - private const String InternationalRegKey = "Control Panel\\International"; - private const String HijriAdvanceRegKeyEntry = "AddHijriDate"; + private const string InternationalRegKey = "Control Panel\\International"; + private const string HijriAdvanceRegKeyEntry = "AddHijriDate"; /*=================================GetAdvanceHijriDate========================== **Action: Gets the AddHijriDate value from the registry. @@ -60,8 +60,8 @@ namespace System.Globalization { return (0); } - String str = value.ToString(); - if (String.Compare(str, 0, HijriAdvanceRegKeyEntry, 0, HijriAdvanceRegKeyEntry.Length, StringComparison.OrdinalIgnoreCase) == 0) + string str = value.ToString(); + if (string.Compare(str, 0, HijriAdvanceRegKeyEntry, 0, HijriAdvanceRegKeyEntry.Length, StringComparison.OrdinalIgnoreCase) == 0) { if (str.Length == HijriAdvanceRegKeyEntry.Length) hijriAdvance = -1; diff --git a/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.cs index 6755844..d6f2bc9 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.cs @@ -191,7 +191,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( "HijriAdjustment", - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Bounds_Lower_Upper, MinAdvancedHijri, @@ -209,7 +209,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( "time", - String.Format( + string.Format( CultureInfo.InvariantCulture, SR.ArgumentOutOfRange_CalendarRange, calendarMinValue, @@ -232,7 +232,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, @@ -249,7 +249,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(month), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, @@ -387,7 +387,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(months), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, -120000, @@ -541,7 +541,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(day), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Day, daysInMonth, @@ -591,7 +591,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(day), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Day, daysInMonth, @@ -631,7 +631,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(value), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 99, @@ -659,7 +659,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, diff --git a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs index 50195d7..fdf2dc6 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.cs @@ -303,7 +303,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, @@ -325,10 +325,10 @@ namespace System.Globalization // Return the various era strings // Note: The arrays are backwards of the eras // - internal static String[] EraNames() + internal static string[] EraNames() { EraInfo[] eras = GetEraInfo(); - String[] eraNames = new String[eras.Length]; + string[] eraNames = new string[eras.Length]; for (int i = 0; i < eras.Length; i++) { @@ -339,10 +339,10 @@ namespace System.Globalization return eraNames; } - internal static String[] AbbrevEraNames() + internal static string[] AbbrevEraNames() { EraInfo[] eras = GetEraInfo(); - String[] erasAbbrev = new String[eras.Length]; + string[] erasAbbrev = new string[eras.Length]; for (int i = 0; i < eras.Length; i++) { @@ -353,10 +353,10 @@ namespace System.Globalization return erasAbbrev; } - internal static String[] EnglishEraNames() + internal static string[] EnglishEraNames() { EraInfo[] eras = GetEraInfo(); - String[] erasEnglish = new String[eras.Length]; + string[] erasEnglish = new string[eras.Length]; for (int i = 0; i < eras.Length; i++) { @@ -392,7 +392,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( "year", - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 99, diff --git a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseLunisolarCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseLunisolarCalendar.cs index e8a2dcd..58da0af 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseLunisolarCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseLunisolarCalendar.cs @@ -204,7 +204,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( "year", - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, MIN_LUNISOLAR_YEAR, diff --git a/src/System.Private.CoreLib/shared/System/Globalization/JulianCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/JulianCalendar.cs index 82e4d58..a1ffbeb 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/JulianCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/JulianCalendar.cs @@ -98,7 +98,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, @@ -142,7 +142,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(day), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, @@ -214,7 +214,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(months), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, -120000, @@ -372,7 +372,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(millisecond), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 0, @@ -404,7 +404,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( "year", - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 99, @@ -427,7 +427,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Bounds_Lower_Upper, 1, diff --git a/src/System.Private.CoreLib/shared/System/Globalization/KoreanCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/KoreanCalendar.cs index 9168b66..3f265f6 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/KoreanCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/KoreanCalendar.cs @@ -237,7 +237,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( "year", - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 99, diff --git a/src/System.Private.CoreLib/shared/System/Globalization/NumberFormatInfo.cs b/src/System.Private.CoreLib/shared/System/Globalization/NumberFormatInfo.cs index a98023d..33d50b3 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/NumberFormatInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/NumberFormatInfo.cs @@ -52,23 +52,23 @@ namespace System.Globalization internal int[] numberGroupSizes = new int[] { 3 }; internal int[] currencyGroupSizes = new int[] { 3 }; internal int[] percentGroupSizes = new int[] { 3 }; - internal String positiveSign = "+"; - internal String negativeSign = "-"; - internal String numberDecimalSeparator = "."; - internal String numberGroupSeparator = ","; - internal String currencyGroupSeparator = ","; - internal String currencyDecimalSeparator = "."; - internal String currencySymbol = "\x00a4"; // U+00a4 is the symbol for International Monetary Fund. - internal String nanSymbol = "NaN"; - internal String positiveInfinitySymbol = "Infinity"; - internal String negativeInfinitySymbol = "-Infinity"; - internal String percentDecimalSeparator = "."; - internal String percentGroupSeparator = ","; - internal String percentSymbol = "%"; - internal String perMilleSymbol = "\u2030"; - - - internal String[] nativeDigits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; + internal string positiveSign = "+"; + internal string negativeSign = "-"; + internal string numberDecimalSeparator = "."; + internal string numberGroupSeparator = ","; + internal string currencyGroupSeparator = ","; + internal string currencyDecimalSeparator = "."; + internal string currencySymbol = "\x00a4"; // U+00a4 is the symbol for International Monetary Fund. + internal string nanSymbol = "NaN"; + internal string positiveInfinitySymbol = "Infinity"; + internal string negativeInfinitySymbol = "-Infinity"; + internal string percentDecimalSeparator = "."; + internal string percentGroupSeparator = ","; + internal string percentSymbol = "%"; + internal string perMilleSymbol = "\u2030"; + + + internal string[] nativeDigits = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; internal int numberDecimalDigits = 2; internal int currencyDecimalDigits = 2; @@ -90,7 +90,7 @@ namespace System.Globalization { } - private static void VerifyDecimalSeparator(String decSep, String propertyName) + private static void VerifyDecimalSeparator(string decSep, string propertyName) { if (decSep == null) { @@ -104,7 +104,7 @@ namespace System.Globalization } } - private static void VerifyGroupSeparator(String groupSep, String propertyName) + private static void VerifyGroupSeparator(string groupSep, string propertyName) { if (groupSep == null) { @@ -254,7 +254,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(CurrencyDecimalDigits), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 0, @@ -266,7 +266,7 @@ namespace System.Globalization } - public String CurrencyDecimalSeparator + public string CurrencyDecimalSeparator { get { return currencyDecimalSeparator; } set @@ -292,7 +292,7 @@ namespace System.Globalization // Every element in the groupSize array should be between 1 and 9 // excpet the last element could be zero. // - internal static void CheckGroupSize(String propName, int[] groupSize) + internal static void CheckGroupSize(string propName, int[] groupSize) { for (int i = 0; i < groupSize.Length; i++) { @@ -376,7 +376,7 @@ namespace System.Globalization } - public String CurrencyGroupSeparator + public string CurrencyGroupSeparator { get { return currencyGroupSeparator; } set @@ -388,7 +388,7 @@ namespace System.Globalization } - public String CurrencySymbol + public string CurrencySymbol { get { return currencySymbol; } set @@ -424,7 +424,7 @@ namespace System.Globalization } - public String NaNSymbol + public string NaNSymbol { get { @@ -453,7 +453,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(CurrencyNegativePattern), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 0, @@ -477,7 +477,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(NumberNegativePattern), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 0, @@ -501,7 +501,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(PercentPositivePattern), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 0, @@ -525,7 +525,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(PercentNegativePattern), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 0, @@ -537,7 +537,7 @@ namespace System.Globalization } - public String NegativeInfinitySymbol + public string NegativeInfinitySymbol { get { @@ -556,7 +556,7 @@ namespace System.Globalization } - public String NegativeSign + public string NegativeSign { get { return negativeSign; } set @@ -581,7 +581,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(NumberDecimalDigits), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 0, @@ -593,7 +593,7 @@ namespace System.Globalization } - public String NumberDecimalSeparator + public string NumberDecimalSeparator { get { return numberDecimalSeparator; } set @@ -605,7 +605,7 @@ namespace System.Globalization } - public String NumberGroupSeparator + public string NumberGroupSeparator { get { return numberGroupSeparator; } set @@ -626,7 +626,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(CurrencyPositivePattern), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 0, @@ -638,7 +638,7 @@ namespace System.Globalization } - public String PositiveInfinitySymbol + public string PositiveInfinitySymbol { get { @@ -657,7 +657,7 @@ namespace System.Globalization } - public String PositiveSign + public string PositiveSign { get { return positiveSign; } set @@ -682,7 +682,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(PercentDecimalDigits), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 0, @@ -694,7 +694,7 @@ namespace System.Globalization } - public String PercentDecimalSeparator + public string PercentDecimalSeparator { get { return percentDecimalSeparator; } set @@ -706,7 +706,7 @@ namespace System.Globalization } - public String PercentGroupSeparator + public string PercentGroupSeparator { get { return percentGroupSeparator; } set @@ -718,7 +718,7 @@ namespace System.Globalization } - public String PercentSymbol + public string PercentSymbol { get { @@ -737,7 +737,7 @@ namespace System.Globalization } - public String PerMilleSymbol + public string PerMilleSymbol { get { return perMilleSymbol; } set @@ -754,7 +754,7 @@ namespace System.Globalization public string[] NativeDigits { - get { return (String[])nativeDigits.Clone(); } + get { return (string[])nativeDigits.Clone(); } set { VerifyWritable(); diff --git a/src/System.Private.CoreLib/shared/System/Globalization/PersianCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/PersianCalendar.cs index 10912f8..a6f964d 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/PersianCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/PersianCalendar.cs @@ -117,7 +117,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( "time", - String.Format( + string.Format( CultureInfo.InvariantCulture, SR.ArgumentOutOfRange_CalendarRange, minDate, @@ -140,7 +140,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, @@ -157,7 +157,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(month), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, @@ -282,7 +282,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(months), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, -120000, @@ -462,7 +462,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(day), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Day, daysInMonth, @@ -521,7 +521,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(day), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Day, daysInMonth, @@ -560,7 +560,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(value), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 99, @@ -589,7 +589,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, diff --git a/src/System.Private.CoreLib/shared/System/Globalization/RegionInfo.cs b/src/System.Private.CoreLib/shared/System/Globalization/RegionInfo.cs index 2cad7bb..b9daea3 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/RegionInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/RegionInfo.cs @@ -31,7 +31,7 @@ namespace System.Globalization // // Name of this region (ie: es-US): serialized, the field used for deserialization // - internal String _name; + internal string _name; // // The CultureData instance that we are going to read data from. @@ -54,7 +54,7 @@ namespace System.Globalization // In Silverlight we enforce that RegionInfos must be created with a full culture name // //////////////////////////////////////////////////////////////////////// - public RegionInfo(String name) + public RegionInfo(string name) { if (name == null) throw new ArgumentNullException(nameof(name)); @@ -71,7 +71,7 @@ namespace System.Globalization _cultureData = CultureData.GetCultureDataForRegion(name, true); if (_cultureData == null) throw new ArgumentException( - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.Argument_InvalidCultureName, name), nameof(name)); @@ -157,7 +157,7 @@ namespace System.Globalization // Returns the name of the region (ie: en-US) // //////////////////////////////////////////////////////////////////////// - public virtual String Name + public virtual string Name { get { @@ -173,7 +173,7 @@ namespace System.Globalization // Returns the name of the region in English. (ie: United States) // //////////////////////////////////////////////////////////////////////// - public virtual String EnglishName + public virtual string EnglishName { get { @@ -190,7 +190,7 @@ namespace System.Globalization // if the current UI language is en-US) // //////////////////////////////////////////////////////////////////////// - public virtual String DisplayName + public virtual string DisplayName { get { @@ -207,7 +207,7 @@ namespace System.Globalization // WARNING: You need a full locale name for this to make sense. // //////////////////////////////////////////////////////////////////////// - public virtual String NativeName + public virtual string NativeName { get { @@ -222,7 +222,7 @@ namespace System.Globalization // Returns the two letter ISO region name (ie: US) // //////////////////////////////////////////////////////////////////////// - public virtual String TwoLetterISORegionName + public virtual string TwoLetterISORegionName { get { @@ -237,7 +237,7 @@ namespace System.Globalization // Returns the three letter ISO region name (ie: USA) // //////////////////////////////////////////////////////////////////////// - public virtual String ThreeLetterISORegionName + public virtual string ThreeLetterISORegionName { get { @@ -252,7 +252,7 @@ namespace System.Globalization // Returns the three letter windows region name (ie: USA) // //////////////////////////////////////////////////////////////////////// - public virtual String ThreeLetterWindowsRegionName + public virtual string ThreeLetterWindowsRegionName { get { @@ -324,7 +324,7 @@ namespace System.Globalization // Currency Symbol for this locale, ie: Fr. or $ // //////////////////////////////////////////////////////////////////////// - public virtual String CurrencySymbol + public virtual string CurrencySymbol { get { @@ -339,7 +339,7 @@ namespace System.Globalization // ISO Currency Symbol for this locale, ie: CHF // //////////////////////////////////////////////////////////////////////// - public virtual String ISOCurrencySymbol + public virtual string ISOCurrencySymbol { get { @@ -391,7 +391,7 @@ namespace System.Globalization // Implements Object.ToString(). Returns the name of the Region, ie: es-US // //////////////////////////////////////////////////////////////////////// - public override String ToString() + public override string ToString() { return (Name); } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/StringInfo.cs b/src/System.Private.CoreLib/shared/System/Globalization/StringInfo.cs index aa62b2c..5b5cd93 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/StringInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/StringInfo.cs @@ -266,7 +266,7 @@ namespace System.Globalization { if (index == len) { - return (String.Empty); + return (string.Empty); } throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_Index); } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs index c516113..e2455cd 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/TaiwanCalendar.cs @@ -243,7 +243,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( "year", - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 99, @@ -268,7 +268,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 1, diff --git a/src/System.Private.CoreLib/shared/System/Globalization/TaiwanLunisolarCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/TaiwanLunisolarCalendar.cs index 60e84f7..451fc30 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/TaiwanLunisolarCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/TaiwanLunisolarCalendar.cs @@ -263,7 +263,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( "year", - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, MIN_LUNISOLAR_YEAR, diff --git a/src/System.Private.CoreLib/shared/System/Globalization/ThaiBuddhistCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/ThaiBuddhistCalendar.cs index 4f8fd8f..1175185 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/ThaiBuddhistCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/ThaiBuddhistCalendar.cs @@ -206,7 +206,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( "year", - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, 99, diff --git a/src/System.Private.CoreLib/shared/System/Globalization/TimeSpanParse.cs b/src/System.Private.CoreLib/shared/System/Globalization/TimeSpanParse.cs index b1e1045..3f642e8 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/TimeSpanParse.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/TimeSpanParse.cs @@ -90,11 +90,11 @@ namespace System.Globalization internal int _zeroes; // Store the number of leading zeroes (if any) internal ReadOnlySpan _sep; // Store the literal that we are parsing (if any) - public TimeSpanToken(TTT type) : this(type, 0, 0, default(ReadOnlySpan)) { } + public TimeSpanToken(TTT type) : this(type, 0, 0, default) { } - public TimeSpanToken(int number) : this(TTT.Num, number, 0, default(ReadOnlySpan)) { } + public TimeSpanToken(int number) : this(TTT.Num, number, 0, default) { } - public TimeSpanToken(int number, int leadingZeroes) : this(TTT.Num, number, leadingZeroes, default(ReadOnlySpan)) { } + public TimeSpanToken(int number, int leadingZeroes) : this(TTT.Num, number, leadingZeroes, default) { } public TimeSpanToken(TTT type, int number, int leadingZeroes, ReadOnlySpan separator) { @@ -160,7 +160,7 @@ namespace System.Globalization int digit; if (++_pos >= _value.Length || (uint)(digit = _value[_pos] - '0') > 9) { - return new TimeSpanToken(TTT.Num, 0, zeroes, default(ReadOnlySpan)); + return new TimeSpanToken(TTT.Num, 0, zeroes, default); } if (digit == 0) @@ -190,7 +190,7 @@ namespace System.Globalization } } - return new TimeSpanToken(TTT.Num, num, zeroes, default(ReadOnlySpan)); + return new TimeSpanToken(TTT.Num, num, zeroes, default); } // Otherwise, we're processing a separator, and we've already processed the first @@ -382,7 +382,7 @@ namespace System.Globalization switch (tok._ttt) { case TTT.Num: - if ((_tokenCount == 0 && !AddSep(default(ReadOnlySpan), ref result)) || !AddNum(tok, ref result)) + if ((_tokenCount == 0 && !AddSep(default, ref result)) || !AddNum(tok, ref result)) { return false; } @@ -458,7 +458,7 @@ namespace System.Globalization internal TimeSpanResult(bool throwOnFailure, ReadOnlySpan originalTimeSpanString) { - parsedTimeSpan = default(TimeSpan); + parsedTimeSpan = default; _throwOnFailure = throwOnFailure; _originalTimeSpanString = originalTimeSpanString; } @@ -622,7 +622,7 @@ namespace System.Globalization return true; } - result = default(TimeSpan); + result = default; return false; } @@ -644,7 +644,7 @@ namespace System.Globalization return true; } - result = default(TimeSpan); + result = default; return false; } @@ -666,7 +666,7 @@ namespace System.Globalization return true; } - result = default(TimeSpan); + result = default; return false; } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/UmAlQuraCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/UmAlQuraCalendar.cs index 21a938f..777af18 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/UmAlQuraCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/UmAlQuraCalendar.cs @@ -355,7 +355,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( "time", - String.Format( + string.Format( CultureInfo.InvariantCulture, SR.ArgumentOutOfRange_CalendarRange, minDate, @@ -378,7 +378,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, MinCalendarYear, @@ -510,7 +510,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(months), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, -120000, @@ -710,7 +710,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(day), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Day, daysInMonth, @@ -774,7 +774,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(day), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Day, daysInMonth, @@ -814,7 +814,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(value), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, MinCalendarYear, @@ -845,7 +845,7 @@ namespace System.Globalization { throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, MinCalendarYear, diff --git a/src/System.Private.CoreLib/shared/System/Guid.cs b/src/System.Private.CoreLib/shared/System/Guid.cs index 37a8dce..01c0e88 100644 --- a/src/System.Private.CoreLib/shared/System/Guid.cs +++ b/src/System.Private.CoreLib/shared/System/Guid.cs @@ -279,7 +279,7 @@ namespace System { if (input == null) { - result = default(Guid); + result = default; return false; } @@ -297,7 +297,7 @@ namespace System } else { - result = default(Guid); + result = default; return false; } } @@ -358,7 +358,7 @@ namespace System { if (input == null) { - result = default(Guid); + result = default; return false; } @@ -369,7 +369,7 @@ namespace System { if (format.Length != 1) { - result = default(Guid); + result = default; return false; } @@ -398,7 +398,7 @@ namespace System break; default: // invalid guid format specification - result = default(Guid); + result = default; return false; } @@ -411,7 +411,7 @@ namespace System } else { - result = default(Guid); + result = default; return false; } } diff --git a/src/System.Private.CoreLib/shared/System/IO/FileStream.Windows.cs b/src/System.Private.CoreLib/shared/System/IO/FileStream.Windows.cs index 80c07df..7ca6a8f 100644 --- a/src/System.Private.CoreLib/shared/System/IO/FileStream.Windows.cs +++ b/src/System.Private.CoreLib/shared/System/IO/FileStream.Windows.cs @@ -868,7 +868,7 @@ namespace System.IO } else { - destination = default(Memory); + destination = default; } } diff --git a/src/System.Private.CoreLib/shared/System/IO/FileStream.cs b/src/System.Private.CoreLib/shared/System/IO/FileStream.cs index a6ad63c..97740f3 100644 --- a/src/System.Private.CoreLib/shared/System/IO/FileStream.cs +++ b/src/System.Private.CoreLib/shared/System/IO/FileStream.cs @@ -355,7 +355,7 @@ namespace System.IO return ReadAsyncTask(buffer, offset, count, cancellationToken); } - public override ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default(CancellationToken)) + public override ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default) { if (!_useAsyncIO || GetType() != typeof(FileStream)) { @@ -461,7 +461,7 @@ namespace System.IO return WriteAsyncInternal(new ReadOnlyMemory(buffer, offset, count), cancellationToken).AsTask(); } - public override ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default(CancellationToken)) + public override ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default) { if (!_useAsyncIO || GetType() != typeof(FileStream)) { diff --git a/src/System.Private.CoreLib/shared/System/IO/MemoryStream.cs b/src/System.Private.CoreLib/shared/System/IO/MemoryStream.cs index fb319de..173917f6 100644 --- a/src/System.Private.CoreLib/shared/System/IO/MemoryStream.cs +++ b/src/System.Private.CoreLib/shared/System/IO/MemoryStream.cs @@ -208,7 +208,7 @@ namespace System.IO { if (!_exposable) { - buffer = default(ArraySegment); + buffer = default; return false; } @@ -426,7 +426,7 @@ namespace System.IO } } - public override ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default(CancellationToken)) + public override ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default) { if (cancellationToken.IsCancellationRequested) { @@ -752,7 +752,7 @@ namespace System.IO } } - public override ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default(CancellationToken)) + public override ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default) { if (cancellationToken.IsCancellationRequested) { diff --git a/src/System.Private.CoreLib/shared/System/IO/TextReader.cs b/src/System.Private.CoreLib/shared/System/IO/TextReader.cs index eb94dd7..98e1e64 100644 --- a/src/System.Private.CoreLib/shared/System/IO/TextReader.cs +++ b/src/System.Private.CoreLib/shared/System/IO/TextReader.cs @@ -251,7 +251,7 @@ namespace System.IO return ReadAsyncInternal(new Memory(buffer, index, count), default).AsTask(); } - public virtual ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default(CancellationToken)) => + public virtual ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default) => new ValueTask(MemoryMarshal.TryGetArray(buffer, out ArraySegment array) ? ReadAsync(array.Array, array.Offset, array.Count) : Task.Factory.StartNew(state => @@ -289,7 +289,7 @@ namespace System.IO return ReadBlockAsyncInternal(new Memory(buffer, index, count), default).AsTask(); } - public virtual ValueTask ReadBlockAsync(Memory buffer, CancellationToken cancellationToken = default(CancellationToken)) => + public virtual ValueTask ReadBlockAsync(Memory buffer, CancellationToken cancellationToken = default) => new ValueTask(MemoryMarshal.TryGetArray(buffer, out ArraySegment array) ? ReadBlockAsync(array.Array, array.Offset, array.Count) : Task.Factory.StartNew(state => diff --git a/src/System.Private.CoreLib/shared/System/IO/TextWriter.cs b/src/System.Private.CoreLib/shared/System/IO/TextWriter.cs index 48e702b..2afe907 100644 --- a/src/System.Private.CoreLib/shared/System/IO/TextWriter.cs +++ b/src/System.Private.CoreLib/shared/System/IO/TextWriter.cs @@ -548,7 +548,7 @@ namespace System.IO tuple, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default); } - public virtual Task WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default(CancellationToken)) => + public virtual Task WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default) => MemoryMarshal.TryGetArray(buffer, out ArraySegment array) ? WriteAsync(array.Array, array.Offset, array.Count) : Task.Factory.StartNew(state => @@ -600,7 +600,7 @@ namespace System.IO tuple, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default); } - public virtual Task WriteLineAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default(CancellationToken)) => + public virtual Task WriteLineAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default) => MemoryMarshal.TryGetArray(buffer, out ArraySegment array) ? WriteLineAsync(array.Array, array.Offset, array.Count) : Task.Factory.StartNew(state => diff --git a/src/System.Private.CoreLib/shared/System/IO/UnmanagedMemoryStream.cs b/src/System.Private.CoreLib/shared/System/IO/UnmanagedMemoryStream.cs index 2bcb16f..70770e4 100644 --- a/src/System.Private.CoreLib/shared/System/IO/UnmanagedMemoryStream.cs +++ b/src/System.Private.CoreLib/shared/System/IO/UnmanagedMemoryStream.cs @@ -488,7 +488,7 @@ namespace System.IO /// /// Buffer to read the bytes to. /// Token that can be used to cancel this operation. - public override ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default(CancellationToken)) + public override ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default) { if (cancellationToken.IsCancellationRequested) { @@ -783,7 +783,7 @@ namespace System.IO /// /// Buffer that will be written. /// Token that can be used to cancel the operation. - public override ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default(CancellationToken)) + public override ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default) { if (cancellationToken.IsCancellationRequested) { diff --git a/src/System.Private.CoreLib/shared/System/IO/UnmanagedMemoryStreamWrapper.cs b/src/System.Private.CoreLib/shared/System/IO/UnmanagedMemoryStreamWrapper.cs index 65a3396..104f559 100644 --- a/src/System.Private.CoreLib/shared/System/IO/UnmanagedMemoryStreamWrapper.cs +++ b/src/System.Private.CoreLib/shared/System/IO/UnmanagedMemoryStreamWrapper.cs @@ -71,7 +71,7 @@ namespace System.IO public override bool TryGetBuffer(out ArraySegment buffer) { - buffer = default(ArraySegment); + buffer = default; return false; } @@ -206,7 +206,7 @@ namespace System.IO return _unmanagedStream.ReadAsync(buffer, offset, count, cancellationToken); } - public override ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default(CancellationToken)) + public override ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default) { return _unmanagedStream.ReadAsync(buffer, cancellationToken); } @@ -217,7 +217,7 @@ namespace System.IO return _unmanagedStream.WriteAsync(buffer, offset, count, cancellationToken); } - public override ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default(CancellationToken)) + public override ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default) { return _unmanagedStream.WriteAsync(buffer, cancellationToken); } diff --git a/src/System.Private.CoreLib/shared/System/Lazy.cs b/src/System.Private.CoreLib/shared/System/Lazy.cs index 6410c2e..02122ca 100644 --- a/src/System.Private.CoreLib/shared/System/Lazy.cs +++ b/src/System.Private.CoreLib/shared/System/Lazy.cs @@ -119,7 +119,7 @@ namespace System default: Debug.Fail("Invalid logic; State should always have a valid value"); - return default(LazyThreadSafetyMode); + return default; } } @@ -454,7 +454,7 @@ namespace System { if (!IsValueCreated) { - return default(T); + return default; } return _value; } diff --git a/src/System.Private.CoreLib/shared/System/MemoryDebugView.cs b/src/System.Private.CoreLib/shared/System/MemoryDebugView.cs index f56a67c..6ab6e50 100644 --- a/src/System.Private.CoreLib/shared/System/MemoryDebugView.cs +++ b/src/System.Private.CoreLib/shared/System/MemoryDebugView.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Diagnostics; -using System.Runtime.InteropServices; namespace System { diff --git a/src/System.Private.CoreLib/shared/System/MemoryExtensions.cs b/src/System.Private.CoreLib/shared/System/MemoryExtensions.cs index b4782dc..639bf06 100644 --- a/src/System.Private.CoreLib/shared/System/MemoryExtensions.cs +++ b/src/System.Private.CoreLib/shared/System/MemoryExtensions.cs @@ -1360,6 +1360,7 @@ namespace System { if (typeof(T) == typeof(byte) || typeof(T) == typeof(sbyte)) { + // The cast to nuint is not redundant on netstandard. Do not remove it. size = (nuint)sizeof(byte); return true; } diff --git a/src/System.Private.CoreLib/shared/System/ObjectDisposedException.cs b/src/System.Private.CoreLib/shared/System/ObjectDisposedException.cs index 3daed13..8f13055 100644 --- a/src/System.Private.CoreLib/shared/System/ObjectDisposedException.cs +++ b/src/System.Private.CoreLib/shared/System/ObjectDisposedException.cs @@ -15,7 +15,7 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class ObjectDisposedException : InvalidOperationException { - private String _objectName; + private string _objectName; // This constructor should only be called by the EE (COMPlusThrow) private ObjectDisposedException() : @@ -23,18 +23,18 @@ namespace System { } - public ObjectDisposedException(String objectName) : + public ObjectDisposedException(string objectName) : this(objectName, SR.ObjectDisposed_Generic) { } - public ObjectDisposedException(String objectName, String message) : base(message) + public ObjectDisposedException(string objectName, string message) : base(message) { HResult = HResults.COR_E_OBJECTDISPOSED; _objectName = objectName; } - public ObjectDisposedException(String message, Exception innerException) + public ObjectDisposedException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_OBJECTDISPOSED; @@ -55,26 +55,26 @@ namespace System /// /// Gets the text for the message for this exception. /// - public override String Message + public override string Message { get { - String name = ObjectName; + string name = ObjectName; if (name == null || name.Length == 0) return base.Message; - String objectDisposed = SR.Format(SR.ObjectDisposed_ObjectName_Name, name); + string objectDisposed = SR.Format(SR.ObjectDisposed_ObjectName_Name, name); return base.Message + Environment.NewLine + objectDisposed; } } - public String ObjectName + public string ObjectName { get { if (_objectName == null) { - return String.Empty; + return string.Empty; } return _objectName; } diff --git a/src/System.Private.CoreLib/shared/System/ReadOnlySpan.Fast.cs b/src/System.Private.CoreLib/shared/System/ReadOnlySpan.Fast.cs index 38d62dc..0ba2097 100644 --- a/src/System.Private.CoreLib/shared/System/ReadOnlySpan.Fast.cs +++ b/src/System.Private.CoreLib/shared/System/ReadOnlySpan.Fast.cs @@ -2,10 +2,11 @@ // 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.ComponentModel; using System.Diagnostics; using System.Runtime.CompilerServices; using System.Runtime.Versioning; +using EditorBrowsableAttribute = System.ComponentModel.EditorBrowsableAttribute; +using EditorBrowsableState = System.ComponentModel.EditorBrowsableState; using Internal.Runtime.CompilerServices; #pragma warning disable 0809 //warning CS0809: Obsolete member 'Span.Equals(object)' overrides non-obsolete member 'object.Equals(object)' @@ -211,7 +212,7 @@ namespace System /// /// For , returns a new instance of string that represents the characters pointed to by the span. - /// Otherwise, returns a with the name of the type and the number of elements. + /// Otherwise, returns a with the name of the type and the number of elements. /// public override string ToString() { diff --git a/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs b/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs index 14b33e2..52a160d 100644 --- a/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs +++ b/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs @@ -94,7 +94,7 @@ namespace System /// /// Returns a 0-length read-only span whose base is the null pointer. /// - public static ReadOnlySpan Empty => default(ReadOnlySpan); + public static ReadOnlySpan Empty => default; /// Gets an enumerator for this span. public Enumerator GetEnumerator() => new Enumerator(this); diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/YieldAwaitable.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/YieldAwaitable.cs index 8aed0fc..68fd5ab 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/YieldAwaitable.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/YieldAwaitable.cs @@ -113,7 +113,7 @@ namespace System.Runtime.CompilerServices // We're targeting a custom scheduler, so queue a task. else { - Task.Factory.StartNew(continuation, default(CancellationToken), TaskCreationOptions.PreferFairness, scheduler); + Task.Factory.StartNew(continuation, default, TaskCreationOptions.PreferFairness, scheduler); } } } diff --git a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/ExternalException.cs b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/ExternalException.cs index 160fe30..ab5a84c 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/ExternalException.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/ExternalException.cs @@ -68,7 +68,7 @@ namespace System.Runtime.InteropServices string s = className + " (0x" + HResult.ToString("X8", CultureInfo.InvariantCulture) + ")"; - if (!(String.IsNullOrEmpty(message))) + if (!(string.IsNullOrEmpty(message))) { s = s + ": " + message; } diff --git a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.Fast.cs b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.Fast.cs index 80ae450..e212f7d 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.Fast.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.Fast.cs @@ -2,9 +2,7 @@ // 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.Buffers; using System.Runtime.CompilerServices; -using System.Collections.Generic; using Internal.Runtime.CompilerServices; namespace System.Runtime.InteropServices diff --git a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.cs b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.cs index 8eec0fd..77f4975 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.cs @@ -69,7 +69,7 @@ namespace System.Runtime.InteropServices { TManager localManager; // Use register for null comparison rather than byref manager = localManager = memory.GetObjectStartLength(out _, out _) as TManager; - return !ReferenceEquals(manager, null); + return manager != null; } /// @@ -92,7 +92,7 @@ namespace System.Runtime.InteropServices Debug.Assert(length >= 0); - if (ReferenceEquals(manager, null)) + if (manager == null) { start = default; length = default; diff --git a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SafeBuffer.cs b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SafeBuffer.cs index 455e413..5b72b01 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SafeBuffer.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SafeBuffer.cs @@ -198,7 +198,7 @@ namespace System.Runtime.InteropServices SpaceCheck(ptr, sizeofT); // return *(T*) (_ptr + byteOffset); - T value = default(T); + T value = default; bool mustCallRelease = false; try { diff --git a/src/System.Private.CoreLib/shared/System/Span.Fast.cs b/src/System.Private.CoreLib/shared/System/Span.Fast.cs index 131694b..c04d60a 100644 --- a/src/System.Private.CoreLib/shared/System/Span.Fast.cs +++ b/src/System.Private.CoreLib/shared/System/Span.Fast.cs @@ -2,10 +2,11 @@ // 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.ComponentModel; using System.Diagnostics; using System.Runtime.CompilerServices; using System.Runtime.Versioning; +using EditorBrowsableAttribute = System.ComponentModel.EditorBrowsableAttribute; +using EditorBrowsableState = System.ComponentModel.EditorBrowsableState; using Internal.Runtime.CompilerServices; #pragma warning disable 0809 //warning CS0809: Obsolete member 'Span.Equals(object)' overrides non-obsolete member 'object.Equals(object)' @@ -290,7 +291,7 @@ namespace System /// /// For , returns a new instance of string that represents the characters pointed to by the span. - /// Otherwise, returns a with the name of the type and the number of elements. + /// Otherwise, returns a with the name of the type and the number of elements. /// public override string ToString() { diff --git a/src/System.Private.CoreLib/shared/System/Span.cs b/src/System.Private.CoreLib/shared/System/Span.cs index 81288a7..2bafa1d 100644 --- a/src/System.Private.CoreLib/shared/System/Span.cs +++ b/src/System.Private.CoreLib/shared/System/Span.cs @@ -95,7 +95,7 @@ namespace System /// /// Returns an empty /// - public static Span Empty => default(Span); + public static Span Empty => default; /// Gets an enumerator for this span. public Enumerator GetEnumerator() => new Enumerator(this); diff --git a/src/System.Private.CoreLib/shared/System/SpanDebugView.cs b/src/System.Private.CoreLib/shared/System/SpanDebugView.cs index caa12ef..f79c673 100644 --- a/src/System.Private.CoreLib/shared/System/SpanDebugView.cs +++ b/src/System.Private.CoreLib/shared/System/SpanDebugView.cs @@ -3,8 +3,6 @@ // See the LICENSE file in the project root for more information. using System.Diagnostics; -using System.Reflection; -using System.Runtime.CompilerServices; namespace System { @@ -14,7 +12,7 @@ namespace System public SpanDebugView(Span span) { - _array = span.ToArray(); + _array = span.ToArray(); } public SpanDebugView(ReadOnlySpan span) diff --git a/src/System.Private.CoreLib/shared/System/SpanHelpers.BinarySearch.cs b/src/System.Private.CoreLib/shared/System/SpanHelpers.BinarySearch.cs index 656b864..00c491f 100644 --- a/src/System.Private.CoreLib/shared/System/SpanHelpers.BinarySearch.cs +++ b/src/System.Private.CoreLib/shared/System/SpanHelpers.BinarySearch.cs @@ -26,7 +26,7 @@ namespace System } public static int BinarySearch( - ref T spanStart, int length, TComparable comparable) + ref T spanStart, int length, TComparable comparable) where TComparable : IComparable { int lo = 0; diff --git a/src/System.Private.CoreLib/shared/System/SpanHelpers.Byte.cs b/src/System.Private.CoreLib/shared/System/SpanHelpers.Byte.cs index 2b91b64..0c7309b 100644 --- a/src/System.Private.CoreLib/shared/System/SpanHelpers.Byte.cs +++ b/src/System.Private.CoreLib/shared/System/SpanHelpers.Byte.cs @@ -80,7 +80,8 @@ namespace System // Reduce space for search, cause we don't care if we find the search value after the index of a previously found value searchSpaceLength = tempIndex; - if (index == 0) break; + if (index == 0) + break; } } return index; @@ -98,7 +99,8 @@ namespace System for (int i = 0; i < valueLength; i++) { var tempIndex = LastIndexOf(ref searchSpace, Unsafe.Add(ref value, i), searchSpaceLength); - if (tempIndex > index) index = tempIndex; + if (tempIndex > index) + index = tempIndex; } return index; } @@ -1007,7 +1009,8 @@ namespace System while ((byte*)minLength > (byte*)i) { int result = Unsafe.AddByteOffset(ref first, i).CompareTo(Unsafe.AddByteOffset(ref second, i)); - if (result != 0) return result; + if (result != 0) + return result; i += 1; } diff --git a/src/System.Private.CoreLib/shared/System/SpanHelpers.T.cs b/src/System.Private.CoreLib/shared/System/SpanHelpers.T.cs index 4567ded..d7a27fd 100644 --- a/src/System.Private.CoreLib/shared/System/SpanHelpers.T.cs +++ b/src/System.Private.CoreLib/shared/System/SpanHelpers.T.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Diagnostics; -using System.Runtime.CompilerServices; +using System.Runtime.CompilerServices; // Do not remove. This is necessary for netstandard, since this file is mirrored into corefx #if !netstandard using Internal.Runtime.CompilerServices; @@ -312,7 +312,8 @@ namespace System // Reduce space for search, cause we don't care if we find the search value after the index of a previously found value searchSpaceLength = tempIndex; - if (index == 0) break; + if (index == 0) + break; } } return index; @@ -598,7 +599,8 @@ namespace System for (int i = 0; i < valueLength; i++) { var tempIndex = LastIndexOf(ref searchSpace, Unsafe.Add(ref value, i), searchSpaceLength); - if (tempIndex > index) index = tempIndex; + if (tempIndex > index) + index = tempIndex; } return index; } @@ -674,11 +676,13 @@ namespace System Debug.Assert(secondLength >= 0); var minLength = firstLength; - if (minLength > secondLength) minLength = secondLength; + if (minLength > secondLength) + minLength = secondLength; for (int i = 0; i < minLength; i++) { int result = Unsafe.Add(ref first, i).CompareTo(Unsafe.Add(ref second, i)); - if (result != 0) return result; + if (result != 0) + return result; } return firstLength.CompareTo(secondLength); } diff --git a/src/System.Private.CoreLib/shared/System/SpanHelpers.cs b/src/System.Private.CoreLib/shared/System/SpanHelpers.cs index 83cdfce..99e0bf9 100644 --- a/src/System.Private.CoreLib/shared/System/SpanHelpers.cs +++ b/src/System.Private.CoreLib/shared/System/SpanHelpers.cs @@ -5,7 +5,6 @@ using System.Diagnostics; using System.Globalization; using System.Runtime; -using System.Runtime.InteropServices; using Internal.Runtime.CompilerServices; @@ -348,14 +347,14 @@ namespace System for (; pointerSizeLength >= 8; pointerSizeLength -= 8) { - Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -1) = default(IntPtr); - Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -2) = default(IntPtr); - Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -3) = default(IntPtr); - Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -4) = default(IntPtr); - Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -5) = default(IntPtr); - Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -6) = default(IntPtr); - Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -7) = default(IntPtr); - Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -8) = default(IntPtr); + Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -1) = default; + Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -2) = default; + Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -3) = default; + Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -4) = default; + Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -5) = default; + Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -6) = default; + Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -7) = default; + Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -8) = default; } Debug.Assert(pointerSizeLength <= 7); @@ -394,23 +393,23 @@ namespace System Debug.Assert(pointerSizeLength >= 4); // Write first four and last three. - Unsafe.Add(ref ip, 2) = default(IntPtr); - Unsafe.Add(ref ip, 3) = default(IntPtr); - Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -3) = default(IntPtr); - Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -2) = default(IntPtr); + Unsafe.Add(ref ip, 2) = default; + Unsafe.Add(ref ip, 3) = default; + Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -3) = default; + Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -2) = default; Write2To3: Debug.Assert(pointerSizeLength >= 2); // Write first two and last one. - Unsafe.Add(ref ip, 1) = default(IntPtr); - Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -1) = default(IntPtr); + Unsafe.Add(ref ip, 1) = default; + Unsafe.Add(ref Unsafe.Add(ref ip, (IntPtr)pointerSizeLength), -1) = default; Write1: Debug.Assert(pointerSizeLength >= 1); // Write only element. - ip = default(IntPtr); + ip = default; } } } diff --git a/src/System.Private.CoreLib/shared/System/String.Searching.cs b/src/System.Private.CoreLib/shared/System/String.Searching.cs index 3a6ffc3..56549d8 100644 --- a/src/System.Private.CoreLib/shared/System/String.Searching.cs +++ b/src/System.Private.CoreLib/shared/System/String.Searching.cs @@ -177,7 +177,7 @@ namespace System private unsafe int IndexOfCharArray(char[] anyOf, int startIndex, int count) { // use probabilistic map, see InitializeProbabilisticMap - ProbabilisticMap map = default(ProbabilisticMap); + ProbabilisticMap map = default; uint* charMap = (uint*)↦ InitializeProbabilisticMap(charMap, anyOf); @@ -417,7 +417,7 @@ namespace System private unsafe int LastIndexOfCharArray(char[] anyOf, int startIndex, int count) { // use probabilistic map, see InitializeProbabilisticMap - ProbabilisticMap map = default(ProbabilisticMap); + ProbabilisticMap map = default; uint* charMap = (uint*)↦ InitializeProbabilisticMap(charMap, anyOf); diff --git a/src/System.Private.CoreLib/shared/System/Text/ASCIIEncoding.cs b/src/System.Private.CoreLib/shared/System/Text/ASCIIEncoding.cs index e89943a..3d25228 100644 --- a/src/System.Private.CoreLib/shared/System/Text/ASCIIEncoding.cs +++ b/src/System.Private.CoreLib/shared/System/Text/ASCIIEncoding.cs @@ -298,7 +298,7 @@ namespace System.Text // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding // parent method is safe - public override unsafe String GetString(byte[] bytes, int byteIndex, int byteCount) + public override unsafe string GetString(byte[] bytes, int byteIndex, int byteCount) { // Validate Parameters if (bytes == null) @@ -312,10 +312,10 @@ namespace System.Text throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); // Avoid problems with empty input buffer - if (byteCount == 0) return String.Empty; + if (byteCount == 0) return string.Empty; fixed (byte* pBytes = bytes) - return String.CreateStringFromEncoding( + return string.CreateStringFromEncoding( pBytes + byteIndex, byteCount, this); } diff --git a/src/System.Private.CoreLib/shared/System/Text/Encoding.cs b/src/System.Private.CoreLib/shared/System/Text/Encoding.cs index e191ce1..90d03cb 100644 --- a/src/System.Private.CoreLib/shared/System/Text/Encoding.cs +++ b/src/System.Private.CoreLib/shared/System/Text/Encoding.cs @@ -325,7 +325,7 @@ namespace System.Text // Returns an Encoding object for a given name or a given code page value. // - public static Encoding GetEncoding(String name) + public static Encoding GetEncoding(string name) { Encoding baseEncoding = EncodingProvider.GetEncodingFromProvider(name); if (baseEncoding != null) @@ -342,7 +342,7 @@ namespace System.Text // Returns an Encoding object for a given name or a given code page value. // - public static Encoding GetEncoding(String name, + public static Encoding GetEncoding(string name, EncoderFallback encoderFallback, DecoderFallback decoderFallback) { Encoding baseEncoding = EncodingProvider.GetEncodingFromProvider(name, encoderFallback, decoderFallback); @@ -386,7 +386,7 @@ namespace System.Text // Returns the name for this encoding that can be used with mail agent body tags. // If the encoding may not be used, the string is empty. - public virtual String BodyName + public virtual string BodyName { get { @@ -443,7 +443,7 @@ namespace System.Text } } #else - public virtual String EncodingName + public virtual string EncodingName { get { @@ -454,7 +454,7 @@ namespace System.Text // Returns the name for this encoding that can be used with mail agent header // tags. If the encoding may not be used, the string is empty. - public virtual String HeaderName + public virtual string HeaderName { get { @@ -467,7 +467,7 @@ namespace System.Text } // Returns the IANA preferred name for this encoding. - public virtual String WebName + public virtual string WebName { get { @@ -646,7 +646,7 @@ namespace System.Text return GetByteCount(chars, 0, chars.Length); } - public virtual int GetByteCount(String s) + public virtual int GetByteCount(string s) { if (s == null) throw new ArgumentNullException(nameof(s)); @@ -767,7 +767,7 @@ namespace System.Text // Returns a byte array containing the encoded representation of the given // string. // - public virtual byte[] GetBytes(String s) + public virtual byte[] GetBytes(string s) { if (s == null) throw new ArgumentNullException(nameof(s), @@ -817,7 +817,7 @@ namespace System.Text } } - public virtual int GetBytes(String s, int charIndex, int charCount, + public virtual int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex) { if (s == null) @@ -1082,7 +1082,7 @@ namespace System.Text if (byteCount < 0) throw new ArgumentOutOfRangeException(nameof(byteCount), SR.ArgumentOutOfRange_NeedNonNegNum); - return String.CreateStringFromEncoding(bytes, byteCount, this); + return string.CreateStringFromEncoding(bytes, byteCount, this); } public unsafe string GetString(ReadOnlySpan bytes) @@ -1184,7 +1184,7 @@ namespace System.Text // Returns a string containing the decoded representation of a given byte // array. // - public virtual String GetString(byte[] bytes) + public virtual string GetString(byte[] bytes) { if (bytes == null) throw new ArgumentNullException(nameof(bytes), @@ -1198,9 +1198,9 @@ namespace System.Text // // Internally we override this for performance // - public virtual String GetString(byte[] bytes, int index, int count) + public virtual string GetString(byte[] bytes, int index, int count) { - return new String(GetChars(bytes, index, count)); + return new string(GetChars(bytes, index, count)); } // Returns an encoding for Unicode format. The returned encoding will be diff --git a/src/System.Private.CoreLib/shared/System/Text/EncodingNLS.cs b/src/System.Private.CoreLib/shared/System/Text/EncodingNLS.cs index d5de9e5..ce33354 100644 --- a/src/System.Private.CoreLib/shared/System/Text/EncodingNLS.cs +++ b/src/System.Private.CoreLib/shared/System/Text/EncodingNLS.cs @@ -265,7 +265,7 @@ namespace System.Text // So if you fix this, fix the others. Currently those include: // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding // parent method is safe - public override unsafe String GetString(byte[] bytes, int index, int count) + public override unsafe string GetString(byte[] bytes, int index, int count) { // Validate Parameters if (bytes == null) @@ -278,10 +278,10 @@ namespace System.Text throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); // Avoid problems with empty input buffer - if (count == 0) return String.Empty; + if (count == 0) return string.Empty; fixed (byte* pBytes = bytes) - return String.CreateStringFromEncoding( + return string.CreateStringFromEncoding( pBytes + index, count, this); } diff --git a/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs b/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs index 8c1e045..bb6e964 100644 --- a/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs +++ b/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs @@ -353,7 +353,7 @@ namespace System.Text return Capacity; } - public override String ToString() + public override string ToString() { AssertInvariants(); @@ -655,7 +655,7 @@ namespace System.Text /// Appends a string to the end of this builder. /// /// The string to append. - public StringBuilder Append(String value) + public StringBuilder Append(string value) { if (value != null) { @@ -910,7 +910,7 @@ namespace System.Text /// The index to insert in this builder. /// The string to insert. /// The number of times to insert the string. - public StringBuilder Insert(int index, String value, int count) + public StringBuilder Insert(int index, string value, int count) { if (count < 0) { @@ -1189,7 +1189,7 @@ namespace System.Text #endregion - public StringBuilder Insert(int index, String value) + public StringBuilder Insert(int index, string value) { if ((uint)index > (uint)Length) { @@ -1319,13 +1319,13 @@ namespace System.Text return this; } - public StringBuilder AppendFormat(String format, Object arg0) => AppendFormatHelper(null, format, new ParamsArray(arg0)); + public StringBuilder AppendFormat(string format, Object arg0) => AppendFormatHelper(null, format, new ParamsArray(arg0)); - public StringBuilder AppendFormat(String format, Object arg0, Object arg1) => AppendFormatHelper(null, format, new ParamsArray(arg0, arg1)); + public StringBuilder AppendFormat(string format, Object arg0, Object arg1) => AppendFormatHelper(null, format, new ParamsArray(arg0, arg1)); - public StringBuilder AppendFormat(String format, Object arg0, Object arg1, Object arg2) => AppendFormatHelper(null, format, new ParamsArray(arg0, arg1, arg2)); + public StringBuilder AppendFormat(string format, Object arg0, Object arg1, Object arg2) => AppendFormatHelper(null, format, new ParamsArray(arg0, arg1, arg2)); - public StringBuilder AppendFormat(String format, params Object[] args) + public StringBuilder AppendFormat(string format, params Object[] args) { if (args == null) { @@ -1338,13 +1338,13 @@ namespace System.Text return AppendFormatHelper(null, format, new ParamsArray(args)); } - public StringBuilder AppendFormat(IFormatProvider provider, String format, Object arg0) => AppendFormatHelper(provider, format, new ParamsArray(arg0)); + public StringBuilder AppendFormat(IFormatProvider provider, string format, Object arg0) => AppendFormatHelper(provider, format, new ParamsArray(arg0)); - public StringBuilder AppendFormat(IFormatProvider provider, String format, Object arg0, Object arg1) => AppendFormatHelper(provider, format, new ParamsArray(arg0, arg1)); + public StringBuilder AppendFormat(IFormatProvider provider, string format, Object arg0, Object arg1) => AppendFormatHelper(provider, format, new ParamsArray(arg0, arg1)); - public StringBuilder AppendFormat(IFormatProvider provider, String format, Object arg0, Object arg1, Object arg2) => AppendFormatHelper(provider, format, new ParamsArray(arg0, arg1, arg2)); + public StringBuilder AppendFormat(IFormatProvider provider, string format, Object arg0, Object arg1, Object arg2) => AppendFormatHelper(provider, format, new ParamsArray(arg0, arg1, arg2)); - public StringBuilder AppendFormat(IFormatProvider provider, String format, params Object[] args) + public StringBuilder AppendFormat(IFormatProvider provider, string format, params Object[] args) { if (args == null) { @@ -1366,7 +1366,7 @@ namespace System.Text private const int IndexLimit = 1000000; // Note: 0 <= ArgIndex < IndexLimit private const int WidthLimit = 1000000; // Note: -WidthLimit < ArgAlign < WidthLimit - internal StringBuilder AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args) + internal StringBuilder AppendFormatHelper(IFormatProvider provider, string format, ParamsArray args) { if (format == null) { @@ -1503,7 +1503,7 @@ namespace System.Text // Start of parsing of optional formatting parameter. // Object arg = args[index]; - String itemFormat = null; + string itemFormat = null; ReadOnlySpan itemFormatSpan = default; // used if itemFormat is null // Is current character a colon? which indicates start of formatting parameter. if (ch == ':') @@ -1573,7 +1573,7 @@ namespace System.Text if (ch != '}') FormatError(); // Construct the output for this arg hole. pos++; - String s = null; + string s = null; if (cf != null) { if (itemFormatSpan.Length != 0 && itemFormat == null) @@ -1616,7 +1616,7 @@ namespace System.Text } } // Append it to the final output of the Format String. - if (s == null) s = String.Empty; + if (s == null) s = string.Empty; int pad = width - s.Length; if (!leftJustify && pad > 0) Append(' ', pad); Append(s); @@ -1635,7 +1635,7 @@ namespace System.Text /// If is null, instances of /// are removed from this builder. /// - public StringBuilder Replace(String oldValue, String newValue) => Replace(oldValue, newValue, 0, Length); + public StringBuilder Replace(string oldValue, string newValue) => Replace(oldValue, newValue, 0, Length); /// /// Determines if the contents of this builder are equal to the contents of another builder. @@ -1724,7 +1724,7 @@ namespace System.Text /// If is null, instances of /// are removed from this builder. /// - public StringBuilder Replace(String oldValue, String newValue, int startIndex, int count) + public StringBuilder Replace(string oldValue, string newValue, int startIndex, int count) { int currentLength = Length; if ((uint)startIndex > (uint)currentLength) diff --git a/src/System.Private.CoreLib/shared/System/Text/UTF32Encoding.cs b/src/System.Private.CoreLib/shared/System/Text/UTF32Encoding.cs index 7828775..00ac666 100644 --- a/src/System.Private.CoreLib/shared/System/Text/UTF32Encoding.cs +++ b/src/System.Private.CoreLib/shared/System/Text/UTF32Encoding.cs @@ -342,7 +342,7 @@ namespace System.Text // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding // parent method is safe - public override unsafe String GetString(byte[] bytes, int index, int count) + public override unsafe string GetString(byte[] bytes, int index, int count) { // Validate Parameters if (bytes == null) @@ -355,10 +355,10 @@ namespace System.Text throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); // Avoid problems with empty input buffer - if (count == 0) return String.Empty; + if (count == 0) return string.Empty; fixed (byte* pBytes = bytes) - return String.CreateStringFromEncoding( + return string.CreateStringFromEncoding( pBytes + index, count, this); } diff --git a/src/System.Private.CoreLib/shared/System/Text/UTF7Encoding.cs b/src/System.Private.CoreLib/shared/System/Text/UTF7Encoding.cs index 0246c28..cfd6c4d 100644 --- a/src/System.Private.CoreLib/shared/System/Text/UTF7Encoding.cs +++ b/src/System.Private.CoreLib/shared/System/Text/UTF7Encoding.cs @@ -14,17 +14,17 @@ namespace System.Text { public class UTF7Encoding : Encoding { - private const String base64Chars = + private const string base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; // 0123456789111111111122222222223333333333444444444455555555556666 // 012345678901234567890123456789012345678901234567890123 // These are the characters that can be directly encoded in UTF7. - private const String directChars = + private const string directChars = "\t\n\r '(),-./0123456789:?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; // These are the characters that can be optionally directly encoded in UTF7. - private const String optionalChars = + private const string optionalChars = "!\"#$%&*;<=>@[]^_`{|}"; // Used by Encoding.UTF7 for lazy initialization @@ -93,7 +93,7 @@ namespace System.Text // UTF7 had an odd decoderFallback behavior, and the Encoder fallback // is irrelevant because we encode surrogates individually and never check for unmatched ones // (so nothing can fallback during encoding) - this.encoderFallback = new EncoderReplacementFallback(String.Empty); + this.encoderFallback = new EncoderReplacementFallback(string.Empty); this.decoderFallback = new DecoderUTF7Fallback(); } @@ -372,7 +372,7 @@ namespace System.Text // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding // parent method is safe - public override unsafe String GetString(byte[] bytes, int index, int count) + public override unsafe string GetString(byte[] bytes, int index, int count) { // Validate Parameters if (bytes == null) @@ -385,10 +385,10 @@ namespace System.Text throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); // Avoid problems with empty input buffer - if (count == 0) return String.Empty; + if (count == 0) return string.Empty; fixed (byte* pBytes = bytes) - return String.CreateStringFromEncoding( + return string.CreateStringFromEncoding( pBytes + index, count, this); } diff --git a/src/System.Private.CoreLib/shared/System/Text/UTF8Encoding.cs b/src/System.Private.CoreLib/shared/System/Text/UTF8Encoding.cs index 2ea5096..f04a50f 100644 --- a/src/System.Private.CoreLib/shared/System/Text/UTF8Encoding.cs +++ b/src/System.Private.CoreLib/shared/System/Text/UTF8Encoding.cs @@ -369,7 +369,7 @@ namespace System.Text // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding // parent method is safe - public override unsafe String GetString(byte[] bytes, int index, int count) + public override unsafe string GetString(byte[] bytes, int index, int count) { // Validate Parameters if (bytes == null) @@ -382,10 +382,10 @@ namespace System.Text throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); // Avoid problems with empty input buffer - if (count == 0) return String.Empty; + if (count == 0) return string.Empty; fixed (byte* pBytes = bytes) - return String.CreateStringFromEncoding( + return string.CreateStringFromEncoding( pBytes + index, count, this); } diff --git a/src/System.Private.CoreLib/shared/System/Text/UnicodeEncoding.cs b/src/System.Private.CoreLib/shared/System/Text/UnicodeEncoding.cs index 342bf53..17fbd44 100644 --- a/src/System.Private.CoreLib/shared/System/Text/UnicodeEncoding.cs +++ b/src/System.Private.CoreLib/shared/System/Text/UnicodeEncoding.cs @@ -341,10 +341,10 @@ namespace System.Text throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); // Avoid problems with empty input buffer - if (count == 0) return String.Empty; + if (count == 0) return string.Empty; fixed (byte* pBytes = bytes) - return String.CreateStringFromEncoding( + return string.CreateStringFromEncoding( pBytes + index, count, this); } diff --git a/src/System.Private.CoreLib/shared/System/Threading/AsyncLocal.cs b/src/System.Private.CoreLib/shared/System/Threading/AsyncLocal.cs index 2bf8a04..84bbd17 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/AsyncLocal.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/AsyncLocal.cs @@ -61,7 +61,7 @@ namespace System.Threading get { object obj = ExecutionContext.GetLocalValue(this); - return (obj == null) ? default(T) : (T)obj; + return (obj == null) ? default : (T)obj; } set { @@ -72,8 +72,8 @@ namespace System.Threading void IAsyncLocal.OnValueChanged(object previousValueObj, object currentValueObj, bool contextChanged) { Debug.Assert(m_valueChangedHandler != null); - T previousValue = previousValueObj == null ? default(T) : (T)previousValueObj; - T currentValue = currentValueObj == null ? default(T) : (T)currentValueObj; + T previousValue = previousValueObj == null ? default : (T)previousValueObj; + T currentValue = currentValueObj == null ? default : (T)currentValueObj; m_valueChangedHandler(new AsyncLocalValueChangedArgs(previousValue, currentValue, contextChanged)); } } diff --git a/src/System.Private.CoreLib/shared/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs b/src/System.Private.CoreLib/shared/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs index 469535c..146e477 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs @@ -295,7 +295,7 @@ namespace System.Threading.Tasks try { processingTask = new Task(thisPair => ((ConcurrentExclusiveSchedulerPair)thisPair).ProcessExclusiveTasks(), this, - default(CancellationToken), GetCreationOptionsForTask(fairly)); + default, GetCreationOptionsForTask(fairly)); processingTask.Start(m_underlyingTaskScheduler); // When we call Start, if the underlying scheduler throws in QueueTask, TPL will fault the task and rethrow // the exception. To deal with that, we need a reference to the task object, so that we can observe its exception. @@ -322,7 +322,7 @@ namespace System.Threading.Tasks try { processingTask = new Task(thisPair => ((ConcurrentExclusiveSchedulerPair)thisPair).ProcessConcurrentTasks(), this, - default(CancellationToken), GetCreationOptionsForTask(fairly)); + default, GetCreationOptionsForTask(fairly)); processingTask.Start(m_underlyingTaskScheduler); // See above logic for why we use new + Start rather than StartNew } catch diff --git a/src/System.Private.CoreLib/shared/System/Threading/Tasks/TaskCompletionSource.cs b/src/System.Private.CoreLib/shared/System/Threading/Tasks/TaskCompletionSource.cs index 992e9db..11ba26d 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/Tasks/TaskCompletionSource.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/Tasks/TaskCompletionSource.cs @@ -315,7 +315,7 @@ namespace System.Threading.Tasks /// The was disposed. public bool TrySetCanceled() { - return TrySetCanceled(default(CancellationToken)); + return TrySetCanceled(default); } // Enables a token to be stored into the canceled task diff --git a/src/System.Private.CoreLib/shared/System/TimeSpan.cs b/src/System.Private.CoreLib/shared/System/TimeSpan.cs index 4293ed5..8738916 100644 --- a/src/System.Private.CoreLib/shared/System/TimeSpan.cs +++ b/src/System.Private.CoreLib/shared/System/TimeSpan.cs @@ -364,7 +364,7 @@ namespace System { if (s == null) { - result = default(TimeSpan); + result = default; return false; } return TimeSpanParse.TryParse(s, null, out result); @@ -378,7 +378,7 @@ namespace System { if (input == null) { - result = default(TimeSpan); + result = default; return false; } return TimeSpanParse.TryParse(input, formatProvider, out result); @@ -405,7 +405,7 @@ namespace System { if (input == null) { - result = default(TimeSpan); + result = default; return false; } return TimeSpanParse.TryParseExactMultiple(input, formats, formatProvider, TimeSpanStyles.None, out result); @@ -437,7 +437,7 @@ namespace System ValidateStyles(styles, nameof(styles)); if (input == null) { - result = default(TimeSpan); + result = default; return false; } return TimeSpanParse.TryParseExactMultiple(input, formats, formatProvider, styles, out result); diff --git a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.AdjustmentRule.cs b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.AdjustmentRule.cs index 0e949a3..54b5d46 100644 --- a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.AdjustmentRule.cs +++ b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.AdjustmentRule.cs @@ -39,8 +39,8 @@ namespace System internal bool HasDaylightSaving => DaylightDelta != TimeSpan.Zero || - (DaylightTransitionStart != default(TransitionTime) && DaylightTransitionStart.TimeOfDay != DateTime.MinValue) || - (DaylightTransitionEnd != default(TransitionTime) && DaylightTransitionEnd.TimeOfDay != DateTime.MinValue.AddMilliseconds(1)); + (DaylightTransitionStart != default && DaylightTransitionStart.TimeOfDay != DateTime.MinValue) || + (DaylightTransitionEnd != default && DaylightTransitionEnd.TimeOfDay != DateTime.MinValue.AddMilliseconds(1)); public bool Equals(AdjustmentRule other) => other != null && diff --git a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.Win32.cs b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.Win32.cs index 03f54a5..443b8d4 100644 --- a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.Win32.cs +++ b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.Win32.cs @@ -422,7 +422,7 @@ namespace System if (!supportsDst) { - transitionTime = default(TransitionTime); + transitionTime = default; return false; } diff --git a/src/System.Private.CoreLib/shared/System/TypeInitializationException.cs b/src/System.Private.CoreLib/shared/System/TypeInitializationException.cs index 4bf2906..2ef822a 100644 --- a/src/System.Private.CoreLib/shared/System/TypeInitializationException.cs +++ b/src/System.Private.CoreLib/shared/System/TypeInitializationException.cs @@ -23,7 +23,7 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public sealed class TypeInitializationException : SystemException { - private String _typeName; + private string _typeName; // This exception is not creatable without specifying the // inner exception. @@ -34,19 +34,19 @@ namespace System } - public TypeInitializationException(String fullTypeName, Exception innerException) + public TypeInitializationException(string fullTypeName, Exception innerException) : this(fullTypeName, SR.Format(SR.TypeInitialization_Type, fullTypeName), innerException) { } // This is called from within the runtime. I believe this is necessary // for Interop only, though it's not particularly useful. - internal TypeInitializationException(String message) : base(message) + internal TypeInitializationException(string message) : base(message) { HResult = HResults.COR_E_TYPEINITIALIZATION; } - internal TypeInitializationException(String fullTypeName, String message, Exception innerException) + internal TypeInitializationException(string fullTypeName, string message, Exception innerException) : base(message, innerException) { _typeName = fullTypeName; @@ -65,13 +65,13 @@ namespace System info.AddValue("TypeName", TypeName, typeof(string)); } - public String TypeName + public string TypeName { get { if (_typeName == null) { - return String.Empty; + return string.Empty; } return _typeName; } diff --git a/src/System.Private.CoreLib/shared/System/ValueTuple.cs b/src/System.Private.CoreLib/shared/System/ValueTuple.cs index d3ae20f..7423dba 100644 --- a/src/System.Private.CoreLib/shared/System/ValueTuple.cs +++ b/src/System.Private.CoreLib/shared/System/ValueTuple.cs @@ -632,7 +632,7 @@ namespace System /// The string returned by this method takes the form (Item1, Item2), /// where Item1 and Item2 represent the values of the /// and fields. If either field value is , - /// it is represented as . + /// it is represented as . /// public override string ToString() { @@ -838,7 +838,7 @@ namespace System /// The string representation of this instance. /// /// The string returned by this method takes the form (Item1, Item2, Item3). - /// If any field value is , it is represented as . + /// If any field value is , it is represented as . /// public override string ToString() { @@ -1063,7 +1063,7 @@ namespace System /// The string representation of this instance. /// /// The string returned by this method takes the form (Item1, Item2, Item3, Item4). - /// If any field value is , it is represented as . + /// If any field value is , it is represented as . /// public override string ToString() { @@ -1307,7 +1307,7 @@ namespace System /// The string representation of this instance. /// /// The string returned by this method takes the form (Item1, Item2, Item3, Item4, Item5). - /// If any field value is , it is represented as . + /// If any field value is , it is represented as . /// public override string ToString() { @@ -1570,7 +1570,7 @@ namespace System /// The string representation of this instance. /// /// The string returned by this method takes the form (Item1, Item2, Item3, Item4, Item5, Item6). - /// If any field value is , it is represented as . + /// If any field value is , it is represented as . /// public override string ToString() { @@ -1852,7 +1852,7 @@ namespace System /// The string representation of this instance. /// /// The string returned by this method takes the form (Item1, Item2, Item3, Item4, Item5, Item6, Item7). - /// If any field value is , it is represented as . + /// If any field value is , it is represented as . /// public override string ToString() { @@ -2252,7 +2252,7 @@ namespace System /// The string representation of this instance. /// /// The string returned by this method takes the form (Item1, Item2, Item3, Item4, Item5, Item6, Item7, Rest). - /// If any field value is , it is represented as . + /// If any field value is , it is represented as . /// public override string ToString() { diff --git a/src/System.Private.CoreLib/shared/System/Version.cs b/src/System.Private.CoreLib/shared/System/Version.cs index fe086be..6bdf969 100644 --- a/src/System.Private.CoreLib/shared/System/Version.cs +++ b/src/System.Private.CoreLib/shared/System/Version.cs @@ -154,7 +154,7 @@ namespace System { return object.ReferenceEquals(value, this) ? 0 : - object.ReferenceEquals(value, null) ? 1 : + value is null ? 1 : _Major != value._Major ? (_Major > value._Major ? 1 : -1) : _Minor != value._Minor ? (_Minor > value._Minor ? 1 : -1) : _Build != value._Build ? (_Build > value._Build ? 1 : -1) : @@ -170,7 +170,7 @@ namespace System public bool Equals(Version obj) { return object.ReferenceEquals(obj, this) || - (!object.ReferenceEquals(obj, null) && + (!(obj is null) && _Major == obj._Major && _Minor == obj._Minor && _Build == obj._Build && @@ -407,9 +407,9 @@ namespace System public static bool operator ==(Version v1, Version v2) { - if (Object.ReferenceEquals(v1, null)) + if (v1 is null) { - return Object.ReferenceEquals(v2, null); + return v2 is null; } return v1.Equals(v2); diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.cs index f9b4af8..90db456 100644 --- a/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.cs +++ b/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.cs @@ -95,7 +95,7 @@ namespace Microsoft.Win32 // Names of keys. This array must be in the same order as the HKEY values listed above. // - private static readonly String[] hkeyNames = new String[] { + private static readonly string[] hkeyNames = new string[] { "HKEY_CLASSES_ROOT", "HKEY_CURRENT_USER", "HKEY_LOCAL_MACHINE", @@ -113,7 +113,7 @@ namespace Microsoft.Win32 private volatile SafeRegistryHandle hkey = null; private volatile int state = 0; - private volatile String keyName; + private volatile string keyName; private volatile bool remoteKey = false; private volatile RegistryKeyPermissionCheck checkMode; private volatile RegistryView regView = RegistryView.Default; @@ -196,7 +196,7 @@ namespace Microsoft.Win32 Dispose(true); } - public void DeleteValue(String name, bool throwOnMissingValue) + public void DeleteValue(string name, bool throwOnMissingValue) { EnsureWriteable(); int errorCode = Win32Native.RegDeleteValue(hkey, name); @@ -304,7 +304,7 @@ namespace Microsoft.Win32 * * @return the Subkey requested, or null if the operation failed. */ - public RegistryKey OpenSubKey(String name) + public RegistryKey OpenSubKey(string name) { return OpenSubKey(name, false); } @@ -447,7 +447,7 @@ namespace Microsoft.Win32 * * @return the data associated with the value. */ - public Object GetValue(String name) + public Object GetValue(string name) { return InternalGetValue(name, null, false, true); } @@ -465,12 +465,12 @@ namespace Microsoft.Win32 * * @return the data associated with the value. */ - public Object GetValue(String name, Object defaultValue) + public Object GetValue(string name, Object defaultValue) { return InternalGetValue(name, defaultValue, false, true); } - public Object GetValue(String name, Object defaultValue, RegistryValueOptions options) + public Object GetValue(string name, Object defaultValue, RegistryValueOptions options) { if (options < RegistryValueOptions.None || options > RegistryValueOptions.DoNotExpandEnvironmentNames) { @@ -480,7 +480,7 @@ namespace Microsoft.Win32 return InternalGetValue(name, defaultValue, doNotExpand, true); } - internal Object InternalGetValue(String name, Object defaultValue, bool doNotExpand, bool checkSecurity) + internal Object InternalGetValue(string name, Object defaultValue, bool doNotExpand, bool checkSecurity) { if (checkSecurity) { @@ -605,13 +605,13 @@ namespace Microsoft.Win32 ret = Win32Native.RegQueryValueEx(hkey, name, null, ref type, blob, ref datasize); if (blob.Length > 0 && blob[blob.Length - 1] == (char)0) { - data = new String(blob, 0, blob.Length - 1); + data = new string(blob, 0, blob.Length - 1); } else { // in the very unlikely case the data is missing null termination, // pass in the whole char[] to prevent truncating a character - data = new String(blob); + data = new string(blob); } } break; @@ -636,17 +636,17 @@ namespace Microsoft.Win32 if (blob.Length > 0 && blob[blob.Length - 1] == (char)0) { - data = new String(blob, 0, blob.Length - 1); + data = new string(blob, 0, blob.Length - 1); } else { // in the very unlikely case the data is missing null termination, // pass in the whole char[] to prevent truncating a character - data = new String(blob); + data = new string(blob); } if (!doNotExpand) - data = Environment.ExpandEnvironmentVariables((String)data); + data = Environment.ExpandEnvironmentVariables((string)data); } break; case Win32Native.REG_MULTI_SZ: @@ -688,7 +688,7 @@ namespace Microsoft.Win32 } - IList strings = new List(); + IList strings = new List(); int cur = 0; int len = blob.Length; @@ -705,25 +705,25 @@ namespace Microsoft.Win32 Debug.Assert(blob[nextNull] == (char)0, "blob[nextNull] should be 0"); if (nextNull - cur > 0) { - strings.Add(new String(blob, cur, nextNull - cur)); + strings.Add(new string(blob, cur, nextNull - cur)); } else { // we found an empty string. But if we're at the end of the data, // it's just the extra null terminator. if (nextNull != len - 1) - strings.Add(String.Empty); + strings.Add(string.Empty); } } else { - strings.Add(new String(blob, cur, len - cur)); + strings.Add(new string(blob, cur, len - cur)); } cur = nextNull + 1; } - data = new String[strings.Count]; - strings.CopyTo((String[])data, 0); + data = new string[strings.Count]; + strings.CopyTo((string[])data, 0); } break; case Win32Native.REG_LINK: @@ -760,12 +760,12 @@ namespace Microsoft.Win32 * @param name Name of value to store data in. * @param value Data to store. */ - public void SetValue(String name, Object value) + public void SetValue(string name, Object value) { SetValue(name, value, RegistryValueKind.Unknown); } - public unsafe void SetValue(String name, Object value, RegistryValueKind valueKind) + public unsafe void SetValue(string name, Object value, RegistryValueKind valueKind) { if (value == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value); @@ -795,7 +795,7 @@ namespace Microsoft.Win32 case RegistryValueKind.ExpandString: case RegistryValueKind.String: { - String data = value.ToString(); + string data = value.ToString(); ret = Win32Native.RegSetValueEx(hkey, name, 0, @@ -834,7 +834,7 @@ namespace Microsoft.Win32 for (int i = 0; i < dataStrings.Length; i++) { // Assumes that the Strings are always null terminated. - String.InternalCopy(dataStrings[i], currentPtr, (checked(dataStrings[i].Length * 2))); + string.InternalCopy(dataStrings[i], currentPtr, (checked(dataStrings[i].Length * 2))); currentPtr = new IntPtr((long)currentPtr + (checked(dataStrings[i].Length * 2))); *(char*)(currentPtr.ToPointer()) = '\0'; currentPtr = new IntPtr((long)currentPtr + 2); @@ -929,7 +929,7 @@ namespace Microsoft.Win32 { if (value is byte[]) return RegistryValueKind.Binary; - else if (value is String[]) + else if (value is string[]) return RegistryValueKind.MultiString; else throw new ArgumentException(SR.Format(SR.Arg_RegSetBadArrType, value.GetType().Name)); @@ -943,7 +943,7 @@ namespace Microsoft.Win32 * * @return a string representing the key. */ - public override String ToString() + public override string ToString() { EnsureNotDisposed(); return keyName; @@ -956,7 +956,7 @@ namespace Microsoft.Win32 * error, and depending on the error, insert a string into the message * gotten from the ResourceManager. */ - internal void Win32Error(int errorCode, String str) + internal void Win32Error(int errorCode, string str) { switch (errorCode) { @@ -994,7 +994,7 @@ namespace Microsoft.Win32 } } - internal static String FixupName(String name) + internal static string FixupName(string name) { Debug.Assert(name != null, "[FixupName]name!=null"); if (name.IndexOf('\\') == -1) diff --git a/src/System.Private.CoreLib/src/System/AppContext/AppContextDefaultValues.cs b/src/System.Private.CoreLib/src/System/AppContext/AppContextDefaultValues.cs index 2388784..8829844 100644 --- a/src/System.Private.CoreLib/src/System/AppContext/AppContextDefaultValues.cs +++ b/src/System.Private.CoreLib/src/System/AppContext/AppContextDefaultValues.cs @@ -46,14 +46,14 @@ namespace System // - The identifier and version is required, profile is optional // - Only three components are allowed. // - The version string must be in the System.Version format; an optional "v" or "V" prefix is allowed - private static bool TryParseFrameworkName(String frameworkName, out String identifier, out int version, out String profile) + private static bool TryParseFrameworkName(string frameworkName, out string identifier, out int version, out string profile) { // For parsing a target Framework moniker, from the FrameworkName class const char c_componentSeparator = ','; const char c_keyValueSeparator = '='; const char c_versionValuePrefix = 'v'; - const String c_versionKey = "Version"; - const String c_profileKey = "Profile"; + const string c_versionKey = "Version"; + const string c_profileKey = "Profile"; identifier = profile = string.Empty; version = 0; @@ -63,7 +63,7 @@ namespace System return false; } - String[] components = frameworkName.Split(c_componentSeparator); + string[] components = frameworkName.Split(c_componentSeparator); version = 0; // Identifer and Version are required, Profile is optional. @@ -125,7 +125,7 @@ namespace System // else if (key.Equals(c_profileKey, StringComparison.OrdinalIgnoreCase)) { - if (!String.IsNullOrEmpty(value)) + if (!string.IsNullOrEmpty(value)) { profile = value; } diff --git a/src/System.Private.CoreLib/src/System/Array.cs b/src/System.Private.CoreLib/src/System/Array.cs index d8a958d..cf50fe8 100644 --- a/src/System.Private.CoreLib/src/System/Array.cs +++ b/src/System.Private.CoreLib/src/System/Array.cs @@ -571,7 +571,7 @@ namespace System int IList.Add(Object value) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); - return default(int); + return default; } bool IList.Contains(Object value) @@ -1004,7 +1004,7 @@ namespace System return array[i]; } } - return default(T); + return default; } public static T[] FindAll(T[] array, Predicate match) @@ -1099,7 +1099,7 @@ namespace System return array[i]; } } - return default(T); + return default; } public static int FindLastIndex(T[] array, Predicate match) @@ -2569,7 +2569,7 @@ namespace System { // Not meaningful for arrays ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); - return default(bool); + return default; } private void RemoveAt(int index) diff --git a/src/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentDictionary.cs b/src/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentDictionary.cs index e34de29..cc6033f 100644 --- a/src/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentDictionary.cs +++ b/src/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentDictionary.cs @@ -211,7 +211,7 @@ namespace System.Collections.Concurrent { if (key == null) ThrowKeyNullException(); - return TryRemoveInternal(key, out value, false, default(TValue)); + return TryRemoveInternal(key, out value, false, default); } /// @@ -256,7 +256,7 @@ namespace System.Collections.Concurrent bool valuesMatch = EqualityComparer.Default.Equals(oldValue, curr._value); if (!valuesMatch) { - value = default(TValue); + value = default; return false; } } @@ -278,7 +278,7 @@ namespace System.Collections.Concurrent } } - value = default(TValue); + value = default; return false; } } @@ -327,7 +327,7 @@ namespace System.Collections.Concurrent n = n._next; } - value = default(TValue); + value = default; return false; } @@ -1224,7 +1224,7 @@ namespace System.Collections.Concurrent get { ThrowHelper.ThrowNotSupportedException(ExceptionResource.ConcurrentCollection_SyncRoot_NotSupported); - return default(object); + return default; } } diff --git a/src/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentStack.cs b/src/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentStack.cs index 2b0ff12..019bc4e 100644 --- a/src/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentStack.cs +++ b/src/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentStack.cs @@ -128,7 +128,7 @@ namespace System.Collections.Concurrent get { ThrowHelper.ThrowNotSupportedException(ExceptionResource.ConcurrentCollection_SyncRoot_NotSupported); - return default(object); + return default; } } @@ -269,7 +269,7 @@ namespace System.Collections.Concurrent //stack is empty if (head == null) { - result = default(T); + result = default; return false; } if (Interlocked.CompareExchange(ref _head, head._next, head) == head) @@ -297,7 +297,7 @@ namespace System.Collections.Concurrent return true; } - result = default(T); + result = default; return false; } diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Contracts/Contracts.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Contracts/Contracts.cs index 5547684..e94ef46 100644 --- a/src/System.Private.CoreLib/src/System/Diagnostics/Contracts/Contracts.cs +++ b/src/System.Private.CoreLib/src/System/Diagnostics/Contracts/Contracts.cs @@ -457,7 +457,7 @@ namespace System.Diagnostics.Contracts /// This method can only be used within the argument to the contract. /// [Pure] - public static T Result() { return default(T); } + public static T Result() { return default; } /// /// Represents the final (output) value of an out parameter when returning from a method. @@ -469,7 +469,7 @@ namespace System.Diagnostics.Contracts /// This method can only be used within the argument to the contract. /// [Pure] - public static T ValueAtReturn(out T value) { value = default(T); return value; } + public static T ValueAtReturn(out T value) { value = default; return value; } /// /// Represents the value of as it was at the start of the method or property. @@ -481,7 +481,7 @@ namespace System.Diagnostics.Contracts /// This method can only be used within the argument to the contract. /// [Pure] - public static T OldValue(T value) { return default(T); } + public static T OldValue(T value) { return default; } #endregion Old, Result, and Out Parameters diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Contracts/ContractsBCL.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Contracts/ContractsBCL.cs index e12bb51..f1cb53c 100644 --- a/src/System.Private.CoreLib/src/System/Diagnostics/Contracts/ContractsBCL.cs +++ b/src/System.Private.CoreLib/src/System/Diagnostics/Contracts/ContractsBCL.cs @@ -28,7 +28,7 @@ namespace System.Diagnostics.Contracts /// This method is used internally to trigger a failure indicating to the "programmer" that he is using the interface incorrectly. /// It is NEVER used to indicate failure of actual contracts at runtime. /// - static void AssertMustUseRewriter(ContractFailureKind kind, String contractKind) + static void AssertMustUseRewriter(ContractFailureKind kind, string contractKind) { // For better diagnostics, report which assembly is at fault. Walk up stack and // find the first non-mscorlib assembly. @@ -47,7 +47,7 @@ namespace System.Diagnostics.Contracts if (probablyNotRewritten == null) probablyNotRewritten = thisAssembly; - String simpleName = probablyNotRewritten.GetName().Name; + string simpleName = probablyNotRewritten.GetName().Name; System.Runtime.CompilerServices.ContractHelper.TriggerFailure(kind, SR.Format(SR.MustUseCCRewrite, contractKind, simpleName), null, null, null); } @@ -62,7 +62,7 @@ namespace System.Diagnostics.Contracts /// System.Runtime.CompilerServices.ContractHelper.TriggerFailure. /// [System.Diagnostics.DebuggerNonUserCode] - static void ReportFailure(ContractFailureKind failureKind, String userMessage, String conditionText, Exception innerException) + static void ReportFailure(ContractFailureKind failureKind, string userMessage, string conditionText, Exception innerException) { if (failureKind < ContractFailureKind.Precondition || failureKind > ContractFailureKind.Assume) throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, failureKind), nameof(failureKind)); @@ -101,15 +101,15 @@ namespace System.Diagnostics.Contracts public sealed class ContractFailedEventArgs : EventArgs { private ContractFailureKind _failureKind; - private String _message; - private String _condition; + private string _message; + private string _condition; private Exception _originalException; private bool _handled; private bool _unwind; internal Exception thrownDuringHandler; - public ContractFailedEventArgs(ContractFailureKind failureKind, String message, String condition, Exception originalException) + public ContractFailedEventArgs(ContractFailureKind failureKind, string message, string condition, Exception originalException) { Debug.Assert(originalException == null || failureKind == ContractFailureKind.PostconditionOnException); _failureKind = failureKind; @@ -118,8 +118,8 @@ namespace System.Diagnostics.Contracts _originalException = originalException; } - public String Message { get { return _message; } } - public String Condition { get { return _condition; } } + public string Message { get { return _message; } } + public string Condition { get { return _condition; } } public ContractFailureKind FailureKind { get { return _failureKind; } } public Exception OriginalException { get { return _originalException; } } @@ -252,13 +252,13 @@ namespace System.Runtime.CompilerServices /// On exit: null if the event was handled and should not trigger a failure. /// Otherwise, returns the localized failure message [System.Diagnostics.DebuggerNonUserCode] - public static string RaiseContractFailedEvent(ContractFailureKind failureKind, String userMessage, String conditionText, Exception innerException) + public static string RaiseContractFailedEvent(ContractFailureKind failureKind, string userMessage, string conditionText, Exception innerException) { if (failureKind < ContractFailureKind.Precondition || failureKind > ContractFailureKind.Assume) throw new ArgumentException(SR.Format(SR.Arg_EnumIllegalVal, failureKind), nameof(failureKind)); string returnValue; - String displayMessage = "contract failed."; // Incomplete, but in case of OOM during resource lookup... + string displayMessage = "contract failed."; // Incomplete, but in case of OOM during resource lookup... ContractFailedEventArgs eventArgs = null; // In case of OOM. try @@ -306,7 +306,7 @@ namespace System.Runtime.CompilerServices /// Rewriter calls this method to get the default failure behavior. /// [System.Diagnostics.DebuggerNonUserCode] - public static void TriggerFailure(ContractFailureKind kind, String displayMessage, String userMessage, String conditionText, Exception innerException) + public static void TriggerFailure(ContractFailureKind kind, string displayMessage, string userMessage, string conditionText, Exception innerException) { if (string.IsNullOrEmpty(displayMessage)) { @@ -316,9 +316,9 @@ namespace System.Runtime.CompilerServices System.Diagnostics.Debug.ContractFailure(false, displayMessage, string.Empty, GetResourceNameForFailure(kind)); } - private static String GetResourceNameForFailure(ContractFailureKind failureKind) + private static string GetResourceNameForFailure(ContractFailureKind failureKind) { - String resourceName = null; + string resourceName = null; switch (failureKind) { case ContractFailureKind.Assert: @@ -353,18 +353,18 @@ namespace System.Runtime.CompilerServices return resourceName; } - private static String GetDisplayMessage(ContractFailureKind failureKind, String userMessage, String conditionText) + private static string GetDisplayMessage(ContractFailureKind failureKind, string userMessage, string conditionText) { - String failureMessage; + string failureMessage; // Well-formatted English messages will take one of four forms. A sentence ending in // either a period or a colon, the condition string, then the message tacked // on to the end with two spaces in front. // Note that both the conditionText and userMessage may be null. Also, // on Silverlight we may not be able to look up a friendly string for the // error message. Let's leverage Silverlight's default error message there. - if (!String.IsNullOrEmpty(conditionText)) + if (!string.IsNullOrEmpty(conditionText)) { - String resourceName = GetResourceNameForFailure(failureKind); + string resourceName = GetResourceNameForFailure(failureKind); resourceName += "_Cnd"; failureMessage = SR.Format(SR.GetResourceString(resourceName), conditionText); } @@ -374,7 +374,7 @@ namespace System.Runtime.CompilerServices } // Now add in the user message, if present. - if (!String.IsNullOrEmpty(userMessage)) + if (!string.IsNullOrEmpty(userMessage)) { return failureMessage + " " + userMessage; } diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Debug.Windows.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Debug.Windows.cs index 7649991..1f5a545 100644 --- a/src/System.Private.CoreLib/src/System/Diagnostics/Debug.Windows.cs +++ b/src/System.Private.CoreLib/src/System/Diagnostics/Debug.Windows.cs @@ -18,11 +18,11 @@ namespace System.Diagnostics // Fail in order to avoid anyone catching an exception and masking // an assert failure. DebugAssertException ex; - if (message == String.Empty) + if (message == string.Empty) { ex = new DebugAssertException(stackTrace); } - else if (detailMessage == String.Empty) + else if (detailMessage == string.Empty) { ex = new DebugAssertException(message, stackTrace); } diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Stacktrace.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Stacktrace.cs index 0535f02..08363d2 100644 --- a/src/System.Private.CoreLib/src/System/Diagnostics/Stacktrace.cs +++ b/src/System.Private.CoreLib/src/System/Diagnostics/Stacktrace.cs @@ -33,14 +33,14 @@ namespace System.Diagnostics private Object dynamicMethods; // Field is not used from managed. private IntPtr[] rgMethodHandle; - private String[] rgAssemblyPath; + private string[] rgAssemblyPath; private IntPtr[] rgLoadedPeAddress; private int[] rgiLoadedPeSize; private IntPtr[] rgInMemoryPdbAddress; private int[] rgiInMemoryPdbSize; // if rgiMethodToken[i] == 0, then don't attempt to get the portable PDB source/info private int[] rgiMethodToken; - private String[] rgFilename; + private string[] rgFilename; private int[] rgiLineNumber; private int[] rgiColumnNumber; private bool[] rgiLastFrameFromForeignExceptionStackTrace; @@ -172,7 +172,7 @@ namespace System.Diagnostics public virtual int GetOffset(int i) { return rgiOffset[i]; } public virtual int GetILOffset(int i) { return rgiILOffset[i]; } - public virtual String GetFilename(int i) { return rgFilename == null ? null : rgFilename[i]; } + public virtual string GetFilename(int i) { return rgFilename == null ? null : rgFilename[i]; } public virtual int GetLineNumber(int i) { return rgiLineNumber == null ? 0 : rgiLineNumber[i]; } public virtual int GetColumnNumber(int i) { return rgiColumnNumber == null ? 0 : rgiColumnNumber[i]; } @@ -320,7 +320,7 @@ namespace System.Diagnostics internal static int CalculateFramesToSkip(StackFrameHelper StackF, int iNumFrames) { int iRetVal = 0; - String PackageName = "System.Diagnostics"; + string PackageName = "System.Diagnostics"; // Check if this method is part of the System.Diagnostics // package. If so, increment counter keeping track of @@ -333,10 +333,10 @@ namespace System.Diagnostics Type t = mb.DeclaringType; if (t == null) break; - String ns = t.Namespace; + string ns = t.Namespace; if (ns == null) break; - if (String.Compare(ns, PackageName, StringComparison.Ordinal) != 0) + if (string.Compare(ns, PackageName, StringComparison.Ordinal) != 0) break; } iRetVal++; @@ -444,7 +444,7 @@ namespace System.Diagnostics // Builds a readable representation of the stack trace // - public override String ToString() + public override string ToString() { // Include a trailing newline for backwards compatibility return ToString(TraceFormat.TrailingNewLine); @@ -461,11 +461,11 @@ namespace System.Diagnostics // Builds a readable representation of the stack trace, specifying // the format for backwards compatibility. - internal String ToString(TraceFormat traceFormat) + internal string ToString(TraceFormat traceFormat) { bool displayFilenames = true; // we'll try, but demand may fail - String word_At = "at"; - String inFileLineNum = "in {0}:line {1}"; + string word_At = "at"; + string inFileLineNum = "in {0}:line {1}"; if (traceFormat != TraceFormat.NoResourceLookup) { @@ -560,7 +560,7 @@ namespace System.Diagnostics else fFirstParam = false; - String typeName = ""; + string typeName = ""; if (pi[j].ParameterType != null) typeName = pi[j].ParameterType.Name; sb.Append(typeName); @@ -583,7 +583,7 @@ namespace System.Diagnostics { // If we don't have a PDB or PDB-reading is disabled for the module, // then the file name will be null. - String fileName = null; + string fileName = null; // Getting the filename from a StackFrame is a privileged operation - we won't want // to disclose full path names to arbitrarily untrusted code. Rather than just omit diff --git a/src/System.Private.CoreLib/src/System/Enum.cs b/src/System.Private.CoreLib/src/System/Enum.cs index eae46cf..c837437 100644 --- a/src/System.Private.CoreLib/src/System/Enum.cs +++ b/src/System.Private.CoreLib/src/System/Enum.cs @@ -368,7 +368,7 @@ namespace System public static bool TryParse(String value, bool ignoreCase, out TEnum result) where TEnum : struct { - result = default(TEnum); + result = default; EnumResult parseResult = new EnumResult(); bool retValue; diff --git a/src/System.Private.CoreLib/src/System/GC.cs b/src/System.Private.CoreLib/src/System/GC.cs index 848141f..dd75601 100644 --- a/src/System.Private.CoreLib/src/System/GC.cs +++ b/src/System.Private.CoreLib/src/System/GC.cs @@ -364,7 +364,7 @@ namespace System if ((maxGenerationThreshold <= 0) || (maxGenerationThreshold >= 100)) { throw new ArgumentOutOfRangeException(nameof(maxGenerationThreshold), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Bounds_Lower_Upper, 1, @@ -374,7 +374,7 @@ namespace System if ((largeObjectHeapThreshold <= 0) || (largeObjectHeapThreshold >= 100)) { throw new ArgumentOutOfRangeException(nameof(largeObjectHeapThreshold), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Bounds_Lower_Upper, 1, diff --git a/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs b/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs index 83a261f..7929956 100644 --- a/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs +++ b/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs @@ -166,13 +166,13 @@ namespace System.Globalization // //////////////////////////////////////////////////////////////////////// - public CultureInfo(String name) + public CultureInfo(string name) : this(name, true) { } - public CultureInfo(String name, bool useUserOverride) + public CultureInfo(string name, bool useUserOverride) { if (name == null) { @@ -260,7 +260,7 @@ namespace System.Globalization // Note that we really cannot use an LCID version of this override as the cached // name we create for it has to include both names, and the logic for this is in // the GetCultureInfo override *only*. - internal CultureInfo(String cultureName, String textAndCompareCultureName) + internal CultureInfo(string cultureName, string textAndCompareCultureName) { if (cultureName == null) { @@ -283,7 +283,7 @@ namespace System.Globalization // // TODO: It would appear that this is only ever called with userOveride = true // and this method only has one caller. Can we fold it into the caller? - private static CultureInfo GetCultureByName(String name, bool userOverride) + private static CultureInfo GetCultureByName(string name, bool userOverride) { CultureInfo ci = null; // Try to get our culture @@ -311,7 +311,7 @@ namespace System.Globalization // if we can't find a bigger name. That doesn't help with things like "zh" though, so // the approach is of questionable value // - public static CultureInfo CreateSpecificCulture(String name) + public static CultureInfo CreateSpecificCulture(string name) { CultureInfo culture; @@ -361,7 +361,7 @@ namespace System.Globalization return (new CultureInfo(culture._cultureData.SSPECIFICCULTURE)); } - internal static bool VerifyCultureName(String cultureName, bool throwException) + internal static bool VerifyCultureName(string cultureName, bool throwException) { // This function is used by ResourceManager.GetResourceFileName(). // ResourceManager searches for resource using CultureInfo.Name, @@ -497,7 +497,7 @@ namespace System.Globalization { string parentName = _cultureData.SPARENT; - if (String.IsNullOrEmpty(parentName)) + if (string.IsNullOrEmpty(parentName)) { _parent = InvariantCulture; } @@ -552,7 +552,7 @@ namespace System.Globalization // "en-US" This version does NOT include sort information in the name. // //////////////////////////////////////////////////////////////////////// - public virtual String Name + public virtual string Name { get { @@ -562,7 +562,7 @@ namespace System.Globalization _nonSortName = _cultureData.SNAME; if (_nonSortName == null) { - _nonSortName = String.Empty; + _nonSortName = string.Empty; } } return _nonSortName; @@ -570,7 +570,7 @@ namespace System.Globalization } // This one has the sort information (ie: de-DE_phoneb) - internal String SortName + internal string SortName { get { @@ -609,7 +609,7 @@ namespace System.Globalization // US English, "Ingles (Estados Unidos)" will be returned. // //////////////////////////////////////////////////////////////////////// - public virtual String DisplayName + public virtual string DisplayName { get { @@ -628,7 +628,7 @@ namespace System.Globalization // (United States)" will be returned. // //////////////////////////////////////////////////////////////////////// - public virtual String NativeName + public virtual string NativeName { get { @@ -645,7 +645,7 @@ namespace System.Globalization // (United States)" will be returned. // //////////////////////////////////////////////////////////////////////// - public virtual String EnglishName + public virtual string EnglishName { get { @@ -654,7 +654,7 @@ namespace System.Globalization } // ie: en - public virtual String TwoLetterISOLanguageName + public virtual string TwoLetterISOLanguageName { get { @@ -663,7 +663,7 @@ namespace System.Globalization } // ie: eng - public virtual String ThreeLetterISOLanguageName + public virtual string ThreeLetterISOLanguageName { get { @@ -679,7 +679,7 @@ namespace System.Globalization // The ISO names are much preferred // //////////////////////////////////////////////////////////////////////// - public virtual String ThreeLetterWindowsLanguageName + public virtual string ThreeLetterWindowsLanguageName { get { @@ -787,7 +787,7 @@ namespace System.Globalization //////////////////////////////////////////////////////////////////////// - public override String ToString() + public override string ToString() { return _name; } diff --git a/src/System.Private.CoreLib/src/System/IO/BinaryReader.cs b/src/System.Private.CoreLib/src/System/IO/BinaryReader.cs index fc7dba4..6e0f54b 100644 --- a/src/System.Private.CoreLib/src/System/IO/BinaryReader.cs +++ b/src/System.Private.CoreLib/src/System/IO/BinaryReader.cs @@ -263,7 +263,7 @@ namespace System.IO } } - public virtual String ReadString() + public virtual string ReadString() { if (_stream == null) throw Error.GetFileNotOpen(); @@ -283,7 +283,7 @@ namespace System.IO if (stringLength == 0) { - return String.Empty; + return string.Empty; } if (_charBytes == null) @@ -310,7 +310,7 @@ namespace System.IO charsRead = _decoder.GetChars(_charBytes, 0, n, _charBuffer, 0); if (currPos == 0 && n == stringLength) - return new String(_charBuffer, 0, charsRead); + return new string(_charBuffer, 0, charsRead); if (sb == null) sb = StringBuilderCache.Acquire(stringLength); // Actual string length in chars may be smaller. diff --git a/src/System.Private.CoreLib/src/System/IO/Stream.cs b/src/System.Private.CoreLib/src/System/IO/Stream.cs index 4cf8435..2f0c4a4 100644 --- a/src/System.Private.CoreLib/src/System/IO/Stream.cs +++ b/src/System.Private.CoreLib/src/System/IO/Stream.cs @@ -374,7 +374,7 @@ namespace System.IO : BeginEndReadAsync(buffer, offset, count); } - public virtual ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default(CancellationToken)) + public virtual ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default) { if (MemoryMarshal.TryGetArray(buffer, out ArraySegment array)) { @@ -513,7 +513,7 @@ namespace System.IO Debug.Assert(t.IsCompletedSuccessfully, "The semaphore wait should always complete successfully."); var rwt = (ReadWriteTask)state; rwt._stream.RunReadWriteTask(rwt); // RunReadWriteTask(readWriteTask); - }, readWriteTask, default(CancellationToken), TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default); + }, readWriteTask, default, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default); } } @@ -683,7 +683,7 @@ namespace System.IO : BeginEndWriteAsync(buffer, offset, count); } - public virtual ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default(CancellationToken)) + public virtual ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default) { if (MemoryMarshal.TryGetArray(buffer, out ArraySegment array)) { @@ -728,7 +728,7 @@ namespace System.IO (stream, asyncResult) => // cached by compiler { stream.EndWrite(asyncResult); - return default(VoidTaskResult); + return default; }); } @@ -982,7 +982,7 @@ namespace System.IO return AsyncTaskMethodBuilder.s_defaultResultTask; } - public override ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default(CancellationToken)) + public override ValueTask ReadAsync(Memory buffer, CancellationToken cancellationToken = default) { return new ValueTask(0); } @@ -1007,7 +1007,7 @@ namespace System.IO Task.CompletedTask; } - public override ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default(CancellationToken)) + public override ValueTask WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default) { return cancellationToken.IsCancellationRequested ? new ValueTask(Task.FromCanceled(cancellationToken)) : diff --git a/src/System.Private.CoreLib/src/System/Internal.cs b/src/System.Private.CoreLib/src/System/Internal.cs index 1534326..a3aa9d2 100644 --- a/src/System.Private.CoreLib/src/System/Internal.cs +++ b/src/System.Private.CoreLib/src/System/Internal.cs @@ -127,7 +127,7 @@ namespace System new KeyValuePair('\0', UInt16.MinValue); new KeyValuePair(UInt16.MinValue, Double.MinValue); - new KeyValuePair(String.Empty, Int32.MinValue); + new KeyValuePair(string.Empty, Int32.MinValue); new KeyValuePair(Int32.MinValue, Int32.MinValue); SZArrayHelper(null); SZArrayHelper(null); @@ -261,20 +261,20 @@ namespace System // instantiate stubs for commonly used methods on IList and ICollection vectorToListAdapter.Indexer_Get(0); - vectorToListAdapter.Indexer_Set(0, default(T)); - vectorToListAdapter.Insert(0, default(T)); + vectorToListAdapter.Indexer_Set(0, default); + vectorToListAdapter.Insert(0, default); vectorToListAdapter.RemoveAt(0); vectorToCollectionAdapter.Count(); - vectorToCollectionAdapter.Add(default(T)); + vectorToCollectionAdapter.Add(default); vectorToCollectionAdapter.Clear(); // instantiate stubs for commonly used methods on IVector listToVectorAdapter.GetAt(0); listToVectorAdapter.Size(); - listToVectorAdapter.SetAt(0, default(T)); - listToVectorAdapter.InsertAt(0, default(T)); + listToVectorAdapter.SetAt(0, default); + listToVectorAdapter.InsertAt(0, default); listToVectorAdapter.RemoveAt(0); - listToVectorAdapter.Append(default(T)); + listToVectorAdapter.Append(default); listToVectorAdapter.RemoveAtEnd(); listToVectorAdapter.Clear(); } @@ -306,22 +306,22 @@ namespace System // instantiate stubs for commonly used methods on IDictionary and ICollection> V dummy; - mapToDictionaryAdapter.Indexer_Get(default(K)); - mapToDictionaryAdapter.Indexer_Set(default(K), default(V)); - mapToDictionaryAdapter.ContainsKey(default(K)); - mapToDictionaryAdapter.Add(default(K), default(V)); - mapToDictionaryAdapter.Remove(default(K)); - mapToDictionaryAdapter.TryGetValue(default(K), out dummy); + mapToDictionaryAdapter.Indexer_Get(default); + mapToDictionaryAdapter.Indexer_Set(default, default); + mapToDictionaryAdapter.ContainsKey(default); + mapToDictionaryAdapter.Add(default, default); + mapToDictionaryAdapter.Remove(default); + mapToDictionaryAdapter.TryGetValue(default, out dummy); mapToCollectionAdapter.Count(); - mapToCollectionAdapter.Add(new KeyValuePair(default(K), default(V))); + mapToCollectionAdapter.Add(new KeyValuePair(default, default)); mapToCollectionAdapter.Clear(); // instantiate stubs for commonly used methods on IMap - dictionaryToMapAdapter.Lookup(default(K)); + dictionaryToMapAdapter.Lookup(default); dictionaryToMapAdapter.Size(); - dictionaryToMapAdapter.HasKey(default(K)); - dictionaryToMapAdapter.Insert(default(K), default(V)); - dictionaryToMapAdapter.Remove(default(K)); + dictionaryToMapAdapter.HasKey(default); + dictionaryToMapAdapter.Insert(default, default); + dictionaryToMapAdapter.Remove(default); dictionaryToMapAdapter.Clear(); } @@ -332,17 +332,17 @@ namespace System // instantiate stubs for commonly used methods on IReadOnlyDictionary V dummy; - mapToDictionaryAdapter.Indexer_Get(default(K)); - mapToDictionaryAdapter.ContainsKey(default(K)); - mapToDictionaryAdapter.TryGetValue(default(K), out dummy); + mapToDictionaryAdapter.Indexer_Get(default); + mapToDictionaryAdapter.ContainsKey(default); + mapToDictionaryAdapter.TryGetValue(default, out dummy); // instantiate stubs for commonly used methods in IReadOnlyCollection mapViewToReadOnlyCollectionAdapter.Count(); // instantiate stubs for commonly used methods on IMapView - dictionaryToMapAdapter.Lookup(default(K)); + dictionaryToMapAdapter.Lookup(default); dictionaryToMapAdapter.Size(); - dictionaryToMapAdapter.HasKey(default(K)); + dictionaryToMapAdapter.HasKey(default); } private static void WinRT_Nullable() where T : struct diff --git a/src/System.Private.CoreLib/src/System/Object.cs b/src/System.Private.CoreLib/src/System/Object.cs index 8d74aae..01e60ce 100644 --- a/src/System.Private.CoreLib/src/System/Object.cs +++ b/src/System.Private.CoreLib/src/System/Object.cs @@ -46,7 +46,7 @@ namespace System // Returns a String which represents the object instance. The default // for an object is to return the fully qualified name of the class. // - public virtual String ToString() + public virtual string ToString() { return GetType().ToString(); } @@ -118,7 +118,7 @@ namespace System // Sets the value specified in the variant on the field // - private void FieldSetter(String typeName, String fieldName, Object val) + private void FieldSetter(string typeName, string fieldName, Object val) { Debug.Assert(typeName != null); Debug.Assert(fieldName != null); @@ -148,7 +148,7 @@ namespace System // Gets the value specified in the variant on the field // - private void FieldGetter(String typeName, String fieldName, ref Object val) + private void FieldGetter(string typeName, string fieldName, ref Object val) { Debug.Assert(typeName != null); Debug.Assert(fieldName != null); @@ -162,7 +162,7 @@ namespace System // Gets the field info object given the type name and field name. // - private FieldInfo GetFieldInfo(String typeName, String fieldName) + private FieldInfo GetFieldInfo(string typeName, string fieldName) { Debug.Assert(typeName != null); Debug.Assert(fieldName != null); @@ -213,7 +213,7 @@ namespace System public static string FixupCoreLibName(string strToFixup) { - if (!String.IsNullOrEmpty(strToFixup)) + if (!string.IsNullOrEmpty(strToFixup)) { strToFixup = strToFixup.Replace("mscorlib", System.CoreLib.Name); } diff --git a/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs b/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs index fb102c1..d541c4c 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs @@ -481,13 +481,13 @@ namespace System.Reflection { string ctorArgs = ""; for (int i = 0; i < ConstructorArguments.Count; i++) - ctorArgs += String.Format(CultureInfo.CurrentCulture, i == 0 ? "{0}" : ", {0}", ConstructorArguments[i]); + ctorArgs += string.Format(CultureInfo.CurrentCulture, i == 0 ? "{0}" : ", {0}", ConstructorArguments[i]); string namedArgs = ""; for (int i = 0; i < NamedArguments.Count; i++) - namedArgs += String.Format(CultureInfo.CurrentCulture, i == 0 && ctorArgs.Length == 0 ? "{0}" : ", {0}", NamedArguments[i]); + namedArgs += string.Format(CultureInfo.CurrentCulture, i == 0 && ctorArgs.Length == 0 ? "{0}" : ", {0}", NamedArguments[i]); - return String.Format(CultureInfo.CurrentCulture, "[{0}({1}{2})]", Constructor.DeclaringType.FullName, ctorArgs, namedArgs); + return string.Format(CultureInfo.CurrentCulture, "[{0}({1}{2})]", Constructor.DeclaringType.FullName, ctorArgs, namedArgs); } public override int GetHashCode() { @@ -615,7 +615,7 @@ namespace System.Reflection if (m_memberInfo == null) return base.ToString(); - return String.Format(CultureInfo.CurrentCulture, "{0} = {1}", MemberInfo.Name, TypedValue.ToString(ArgumentType != typeof(object))); + return string.Format(CultureInfo.CurrentCulture, "{0} = {1}", MemberInfo.Name, TypedValue.ToString(ArgumentType != typeof(object))); } public override int GetHashCode() { @@ -772,7 +772,7 @@ namespace System.Reflection if (type == null) throw new InvalidOperationException( - String.Format(CultureInfo.CurrentUICulture, SR.Arg_CATypeResolutionFailed, typeName)); + string.Format(CultureInfo.CurrentUICulture, SR.Arg_CATypeResolutionFailed, typeName)); return type; } @@ -887,19 +887,19 @@ namespace System.Reflection return base.ToString(); if (ArgumentType.IsEnum) - return String.Format(CultureInfo.CurrentCulture, typed ? "{0}" : "({1}){0}", Value, ArgumentType.FullName); + return string.Format(CultureInfo.CurrentCulture, typed ? "{0}" : "({1}){0}", Value, ArgumentType.FullName); else if (Value == null) - return String.Format(CultureInfo.CurrentCulture, typed ? "null" : "({0})null", ArgumentType.Name); + return string.Format(CultureInfo.CurrentCulture, typed ? "null" : "({0})null", ArgumentType.Name); else if (ArgumentType == typeof(string)) - return String.Format(CultureInfo.CurrentCulture, "\"{0}\"", Value); + return string.Format(CultureInfo.CurrentCulture, "\"{0}\"", Value); else if (ArgumentType == typeof(char)) - return String.Format(CultureInfo.CurrentCulture, "'{0}'", Value); + return string.Format(CultureInfo.CurrentCulture, "'{0}'", Value); else if (ArgumentType == typeof(Type)) - return String.Format(CultureInfo.CurrentCulture, "typeof({0})", ((Type)Value).FullName); + return string.Format(CultureInfo.CurrentCulture, "typeof({0})", ((Type)Value).FullName); else if (ArgumentType.IsArray) { @@ -907,15 +907,15 @@ namespace System.Reflection IList array = Value as IList; Type elementType = ArgumentType.GetElementType(); - result = String.Format(CultureInfo.CurrentCulture, @"new {0}[{1}] {{ ", elementType.IsEnum ? elementType.FullName : elementType.Name, array.Count); + result = string.Format(CultureInfo.CurrentCulture, @"new {0}[{1}] {{ ", elementType.IsEnum ? elementType.FullName : elementType.Name, array.Count); for (int i = 0; i < array.Count; i++) - result += String.Format(CultureInfo.CurrentCulture, i == 0 ? "{0}" : ", {0}", array[i].ToString(elementType != typeof(object))); + result += string.Format(CultureInfo.CurrentCulture, i == 0 ? "{0}" : ", {0}", array[i].ToString(elementType != typeof(object))); return result += " }"; } - return String.Format(CultureInfo.CurrentCulture, typed ? "{0}" : "({1}){0}", Value, ArgumentType.Name); + return string.Format(CultureInfo.CurrentCulture, typed ? "{0}" : "({1}){0}", Value, ArgumentType.Name); } public override int GetHashCode() @@ -1600,7 +1600,7 @@ namespace System.Reflection if (property == null) { throw new CustomAttributeFormatException( - String.Format(CultureInfo.CurrentUICulture, + string.Format(CultureInfo.CurrentUICulture, isProperty ? SR.RFLCT_InvalidPropFail : SR.RFLCT_InvalidFieldFail, name)); } @@ -1624,7 +1624,7 @@ namespace System.Reflection catch (Exception e) { throw new CustomAttributeFormatException( - String.Format(CultureInfo.CurrentUICulture, + string.Format(CultureInfo.CurrentUICulture, isProperty ? SR.RFLCT_InvalidPropFail : SR.RFLCT_InvalidFieldFail, name), e); } #endregion @@ -1797,7 +1797,7 @@ namespace System.Reflection continue; if (attributeUsageAttribute != null) - throw new FormatException(String.Format( + throw new FormatException(string.Format( CultureInfo.CurrentUICulture, SR.Format_AttributeUsage, attributeType)); AttributeTargets targets; diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs index 5ecf0be..5f26578 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs @@ -184,7 +184,7 @@ namespace System.Reflection.Emit PutInteger4(token); } - public override void Emit(OpCode opcode, String str) + public override void Emit(OpCode opcode, string str) { if (str == null) throw new ArgumentNullException(nameof(str)); @@ -414,7 +414,7 @@ namespace System.Reflection.Emit // debugger related calls. // // - public override void UsingNamespace(String ns) + public override void UsingNamespace(string ns) { throw new NotSupportedException(SR.InvalidOperation_NotAllowedInDynamicMethod); } @@ -554,7 +554,7 @@ namespace System.Reflection.Emit return m_scope.GetTokenFor(varArgMeth); } - private int GetTokenForString(String s) + private int GetTokenForString(string s) { return m_scope.GetTokenFor(s); } @@ -785,7 +785,7 @@ namespace System.Reflection.Emit } } - internal override String GetStringLiteral(int token) { return m_scope.GetString(token); } + internal override string GetStringLiteral(int token) { return m_scope.GetString(token); } internal override void ResolveToken(int token, out IntPtr typeHandle, out IntPtr methodHandle, out IntPtr fieldHandle) @@ -975,7 +975,7 @@ namespace System.Reflection.Emit MethodBase m = RuntimeType.GetMethodBase(methodReal); Type t = m.DeclaringType.GetGenericTypeDefinition(); - throw new ArgumentException(String.Format( + throw new ArgumentException(string.Format( CultureInfo.CurrentCulture, SR.Argument_MethodDeclaringTypeGenericLcg, m, t)); } } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.cs index 38aaab2..1e4d308 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.cs @@ -31,7 +31,7 @@ namespace System.Reflection.Emit // Define literal for enum - public FieldBuilder DefineLiteral(String literalName, Object literalValue) + public FieldBuilder DefineLiteral(string literalName, Object literalValue) { // Define the underlying field for the enum. It will be a non-static, private field with special name bit set. FieldBuilder fieldBuilder = m_typeBuilder.DefineField( @@ -66,7 +66,7 @@ namespace System.Reflection.Emit get { return m_underlyingField; } } - public override String Name + public override string Name { get { return m_typeBuilder.Name; } } @@ -85,14 +85,14 @@ namespace System.Reflection.Emit } public override Object InvokeMember( - String name, + string name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, - String[] namedParameters) + string[] namedParameters) { return m_typeBuilder.InvokeMember(name, invokeAttr, binder, target, args, modifiers, culture, namedParameters); } @@ -112,12 +112,12 @@ namespace System.Reflection.Emit get { return m_typeBuilder.TypeHandle; } } - public override String FullName + public override string FullName { get { return m_typeBuilder.FullName; } } - public override String AssemblyQualifiedName + public override string AssemblyQualifiedName { get { @@ -125,7 +125,7 @@ namespace System.Reflection.Emit } } - public override String Namespace + public override string Namespace { get { return m_typeBuilder.Namespace; } } @@ -147,7 +147,7 @@ namespace System.Reflection.Emit return m_typeBuilder.GetConstructors(bindingAttr); } - protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, + protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { if (types == null) @@ -161,7 +161,7 @@ namespace System.Reflection.Emit return m_typeBuilder.GetMethods(bindingAttr); } - public override FieldInfo GetField(String name, BindingFlags bindingAttr) + public override FieldInfo GetField(string name, BindingFlags bindingAttr) { return m_typeBuilder.GetField(name, bindingAttr); } @@ -171,7 +171,7 @@ namespace System.Reflection.Emit return m_typeBuilder.GetFields(bindingAttr); } - public override Type GetInterface(String name, bool ignoreCase) + public override Type GetInterface(string name, bool ignoreCase) { return m_typeBuilder.GetInterface(name, ignoreCase); } @@ -181,7 +181,7 @@ namespace System.Reflection.Emit return m_typeBuilder.GetInterfaces(); } - public override EventInfo GetEvent(String name, BindingFlags bindingAttr) + public override EventInfo GetEvent(string name, BindingFlags bindingAttr) { return m_typeBuilder.GetEvent(name, bindingAttr); } @@ -191,7 +191,7 @@ namespace System.Reflection.Emit return m_typeBuilder.GetEvents(); } - protected override PropertyInfo GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, + protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(SR.NotSupported_DynamicModule); @@ -207,12 +207,12 @@ namespace System.Reflection.Emit return m_typeBuilder.GetNestedTypes(bindingAttr); } - public override Type GetNestedType(String name, BindingFlags bindingAttr) + public override Type GetNestedType(string name, BindingFlags bindingAttr) { return m_typeBuilder.GetNestedType(name, bindingAttr); } - public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr) + public override MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr) { return m_typeBuilder.GetMember(name, type, bindingAttr); } @@ -384,7 +384,7 @@ namespace System.Reflection.Emit szrank += ","; } - string s = String.Format(CultureInfo.InvariantCulture, "[{0}]", szrank); // [,,] + string s = string.Format(CultureInfo.InvariantCulture, "[{0}]", szrank); // [,,] return SymbolType.FormCompoundType(s, this, 0); } @@ -392,7 +392,7 @@ namespace System.Reflection.Emit // Constructs a EnumBuilder. // EnumBuilder can only be a top-level (not nested) enum type. internal EnumBuilder( - String name, // name of type + string name, // name of type Type underlyingType, // underlying type for an Enum TypeAttributes visibility, // any bits on TypeAttributes.VisibilityMask) ModuleBuilder module) // module containing this type diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs index 4da7b65..a79e884 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs @@ -32,7 +32,7 @@ namespace System.Reflection.Emit #endregion #region Object Overrides - public override String ToString() + public override string ToString() { return m_type.Name; } @@ -53,7 +53,7 @@ namespace System.Reflection.Emit public override Type ReflectedType { get { return m_type.ReflectedType; } } - public override String Name { get { return m_type.Name; } } + public override string Name { get { return m_type.Name; } } public override Module Module { get { return m_type.Module; } } @@ -93,24 +93,24 @@ namespace System.Reflection.Emit szrank += ","; } - string s = String.Format(CultureInfo.InvariantCulture, "[{0}]", szrank); // [,,] + string s = string.Format(CultureInfo.InvariantCulture, "[{0}]", szrank); // [,,] SymbolType st = SymbolType.FormCompoundType(s, this, 0) as SymbolType; return st; } public override Guid GUID { get { throw new NotSupportedException(); } } - public override Object InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) { throw new NotSupportedException(); } + public override Object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) { throw new NotSupportedException(); } public override Assembly Assembly { get { return m_type.Assembly; } } public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } } - public override String FullName { get { return null; } } + public override string FullName { get { return null; } } - public override String Namespace { get { return null; } } + public override string Namespace { get { return null; } } - public override String AssemblyQualifiedName { get { return null; } } + public override string AssemblyQualifiedName { get { return null; } } public override Type BaseType { get { return m_type.BaseType; } } @@ -118,31 +118,31 @@ namespace System.Reflection.Emit public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) { throw new NotSupportedException(); } - protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); } + protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); } public override MethodInfo[] GetMethods(BindingFlags bindingAttr) { throw new NotSupportedException(); } - public override FieldInfo GetField(String name, BindingFlags bindingAttr) { throw new NotSupportedException(); } + public override FieldInfo GetField(string name, BindingFlags bindingAttr) { throw new NotSupportedException(); } public override FieldInfo[] GetFields(BindingFlags bindingAttr) { throw new NotSupportedException(); } - public override Type GetInterface(String name, bool ignoreCase) { throw new NotSupportedException(); } + public override Type GetInterface(string name, bool ignoreCase) { throw new NotSupportedException(); } public override Type[] GetInterfaces() { throw new NotSupportedException(); } - public override EventInfo GetEvent(String name, BindingFlags bindingAttr) { throw new NotSupportedException(); } + public override EventInfo GetEvent(string name, BindingFlags bindingAttr) { throw new NotSupportedException(); } public override EventInfo[] GetEvents() { throw new NotSupportedException(); } - protected override PropertyInfo GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); } + protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); } public override PropertyInfo[] GetProperties(BindingFlags bindingAttr) { throw new NotSupportedException(); } public override Type[] GetNestedTypes(BindingFlags bindingAttr) { throw new NotSupportedException(); } - public override Type GetNestedType(String name, BindingFlags bindingAttr) { throw new NotSupportedException(); } + public override Type GetNestedType(string name, BindingFlags bindingAttr) { throw new NotSupportedException(); } - public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr) { throw new NotSupportedException(); } + public override MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr) { throw new NotSupportedException(); } public override InterfaceMapping GetInterfaceMap(Type interfaceType) { throw new NotSupportedException(); } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs index 9b2d878..62c6f26 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs @@ -53,12 +53,12 @@ namespace System.Reflection.Emit #region FCalls [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern IntPtr nCreateISymWriterForDynamicModule(Module module, String filename); + internal static extern IntPtr nCreateISymWriterForDynamicModule(Module module, string filename); #endregion #region Internal Static Members - internal static String UnmangleTypeName(String typeName) + internal static string UnmangleTypeName(string typeName) { // Gets the original type name, without '+' name mangling. @@ -112,7 +112,7 @@ namespace System.Reflection.Emit m_TypeBuilderDict.Add(name, type); } - internal void CheckTypeNameConflict(String strTypeName, Type enclosingType) + internal void CheckTypeNameConflict(string strTypeName, Type enclosingType) { Type foundType = null; if (m_TypeBuilderDict.TryGetValue(strTypeName, out foundType) && @@ -123,11 +123,11 @@ namespace System.Reflection.Emit } } - private Type GetType(String strFormat, Type baseType) + private Type GetType(string strFormat, Type baseType) { // This function takes a string to describe the compound type, such as "[,][]", and a baseType. - if (strFormat == null || strFormat.Equals(String.Empty)) + if (strFormat == null || strFormat.Equals(string.Empty)) { return baseType; } @@ -148,7 +148,7 @@ namespace System.Reflection.Emit [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - private static extern int GetTypeRef(RuntimeModule module, String strFullName, RuntimeModule refedModule, String strRefedModuleFileName, int tkResolution); + private static extern int GetTypeRef(RuntimeModule module, string strFullName, RuntimeModule refedModule, string strRefedModuleFileName, int tkResolution); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] private static extern int GetMemberRef(RuntimeModule module, RuntimeModule refedModule, int tr, int defToken); @@ -159,9 +159,9 @@ namespace System.Reflection.Emit } [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - private static extern int GetMemberRefFromSignature(RuntimeModule module, int tr, String methodName, byte[] signature, int length); + private static extern int GetMemberRefFromSignature(RuntimeModule module, int tr, string methodName, byte[] signature, int length); - private int GetMemberRefFromSignature(int tr, String methodName, byte[] signature, int length) + private int GetMemberRefFromSignature(int tr, string methodName, byte[] signature, int length) { return GetMemberRefFromSignature(GetNativeHandle(), tr, methodName, signature, length); } @@ -202,10 +202,10 @@ namespace System.Reflection.Emit } [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - private static extern int GetArrayMethodToken(RuntimeModule module, int tkTypeSpec, String methodName, byte[] signature, int sigLength); + private static extern int GetArrayMethodToken(RuntimeModule module, int tkTypeSpec, string methodName, byte[] signature, int sigLength); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - private static extern int GetStringConstant(RuntimeModule module, String str, int length); + private static extern int GetStringConstant(RuntimeModule module, string str, int length); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] internal static extern void SetFieldRVAContent(RuntimeModule module, int fdToken, byte[] data, int length); @@ -213,13 +213,13 @@ namespace System.Reflection.Emit #endregion #region Internal Members - internal virtual Type FindTypeBuilderWithName(String strTypeName, bool ignoreCase) + internal virtual Type FindTypeBuilderWithName(string strTypeName, bool ignoreCase) { if (ignoreCase) { foreach (string name in m_TypeBuilderDict.Keys) { - if (String.Compare(name, strTypeName, (StringComparison.OrdinalIgnoreCase)) == 0) + if (string.Compare(name, strTypeName, (StringComparison.OrdinalIgnoreCase)) == 0) return m_TypeBuilderDict[name]; } } @@ -233,13 +233,13 @@ namespace System.Reflection.Emit return null; } - private int GetTypeRefNested(Type type, Module refedModule, String strRefedModuleFileName) + private int GetTypeRefNested(Type type, Module refedModule, string strRefedModuleFileName) { // This function will generate correct TypeRef token for top level type and nested type. Type enclosingType = type.DeclaringType; int tkResolution = 0; - String typeName = type.FullName; + string typeName = type.FullName; if (enclosingType != null) { @@ -325,7 +325,7 @@ namespace System.Reflection.Emit return new MethodToken(mr); } - internal void Init(String strModuleName, String strFileName, int tkFile) + internal void Init(string strModuleName, string strFileName, int tkFile) { m_moduleData = new ModuleBuilderData(this, strModuleName, strFileName, tkFile); m_TypeBuilderDict = new Dictionary(); @@ -585,17 +585,17 @@ namespace System.Reflection.Emit return typeList; } - public override Type GetType(String className) + public override Type GetType(string className) { return GetType(className, false, false); } - public override Type GetType(String className, bool ignoreCase) + public override Type GetType(string className, bool ignoreCase) { return GetType(className, false, ignoreCase); } - public override Type GetType(String className, bool throwOnError, bool ignoreCase) + public override Type GetType(string className, bool throwOnError, bool ignoreCase) { lock (SyncRoot) { @@ -603,7 +603,7 @@ namespace System.Reflection.Emit } } - private Type GetTypeNoLock(String className, bool throwOnError, bool ignoreCase) + private Type GetTypeNoLock(string className, bool throwOnError, bool ignoreCase) { // public API to to a type. The reason that we need this function override from module // is because clients might need to get foo[] when foo is being built. For example, if @@ -620,8 +620,8 @@ namespace System.Reflection.Emit // Now try to see if we contain a TypeBuilder for this type or not. // Might have a compound type name, indicated via an unescaped // '[', '*' or '&'. Split the name at this point. - String baseName = null; - String parameters = null; + string baseName = null; + string parameters = null; int startIndex = 0; while (startIndex <= className.Length) @@ -701,7 +701,7 @@ namespace System.Reflection.Emit return GetType(parameters, baseType); } - public override String FullyQualifiedName + public override string FullyQualifiedName { get { @@ -778,7 +778,7 @@ namespace System.Reflection.Emit return InternalModule.GetFields(bindingFlags); } - public override FieldInfo GetField(String name, BindingFlags bindingAttr) + public override FieldInfo GetField(string name, BindingFlags bindingAttr) { return InternalModule.GetField(name, bindingAttr); } @@ -788,14 +788,14 @@ namespace System.Reflection.Emit return InternalModule.GetMethods(bindingFlags); } - protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, + protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { // Cannot call InternalModule.GetMethods because it doesn't allow types to be null return InternalModule.GetMethodInternal(name, bindingAttr, binder, callConvention, types, modifiers); } - public override String ScopeName + public override string ScopeName { get { @@ -803,7 +803,7 @@ namespace System.Reflection.Emit } } - public override String Name + public override string Name { get { @@ -824,7 +824,7 @@ namespace System.Reflection.Emit #region Public Members #region Define Type - public TypeBuilder DefineType(String name) + public TypeBuilder DefineType(string name) { lock (SyncRoot) { @@ -832,7 +832,7 @@ namespace System.Reflection.Emit } } - public TypeBuilder DefineType(String name, TypeAttributes attr) + public TypeBuilder DefineType(string name, TypeAttributes attr) { lock (SyncRoot) { @@ -840,7 +840,7 @@ namespace System.Reflection.Emit } } - public TypeBuilder DefineType(String name, TypeAttributes attr, Type parent) + public TypeBuilder DefineType(string name, TypeAttributes attr, Type parent) { lock (SyncRoot) { @@ -851,7 +851,7 @@ namespace System.Reflection.Emit } } - public TypeBuilder DefineType(String name, TypeAttributes attr, Type parent, int typesize) + public TypeBuilder DefineType(string name, TypeAttributes attr, Type parent, int typesize) { lock (SyncRoot) { @@ -859,7 +859,7 @@ namespace System.Reflection.Emit } } - public TypeBuilder DefineType(String name, TypeAttributes attr, Type parent, PackingSize packingSize, int typesize) + public TypeBuilder DefineType(string name, TypeAttributes attr, Type parent, PackingSize packingSize, int typesize) { lock (SyncRoot) { @@ -867,7 +867,7 @@ namespace System.Reflection.Emit } } - public TypeBuilder DefineType(String name, TypeAttributes attr, Type parent, Type[] interfaces) + public TypeBuilder DefineType(string name, TypeAttributes attr, Type parent, Type[] interfaces) { lock (SyncRoot) { @@ -875,12 +875,12 @@ namespace System.Reflection.Emit } } - private TypeBuilder DefineTypeNoLock(String name, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packingSize, int typesize) + private TypeBuilder DefineTypeNoLock(string name, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packingSize, int typesize) { return new TypeBuilder(name, attr, parent, interfaces, this, packingSize, typesize, null); ; } - public TypeBuilder DefineType(String name, TypeAttributes attr, Type parent, PackingSize packsize) + public TypeBuilder DefineType(string name, TypeAttributes attr, Type parent, PackingSize packsize) { lock (SyncRoot) { @@ -888,7 +888,7 @@ namespace System.Reflection.Emit } } - private TypeBuilder DefineTypeNoLock(String name, TypeAttributes attr, Type parent, PackingSize packsize) + private TypeBuilder DefineTypeNoLock(string name, TypeAttributes attr, Type parent, PackingSize packsize) { return new TypeBuilder(name, attr, parent, null, this, packsize, TypeBuilder.UnspecifiedTypeSize, null); } @@ -899,7 +899,7 @@ namespace System.Reflection.Emit // This API can only be used to construct a top-level (not nested) enum type. // Nested enum types can be defined manually using ModuleBuilder.DefineType. - public EnumBuilder DefineEnum(String name, TypeAttributes visibility, Type underlyingType) + public EnumBuilder DefineEnum(string name, TypeAttributes visibility, Type underlyingType) { CheckContext(underlyingType); lock (SyncRoot) @@ -923,7 +923,7 @@ namespace System.Reflection.Emit } } - private EnumBuilder DefineEnumNoLock(String name, TypeAttributes visibility, Type underlyingType) + private EnumBuilder DefineEnumNoLock(string name, TypeAttributes visibility, Type underlyingType) { return new EnumBuilder(name, underlyingType, visibility, this); } @@ -935,18 +935,18 @@ namespace System.Reflection.Emit #endregion #region Define Global Method - public MethodBuilder DefineGlobalMethod(String name, MethodAttributes attributes, Type returnType, Type[] parameterTypes) + public MethodBuilder DefineGlobalMethod(string name, MethodAttributes attributes, Type returnType, Type[] parameterTypes) { return DefineGlobalMethod(name, attributes, CallingConventions.Standard, returnType, parameterTypes); } - public MethodBuilder DefineGlobalMethod(String name, MethodAttributes attributes, CallingConventions callingConvention, + public MethodBuilder DefineGlobalMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { return DefineGlobalMethod(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null); } - public MethodBuilder DefineGlobalMethod(String name, MethodAttributes attributes, CallingConventions callingConvention, + public MethodBuilder DefineGlobalMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { @@ -958,7 +958,7 @@ namespace System.Reflection.Emit } } - private MethodBuilder DefineGlobalMethodNoLock(String name, MethodAttributes attributes, CallingConventions callingConvention, + private MethodBuilder DefineGlobalMethodNoLock(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] requiredReturnTypeCustomModifiers, Type[] optionalReturnTypeCustomModifiers, Type[] parameterTypes, Type[][] requiredParameterTypeCustomModifiers, Type[][] optionalParameterTypeCustomModifiers) { @@ -1009,7 +1009,7 @@ namespace System.Reflection.Emit #region Define Data - public FieldBuilder DefineInitializedData(String name, byte[] data, FieldAttributes attributes) + public FieldBuilder DefineInitializedData(string name, byte[] data, FieldAttributes attributes) { // This method will define an initialized Data in .sdata. // We will create a fake TypeDef to represent the data with size. This TypeDef @@ -1021,7 +1021,7 @@ namespace System.Reflection.Emit } } - private FieldBuilder DefineInitializedDataNoLock(String name, byte[] data, FieldAttributes attributes) + private FieldBuilder DefineInitializedDataNoLock(string name, byte[] data, FieldAttributes attributes) { // This method will define an initialized Data in .sdata. // We will create a fake TypeDef to represent the data with size. This TypeDef @@ -1035,7 +1035,7 @@ namespace System.Reflection.Emit return m_moduleData.m_globalTypeBuilder.DefineInitializedData(name, data, attributes); } - public FieldBuilder DefineUninitializedData(String name, int size, FieldAttributes attributes) + public FieldBuilder DefineUninitializedData(string name, int size, FieldAttributes attributes) { lock (SyncRoot) { @@ -1043,7 +1043,7 @@ namespace System.Reflection.Emit } } - private FieldBuilder DefineUninitializedDataNoLock(String name, int size, FieldAttributes attributes) + private FieldBuilder DefineUninitializedDataNoLock(string name, int size, FieldAttributes attributes) { // This method will define an uninitialized Data in .sdata. // We will create a fake TypeDef to represent the data with size. This TypeDef @@ -1139,7 +1139,7 @@ namespace System.Reflection.Emit return new TypeToken(paramBuilder.MetadataTokenInternal); } - return new TypeToken(GetTypeRefNested(type, this, String.Empty)); + return new TypeToken(GetTypeRefNested(type, this, string.Empty)); } // After this point, the referenced module is not the same as the referencing @@ -1147,7 +1147,7 @@ namespace System.Reflection.Emit // ModuleBuilder refedModuleBuilder = refedModule as ModuleBuilder; - String strRefedModuleFileName = String.Empty; + string strRefedModuleFileName = string.Empty; if (refedModule.Assembly.Equals(this.Assembly)) { // if the referenced module is in the same assembly, the resolution @@ -1166,7 +1166,7 @@ namespace System.Reflection.Emit return new TypeToken(GetTypeRefNested(type, refedModule, strRefedModuleFileName)); } - public TypeToken GetTypeToken(String name) + public TypeToken GetTypeToken(string name) { // Return a token for the class relative to the Module. // Module.GetType() verifies name @@ -1371,7 +1371,7 @@ namespace System.Reflection.Emit return tk; } - public MethodToken GetArrayMethodToken(Type arrayClass, String methodName, CallingConventions callingConvention, + public MethodToken GetArrayMethodToken(Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { lock (SyncRoot) @@ -1380,7 +1380,7 @@ namespace System.Reflection.Emit } } - private MethodToken GetArrayMethodTokenNoLock(Type arrayClass, String methodName, CallingConventions callingConvention, + private MethodToken GetArrayMethodTokenNoLock(Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { if (arrayClass == null) @@ -1414,7 +1414,7 @@ namespace System.Reflection.Emit typeSpec.Token, methodName, sigBytes, length)); } - public MethodInfo GetArrayMethod(Type arrayClass, String methodName, CallingConventions callingConvention, + public MethodInfo GetArrayMethod(Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { CheckContext(returnType, arrayClass); @@ -1532,7 +1532,7 @@ namespace System.Reflection.Emit return new FieldToken(mr, field.GetType()); } - public StringToken GetStringConstant(String str) + public StringToken GetStringConstant(string str) { if (str == null) { @@ -1635,7 +1635,7 @@ namespace System.Reflection.Emit return m_iSymWriter; } - public ISymbolDocumentWriter DefineDocument(String url, Guid language, Guid languageVendor, Guid documentType) + public ISymbolDocumentWriter DefineDocument(string url, Guid language, Guid languageVendor, Guid documentType) { // url cannot be null but can be an empty string if (url == null) @@ -1647,7 +1647,7 @@ namespace System.Reflection.Emit } } - private ISymbolDocumentWriter DefineDocumentNoLock(String url, Guid language, Guid languageVendor, Guid documentType) + private ISymbolDocumentWriter DefineDocumentNoLock(string url, Guid language, Guid languageVendor, Guid documentType) { if (m_iSymWriter == null) { diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilderData.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilderData.cs index 0364ae5..066bb24 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilderData.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilderData.cs @@ -16,7 +16,7 @@ namespace System.Reflection.Emit // this class cannot be accessed from the EE. internal class ModuleBuilderData { - internal ModuleBuilderData(ModuleBuilder module, String strModuleName, String strFileName, int tkFile) + internal ModuleBuilderData(ModuleBuilder module, string strModuleName, string strFileName, int tkFile) { m_globalTypeBuilder = new TypeBuilder(module); m_module = module; @@ -26,7 +26,7 @@ namespace System.Reflection.Emit } // Initialize module and file names. - private void InitNames(String strModuleName, String strFileName) + private void InitNames(string strModuleName, string strFileName) { m_strModuleName = strModuleName; if (strFileName == null) @@ -36,8 +36,8 @@ namespace System.Reflection.Emit } else { - String strExtension = Path.GetExtension(strFileName); - if (strExtension == null || strExtension == String.Empty) + string strExtension = Path.GetExtension(strFileName); + 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(SR.Format(SR.Argument_NoModuleFileExtension, strFileName)); @@ -46,8 +46,8 @@ namespace System.Reflection.Emit } } - internal String m_strModuleName; // scope name (can be different from file name) - internal String m_strFileName; + internal string m_strModuleName; // scope name (can be different from file name) + internal string m_strFileName; internal bool m_fGlobalBeenCreated; internal bool m_fHasGlobal; internal TypeBuilder m_globalTypeBuilder; @@ -55,8 +55,8 @@ namespace System.Reflection.Emit private int m_tkFile; internal bool m_isSaved; - internal const String MULTI_BYTE_VALUE_CLASS = "$ArrayType$"; - internal String m_strResourceFileName; + internal const string MULTI_BYTE_VALUE_CLASS = "$ArrayType$"; + internal string m_strResourceFileName; internal byte[] m_resourceBytes; } } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolType.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolType.cs index 6057c1d..07fd6d9 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolType.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolType.cs @@ -304,7 +304,7 @@ namespace System.Reflection.Emit szrank += ","; } - string s = String.Format(CultureInfo.InvariantCulture, "[{0}]", szrank); // [,,] + string s = string.Format(CultureInfo.InvariantCulture, "[{0}]", szrank); // [,,] SymbolType st = SymbolType.FormCompoundType(m_format + s, m_baseType, 0) as SymbolType; return st; } @@ -322,8 +322,8 @@ namespace System.Reflection.Emit 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) + public override Object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, Object target, + Object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) { throw new NotSupportedException(SR.NotSupported_NonReflectedType); } @@ -356,12 +356,12 @@ namespace System.Reflection.Emit get { throw new NotSupportedException(SR.NotSupported_NonReflectedType); } } - public override String Name + public override string Name { get { Type baseType; - String sFormat = m_format; + string sFormat = m_format; for (baseType = m_baseType; baseType is SymbolType; baseType = ((SymbolType)baseType).m_baseType) sFormat = ((SymbolType)baseType).m_format + sFormat; @@ -370,7 +370,7 @@ namespace System.Reflection.Emit } } - public override String FullName + public override string FullName { get { @@ -378,7 +378,7 @@ namespace System.Reflection.Emit } } - public override String AssemblyQualifiedName + public override string AssemblyQualifiedName { get { @@ -386,12 +386,12 @@ namespace System.Reflection.Emit } } - public override String ToString() + public override string ToString() { return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.ToString); } - public override String Namespace + public override string Namespace { get { return m_baseType.Namespace; } } @@ -412,7 +412,7 @@ namespace System.Reflection.Emit throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, + protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(SR.NotSupported_NonReflectedType); @@ -423,7 +423,7 @@ namespace System.Reflection.Emit throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - public override FieldInfo GetField(String name, BindingFlags bindingAttr) + public override FieldInfo GetField(string name, BindingFlags bindingAttr) { throw new NotSupportedException(SR.NotSupported_NonReflectedType); } @@ -433,7 +433,7 @@ namespace System.Reflection.Emit throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - public override Type GetInterface(String name, bool ignoreCase) + public override Type GetInterface(string name, bool ignoreCase) { throw new NotSupportedException(SR.NotSupported_NonReflectedType); } @@ -443,7 +443,7 @@ namespace System.Reflection.Emit throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - public override EventInfo GetEvent(String name, BindingFlags bindingAttr) + public override EventInfo GetEvent(string name, BindingFlags bindingAttr) { throw new NotSupportedException(SR.NotSupported_NonReflectedType); } @@ -453,7 +453,7 @@ namespace System.Reflection.Emit throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - protected override PropertyInfo GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, + protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(SR.NotSupported_NonReflectedType); @@ -469,12 +469,12 @@ namespace System.Reflection.Emit throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - public override Type GetNestedType(String name, BindingFlags bindingAttr) + public override Type GetNestedType(string name, BindingFlags bindingAttr) { throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr) + public override MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr) { throw new NotSupportedException(SR.NotSupported_NonReflectedType); } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs index 7fc7132..3f4a838 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs @@ -171,14 +171,14 @@ namespace System.Reflection.Emit #region Internal Static FCalls [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - internal static extern int DefineMethod(RuntimeModule module, int tkParent, String name, byte[] signature, int sigLength, + internal static extern int DefineMethod(RuntimeModule module, int tkParent, string name, byte[] signature, int sigLength, MethodAttributes attributes); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] internal static extern int DefineMethodSpec(RuntimeModule module, int tkParent, byte[] signature, int sigLength); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - internal static extern int DefineField(RuntimeModule module, int tkParent, String name, byte[] signature, int sigLength, + internal static extern int DefineField(RuntimeModule module, int tkParent, string name, byte[] signature, int sigLength, FieldAttributes attributes); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] @@ -209,11 +209,11 @@ namespace System.Reflection.Emit } [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - internal static extern int DefineProperty(RuntimeModule module, int tkParent, String name, PropertyAttributes attributes, + internal static extern int DefineProperty(RuntimeModule module, int tkParent, string name, PropertyAttributes attributes, byte[] signature, int sigLength); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - internal static extern int DefineEvent(RuntimeModule module, int tkParent, String name, EventAttributes attributes, int tkEventType); + internal static extern int DefineEvent(RuntimeModule module, int tkParent, string name, EventAttributes attributes, int tkEventType); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] internal static extern void DefineMethodSemantics(RuntimeModule module, int tkAssociation, @@ -227,7 +227,7 @@ namespace System.Reflection.Emit [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] internal static extern int SetParamInfo(RuntimeModule module, int tkMethod, int iSequence, - ParameterAttributes iParamAttributes, String strParamName); + ParameterAttributes iParamAttributes, string strParamName); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] internal static extern int GetTokenFromSig(RuntimeModule module, byte[] signature, int sigLength); @@ -382,7 +382,7 @@ namespace System.Reflection.Emit break; default: - if (type == typeof(String)) + if (type == typeof(string)) { fixed (char* pString = (string)value) SetConstantValue(module.GetNativeHandle(), tk, (int)CorElementType.String, pString); @@ -416,9 +416,9 @@ namespace System.Reflection.Emit private List m_ca; private TypeToken m_tdType; private ModuleBuilder m_module; - private String m_strName; - private String m_strNameSpace; - private String m_strFullQualName; + private string m_strName; + private string m_strNameSpace; + private string m_strFullQualName; private Type m_typeParent; private List m_typeInterfaces; private TypeAttributes m_iAttr; @@ -484,7 +484,7 @@ namespace System.Reflection.Emit } internal TypeBuilder( - String name, + string name, TypeAttributes attr, Type parent, Type[] interfaces, @@ -496,7 +496,7 @@ namespace System.Reflection.Emit Init(name, attr, parent, interfaces, module, iPackingSize, iTypeSize, enclosingType); } - private void Init(String fullname, TypeAttributes attr, Type parent, Type[] interfaces, ModuleBuilder module, + private void Init(string fullname, TypeAttributes attr, Type parent, Type[] interfaces, ModuleBuilder module, PackingSize iPackingSize, int iTypeSize, TypeBuilder enclosingType) { if (fullname == null) @@ -550,7 +550,7 @@ namespace System.Reflection.Emit if (iLast == -1 || iLast == 0) { // no name space - m_strNameSpace = String.Empty; + m_strNameSpace = string.Empty; m_strName = fullname; } else @@ -595,9 +595,9 @@ namespace System.Reflection.Emit #endregion #region Private Members - private FieldBuilder DefineDataHelper(String name, byte[] data, int size, FieldAttributes attributes) + private FieldBuilder DefineDataHelper(string name, byte[] data, int size, FieldAttributes attributes) { - String strValueClassName; + string strValueClassName; TypeBuilder valueClassType; FieldBuilder fdBuilder; TypeAttributes typeAttributes; @@ -679,11 +679,11 @@ namespace System.Reflection.Emit #region FCalls [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] private static extern int DefineType(RuntimeModule module, - String fullname, int tkParent, TypeAttributes attributes, int tkEnclosingType, int[] interfaceTokens); + string fullname, int tkParent, TypeAttributes attributes, int tkEnclosingType, int[] interfaceTokens); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] private static extern int DefineGenericParam(RuntimeModule module, - String name, int tkParent, GenericParameterAttributes attributes, int position, int[] constraints); + string name, int tkParent, GenericParameterAttributes attributes, int position, int[] constraints); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] private static extern void TermCreateClass(RuntimeModule module, int tk, ObjectHandleOnStack type); @@ -752,7 +752,7 @@ namespace System.Reflection.Emit #endregion #region Object Overrides - public override String ToString() + public override string ToString() { return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.ToString); } @@ -772,7 +772,7 @@ namespace System.Reflection.Emit get { return m_DeclaringType; } } - public override String Name + public override string Name { get { return m_strName; } } @@ -801,8 +801,8 @@ namespace System.Reflection.Emit } } - public override Object InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, - Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) + public override Object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, Object target, + Object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) { if (!IsCreated()) throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); @@ -820,7 +820,7 @@ namespace System.Reflection.Emit get { throw new NotSupportedException(SR.NotSupported_DynamicModule); } } - public override String FullName + public override string FullName { get { @@ -831,12 +831,12 @@ namespace System.Reflection.Emit } } - public override String Namespace + public override string Namespace { get { return m_strNameSpace; } } - public override String AssemblyQualifiedName + public override string AssemblyQualifiedName { get { @@ -866,7 +866,7 @@ namespace System.Reflection.Emit return m_bakedRuntimeType.GetConstructors(bindingAttr); } - protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, + protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { if (!IsCreated()) @@ -890,7 +890,7 @@ namespace System.Reflection.Emit return m_bakedRuntimeType.GetMethods(bindingAttr); } - public override FieldInfo GetField(String name, BindingFlags bindingAttr) + public override FieldInfo GetField(string name, BindingFlags bindingAttr) { if (!IsCreated()) throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); @@ -906,7 +906,7 @@ namespace System.Reflection.Emit return m_bakedRuntimeType.GetFields(bindingAttr); } - public override Type GetInterface(String name, bool ignoreCase) + public override Type GetInterface(string name, bool ignoreCase) { if (!IsCreated()) throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); @@ -929,7 +929,7 @@ namespace System.Reflection.Emit return m_typeInterfaces.ToArray(); } - public override EventInfo GetEvent(String name, BindingFlags bindingAttr) + public override EventInfo GetEvent(string name, BindingFlags bindingAttr) { if (!IsCreated()) throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); @@ -945,7 +945,7 @@ namespace System.Reflection.Emit return m_bakedRuntimeType.GetEvents(); } - protected override PropertyInfo GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, + protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(SR.NotSupported_DynamicModule); @@ -967,7 +967,7 @@ namespace System.Reflection.Emit return m_bakedRuntimeType.GetNestedTypes(bindingAttr); } - public override Type GetNestedType(String name, BindingFlags bindingAttr) + public override Type GetNestedType(string name, BindingFlags bindingAttr) { if (!IsCreated()) throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); @@ -975,7 +975,7 @@ namespace System.Reflection.Emit return m_bakedRuntimeType.GetNestedType(name, bindingAttr); } - public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr) + public override MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr) { if (!IsCreated()) throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); @@ -1185,7 +1185,7 @@ namespace System.Reflection.Emit szrank += ","; } - string s = String.Format(CultureInfo.InvariantCulture, "[{0}]", szrank); // [,,] + string s = string.Format(CultureInfo.InvariantCulture, "[{0}]", szrank); // [,,] return SymbolType.FormCompoundType(s, this, 0); } @@ -1326,28 +1326,28 @@ namespace System.Reflection.Emit DefineMethodImpl(m_module.GetNativeHandle(), m_tdType.Token, tkBody.Token, tkDecl.Token); } - public MethodBuilder DefineMethod(String name, MethodAttributes attributes, Type returnType, Type[] parameterTypes) + public MethodBuilder DefineMethod(string name, MethodAttributes attributes, Type returnType, Type[] parameterTypes) { return DefineMethod(name, attributes, CallingConventions.Standard, returnType, parameterTypes); } - public MethodBuilder DefineMethod(String name, MethodAttributes attributes) + public MethodBuilder DefineMethod(string name, MethodAttributes attributes) { return DefineMethod(name, attributes, CallingConventions.Standard, null, null); } - public MethodBuilder DefineMethod(String name, MethodAttributes attributes, CallingConventions callingConvention) + public MethodBuilder DefineMethod(string name, MethodAttributes attributes, CallingConventions callingConvention) { return DefineMethod(name, attributes, callingConvention, null, null); } - public MethodBuilder DefineMethod(String name, MethodAttributes attributes, CallingConventions callingConvention, + public MethodBuilder DefineMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { return DefineMethod(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null); } - public MethodBuilder DefineMethod(String name, MethodAttributes attributes, CallingConventions callingConvention, + public MethodBuilder DefineMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) { @@ -1359,7 +1359,7 @@ namespace System.Reflection.Emit } } - private MethodBuilder DefineMethodNoLock(String name, MethodAttributes attributes, CallingConventions callingConvention, + private MethodBuilder DefineMethodNoLock(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) { @@ -1534,7 +1534,7 @@ namespace System.Reflection.Emit ThrowIfCreated(); - String name; + string name; if ((attributes & MethodAttributes.Static) == 0) { @@ -1559,7 +1559,7 @@ namespace System.Reflection.Emit #endregion #region Define Nested Type - public TypeBuilder DefineNestedType(String name) + public TypeBuilder DefineNestedType(string name) { lock (SyncRoot) { @@ -1567,7 +1567,7 @@ namespace System.Reflection.Emit } } - public TypeBuilder DefineNestedType(String name, TypeAttributes attr, Type parent, Type[] interfaces) + public TypeBuilder DefineNestedType(string name, TypeAttributes attr, Type parent, Type[] interfaces) { lock (SyncRoot) { @@ -1579,7 +1579,7 @@ namespace System.Reflection.Emit } } - public TypeBuilder DefineNestedType(String name, TypeAttributes attr, Type parent) + public TypeBuilder DefineNestedType(string name, TypeAttributes attr, Type parent) { lock (SyncRoot) { @@ -1587,7 +1587,7 @@ namespace System.Reflection.Emit } } - public TypeBuilder DefineNestedType(String name, TypeAttributes attr) + public TypeBuilder DefineNestedType(string name, TypeAttributes attr) { lock (SyncRoot) { @@ -1595,7 +1595,7 @@ namespace System.Reflection.Emit } } - public TypeBuilder DefineNestedType(String name, TypeAttributes attr, Type parent, int typeSize) + public TypeBuilder DefineNestedType(string name, TypeAttributes attr, Type parent, int typeSize) { lock (SyncRoot) { @@ -1603,7 +1603,7 @@ namespace System.Reflection.Emit } } - public TypeBuilder DefineNestedType(String name, TypeAttributes attr, Type parent, PackingSize packSize) + public TypeBuilder DefineNestedType(string name, TypeAttributes attr, Type parent, PackingSize packSize) { lock (SyncRoot) { @@ -1611,7 +1611,7 @@ namespace System.Reflection.Emit } } - public TypeBuilder DefineNestedType(String name, TypeAttributes attr, Type parent, PackingSize packSize, int typeSize) + public TypeBuilder DefineNestedType(string name, TypeAttributes attr, Type parent, PackingSize packSize, int typeSize) { lock (SyncRoot) { @@ -1619,7 +1619,7 @@ namespace System.Reflection.Emit } } - private TypeBuilder DefineNestedTypeNoLock(String name, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packSize, int typeSize) + private TypeBuilder DefineNestedTypeNoLock(string name, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packSize, int typeSize) { return new TypeBuilder(name, attr, parent, interfaces, m_module, packSize, typeSize, this); } @@ -1627,12 +1627,12 @@ namespace System.Reflection.Emit #endregion #region Define Field - public FieldBuilder DefineField(String fieldName, Type type, FieldAttributes attributes) + public FieldBuilder DefineField(string fieldName, Type type, FieldAttributes attributes) { return DefineField(fieldName, type, null, null, attributes); } - public FieldBuilder DefineField(String fieldName, Type type, Type[] requiredCustomModifiers, + public FieldBuilder DefineField(string fieldName, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attributes) { lock (SyncRoot) @@ -1641,7 +1641,7 @@ namespace System.Reflection.Emit } } - private FieldBuilder DefineFieldNoLock(String fieldName, Type type, Type[] requiredCustomModifiers, + private FieldBuilder DefineFieldNoLock(string fieldName, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attributes) { ThrowIfCreated(); @@ -1660,7 +1660,7 @@ namespace System.Reflection.Emit return new FieldBuilder(this, fieldName, type, requiredCustomModifiers, optionalCustomModifiers, attributes); } - public FieldBuilder DefineInitializedData(String name, byte[] data, FieldAttributes attributes) + public FieldBuilder DefineInitializedData(string name, byte[] data, FieldAttributes attributes) { lock (SyncRoot) { @@ -1668,7 +1668,7 @@ namespace System.Reflection.Emit } } - private FieldBuilder DefineInitializedDataNoLock(String name, byte[] data, FieldAttributes attributes) + private FieldBuilder DefineInitializedDataNoLock(string name, byte[] data, FieldAttributes attributes) { if (data == null) throw new ArgumentNullException(nameof(data)); @@ -1680,7 +1680,7 @@ namespace System.Reflection.Emit return DefineDataHelper(name, data, data.Length, attributes); } - public FieldBuilder DefineUninitializedData(String name, int size, FieldAttributes attributes) + public FieldBuilder DefineUninitializedData(string name, int size, FieldAttributes attributes) { lock (SyncRoot) { @@ -1688,7 +1688,7 @@ namespace System.Reflection.Emit } } - private FieldBuilder DefineUninitializedDataNoLock(String name, int size, FieldAttributes attributes) + private FieldBuilder DefineUninitializedDataNoLock(string name, int size, FieldAttributes attributes) { // This method will define an uninitialized Data in .sdata. // We will create a fake TypeDef to represent the data with size. This TypeDef @@ -1699,19 +1699,19 @@ namespace System.Reflection.Emit #endregion #region Define Properties and Events - public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes, Type returnType, Type[] parameterTypes) + public PropertyBuilder DefineProperty(string name, PropertyAttributes attributes, Type returnType, Type[] parameterTypes) { return DefineProperty(name, attributes, returnType, null, null, parameterTypes, null, null); } - public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes, + public PropertyBuilder DefineProperty(string name, PropertyAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { return DefineProperty(name, attributes, callingConvention, returnType, null, null, parameterTypes, null, null); } - public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes, + public PropertyBuilder DefineProperty(string name, PropertyAttributes attributes, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) { @@ -1720,7 +1720,7 @@ namespace System.Reflection.Emit parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers); } - public PropertyBuilder DefineProperty(String name, PropertyAttributes attributes, CallingConventions callingConvention, + public PropertyBuilder DefineProperty(string name, PropertyAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) { @@ -1731,7 +1731,7 @@ namespace System.Reflection.Emit } } - private PropertyBuilder DefinePropertyNoLock(String name, PropertyAttributes attributes, CallingConventions callingConvention, + private PropertyBuilder DefinePropertyNoLock(string name, PropertyAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers) { @@ -1779,7 +1779,7 @@ namespace System.Reflection.Emit this); } - public EventBuilder DefineEvent(String name, EventAttributes attributes, Type eventtype) + public EventBuilder DefineEvent(string name, EventAttributes attributes, Type eventtype) { lock (SyncRoot) { @@ -1787,7 +1787,7 @@ namespace System.Reflection.Emit } } - private EventBuilder DefineEventNoLock(String name, EventAttributes attributes, Type eventtype) + private EventBuilder DefineEventNoLock(string name, EventAttributes attributes, Type eventtype) { if (name == null) throw new ArgumentNullException(nameof(name)); diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs index d674f34..677f51c 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs @@ -60,7 +60,7 @@ namespace System.Reflection.Emit #endregion #region Object Overrides - public override String ToString() + public override string ToString() { return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.ToString); } @@ -71,7 +71,7 @@ namespace System.Reflection.Emit public override Type ReflectedType { get { return m_type.ReflectedType; } } - public override String Name { get { return m_type.Name; } } + public override string Name { get { return m_type.Name; } } public override Module Module { get { return m_type.Module; } } #endregion @@ -98,14 +98,14 @@ namespace System.Reflection.Emit for (int i = 1; i < rank; i++) comma += ","; - string s = String.Format(CultureInfo.InvariantCulture, "[{0}]", comma); + string s = string.Format(CultureInfo.InvariantCulture, "[{0}]", comma); return SymbolType.FormCompoundType(s, this, 0); } public override Guid GUID { get { throw new NotSupportedException(); } } - public override Object InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) { throw new NotSupportedException(); } + public override Object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) { throw new NotSupportedException(); } public override Assembly Assembly { get { return m_type.Assembly; } } public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } } - public override String FullName + public override string FullName { get { @@ -114,8 +114,8 @@ namespace System.Reflection.Emit return m_strFullQualName; } } - public override String Namespace { get { return m_type.Namespace; } } - public override String AssemblyQualifiedName { get { return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.AssemblyQualifiedName); } } + public override string Namespace { get { return m_type.Namespace; } } + public override string AssemblyQualifiedName { get { return TypeNameBuilder.ToString(this, TypeNameBuilder.Format.AssemblyQualifiedName); } } private Type Substitute(Type[] substitutes) { Type[] inst = GetGenericArguments(); @@ -168,19 +168,19 @@ namespace System.Reflection.Emit protected override ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); } public override ConstructorInfo[] GetConstructors(BindingFlags bindingAttr) { throw new NotSupportedException(); } - protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); } + protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); } public override MethodInfo[] GetMethods(BindingFlags bindingAttr) { throw new NotSupportedException(); } - public override FieldInfo GetField(String name, BindingFlags bindingAttr) { throw new NotSupportedException(); } + public override FieldInfo GetField(string name, BindingFlags bindingAttr) { throw new NotSupportedException(); } public override FieldInfo[] GetFields(BindingFlags bindingAttr) { throw new NotSupportedException(); } - public override Type GetInterface(String name, bool ignoreCase) { throw new NotSupportedException(); } + public override Type GetInterface(string name, bool ignoreCase) { throw new NotSupportedException(); } public override Type[] GetInterfaces() { throw new NotSupportedException(); } - public override EventInfo GetEvent(String name, BindingFlags bindingAttr) { throw new NotSupportedException(); } + public override EventInfo GetEvent(string name, BindingFlags bindingAttr) { throw new NotSupportedException(); } public override EventInfo[] GetEvents() { throw new NotSupportedException(); } - protected override PropertyInfo GetPropertyImpl(String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); } + protected override PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) { throw new NotSupportedException(); } public override PropertyInfo[] GetProperties(BindingFlags bindingAttr) { throw new NotSupportedException(); } public override Type[] GetNestedTypes(BindingFlags bindingAttr) { throw new NotSupportedException(); } - public override Type GetNestedType(String name, BindingFlags bindingAttr) { throw new NotSupportedException(); } - public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr) { throw new NotSupportedException(); } + public override Type GetNestedType(string name, BindingFlags bindingAttr) { throw new NotSupportedException(); } + public override MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr) { throw new NotSupportedException(); } public override InterfaceMapping GetInterfaceMap(Type interfaceType) { throw new NotSupportedException(); } public override EventInfo[] GetEvents(BindingFlags bindingAttr) { throw new NotSupportedException(); } diff --git a/src/System.Private.CoreLib/src/System/Reflection/ExceptionHandlingClause.cs b/src/System.Private.CoreLib/src/System/Reflection/ExceptionHandlingClause.cs index 66ad4eb..89a3e23 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/ExceptionHandlingClause.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/ExceptionHandlingClause.cs @@ -69,19 +69,19 @@ namespace System.Reflection { if (Flags == ExceptionHandlingClauseOptions.Clause) { - return String.Format(CultureInfo.CurrentUICulture, + return string.Format(CultureInfo.CurrentUICulture, "Flags={0}, TryOffset={1}, TryLength={2}, HandlerOffset={3}, HandlerLength={4}, CatchType={5}", Flags, TryOffset, TryLength, HandlerOffset, HandlerLength, CatchType); } if (Flags == ExceptionHandlingClauseOptions.Filter) { - return String.Format(CultureInfo.CurrentUICulture, + return string.Format(CultureInfo.CurrentUICulture, "Flags={0}, TryOffset={1}, TryLength={2}, HandlerOffset={3}, HandlerLength={4}, FilterOffset={5}", Flags, TryOffset, TryLength, HandlerOffset, HandlerLength, FilterOffset); } - return String.Format(CultureInfo.CurrentUICulture, + return string.Format(CultureInfo.CurrentUICulture, "Flags={0}, TryOffset={1}, TryLength={2}, HandlerOffset={3}, HandlerLength={4}", Flags, TryOffset, TryLength, HandlerOffset, HandlerLength); } diff --git a/src/System.Private.CoreLib/src/System/Reflection/FieldInfo.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Reflection/FieldInfo.CoreCLR.cs index bcda341..56f4578 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/FieldInfo.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/FieldInfo.CoreCLR.cs @@ -17,7 +17,7 @@ namespace System.Reflection Type declaringType = f.DeclaringType; if (declaringType != null && declaringType.IsGenericType) - throw new ArgumentException(String.Format( + throw new ArgumentException(string.Format( CultureInfo.CurrentCulture, SR.Argument_FieldDeclaringTypeGeneric, f.Name, declaringType.GetGenericTypeDefinition())); diff --git a/src/System.Private.CoreLib/src/System/Reflection/MdConstant.cs b/src/System.Private.CoreLib/src/System/Reflection/MdConstant.cs index e7e0684..b959b2c 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/MdConstant.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/MdConstant.cs @@ -15,7 +15,7 @@ namespace System.Reflection CorElementType corElementType = 0; long buffer = 0; int length; - String stringVal; + string stringVal; stringVal = scope.GetDefaultValue(token, out buffer, out length, out corElementType); @@ -164,7 +164,7 @@ namespace System.Reflection case CorElementType.String: // A string constant can be empty but never null. // A nullref constant can only be type CorElementType.Class. - return stringVal == null ? String.Empty : stringVal; + return stringVal == null ? string.Empty : stringVal; case CorElementType.Class: return null; diff --git a/src/System.Private.CoreLib/src/System/Reflection/MdImport.cs b/src/System.Private.CoreLib/src/System/Reflection/MdImport.cs index 8589e14..4515324 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/MdImport.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/MdImport.cs @@ -237,7 +237,7 @@ namespace System.Reflection #endregion #region Object Overrides - public override string ToString() { return String.Format(CultureInfo.InvariantCulture, "0x{0:x8}", Value); } + public override string ToString() { return string.Format(CultureInfo.InvariantCulture, "0x{0:x8}", Value); } #endregion } @@ -376,11 +376,11 @@ namespace System.Reflection } [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern String _GetDefaultValue(IntPtr scope, int mdToken, out long value, out int length, out int corElementType); - public String GetDefaultValue(int mdToken, out long value, out int length, out CorElementType corElementType) + private static extern string _GetDefaultValue(IntPtr scope, int mdToken, out long value, out int length, out int corElementType); + public string GetDefaultValue(int mdToken, out long value, out int length, out CorElementType corElementType) { int _corElementType; - String stringVal; + string stringVal; stringVal = _GetDefaultValue(m_metadataImport2, mdToken, out value, out length, out _corElementType); corElementType = (CorElementType)_corElementType; return stringVal; @@ -388,7 +388,7 @@ namespace System.Reflection [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern unsafe void _GetUserString(IntPtr scope, int mdToken, void** name, out int length); - public unsafe String GetUserString(int mdToken) + public unsafe string GetUserString(int mdToken) { void* name; int length; @@ -407,7 +407,7 @@ namespace System.Reflection #endif } - return new String(c); + return new string(c); } [MethodImplAttribute(MethodImplOptions.InternalCall)] @@ -634,8 +634,8 @@ namespace System.Reflection public unsafe void GetPInvokeMap( int token, out PInvokeAttributes attributes, - out String importName, - out String importDll) + out string importName, + out string importDll) { int _attributes; void* _importName, _importDll; @@ -663,7 +663,7 @@ namespace System.Reflection public override string ToString() { - return String.Format(CultureInfo.CurrentCulture, "MetadataException HResult = {0:x}.", m_hr); + return string.Format(CultureInfo.CurrentCulture, "MetadataException HResult = {0:x}.", m_hr); } } } diff --git a/src/System.Private.CoreLib/src/System/Reflection/MethodBase.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Reflection/MethodBase.CoreCLR.cs index 3afd396..09d3520 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/MethodBase.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/MethodBase.CoreCLR.cs @@ -21,7 +21,7 @@ namespace System.Reflection Type declaringType = m.DeclaringType; if (declaringType != null && declaringType.IsGenericType) - throw new ArgumentException(String.Format( + throw new ArgumentException(string.Format( CultureInfo.CurrentCulture, SR.Argument_MethodDeclaringTypeGeneric, m, declaringType.GetGenericTypeDefinition())); @@ -96,7 +96,7 @@ namespace System.Reflection { get { - return String.Format("{0}.{1}", DeclaringType.FullName, FormatNameAndSig()); + return string.Format("{0}.{1}", DeclaringType.FullName, FormatNameAndSig()); } } internal string FormatNameAndSig() diff --git a/src/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs b/src/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs index fedffad..0ebed6e 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs @@ -103,7 +103,7 @@ namespace System.Reflection else { throw new ArgumentException( - String.Format(CultureInfo.CurrentUICulture, SR.Arg_FieldDeclTarget, + string.Format(CultureInfo.CurrentUICulture, SR.Arg_FieldDeclTarget, Name, m_declaringType, target.GetType())); } } @@ -237,7 +237,7 @@ namespace System.Reflection #endregion #region MemberInfo Overrides - public override String Name + public override string Name { get { @@ -248,11 +248,11 @@ namespace System.Reflection } } - internal String FullName + internal string FullName { get { - return String.Format("{0}.{1}", DeclaringType.FullName, Name); + return string.Format("{0}.{1}", DeclaringType.FullName, Name); } } diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs index 17910e1..f7fc084 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs @@ -53,25 +53,25 @@ namespace System.Reflection } } - private const String s_localFilePrefix = "file:"; + private const string s_localFilePrefix = "file:"; [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] private static extern void GetCodeBase(RuntimeAssembly assembly, bool copiedName, StringHandleOnStack retString); - internal String GetCodeBase(bool copiedName) + internal string GetCodeBase(bool copiedName) { - String codeBase = null; + string codeBase = null; GetCodeBase(GetNativeHandle(), copiedName, JitHelpers.GetStringHandleOnStack(ref codeBase)); return codeBase; } - public override String CodeBase + public override string CodeBase { get { - String codeBase = GetCodeBase(false); + string codeBase = GetCodeBase(false); return codeBase; } } @@ -88,7 +88,7 @@ namespace System.Reflection { AssemblyName an = new AssemblyName(); - String codeBase = GetCodeBase(copiedName); + string codeBase = GetCodeBase(copiedName); an.Init(GetSimpleName(), GetPublicKey(), @@ -119,7 +119,7 @@ namespace System.Reflection [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] private static extern void GetFullName(RuntimeAssembly assembly, StringHandleOnStack retString); - public override String FullName + public override string FullName { get { @@ -154,13 +154,13 @@ namespace System.Reflection [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] private static extern void GetType(RuntimeAssembly assembly, - String name, + string name, bool throwOnError, bool ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive); - public override Type GetType(String name, bool throwOnError, bool ignoreCase) + public override Type GetType(string name, bool throwOnError, bool ignoreCase) { // throw on null strings regardless of the value of "throwOnError" if (name == null) @@ -203,14 +203,14 @@ namespace System.Reflection // Load a resource based on the NameSpace of the type. [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod - public override Stream GetManifestResourceStream(Type type, String name) + public override Stream GetManifestResourceStream(Type type, string name) { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; return GetManifestResourceStream(type, name, false, ref stackMark); } [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod - public override Stream GetManifestResourceStream(String name) + public override Stream GetManifestResourceStream(string name) { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; return GetManifestResourceStream(name, ref stackMark, false); @@ -269,14 +269,14 @@ namespace System.Reflection } // Wrapper function to wrap the typical use of InternalLoad. - internal static RuntimeAssembly InternalLoad(String assemblyString, + internal static RuntimeAssembly InternalLoad(string assemblyString, ref StackCrawlMark stackMark) { return InternalLoad(assemblyString, ref stackMark, IntPtr.Zero); } [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod - internal static RuntimeAssembly InternalLoad(String assemblyString, + internal static RuntimeAssembly InternalLoad(string assemblyString, ref StackCrawlMark stackMark, IntPtr pPrivHostBinder) { @@ -296,7 +296,7 @@ namespace System.Reflection // Creates AssemblyName. Fills assembly if AssemblyResolve event has been raised. internal static AssemblyName CreateAssemblyName( - String assemblyString, + string assemblyString, out RuntimeAssembly assemblyFromResolveEvent) { if (assemblyString == null) @@ -320,7 +320,7 @@ namespace System.Reflection RuntimeAssembly reqAssembly, ref StackCrawlMark stackMark, bool throwOnFileNotFound, - IntPtr ptrLoadContextBinder = default(IntPtr)) + IntPtr ptrLoadContextBinder = default) { return InternalLoadAssemblyName(assemblyRef, reqAssembly, ref stackMark, IntPtr.Zero, true /*throwOnError*/, ptrLoadContextBinder); } @@ -331,7 +331,7 @@ namespace System.Reflection ref StackCrawlMark stackMark, IntPtr pPrivHostBinder, bool throwOnFileNotFound, - IntPtr ptrLoadContextBinder = default(IntPtr)) + IntPtr ptrLoadContextBinder = default) { if (assemblyRef == null) throw new ArgumentNullException(nameof(assemblyRef)); @@ -348,7 +348,7 @@ namespace System.Reflection assemblyRef.ProcessorArchitecture = ProcessorArchitecture.None; } - String codeBase = VerifyCodeBase(assemblyRef.CodeBase); + string codeBase = VerifyCodeBase(assemblyRef.CodeBase); return nLoad(assemblyRef, codeBase, reqAssembly, ref stackMark, pPrivHostBinder, @@ -357,12 +357,12 @@ namespace System.Reflection [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern RuntimeAssembly nLoad(AssemblyName fileName, - String codeBase, + string codeBase, RuntimeAssembly locationHint, ref StackCrawlMark stackMark, IntPtr pPrivHostBinder, bool throwOnFileNotFound, - IntPtr ptrLoadContextBinder = default(IntPtr)); + IntPtr ptrLoadContextBinder = default); public override bool ReflectionOnly { @@ -375,9 +375,9 @@ namespace System.Reflection // Returns the module in this assembly with name 'name' [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - private static extern void GetModule(RuntimeAssembly assembly, String name, ObjectHandleOnStack retModule); + private static extern void GetModule(RuntimeAssembly assembly, string name, ObjectHandleOnStack retModule); - public override Module GetModule(String name) + public override Module GetModule(string name) { Module retModule = null; GetModule(GetNativeHandle(), name, JitHelpers.GetObjectHandleOnStack(ref retModule)); @@ -386,7 +386,7 @@ namespace System.Reflection // Returns the file in the File table of the manifest that matches the // given name. (Name should not include path.) - public override FileStream GetFile(String name) + public override FileStream GetFile(string name) { RuntimeModule m = (RuntimeModule)GetModule(name); if (m == null) @@ -414,10 +414,10 @@ namespace System.Reflection // Returns the names of all the resources [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern String[] GetManifestResourceNames(RuntimeAssembly assembly); + private static extern string[] GetManifestResourceNames(RuntimeAssembly assembly); // Returns the names of all the resources - public override String[] GetManifestResourceNames() + public override string[] GetManifestResourceNames() { return GetManifestResourceNames(GetNativeHandle()); } @@ -443,16 +443,16 @@ namespace System.Reflection [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] private static extern int GetManifestResourceInfo(RuntimeAssembly assembly, - String resourceName, + string resourceName, ObjectHandleOnStack assemblyRef, StringHandleOnStack retFileName, StackCrawlMarkHandle stackMark); [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod - public override ManifestResourceInfo GetManifestResourceInfo(String resourceName) + public override ManifestResourceInfo GetManifestResourceInfo(string resourceName) { RuntimeAssembly retAssembly = null; - String fileName = null; + string fileName = null; StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; int location = GetManifestResourceInfo(GetNativeHandle(), resourceName, JitHelpers.GetObjectHandleOnStack(ref retAssembly), @@ -469,11 +469,11 @@ namespace System.Reflection [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] private static extern void GetLocation(RuntimeAssembly assembly, StringHandleOnStack retString); - public override String Location + public override string Location { get { - String location = null; + string location = null; GetLocation(GetNativeHandle(), JitHelpers.GetStringHandleOnStack(ref location)); @@ -484,11 +484,11 @@ namespace System.Reflection [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] private static extern void GetImageRuntimeVersion(RuntimeAssembly assembly, StringHandleOnStack retString); - public override String ImageRuntimeVersion + public override string ImageRuntimeVersion { get { - String s = null; + string s = null; GetImageRuntimeVersion(GetNativeHandle(), JitHelpers.GetStringHandleOnStack(ref s)); return s; } @@ -510,7 +510,7 @@ namespace System.Reflection } } - private static String VerifyCodeBase(String codebase) + private static string VerifyCodeBase(string codebase) { if (codebase == null) return null; @@ -540,7 +540,7 @@ namespace System.Reflection internal Stream GetManifestResourceStream( Type type, - String name, + string name, bool skipSecurityCheck, ref StackCrawlMark stackMark) { @@ -552,7 +552,7 @@ namespace System.Reflection } else { - String nameSpace = type.Namespace; + string nameSpace = type.Namespace; if (nameSpace != null) { sb.Append(nameSpace); @@ -570,12 +570,12 @@ namespace System.Reflection // GetResource will return a pointer to the resources in memory. [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] private static extern unsafe byte* GetResource(RuntimeAssembly assembly, - String resourceName, + string resourceName, out ulong length, StackCrawlMarkHandle stackMark, bool skipSecurityCheck); - internal unsafe Stream GetManifestResourceStream(String name, ref StackCrawlMark stackMark, bool skipSecurityCheck) + internal unsafe Stream GetManifestResourceStream(string name, ref StackCrawlMark stackMark, bool skipSecurityCheck) { ulong length = 0; byte* pbInMemoryResource = GetResource(GetNativeHandle(), name, out length, JitHelpers.GetStackCrawlMarkHandle(ref stackMark), skipSecurityCheck); @@ -612,7 +612,7 @@ namespace System.Reflection internal CultureInfo GetLocale() { - String locale = null; + string locale = null; GetLocale(GetNativeHandle(), JitHelpers.GetStringHandleOnStack(ref locale)); @@ -636,7 +636,7 @@ namespace System.Reflection [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] private static extern void GetSimpleName(RuntimeAssembly assembly, StringHandleOnStack retSimpleName); - internal String GetSimpleName() + internal string GetSimpleName() { string name = null; GetSimpleName(GetNativeHandle(), JitHelpers.GetStringHandleOnStack(ref name)); @@ -670,7 +670,7 @@ namespace System.Reflection } // This method is called by the VM. - private RuntimeModule OnModuleResolveEvent(String moduleName) + private RuntimeModule OnModuleResolveEvent(string moduleName) { ModuleResolveEventHandler moduleResolve = _ModuleResolve; if (moduleResolve == null) @@ -710,12 +710,12 @@ namespace System.Reflection throw new ArgumentNullException(nameof(culture)); - String name = GetSimpleName() + ".resources"; + string name = GetSimpleName() + ".resources"; return InternalGetSatelliteAssembly(name, culture, version, true, ref stackMark); } [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod - internal RuntimeAssembly InternalGetSatelliteAssembly(String name, + internal RuntimeAssembly InternalGetSatelliteAssembly(string name, CultureInfo culture, Version version, bool throwOnFileNotFound, @@ -740,7 +740,7 @@ namespace System.Reflection if (retAssembly == this || (retAssembly == null && throwOnFileNotFound)) { - throw new FileNotFoundException(String.Format(culture, SR.IO_FileNotFound_FileName, an.Name)); + throw new FileNotFoundException(string.Format(culture, SR.IO_FileNotFound_FileName, an.Name)); } return retAssembly; diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs index ad9a1a4..59f3b50 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs @@ -138,7 +138,7 @@ namespace System.Reflection #endregion #region Object Overrides - public override String ToString() + public override string ToString() { // "Void" really doesn't make sense here. But we'll keep it for compat reasons. if (m_toString == null) @@ -188,7 +188,7 @@ namespace System.Reflection #region MemberInfo Overrides - public override String Name + public override string Name { get { return RuntimeMethodHandle.GetName(this); } } @@ -295,12 +295,12 @@ namespace System.Reflection // ctor is declared on interface class else if (declaringType.IsInterface) throw new MemberAccessException( - String.Format(CultureInfo.CurrentUICulture, SR.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, SR.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)) @@ -314,7 +314,7 @@ namespace System.Reflection else if (declaringType.ContainsGenericParameters) { throw new MemberAccessException( - String.Format(CultureInfo.CurrentUICulture, SR.Acc_CreateGenericEx, declaringType)); + string.Format(CultureInfo.CurrentUICulture, SR.Acc_CreateGenericEx, declaringType)); } // ctor is declared on System.Void diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs index e4b1135..600147c 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs @@ -17,7 +17,7 @@ namespace System.Reflection #region FCalls [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - private static extern void GetType(RuntimeModule module, String className, bool throwOnError, bool ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive); + private static extern void GetType(RuntimeModule module, string className, bool throwOnError, bool ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive); [DllImport(JitHelpers.QCall)] private static extern bool nIsTransientInternal(RuntimeModule module); @@ -145,7 +145,7 @@ namespace System.Reflection if (!MetadataImport.IsValidToken(tk) || !tk.IsFieldDef) throw new ArgumentOutOfRangeException(nameof(metadataToken), - String.Format(CultureInfo.CurrentUICulture, SR.Format(SR.Argument_InvalidToken, tk, this))); + string.Format(CultureInfo.CurrentUICulture, SR.Format(SR.Argument_InvalidToken, tk, this))); int tkDeclaringType; string fieldName; @@ -305,17 +305,17 @@ namespace System.Reflection MetadataToken tk = new MetadataToken(metadataToken); if (!tk.IsString) throw new ArgumentException( - String.Format(CultureInfo.CurrentUICulture, SR.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, SR.Format(SR.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, SR.Argument_ResolveString, metadataToken, ToString())); + string.Format(CultureInfo.CurrentUICulture, SR.Argument_ResolveString, metadataToken, ToString())); return str; } @@ -347,13 +347,13 @@ namespace System.Reflection #endregion #region Protected Virtuals - protected override MethodInfo GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, + protected override MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { return GetMethodInternal(name, bindingAttr, binder, callConvention, types, modifiers); } - internal MethodInfo GetMethodInternal(String name, BindingFlags bindingAttr, Binder binder, + internal MethodInfo GetMethodInternal(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) { if (RuntimeType == null) @@ -443,7 +443,7 @@ namespace System.Reflection throw new PlatformNotSupportedException(); } - public override Type GetType(String className, bool throwOnError, bool ignoreCase) + public override Type GetType(string className, bool throwOnError, bool ignoreCase) { // throw on null strings regardless of the value of "throwOnError" if (className == null) @@ -458,12 +458,12 @@ namespace System.Reflection internal string GetFullyQualifiedName() { - String fullyQualifiedName = null; + string fullyQualifiedName = null; GetFullyQualifiedName(GetNativeHandle(), JitHelpers.GetStringHandleOnStack(ref fullyQualifiedName)); return fullyQualifiedName; } - public override String FullyQualifiedName + public override string FullyQualifiedName { get { @@ -514,7 +514,7 @@ namespace System.Reflection return RuntimeType.GetFields(bindingFlags); } - public override FieldInfo GetField(String name, BindingFlags bindingAttr) + public override FieldInfo GetField(string name, BindingFlags bindingAttr) { if (name == null) throw new ArgumentNullException(nameof(name)); @@ -533,7 +533,7 @@ namespace System.Reflection return RuntimeType.GetMethods(bindingFlags); } - public override String ScopeName + public override string ScopeName { get { @@ -543,11 +543,11 @@ namespace System.Reflection } } - public override String Name + public override string Name { get { - String s = GetFullyQualifiedName(); + string s = GetFullyQualifiedName(); #if !FEATURE_PAL int i = s.LastIndexOf('\\'); diff --git a/src/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs b/src/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs index 1dc986b..9e28e7b 100644 --- a/src/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs +++ b/src/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs @@ -51,7 +51,7 @@ namespace System.Resources _mediator = mediator; } - public ResourceSet GrovelForResourceSet(CultureInfo culture, Dictionary localResourceSets, bool tryParents, bool createIfNotExists, ref StackCrawlMark stackMark) + public ResourceSet GrovelForResourceSet(CultureInfo culture, Dictionary localResourceSets, bool tryParents, bool createIfNotExists, ref StackCrawlMark stackMark) { Debug.Assert(culture != null, "culture shouldn't be null; check caller"); Debug.Assert(localResourceSets != null, "localResourceSets shouldn't be null; check caller"); @@ -93,7 +93,7 @@ namespace System.Resources // get resource file name we'll search for. Note, be careful if you're moving this statement // around because lookForCulture may be modified from originally requested culture above. - String fileName = _mediator.GetResourceFileName(lookForCulture); + string fileName = _mediator.GetResourceFileName(lookForCulture); // 3. If we identified an assembly to search; look in manifest resource stream for resource file if (satellite != null) @@ -209,7 +209,7 @@ namespace System.Resources if (bytes == ResourceManager.MagicNumber) { int resMgrHeaderVersion = br.ReadInt32(); - String readerTypeName = null, resSetTypeName = null; + string readerTypeName = null, resSetTypeName = null; if (resMgrHeaderVersion == ResourceManager.HeaderVersionNumber) { br.ReadInt32(); // We don't want the number of bytes to skip. @@ -314,7 +314,7 @@ namespace System.Resources } } - private Stream GetManifestResourceStream(RuntimeAssembly satellite, String fileName, ref StackCrawlMark stackMark) + private Stream GetManifestResourceStream(RuntimeAssembly satellite, string fileName, ref StackCrawlMark stackMark) { Debug.Assert(satellite != null, "satellite shouldn't be null; check caller"); Debug.Assert(fileName != null, "fileName shouldn't be null; check caller"); @@ -338,7 +338,7 @@ namespace System.Resources // dev lead refuses to make all assembly manifest resource lookups case-insensitive, // even optionally case-insensitive. [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod - private Stream CaseInsensitiveManifestResourceStreamLookup(RuntimeAssembly satellite, String name) + private Stream CaseInsensitiveManifestResourceStreamLookup(RuntimeAssembly satellite, string name) { Debug.Assert(satellite != null, "satellite shouldn't be null; check caller"); Debug.Assert(name != null, "name shouldn't be null; check caller"); @@ -346,7 +346,7 @@ namespace System.Resources StringBuilder sb = new StringBuilder(); if (_mediator.LocationInfo != null) { - String nameSpace = _mediator.LocationInfo.Namespace; + string nameSpace = _mediator.LocationInfo.Namespace; if (nameSpace != null) { sb.Append(nameSpace); @@ -356,11 +356,11 @@ namespace System.Resources } sb.Append(name); - String givenName = sb.ToString(); - String canonicalName = null; - foreach (String existingName in satellite.GetManifestResourceNames()) + string givenName = sb.ToString(); + string canonicalName = null; + foreach (string existingName in satellite.GetManifestResourceNames()) { - if (String.Equals(existingName, givenName, StringComparison.InvariantCultureIgnoreCase)) + if (string.Equals(existingName, givenName, StringComparison.InvariantCultureIgnoreCase)) { if (canonicalName == null) { @@ -395,7 +395,7 @@ namespace System.Resources } RuntimeAssembly satellite = null; - String satAssemblyName = GetSatelliteAssemblyName(); + string satAssemblyName = GetSatelliteAssemblyName(); // Look up the satellite assembly, but don't let problems // like a partially signed satellite assembly stop us from @@ -435,7 +435,7 @@ namespace System.Resources // a security check (since the link-time check on the constructor that // takes a String is turned into a full demand with a stack walk) // and causes partially trusted localized apps to fail. - private bool CanUseDefaultResourceClasses(String readerTypeName, String resSetTypeName) + private bool CanUseDefaultResourceClasses(string readerTypeName, string resSetTypeName) { Debug.Assert(readerTypeName != null, "readerTypeName shouldn't be null; check caller"); Debug.Assert(resSetTypeName != null, "resSetTypeName shouldn't be null; check caller"); @@ -463,16 +463,16 @@ namespace System.Resources return true; } - private String GetSatelliteAssemblyName() + private string GetSatelliteAssemblyName() { - String satAssemblyName = _mediator.MainAssembly.GetSimpleName(); + string satAssemblyName = _mediator.MainAssembly.GetSimpleName(); satAssemblyName += ".resources"; return satAssemblyName; } private void HandleSatelliteMissing() { - String satAssemName = _mediator.MainAssembly.GetSimpleName() + ".resources.dll"; + string satAssemName = _mediator.MainAssembly.GetSimpleName() + ".resources.dll"; if (_mediator.SatelliteContractVersion != null) { satAssemName += ", Version=" + _mediator.SatelliteContractVersion.ToString(); @@ -490,7 +490,7 @@ namespace System.Resources } satAssemName += ", PublicKeyToken=" + publicKeyTok; - String missingCultureName = _mediator.NeutralResourcesCulture.Name; + string missingCultureName = _mediator.NeutralResourcesCulture.Name; if (missingCultureName.Length == 0) { missingCultureName = ""; @@ -498,7 +498,7 @@ namespace System.Resources throw new MissingSatelliteAssemblyException(SR.Format(SR.MissingSatelliteAssembly_Culture_Name, _mediator.NeutralResourcesCulture, satAssemName), missingCultureName); } - private void HandleResourceStreamMissing(String fileName) + private void HandleResourceStreamMissing(string fileName) { // Keep people from bothering me about resources problems if (_mediator.MainAssembly == typeof(Object).Assembly && _mediator.BaseName.Equals(System.CoreLib.Name)) @@ -512,7 +512,7 @@ namespace System.Resources } // We really don't think this should happen - we always // expect the neutral locale's resources to be present. - String resName = String.Empty; + string resName = string.Empty; if (_mediator.LocationInfo != null && _mediator.LocationInfo.Namespace != null) resName = _mediator.LocationInfo.Namespace + Type.Delimiter; resName += fileName; diff --git a/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs b/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs index f17dc75..18a751c 100644 --- a/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs +++ b/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs @@ -44,7 +44,7 @@ namespace System.Resources { public abstract bool Initialize(string libpath, string reswFilename, out PRIExceptionInfo exceptionInfo); - public abstract String GetString(String stringName, String startingCulture, String neutralResourcesCulture); + public abstract string GetString(string stringName, string startingCulture, string neutralResourcesCulture); public abstract CultureInfo GlobalResourceContextBestFitCultureInfo { @@ -146,19 +146,19 @@ namespace System.Resources { internal class CultureNameResourceSetPair { - public String lastCultureName; + public string lastCultureName; public ResourceSet lastResourceSet; } - protected String BaseNameField; + protected string BaseNameField; // Sets is a many-to-one table of CultureInfos mapped to ResourceSets. // Don't synchronize ResourceSets - too fine-grained a lock to be effective [Obsolete("call InternalGetResourceSet instead")] internal Hashtable ResourceSets; - private Dictionary _resourceSets; - private String moduleDir; // For assembly-ignorant directory location + private Dictionary _resourceSets; + private string moduleDir; // For assembly-ignorant directory location protected Assembly MainAssembly; // Need the assembly manifest sometimes. private Type _locationInfo; // For Assembly or type-based directory layout private Type _userResourceSet; // Which ResourceSet instance to create @@ -213,10 +213,10 @@ namespace System.Resources // These Strings are used to avoid using Reflection in CreateResourceSet. // The first set are used by ResourceWriter. The second are used by // InternalResGen. - internal static readonly String ResReaderTypeName = typeof(ResourceReader).FullName; - internal static readonly String ResSetTypeName = typeof(RuntimeResourceSet).FullName; - internal static readonly String MscorlibName = typeof(ResourceReader).Assembly.FullName; - internal const String ResFileExtension = ".resources"; + internal static readonly string ResReaderTypeName = typeof(ResourceReader).FullName; + internal static readonly string ResSetTypeName = typeof(RuntimeResourceSet).FullName; + internal static readonly string MscorlibName = typeof(ResourceReader).Assembly.FullName; + internal const string ResFileExtension = ".resources"; internal const int ResFileExtensionLength = 10; private static volatile bool s_IsAppXModel; @@ -246,7 +246,7 @@ namespace System.Resources // // Note: System.Windows.Forms uses this method at design time. // - private ResourceManager(String baseName, String resourceDir, Type usingResourceSet) + private ResourceManager(string baseName, string resourceDir, Type usingResourceSet) { if (null == baseName) throw new ArgumentNullException(nameof(baseName)); @@ -260,7 +260,7 @@ namespace System.Resources #pragma warning disable 618 ResourceSets = new Hashtable(); // for backward compatibility #pragma warning restore 618 - _resourceSets = new Dictionary(); + _resourceSets = new Dictionary(); _lastUsedResourceCache = new CultureNameResourceSetPair(); UseManifest = false; @@ -269,7 +269,7 @@ namespace System.Resources } [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod - public ResourceManager(String baseName, Assembly assembly) + public ResourceManager(string baseName, Assembly assembly) { if (null == baseName) throw new ArgumentNullException(nameof(baseName)); @@ -299,7 +299,7 @@ namespace System.Resources } [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod - public ResourceManager(String baseName, Assembly assembly, Type usingResourceSet) + public ResourceManager(string baseName, Assembly assembly, Type usingResourceSet) { if (null == baseName) throw new ArgumentNullException(nameof(baseName)); @@ -358,7 +358,7 @@ namespace System.Resources // Now we can use the managed resources even when using PRI's to support the APIs GetObject, GetStream...etc. UseManifest = true; - _resourceSets = new Dictionary(); + _resourceSets = new Dictionary(); _lastUsedResourceCache = new CultureNameResourceSetPair(); _fallbackLoc = UltimateResourceFallbackLocation.MainAssembly; @@ -370,7 +370,7 @@ namespace System.Resources } // Gets the base name for the ResourceManager. - public virtual String BaseName + public virtual string BaseName { get { return BaseNameField; } } @@ -407,11 +407,11 @@ namespace System.Resources // creating a new ResourceManager isn't quite the correct behavior. public virtual void ReleaseAllResources() { - Dictionary localResourceSets = _resourceSets; + Dictionary localResourceSets = _resourceSets; // If any calls to Close throw, at least leave ourselves in a // consistent state. - _resourceSets = new Dictionary(); + _resourceSets = new Dictionary(); _lastUsedResourceCache = new CultureNameResourceSetPair(); lock (localResourceSets) @@ -423,7 +423,7 @@ namespace System.Resources } } - public static ResourceManager CreateFileBasedResourceManager(String baseName, String resourceDir, Type usingResourceSet) + public static ResourceManager CreateFileBasedResourceManager(string baseName, string resourceDir, Type usingResourceSet) { return new ResourceManager(baseName, resourceDir, usingResourceSet); } @@ -438,7 +438,7 @@ namespace System.Resources // // This method can be overriden to look for a different extension, // such as ".ResX", or a completely different format for naming files. - protected virtual String GetResourceFileName(CultureInfo culture) + protected virtual string GetResourceFileName(CultureInfo culture) { // If this is the neutral culture, don't include the culture name. if (culture.HasInvariantCultureName) @@ -472,7 +472,7 @@ namespace System.Resources } // Look in the ResourceSet table - Dictionary localResourceSets = _resourceSets; + Dictionary localResourceSets = _resourceSets; ResourceSet rs = null; if (localResourceSets != null) { @@ -513,7 +513,7 @@ namespace System.Resources if (null == culture) throw new ArgumentNullException(nameof(culture)); - Dictionary localResourceSets = _resourceSets; + Dictionary localResourceSets = _resourceSets; ResourceSet rs; if (localResourceSets != null) { @@ -569,7 +569,7 @@ namespace System.Resources // This will take a minimal number of locks. private ResourceSet InternalGetResourceSet(CultureInfo requestedCulture, bool createIfNotExists, bool tryParents, ref StackCrawlMark stackMark) { - Dictionary localResourceSets = _resourceSets; + Dictionary localResourceSets = _resourceSets; ResourceSet rs = null; CultureInfo foundCulture = null; lock (localResourceSets) @@ -634,7 +634,7 @@ namespace System.Resources } // Simple helper to ease maintenance and improve readability. - private static void AddResourceSet(Dictionary localResourceSets, String cultureName, ref ResourceSet rs) + private static void AddResourceSet(Dictionary localResourceSets, string cultureName, ref ResourceSet rs) { // InternalGetResourceSet is both recursive and reentrant - // assembly load callbacks in particular are a way we can call @@ -686,8 +686,8 @@ namespace System.Resources } // IGNORES VERSION - internal static bool CompareNames(String asmTypeName1, - String typeName2, + internal static bool CompareNames(string asmTypeName1, + string typeName2, AssemblyName asmName2) { Debug.Assert(asmTypeName1 != null, "asmTypeName1 was unexpectedly null"); @@ -698,7 +698,7 @@ namespace System.Resources return false; // case sensitive - if (String.Compare(asmTypeName1, 0, typeName2, 0, typeName2.Length, StringComparison.Ordinal) != 0) + if (string.Compare(asmTypeName1, 0, typeName2, 0, typeName2.Length, StringComparison.Ordinal) != 0) return false; if (comma == -1) return true; @@ -709,11 +709,11 @@ namespace System.Resources // case insensitive AssemblyName an1 = new AssemblyName(asmTypeName1.Substring(comma)); - if (String.Compare(an1.Name, asmName2.Name, StringComparison.OrdinalIgnoreCase) != 0) + if (string.Compare(an1.Name, asmName2.Name, StringComparison.OrdinalIgnoreCase) != 0) return false; // to match IsMscorlib() in VM - if (String.Compare(an1.Name, System.CoreLib.Name, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Compare(an1.Name, System.CoreLib.Name, StringComparison.OrdinalIgnoreCase) == 0) return true; @@ -744,7 +744,7 @@ namespace System.Resources } #if FEATURE_APPX - private string GetStringFromPRI(String stringName, String startingCulture, String neutralResourcesCulture) + private string GetStringFromPRI(string stringName, string startingCulture, string neutralResourcesCulture) { Debug.Assert(_bUsingModernResourceManagement); Debug.Assert(_WinRTResourceManager != null); @@ -760,8 +760,8 @@ namespace System.Resources // exception types that the ResourceManager class is not documented to throw. resourceString = _WinRTResourceManager.GetString( stringName, - String.IsNullOrEmpty(startingCulture) ? null : startingCulture, - String.IsNullOrEmpty(neutralResourcesCulture) ? null : neutralResourcesCulture); + string.IsNullOrEmpty(startingCulture) ? null : startingCulture, + string.IsNullOrEmpty(neutralResourcesCulture) ? null : neutralResourcesCulture); return resourceString; } @@ -802,8 +802,8 @@ namespace System.Resources if (!fUseSatelliteAssemblyResourceLookupUnderAppX) { // Check to see if the assembly is under PLATFORM_RESOURCE_ROOTS. If it is, then we should use satellite assembly lookup for it. - String platformResourceRoots = (String)(AppDomain.CurrentDomain.GetData("PLATFORM_RESOURCE_ROOTS")); - if ((platformResourceRoots != null) && (platformResourceRoots != String.Empty)) + string platformResourceRoots = (string)(AppDomain.CurrentDomain.GetData("PLATFORM_RESOURCE_ROOTS")); + if ((platformResourceRoots != null) && (platformResourceRoots != string.Empty)) { string resourceAssemblyPath = resourcesAssembly.Location; @@ -853,7 +853,7 @@ namespace System.Resources s_IsAppXModel = true; // If we have the type information from the ResourceManager(Type) constructor, we use it. Otherwise, we use BaseNameField. - String reswFilename = _locationInfo == null ? BaseNameField : _locationInfo.FullName; + string reswFilename = _locationInfo == null ? BaseNameField : _locationInfo.FullName; // The only way this can happen is if a class inherited from ResourceManager and // did not set the BaseNameField before calling the protected ResourceManager() constructor. @@ -865,7 +865,7 @@ namespace System.Resources // throw a MissingManifestResourceException when GetString is called indicating that a // resW filename called "" could not be found. if (reswFilename == null) - reswFilename = String.Empty; + reswFilename = string.Empty; WindowsRuntimeResourceManagerBase WRRM = null; bool bWRRM_Initialized = false; @@ -982,7 +982,7 @@ namespace System.Resources // current thread's CultureInfo, and if not found, all parent CultureInfos. // Returns null if the resource wasn't found. // - public virtual String GetString(String name) + public virtual string GetString(string name) { return GetString(name, (CultureInfo)null); } @@ -991,7 +991,7 @@ namespace System.Resources // specified CultureInfo, and if not found, all parent CultureInfos. // Returns null if the resource wasn't found. // - public virtual String GetString(String name, CultureInfo culture) + public virtual string GetString(string name, CultureInfo culture) { if (null == name) throw new ArgumentNullException(nameof(name)); @@ -1041,7 +1041,7 @@ namespace System.Resources if (last != null) { - String value = last.GetString(name, _ignoreCase); + string value = last.GetString(name, _ignoreCase); if (value != null) return value; } @@ -1059,7 +1059,7 @@ namespace System.Resources if (rs != last) { - String value = rs.GetString(name, _ignoreCase); + string value = rs.GetString(name, _ignoreCase); if (value != null) { // update last used ResourceSet @@ -1087,7 +1087,7 @@ namespace System.Resources // current thread's CultureInfo, and if not found, all parent CultureInfos. // Returns null if the resource wasn't found. // - public virtual Object GetObject(String name) + public virtual Object GetObject(string name) { return GetObject(name, (CultureInfo)null, true); } @@ -1095,12 +1095,12 @@ namespace System.Resources // Looks up a resource value for a particular name. Looks in the // specified CultureInfo, and if not found, all parent CultureInfos. // Returns null if the resource wasn't found. - public virtual Object GetObject(String name, CultureInfo culture) + public virtual Object GetObject(string name, CultureInfo culture) { return GetObject(name, culture, true); } - private Object GetObject(String name, CultureInfo culture, bool wrapUnmanagedMemStream) + private Object GetObject(string name, CultureInfo culture, bool wrapUnmanagedMemStream) { if (null == name) throw new ArgumentNullException(nameof(name)); @@ -1185,12 +1185,12 @@ namespace System.Resources return null; } - public UnmanagedMemoryStream GetStream(String name) + public UnmanagedMemoryStream GetStream(string name) { return GetStream(name, (CultureInfo)null); } - public UnmanagedMemoryStream GetStream(String name, CultureInfo culture) + public UnmanagedMemoryStream GetStream(string name, CultureInfo culture) { Object obj = GetObject(name, culture, false); UnmanagedMemoryStream ums = obj as UnmanagedMemoryStream; @@ -1219,7 +1219,7 @@ namespace System.Resources if (_installedSatelliteInfo == null) return true; - String[] installedSatellites = (String[])_installedSatelliteInfo[MainAssembly.FullName]; + string[] installedSatellites = (string[])_installedSatelliteInfo[MainAssembly.FullName]; if (installedSatellites == null) return true; @@ -1252,7 +1252,7 @@ namespace System.Resources } // NEEDED ONLY BY FILE-BASED - internal String ModuleDir + internal string ModuleDir { get { return _rm.moduleDir; } } @@ -1268,7 +1268,7 @@ namespace System.Resources get { return _rm._userResourceSet; } } - internal String BaseNameField + internal string BaseNameField { get { return _rm.BaseNameField; } } @@ -1279,7 +1279,7 @@ namespace System.Resources set { _rm._neutralResourcesCulture = value; } } - internal String GetResourceFileName(CultureInfo culture) + internal string GetResourceFileName(CultureInfo culture) { return _rm.GetResourceFileName(culture); } @@ -1320,7 +1320,7 @@ namespace System.Resources // this is weird because we have BaseNameField accessor above, but we're sticking // with it for compat. - internal String BaseName + internal string BaseName { get { return _rm.BaseName; } } diff --git a/src/System.Private.CoreLib/src/System/Resources/ResourceReader.cs b/src/System.Private.CoreLib/src/System/Resources/ResourceReader.cs index 75c1768..6b9732d 100644 --- a/src/System.Private.CoreLib/src/System/Resources/ResourceReader.cs +++ b/src/System.Private.CoreLib/src/System/Resources/ResourceReader.cs @@ -82,7 +82,7 @@ namespace System.Resources // Used by RuntimeResourceSet and this class's enumerator. Maps // resource name to a value, a ResourceLocator, or a // LooselyLinkedManifestResource. - internal Dictionary _resCache; + internal Dictionary _resCache; private long _nameSectionOffset; // Offset to name section of file. private long _dataSectionOffset; // Offset to Data section of file. @@ -107,9 +107,9 @@ namespace System.Resources private int _version; - public ResourceReader(String fileName) + public ResourceReader(string fileName) { - _resCache = new Dictionary(FastResourceComparer.Default); + _resCache = new Dictionary(FastResourceComparer.Default); _store = new BinaryReader(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read, DefaultFileStreamBufferSize, FileOptions.RandomAccess), Encoding.UTF8); try @@ -130,7 +130,7 @@ namespace System.Resources if (!stream.CanRead) throw new ArgumentException(SR.Argument_StreamNotReadable); - _resCache = new Dictionary(FastResourceComparer.Default); + _resCache = new Dictionary(FastResourceComparer.Default); _store = new BinaryReader(stream, Encoding.UTF8); // We have a faster code path for reading resource files from an assembly. _ums = stream as UnmanagedMemoryStream; @@ -142,7 +142,7 @@ namespace System.Resources // passing in the stream to read from and the RuntimeResourceSet's // internal hash table (hash table of names with file offsets // and values, coupled to this ResourceReader). - internal ResourceReader(Stream stream, Dictionary resCache) + internal ResourceReader(Stream stream, Dictionary resCache) { Debug.Assert(stream != null, "Need a stream!"); Debug.Assert(stream.CanRead, "Stream should be readable!"); @@ -257,7 +257,7 @@ namespace System.Resources // To read the data, seek to _dataSectionOffset + dataPos, then // read the resource type & data. // This does a binary search through the names. - internal int FindPosForResource(String name) + internal int FindPosForResource(string name) { Debug.Assert(_store != null, "ResourceReader is closed!"); int hash = FastResourceComparer.HashFunction(name); @@ -338,7 +338,7 @@ namespace System.Resources // with the string you pass in. // Whoever calls this method should make sure that they take a lock // so no one else can cause us to seek in the stream. - private unsafe bool CompareStringEqualsName(String name) + private unsafe bool CompareStringEqualsName(string name) { Debug.Assert(_store != null, "ResourceReader is closed!"); int byteLen = _store.Read7BitEncodedInt(); @@ -380,7 +380,7 @@ namespace System.Resources // This is used in the enumerator. The enumerator iterates from 0 to n // of our resources and this returns the resource name for a particular // index. The parameter is NOT a virtual offset. - private unsafe String AllocateStringForNameIndex(int index, out int dataOffset) + private unsafe string AllocateStringForNameIndex(int index, out int dataOffset) { Debug.Assert(_store != null, "ResourceReader is closed!"); byte[] bytes; @@ -401,10 +401,10 @@ namespace System.Resources if (_ums.Position > _ums.Length - byteLen) throw new BadImageFormatException(SR.Format(SR.BadImageFormat_ResourcesIndexTooLong, index)); - String s = null; + string s = null; char* charPtr = (char*)_ums.PositionPointer; - s = new String(charPtr, 0, byteLen / 2); + s = new string(charPtr, 0, byteLen / 2); _ums.Position += byteLen; dataOffset = _store.ReadInt32(); @@ -466,17 +466,17 @@ namespace System.Resources // from that location. // Anyone who calls LoadObject should make sure they take a lock so // no one can cause us to do a seek in here. - internal String LoadString(int pos) + internal string LoadString(int pos) { Debug.Assert(_store != null, "ResourceReader is closed!"); _store.BaseStream.Seek(_dataSectionOffset + pos, SeekOrigin.Begin); - String s = null; + string s = null; int typeIndex = _store.Read7BitEncodedInt(); if (_version == 1) { if (typeIndex == -1) return null; - if (FindType(typeIndex) != typeof(String)) + if (FindType(typeIndex) != typeof(string)) throw new InvalidOperationException(SR.Format(SR.InvalidOperation_ResourceNotString_Type, FindType(typeIndex).FullName)); s = _store.ReadString(); } @@ -485,7 +485,7 @@ namespace System.Resources ResourceTypeCode typeCode = (ResourceTypeCode)typeIndex; if (typeCode != ResourceTypeCode.String && typeCode != ResourceTypeCode.Null) { - String typeString; + string typeString; if (typeCode < ResourceTypeCode.StartOfUserTypes) typeString = typeCode.ToString(); else @@ -513,7 +513,7 @@ namespace System.Resources if (_version == 1) { Object o = LoadObjectV1(pos); - typeCode = (o is String) ? ResourceTypeCode.String : ResourceTypeCode.StartOfUserTypes; + typeCode = (o is string) ? ResourceTypeCode.String : ResourceTypeCode.StartOfUserTypes; return o; } return LoadObjectV2(pos, out typeCode); @@ -555,7 +555,7 @@ namespace System.Resources // primitive or a value type first, so we can reach the // deserialization code faster for arbitrary objects. - if (type == typeof(String)) + if (type == typeof(string)) return _store.ReadString(); else if (type == typeof(Int32)) return _store.ReadInt32(); @@ -801,7 +801,7 @@ namespace System.Resources // Read in type name for a suitable ResourceReader // Note ResourceWriter & InternalResGen use different Strings. - String readerType = _store.ReadString(); + string readerType = _store.ReadString(); readerType = System.CoreLib.FixupCoreLibName(readerType); AssemblyName mscorlib = new AssemblyName(ResourceManager.MscorlibName); @@ -948,7 +948,7 @@ namespace System.Resources try { _store.BaseStream.Position = _typeNamePositions[typeIndex]; - String typeName = _store.ReadString(); + string typeName = _store.ReadString(); _typeTable[typeIndex] = (RuntimeType)Type.GetType(typeName, true); } // If serialization isn't supported, we convert FileNotFoundException to @@ -975,7 +975,7 @@ namespace System.Resources } - public void GetResourceData(String resourceName, out String resourceType, out byte[] resourceData) + public void GetResourceData(string resourceName, out string resourceType, out byte[] resourceData) { if (resourceName == null) throw new ArgumentNullException(nameof(resourceName)); @@ -1041,12 +1041,12 @@ namespace System.Resources } } - private String TypeNameFromTypeCode(ResourceTypeCode typeCode) + private string TypeNameFromTypeCode(ResourceTypeCode typeCode) { Debug.Assert(typeCode >= 0, "can't be negative"); if (typeCode < ResourceTypeCode.StartOfUserTypes) { - Debug.Assert(!String.Equals(typeCode.ToString(), "LastPrimitive"), "Change ResourceTypeCode metadata order so LastPrimitive isn't what Enum.ToString prefers."); + Debug.Assert(!string.Equals(typeCode.ToString(), "LastPrimitive"), "Change ResourceTypeCode metadata order so LastPrimitive isn't what Enum.ToString prefers."); return "ResourceTypeCode." + typeCode.ToString(); } else @@ -1135,7 +1135,7 @@ namespace System.Resources if (!_currentIsValid) throw new InvalidOperationException(SR.InvalidOperation_EnumNotStarted); if (_reader._resCache == null) throw new InvalidOperationException(SR.ResourceReaderIsClosed); - String key; + string key; Object value = null; lock (_reader) { // locks should be taken in the same order as in RuntimeResourceSet.GetObject to avoid deadlock diff --git a/src/System.Private.CoreLib/src/System/Resources/__FastResourceComparer.cs b/src/System.Private.CoreLib/src/System/Resources/__FastResourceComparer.cs index b9e2f81..59ca943 100644 --- a/src/System.Private.CoreLib/src/System/Resources/__FastResourceComparer.cs +++ b/src/System.Private.CoreLib/src/System/Resources/__FastResourceComparer.cs @@ -21,18 +21,18 @@ using System.Diagnostics; namespace System.Resources { - internal sealed class FastResourceComparer : IComparer, IEqualityComparer, IComparer, IEqualityComparer + internal sealed class FastResourceComparer : IComparer, IEqualityComparer, IComparer, IEqualityComparer { internal static readonly FastResourceComparer Default = new FastResourceComparer(); // Implements IHashCodeProvider too, due to Hashtable requirements. public int GetHashCode(Object key) { - String s = (String)key; + string s = (string)key; return FastResourceComparer.HashFunction(s); } - public int GetHashCode(String key) + public int GetHashCode(string key) { return FastResourceComparer.HashFunction(key); } @@ -40,7 +40,7 @@ namespace System.Resources // This hash function MUST be publically documented with the resource // file format, AND we may NEVER change this hash function's return // value (without changing the file format). - internal static int HashFunction(String key) + internal static int HashFunction(string key) { // Never change this hash function. We must standardize it so that // others can read & write our .resources files. Additionally, we @@ -55,32 +55,32 @@ namespace System.Resources public int Compare(Object a, Object b) { if (a == b) return 0; - String sa = (String)a; - String sb = (String)b; - return String.CompareOrdinal(sa, sb); + string sa = (string)a; + string sb = (string)b; + return string.CompareOrdinal(sa, sb); } - public int Compare(String a, String b) + public int Compare(string a, string b) { - return String.CompareOrdinal(a, b); + return string.CompareOrdinal(a, b); } - public bool Equals(String a, String b) + public bool Equals(string a, string b) { - return String.Equals(a, b); + return string.Equals(a, b); } public new bool Equals(Object a, Object b) { if (a == b) return true; - String sa = (String)a; - String sb = (String)b; - return String.Equals(sa, sb); + string sa = (string)a; + string sb = (string)b; + return string.Equals(sa, sb); } // Input is one string to compare with, and a byte[] containing chars in // little endian unicode. Pass in the number of valid chars. - public static unsafe int CompareOrdinal(String a, byte[] bytes, int bCharLength) + public static unsafe int CompareOrdinal(string a, byte[] bytes, int bCharLength) { Debug.Assert(a != null && bytes != null, "FastResourceComparer::CompareOrdinal must have non-null params"); Debug.Assert(bCharLength * 2 <= bytes.Length, "FastResourceComparer::CompareOrdinal - numChars is too big!"); @@ -109,14 +109,14 @@ namespace System.Resources return a.Length - bCharLength; } - public static int CompareOrdinal(byte[] bytes, int aCharLength, String b) + public static int CompareOrdinal(byte[] bytes, int aCharLength, string b) { return -CompareOrdinal(b, bytes, aCharLength); } // This method is to handle potentially misaligned data accesses. // The byte* must point to little endian Unicode characters. - internal static unsafe int CompareOrdinal(byte* a, int byteLen, String b) + internal static unsafe int CompareOrdinal(byte* a, int byteLen, string b) { Debug.Assert((byteLen & 1) == 0, "CompareOrdinal is expecting a UTF-16 string length, which must be even!"); Debug.Assert(a != null && b != null, "Null args not allowed."); diff --git a/src/System.Private.CoreLib/src/System/RtType.cs b/src/System.Private.CoreLib/src/System/RtType.cs index ca25f85..c910bf5 100644 --- a/src/System.Private.CoreLib/src/System/RtType.cs +++ b/src/System.Private.CoreLib/src/System/RtType.cs @@ -1128,8 +1128,8 @@ namespace System Debug.Assert(ReflectedType != null); // Do not create the dictionary if we are filtering the properties by name already - Dictionary csEventInfos = filter.CaseSensitive() ? null : - new Dictionary(); + Dictionary csEventInfos = filter.CaseSensitive() ? null : + new Dictionary(); RuntimeType declaringType = ReflectedType; ListBuilder list = new ListBuilder(); @@ -1156,7 +1156,7 @@ namespace System } private unsafe void PopulateEvents( - Filter filter, RuntimeType declaringType, Dictionary csEventInfos, ref ListBuilder list) + Filter filter, RuntimeType declaringType, Dictionary csEventInfos, ref ListBuilder list) { int tkDeclaringType = RuntimeTypeHandle.GetToken(declaringType); @@ -1233,8 +1233,8 @@ namespace System declaringType = declaringType.GetBaseType(); // Do not create the dictionary if we are filtering the properties by name already - Dictionary> csPropertyInfos = filter.CaseSensitive() ? null : - new Dictionary>(); + Dictionary> csPropertyInfos = filter.CaseSensitive() ? null : + new Dictionary>(); // All elements automatically initialized to false. bool[] usedSlots = new bool[RuntimeTypeHandle.GetNumVirtuals(declaringType)]; @@ -1258,7 +1258,7 @@ namespace System private unsafe void PopulateProperties( Filter filter, RuntimeType declaringType, - Dictionary> csPropertyInfos, + Dictionary> csPropertyInfos, bool[] usedSlots, ref ListBuilder list) { @@ -1754,7 +1754,7 @@ namespace System #region Static Members #region Internal - internal static RuntimeType GetType(String typeName, bool throwOnError, bool ignoreCase, bool reflectionOnly, + internal static RuntimeType GetType(string typeName, bool throwOnError, bool ignoreCase, bool reflectionOnly, ref StackCrawlMark stackMark) { if (typeName == null) @@ -1827,7 +1827,7 @@ namespace System } if (!loaderAssuredCompatible) - throw new ArgumentException(String.Format( + throw new ArgumentException(string.Format( CultureInfo.CurrentCulture, SR.Argument_ResolveMethodHandle, reflectedType.ToString(), declaredType.ToString())); } @@ -1855,7 +1855,7 @@ namespace System if (baseType == null) { // ignoring instantiation is the ReflectedType is not a subtype of the DeclaringType - throw new ArgumentException(String.Format( + throw new ArgumentException(string.Format( CultureInfo.CurrentCulture, SR.Argument_ResolveMethodHandle, reflectedType.ToString(), declaredType.ToString())); } @@ -1877,7 +1877,7 @@ namespace System else if (!declaredType.IsAssignableFrom(reflectedType)) { // declaredType is not Array, not generic, and not assignable from reflectedType - throw new ArgumentException(String.Format( + throw new ArgumentException(string.Format( CultureInfo.CurrentCulture, SR.Argument_ResolveMethodHandle, reflectedType.ToString(), declaredType.ToString())); } @@ -1945,7 +1945,7 @@ namespace System if (!RuntimeFieldHandle.AcquiresContextFromThis(fieldHandle) || !RuntimeTypeHandle.CompareCanonicalHandles(declaredType, reflectedType)) { - throw new ArgumentException(String.Format( + throw new ArgumentException(string.Format( CultureInfo.CurrentCulture, SR.Argument_ResolveFieldHandle, reflectedType.ToString(), declaredType.ToString())); @@ -2482,7 +2482,7 @@ namespace System private const int GenericParameterCountAny = -1; private ListBuilder GetMethodCandidates( - String name, int genericParameterCount, BindingFlags bindingAttr, CallingConventions callConv, + string name, int genericParameterCount, BindingFlags bindingAttr, CallingConventions callConv, Type[] types, bool allowPrefixLookup) { bool prefixLookup, ignoreCase; @@ -2534,7 +2534,7 @@ namespace System private ListBuilder GetPropertyCandidates( - String name, BindingFlags bindingAttr, Type[] types, bool allowPrefixLookup) + string name, BindingFlags bindingAttr, Type[] types, bool allowPrefixLookup) { bool prefixLookup, ignoreCase; MemberListType listType; @@ -2559,7 +2559,7 @@ namespace System return candidates; } - private ListBuilder GetEventCandidates(String name, BindingFlags bindingAttr, bool allowPrefixLookup) + private ListBuilder GetEventCandidates(string name, BindingFlags bindingAttr, bool allowPrefixLookup) { bool prefixLookup, ignoreCase; MemberListType listType; @@ -2583,7 +2583,7 @@ namespace System return candidates; } - private ListBuilder GetFieldCandidates(String name, BindingFlags bindingAttr, bool allowPrefixLookup) + private ListBuilder GetFieldCandidates(string name, BindingFlags bindingAttr, bool allowPrefixLookup) { bool prefixLookup, ignoreCase; MemberListType listType; @@ -2607,7 +2607,7 @@ namespace System return candidates; } - private ListBuilder GetNestedTypeCandidates(String fullname, BindingFlags bindingAttr, bool allowPrefixLookup) + private ListBuilder GetNestedTypeCandidates(string fullname, BindingFlags bindingAttr, bool allowPrefixLookup) { bool prefixLookup, ignoreCase; bindingAttr &= ~BindingFlags.Static; @@ -2769,21 +2769,21 @@ namespace System #region Find XXXInfo protected override MethodInfo GetMethodImpl( - String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, + string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers) { return GetMethodImplCommon(name, GenericParameterCountAny, bindingAttr, binder, callConv, types, modifiers); } protected override MethodInfo GetMethodImpl( - String name, int genericParameterCount, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, + string name, int genericParameterCount, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers) { return GetMethodImplCommon(name, genericParameterCount, bindingAttr, binder, callConv, types, modifiers); } private MethodInfo GetMethodImplCommon( - String name, int genericParameterCount, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, + string name, int genericParameterCount, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers) { ListBuilder candidates = GetMethodCandidates(name, genericParameterCount, bindingAttr, callConv, types, false); @@ -2853,7 +2853,7 @@ namespace System protected override PropertyInfo GetPropertyImpl( - String name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) + string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers) { if (name == null) throw new ArgumentNullException(); @@ -2892,7 +2892,7 @@ namespace System } - public override EventInfo GetEvent(String name, BindingFlags bindingAttr) + public override EventInfo GetEvent(string name, BindingFlags bindingAttr) { if (name == null) throw new ArgumentNullException(); @@ -2920,7 +2920,7 @@ namespace System return match; } - public override FieldInfo GetField(String name, BindingFlags bindingAttr) + public override FieldInfo GetField(string name, BindingFlags bindingAttr) { if (name == null) throw new ArgumentNullException(); @@ -2959,7 +2959,7 @@ namespace System return match; } - public override Type GetInterface(String fullname, bool ignoreCase) + public override Type GetInterface(string fullname, bool ignoreCase) { if (fullname == null) throw new ArgumentNullException(); @@ -2994,7 +2994,7 @@ namespace System return match; } - public override Type GetNestedType(String fullname, BindingFlags bindingAttr) + public override Type GetNestedType(string fullname, BindingFlags bindingAttr) { if (fullname == null) throw new ArgumentNullException(); @@ -3024,7 +3024,7 @@ namespace System return match; } - public override MemberInfo[] GetMember(String name, MemberTypes type, BindingFlags bindingAttr) + public override MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr) { if (name == null) throw new ArgumentNullException(); @@ -3372,7 +3372,7 @@ namespace System #endregion #region Name - public override String FullName + public override string FullName { get { @@ -3380,7 +3380,7 @@ namespace System } } - public override String AssemblyQualifiedName + public override string AssemblyQualifiedName { get { @@ -3394,7 +3394,7 @@ namespace System } } - public override String Namespace + public override string Namespace { get { @@ -3557,10 +3557,10 @@ namespace System if (!IsEnum) throw new ArgumentException(SR.Arg_MustBeEnum, "enumType"); - String[] ret = Enum.InternalGetNames(this); + string[] ret = Enum.InternalGetNames(this); // Make a copy since we can't hand out the same array since users can modify them - String[] retVal = new String[ret.Length]; + string[] retVal = new string[ret.Length]; Array.Copy(ret, retVal, ret.Length); @@ -3903,7 +3903,7 @@ namespace System } if ((invokeAttr & BindingFlags.ExactBinding) == BindingFlags.ExactBinding) - throw new ArgumentException(String.Format(CultureInfo.CurrentUICulture, SR.Arg_ObjObjEx, value.GetType(), this)); + throw new ArgumentException(string.Format(CultureInfo.CurrentUICulture, SR.Arg_ObjObjEx, value.GetType(), this)); return TryChangeType(value, binder, culture, needsSpecialCast); } @@ -3944,7 +3944,7 @@ namespace System } } - throw new ArgumentException(String.Format(CultureInfo.CurrentUICulture, SR.Arg_ObjObjEx, value.GetType(), this)); + throw new ArgumentException(string.Format(CultureInfo.CurrentUICulture, SR.Arg_ObjObjEx, value.GetType(), this)); } // GetDefaultMembers @@ -3954,7 +3954,7 @@ namespace System // See if we have cached the default member name MemberInfo[] members = null; - String defaultMemberName = GetDefaultMemberName(); + string defaultMemberName = GetDefaultMemberName(); if (defaultMemberName != null) { members = GetMember(defaultMemberName); @@ -3971,8 +3971,8 @@ namespace System [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] public override Object InvokeMember( - String name, BindingFlags bindingFlags, Binder binder, Object target, - Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) + string name, BindingFlags bindingFlags, Binder binder, Object target, + Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParams) { if (IsGenericParameter) throw new InvalidOperationException(SR.Arg_GenericParameter); @@ -4434,7 +4434,7 @@ namespace System return RuntimeHelpers.GetHashCode(this); } - public override String ToString() + public override string ToString() { return GetCachedName(TypeNameKind.ToString); } @@ -4486,7 +4486,7 @@ namespace System #endregion #region MemberInfo Overrides - public override String Name + public override string Name { get { @@ -4668,7 +4668,7 @@ namespace System { Debug.Assert((invokeMethod.CallingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs); - throw new NotSupportedException(String.Format(CultureInfo.CurrentCulture, + throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, SR.NotSupported_CallToVarArg)); } @@ -4769,7 +4769,7 @@ namespace System // the slow path of CreateInstanceDefaultCtor internal Object CreateInstanceSlow(bool publicOnly, bool wrapExceptions, bool skipCheckThis, bool fillCache) { - RuntimeMethodHandleInternal runtime_ctor = default(RuntimeMethodHandleInternal); + RuntimeMethodHandleInternal runtime_ctor = default; bool bCanBeCached = false; if (!skipCheckThis) @@ -4865,16 +4865,16 @@ namespace System #if FEATURE_COMINTEROP [MethodImplAttribute(MethodImplOptions.InternalCall)] private extern Object InvokeDispMethod( - String name, BindingFlags invokeAttr, Object target, Object[] args, - bool[] byrefModifiers, int culture, String[] namedParameters); + string name, BindingFlags invokeAttr, Object target, Object[] args, + bool[] byrefModifiers, int culture, string[] namedParameters); #endif // FEATURE_COMINTEROP #if FEATURE_COMINTEROP_UNMANAGED_ACTIVATION [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern Type GetTypeFromProgIDImpl(String progID, String server, bool throwOnError); + internal static extern Type GetTypeFromProgIDImpl(string progID, string server, bool throwOnError); [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern Type GetTypeFromCLSIDImpl(Guid clsid, String server, bool throwOnError); + internal static extern Type GetTypeFromCLSIDImpl(Guid clsid, string server, bool throwOnError); #else // FEATURE_COMINTEROP_UNMANAGED_ACTIVATION internal static Type GetTypeFromProgIDImpl(String progID, String server, bool throwOnError) { @@ -5152,7 +5152,7 @@ namespace System.Reflection { Table table = Volatile.Read(ref m_Table); if (table == null) - return default(V); + return default; int hashcode = GetHashCodeHelper(key); if (hashcode < 0) @@ -5177,7 +5177,7 @@ namespace System.Reflection } else { - return default(V); + return default; } } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs index f247d10..d411609 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs @@ -193,7 +193,7 @@ namespace System.Runtime.CompilerServices /// Initializes a new . /// The initialized . - public static AsyncTaskMethodBuilder Create() => default(AsyncTaskMethodBuilder); + public static AsyncTaskMethodBuilder Create() => default; /// Initiates the builder's execution with the associated state machine. /// Specifies the type of the state machine. @@ -304,7 +304,7 @@ namespace System.Runtime.CompilerServices /// The initialized . public static AsyncTaskMethodBuilder Create() { - return default(AsyncTaskMethodBuilder); + return default; // NOTE: If this method is ever updated to perform more initialization, // other Create methods like AsyncTaskMethodBuilder.Create and // AsyncValueTaskMethodBuilder.Create must be updated to call this. @@ -682,7 +682,7 @@ namespace System.Runtime.CompilerServices else { // Otherwise, complete the task that's there. - SetExistingTaskResult(default(TResult)); + SetExistingTaskResult(default); } } @@ -821,16 +821,16 @@ namespace System.Runtime.CompilerServices } // For other known value types, we only special-case 0 / default(TResult). else if ( - (typeof(TResult) == typeof(UInt32) && default(UInt32) == (UInt32)(object)result) || + (typeof(TResult) == typeof(UInt32) && default == (UInt32)(object)result) || (typeof(TResult) == typeof(Byte) && default(Byte) == (Byte)(object)result) || (typeof(TResult) == typeof(SByte) && default(SByte) == (SByte)(object)result) || (typeof(TResult) == typeof(Char) && default(Char) == (Char)(object)result) || - (typeof(TResult) == typeof(Int64) && default(Int64) == (Int64)(object)result) || - (typeof(TResult) == typeof(UInt64) && default(UInt64) == (UInt64)(object)result) || + (typeof(TResult) == typeof(Int64) && default == (Int64)(object)result) || + (typeof(TResult) == typeof(UInt64) && default == (UInt64)(object)result) || (typeof(TResult) == typeof(Int16) && default(Int16) == (Int16)(object)result) || (typeof(TResult) == typeof(UInt16) && default(UInt16) == (UInt16)(object)result) || - (typeof(TResult) == typeof(IntPtr) && default(IntPtr) == (IntPtr)(object)result) || - (typeof(TResult) == typeof(UIntPtr) && default(UIntPtr) == (UIntPtr)(object)result)) + (typeof(TResult) == typeof(IntPtr) && default == (IntPtr)(object)result) || + (typeof(TResult) == typeof(UIntPtr) && default == (UIntPtr)(object)result)) { return s_defaultResultTask; } @@ -878,7 +878,7 @@ namespace System.Runtime.CompilerServices /// The result for the task. /// The cacheable task. internal static Task CreateCacheableTask(TResult result) => - new Task(false, result, (TaskCreationOptions)InternalTaskOptions.DoNotDispose, default(CancellationToken)); + new Task(false, result, (TaskCreationOptions)InternalTaskOptions.DoNotDispose, default); } /// diff --git a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs index 2bbed36..2f0cca9 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs @@ -357,7 +357,7 @@ namespace System.Runtime.CompilerServices if (table != null) { // Ensure we don't keep the last current alive unnecessarily - _current = default(KeyValuePair); + _current = default; // Decrement the ref count that was incremented when constructed lock (table._lock) @@ -634,8 +634,8 @@ namespace System.Runtime.CompilerServices } } - key = default(TKey); - value = default(TValue); + key = default; + value = default; return false; } diff --git a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/TaskAwaiter.cs b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/TaskAwaiter.cs index 487a311..3d72798 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/TaskAwaiter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/TaskAwaiter.cs @@ -143,7 +143,7 @@ namespace System.Runtime.CompilerServices // but where for one reason or another synchronous rather than asynchronous waiting is needed. if (!task.IsCompleted) { - bool taskCompleted = task.InternalWait(Timeout.Infinite, default(CancellationToken)); + bool taskCompleted = task.InternalWait(Timeout.Infinite, default); Debug.Assert(taskCompleted, "With an infinite timeout, the task should have always completed."); } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs index 52ca18c..d4eb69e 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs @@ -100,10 +100,10 @@ namespace System.Runtime.InteropServices // The name, title and description of the assembly that will contain // the dynamically generated interop types. //==================================================================== - private const String s_strConvertedTypeInfoAssemblyName = "InteropDynamicTypes"; - private const String s_strConvertedTypeInfoAssemblyTitle = "Interop Dynamic Types"; - private const String s_strConvertedTypeInfoAssemblyDesc = "Type dynamically generated from ITypeInfo's"; - private const String s_strConvertedTypeInfoNameSpace = "InteropDynamicTypes"; + private const string s_strConvertedTypeInfoAssemblyName = "InteropDynamicTypes"; + private const string s_strConvertedTypeInfoAssemblyTitle = "Interop Dynamic Types"; + private const string s_strConvertedTypeInfoAssemblyDesc = "Type dynamically generated from ITypeInfo's"; + private const string s_strConvertedTypeInfoNameSpace = "InteropDynamicTypes"; //==================================================================== @@ -112,7 +112,7 @@ namespace System.Runtime.InteropServices [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern int GetSystemMaxDBCSCharSize(); - public static unsafe String PtrToStringAnsi(IntPtr ptr) + public static unsafe string PtrToStringAnsi(IntPtr ptr) { if (IntPtr.Zero == ptr) { @@ -131,38 +131,38 @@ namespace System.Runtime.InteropServices } else { - return new String((sbyte*)ptr); + return new string((sbyte*)ptr); } } } - public static unsafe String PtrToStringAnsi(IntPtr ptr, int len) + public static unsafe string PtrToStringAnsi(IntPtr ptr, int len) { if (ptr == IntPtr.Zero) throw new ArgumentNullException(nameof(ptr)); if (len < 0) throw new ArgumentException(null, nameof(len)); - return new String((sbyte*)ptr, 0, len); + return new string((sbyte*)ptr, 0, len); } - public static unsafe String PtrToStringUni(IntPtr ptr, int len) + public static unsafe string PtrToStringUni(IntPtr ptr, int len) { if (ptr == IntPtr.Zero) throw new ArgumentNullException(nameof(ptr)); if (len < 0) throw new ArgumentException(null, nameof(len)); - return new String((char*)ptr, 0, len); + return new string((char*)ptr, 0, len); } - public static String PtrToStringAuto(IntPtr ptr, int len) + public static string PtrToStringAuto(IntPtr ptr, int len) { // Ansi platforms are no longer supported return PtrToStringUni(ptr, len); } - public static unsafe String PtrToStringUni(IntPtr ptr) + public static unsafe string PtrToStringUni(IntPtr ptr) { if (IntPtr.Zero == ptr) { @@ -174,17 +174,17 @@ namespace System.Runtime.InteropServices } else { - return new String((char*)ptr); + return new string((char*)ptr); } } - public static String PtrToStringAuto(IntPtr ptr) + public static string PtrToStringAuto(IntPtr ptr) { // Ansi platforms are no longer supported return PtrToStringUni(ptr); } - public static unsafe String PtrToStringUTF8(IntPtr ptr) + public static unsafe string PtrToStringUTF8(IntPtr ptr) { if (IntPtr.Zero == ptr) { @@ -197,7 +197,7 @@ namespace System.Runtime.InteropServices } } - public static unsafe String PtrToStringUTF8(IntPtr ptr, int byteLen) + public static unsafe string PtrToStringUTF8(IntPtr ptr, int byteLen) { if (byteLen < 0) { @@ -262,7 +262,7 @@ namespace System.Runtime.InteropServices //==================================================================== // OffsetOf() //==================================================================== - public static IntPtr OffsetOf(Type t, String fieldName) + public static IntPtr OffsetOf(Type t, string fieldName) { if (t == null) throw new ArgumentNullException(nameof(t)); @@ -1071,7 +1071,7 @@ namespace System.Runtime.InteropServices //==================================================================== // String convertions. //==================================================================== - public static unsafe IntPtr StringToHGlobalAnsi(String s) + public static unsafe IntPtr StringToHGlobalAnsi(string s) { if (s == null) { @@ -1100,7 +1100,7 @@ namespace System.Runtime.InteropServices } } - public static unsafe IntPtr StringToHGlobalUni(String s) + public static unsafe IntPtr StringToHGlobalUni(string s) { if (s == null) { @@ -1125,14 +1125,14 @@ namespace System.Runtime.InteropServices { fixed (char* firstChar = s) { - String.wstrcpy((char*)hglobal, firstChar, s.Length + 1); + string.wstrcpy((char*)hglobal, firstChar, s.Length + 1); } return hglobal; } } } - public static IntPtr StringToHGlobalAuto(String s) + public static IntPtr StringToHGlobalAuto(string s) { // Ansi platforms are no longer supported return StringToHGlobalUni(s); @@ -1161,15 +1161,15 @@ namespace System.Runtime.InteropServices //==================================================================== // Given a managed object that wraps an ITypeInfo, return its name //==================================================================== - public static String GetTypeInfoName(ITypeInfo typeInfo) + public static string GetTypeInfoName(ITypeInfo typeInfo) { if (typeInfo == null) throw new ArgumentNullException(nameof(typeInfo)); - String strTypeLibName = null; - String strDocString = null; + string strTypeLibName = null; + string strDocString = null; int dwHelpContext = 0; - String strHelpFile = null; + string strHelpFile = null; typeInfo.GetDocumentation(-1, out strTypeLibName, out strDocString, out dwHelpContext, out strHelpFile); @@ -1300,7 +1300,7 @@ namespace System.Runtime.InteropServices return pNewMem; } - public static unsafe IntPtr StringToCoTaskMemUni(String s) + public static unsafe IntPtr StringToCoTaskMemUni(string s) { if (s == null) { @@ -1324,14 +1324,14 @@ namespace System.Runtime.InteropServices { fixed (char* firstChar = s) { - String.wstrcpy((char*)hglobal, firstChar, s.Length + 1); + string.wstrcpy((char*)hglobal, firstChar, s.Length + 1); } return hglobal; } } } - public static unsafe IntPtr StringToCoTaskMemUTF8(String s) + public static unsafe IntPtr StringToCoTaskMemUTF8(string s) { if (s == null) { @@ -1360,13 +1360,13 @@ namespace System.Runtime.InteropServices } } - public static IntPtr StringToCoTaskMemAuto(String s) + public static IntPtr StringToCoTaskMemAuto(string s) { // Ansi platforms are no longer supported return StringToCoTaskMemUni(s); } - public static unsafe IntPtr StringToCoTaskMemAnsi(String s) + public static unsafe IntPtr StringToCoTaskMemAnsi(string s) { if (s == null) { @@ -1423,7 +1423,7 @@ namespace System.Runtime.InteropServices } } - public static IntPtr StringToBSTR(String s) + public static IntPtr StringToBSTR(string s) { if (s == null) return IntPtr.Zero; @@ -1439,7 +1439,7 @@ namespace System.Runtime.InteropServices return bstr; } - public static String PtrToStringBSTR(IntPtr ptr) + public static string PtrToStringBSTR(IntPtr ptr) { return PtrToStringUni(ptr, (int)Win32Native.SysStringLen(ptr)); } @@ -1650,7 +1650,7 @@ namespace System.Runtime.InteropServices // PROGID is generated based on the fully qualified name of the // type. //==================================================================== - public static String GenerateProgIdForType(Type type) + public static string GenerateProgIdForType(Type type) { if (type == null) throw new ArgumentNullException(nameof(type)); @@ -1669,12 +1669,12 @@ namespace System.Runtime.InteropServices Debug.Assert(caConstructorArgs.Count == 1, "caConstructorArgs.Count == 1"); CustomAttributeTypedArgument progIdConstructorArg = caConstructorArgs[0]; - Debug.Assert(progIdConstructorArg.ArgumentType == typeof(String), "progIdConstructorArg.ArgumentType == typeof(String)"); + Debug.Assert(progIdConstructorArg.ArgumentType == typeof(string), "progIdConstructorArg.ArgumentType == typeof(String)"); - String strProgId = (String)progIdConstructorArg.Value; + string strProgId = (string)progIdConstructorArg.Value; if (strProgId == null) - strProgId = String.Empty; + strProgId = string.Empty; return strProgId; } @@ -1688,7 +1688,7 @@ namespace System.Runtime.InteropServices //==================================================================== // This method binds to the specified moniker. //==================================================================== - public static Object BindToMoniker(String monikerName) + public static Object BindToMoniker(string monikerName) { Object obj = null; IBindCtx bindctx = null; @@ -1706,7 +1706,7 @@ namespace System.Runtime.InteropServices private static extern void CreateBindCtx(UInt32 reserved, out IBindCtx ppbc); [DllImport(Interop.Libraries.Ole32, PreserveSig = false)] - private static extern void MkParseDisplayName(IBindCtx pbc, [MarshalAs(UnmanagedType.LPWStr)] String szUserName, out UInt32 pchEaten, out IMoniker ppmk); + private static extern void MkParseDisplayName(IBindCtx pbc, [MarshalAs(UnmanagedType.LPWStr)] string szUserName, out UInt32 pchEaten, out IMoniker ppmk); [DllImport(Interop.Libraries.Ole32, PreserveSig = false)] private static extern void BindMoniker(IMoniker pmk, UInt32 grfOpt, ref Guid iidResult, [MarshalAs(UnmanagedType.Interface)] out Object ppvResult); diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs index 85b6c39..7573af6 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs @@ -150,12 +150,12 @@ namespace System.Runtime.InteropServices.WindowsRuntime public bool TryGetValue(TKey key, out TValue value) { - KeyValuePair searchKey = new KeyValuePair(key, default(TValue)); + KeyValuePair searchKey = new KeyValuePair(key, default); int index = Array.BinarySearch(items, firstItemIndex, Count, searchKey, keyValuePairComparator); if (index < 0) { - value = default(TValue); + value = default; return false; } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs index 1d7a5df..5a19e0d 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs @@ -110,7 +110,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime if (!accessor.IsPublic) throw new MethodAccessException( - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.Arg_MethodAccessException_WithMethodName, accessor.ToString(), diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/EnumeratorToIteratorAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/EnumeratorToIteratorAdapter.cs index 861ee6e..3f3d8a9 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/EnumeratorToIteratorAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/EnumeratorToIteratorAdapter.cs @@ -158,7 +158,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // Fill the rest of the array with String.Empty to avoid marshaling failure for (int i = index; i < items.Length; ++i) - stringItems[i] = String.Empty; + stringItems[i] = string.Empty; } return index; diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs index e131d56..f4f6ab9 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs @@ -79,7 +79,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // throw an exception from Lookup. if (!_this.HasKey(key)) { - value = default(V); + value = default; return false; } @@ -92,7 +92,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime { if (HResults.E_BOUNDS == ex._HResult) { - value = default(V); + value = default; return false; } throw; diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyListToIVectorViewAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyListToIVectorViewAdapter.cs index be52bce..8f8fabf 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyListToIVectorViewAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyListToIVectorViewAdapter.cs @@ -112,7 +112,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // Fill in the rest of the array with String.Empty to avoid marshaling failure for (uint i = itemCount; i < items.Length; ++i) - stringItems[i] = String.Empty; + stringItems[i] = string.Empty; } return itemCount; diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ListToVectorAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ListToVectorAdapter.cs index 12ba366..44b9852 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ListToVectorAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ListToVectorAdapter.cs @@ -235,7 +235,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // Fill in rest of the array with String.Empty to avoid marshaling failure for (uint i = itemCount; i < items.Length; ++i) - stringItems[i] = String.Empty; + stringItems[i] = string.Empty; } return itemCount; diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/MapToDictionaryAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/MapToDictionaryAdapter.cs index cbac962..4f674fe 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/MapToDictionaryAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/MapToDictionaryAdapter.cs @@ -125,7 +125,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime IMap _this = Unsafe.As>(this); if (!_this.HasKey(key)) { - value = default(V); + value = default; return false; } @@ -136,7 +136,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime } catch (KeyNotFoundException) { - value = default(V); + value = default; return false; } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs index 1cdb855..3f0c771 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs @@ -1043,7 +1043,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime // There is no difference between a null and empty HSTRING if (hstring == IntPtr.Zero) { - return String.Empty; + return string.Empty; } unsafe @@ -1256,7 +1256,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime } } - public static String PtrToStringHString(IntPtr ptr) + public static string PtrToStringHString(IntPtr ptr) { if (!Environment.IsWinRTSupported) { diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs index ecc1916..d5e2878 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMetadata.cs @@ -37,7 +37,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime int retIndex = 0; foreach (string assemblyFile in assemblyFilesCollection) { - if (String.IsNullOrEmpty(assemblyFile)) + if (string.IsNullOrEmpty(assemblyFile)) { // DesignerNamespaceResolve event returned null or empty file name - that is not allowed throw new ArgumentException(SR.Arg_EmptyOrNullString, "DesignerNamespaceResolveEventArgs.ResolvedAssemblyFiles"); } diff --git a/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs b/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs index 806c2f7..cf5fc3c 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs @@ -221,7 +221,7 @@ namespace System.Runtime.Loader } // The simple names should match at the very least - if (String.IsNullOrEmpty(loadedSimpleName) || (!requestedSimpleName.Equals(loadedSimpleName, StringComparison.InvariantCultureIgnoreCase))) + if (string.IsNullOrEmpty(loadedSimpleName) || (!requestedSimpleName.Equals(loadedSimpleName, StringComparison.InvariantCultureIgnoreCase))) throw new InvalidOperationException(SR.Argument_CustomAssemblyLoadContextRequestedNameMismatch); return assembly; diff --git a/src/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.cs b/src/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.cs index d05c346..c000cda 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.cs @@ -443,7 +443,7 @@ namespace System.Runtime private ulong _totalFreeAddressSpace; private long _lastKnownFreeAddressSpace; private ulong _reservedMem; - private String _stackTrace; // Where did we fail, for additional debugging. + private string _stackTrace; // Where did we fail, for additional debugging. internal MemoryFailPointState(int allocationSizeInMB, ulong segmentSize, bool needPageFile, bool needAddressSpace, bool needContiguousVASpace, ulong availPageFile, ulong totalFreeAddressSpace, long lastKnownFreeAddressSpace, ulong reservedMem) { @@ -470,9 +470,9 @@ namespace System.Runtime } } - public override String ToString() + public override string ToString() { - return String.Format(System.Globalization.CultureInfo.InvariantCulture, "MemoryFailPoint detected insufficient memory to guarantee an operation could complete. Checked for {0} MB, for allocation size of {1} MB. Need page file? {2} Need Address Space? {3} Need Contiguous address space? {4} Avail page file: {5} MB Total free VA space: {6} MB Contiguous free address space (found): {7} MB Space reserved by process's MemoryFailPoints: {8} MB", + return string.Format(System.Globalization.CultureInfo.InvariantCulture, "MemoryFailPoint detected insufficient memory to guarantee an operation could complete. Checked for {0} MB, for allocation size of {1} MB. Need page file? {2} Need Address Space? {3} Need Contiguous address space? {4} Avail page file: {5} MB Total free VA space: {6} MB Contiguous free address space (found): {7} MB Space reserved by process's MemoryFailPoints: {8} MB", _segmentSize >> 20, _allocationSizeInMB, _needPageFile, _needAddressSpace, _needContiguousVASpace, _availPageFile >> 20, _totalFreeAddressSpace >> 20, diff --git a/src/System.Private.CoreLib/src/System/StubHelpers.cs b/src/System.Private.CoreLib/src/System/StubHelpers.cs index 1516217..f64fcd4 100644 --- a/src/System.Private.CoreLib/src/System/StubHelpers.cs +++ b/src/System.Private.CoreLib/src/System/StubHelpers.cs @@ -163,7 +163,7 @@ namespace System.StubHelpers if (IntPtr.Zero == cstr) return null; int nbBytes = StubHelpers.strlen((sbyte*)cstr); - return String.CreateStringFromEncoding((byte*)cstr, nbBytes, Encoding.UTF8); + return string.CreateStringFromEncoding((byte*)cstr, nbBytes, Encoding.UTF8); } internal static void ClearNative(IntPtr pNative) @@ -308,7 +308,7 @@ namespace System.StubHelpers // String .ctor, since newing up a 0 sized string will always return String.Emtpy. // When we marshal that out as a bstr, it can wind up getting modified which // corrupts String.Empty. - ret = String.FastAllocateString(0); + ret = string.FastAllocateString(0); } else { @@ -1065,7 +1065,7 @@ namespace System.StubHelpers int allocSize = (pManagedHome.Length + 1) * 2; pNativeHome = Marshal.AllocCoTaskMem(allocSize); - String.InternalCopy(pManagedHome, pNativeHome, allocSize); + string.InternalCopy(pManagedHome, pNativeHome, allocSize); } return pNativeHome; @@ -1380,7 +1380,7 @@ namespace System.StubHelpers } string typeName = WindowsRuntimeMarshal.HStringToString(pNativeType->typeName); - if (String.IsNullOrEmpty(typeName)) + if (string.IsNullOrEmpty(typeName)) { managedType = null; return; diff --git a/src/System.Private.CoreLib/src/System/Text/EncodingTable.cs b/src/System.Private.CoreLib/src/System/Text/EncodingTable.cs index ab9fbc0..6925be2 100644 --- a/src/System.Private.CoreLib/src/System/Text/EncodingTable.cs +++ b/src/System.Private.CoreLib/src/System/Text/EncodingTable.cs @@ -93,7 +93,7 @@ namespace System.Text } // The encoding name is not valid. throw new ArgumentException( - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.Argument_EncodingNotSupported, name), nameof(name)); } diff --git a/src/System.Private.CoreLib/src/System/Threading/CancellationToken.cs b/src/System.Private.CoreLib/src/System/Threading/CancellationToken.cs index 886210c..cffaf22 100644 --- a/src/System.Private.CoreLib/src/System/Threading/CancellationToken.cs +++ b/src/System.Private.CoreLib/src/System/Threading/CancellationToken.cs @@ -43,7 +43,7 @@ namespace System.Threading /// /// The value returned by this property will be non-cancelable by default. /// - public static CancellationToken None => default(CancellationToken); + public static CancellationToken None => default; /// /// Gets whether cancellation has been requested for this token. @@ -235,7 +235,7 @@ namespace System.Threading CancellationTokenSource source = _source; return source != null ? source.InternalRegister(callback, state, useSyncContext ? SynchronizationContext.Current : null, useExecutionContext ? ExecutionContext.Capture() : null) : - default(CancellationTokenRegistration); // Nothing to do for tokens than can never reach the canceled state. Give back a dummy registration. + default; // Nothing to do for tokens than can never reach the canceled state. Give back a dummy registration. } /// diff --git a/src/System.Private.CoreLib/src/System/Threading/CancellationTokenRegistration.cs b/src/System.Private.CoreLib/src/System/Threading/CancellationTokenRegistration.cs index 3c964a9..67ec05c 100644 --- a/src/System.Private.CoreLib/src/System/Threading/CancellationTokenRegistration.cs +++ b/src/System.Private.CoreLib/src/System/Threading/CancellationTokenRegistration.cs @@ -41,7 +41,7 @@ namespace System.Threading /// registration isn't associated with a token (such as after the registration has been disposed), /// this will return a default token. /// - public CancellationToken Token => _node?.Partition.Source.Token ?? default(CancellationToken); + public CancellationToken Token => _node?.Partition.Source.Token ?? default; /// /// Disposes of the registration and unregisters the target callback from the associated diff --git a/src/System.Private.CoreLib/src/System/Threading/CancellationTokenSource.cs b/src/System.Private.CoreLib/src/System/Threading/CancellationTokenSource.cs index 3b47cf5..7eb1a30 100644 --- a/src/System.Private.CoreLib/src/System/Threading/CancellationTokenSource.cs +++ b/src/System.Private.CoreLib/src/System/Threading/CancellationTokenSource.cs @@ -543,7 +543,7 @@ namespace System.Threading // Cancellation already occurred. Run the callback on this thread and return an empty registration. callback(stateForCallback); - return default(CancellationTokenRegistration); + return default; } private void NotifyCancellation(bool throwOnFirstException) diff --git a/src/System.Private.CoreLib/src/System/Threading/ClrThreadPoolPreAllocatedOverlapped.cs b/src/System.Private.CoreLib/src/System/Threading/ClrThreadPoolPreAllocatedOverlapped.cs index a42e0c7..27ea8a4 100644 --- a/src/System.Private.CoreLib/src/System/Threading/ClrThreadPoolPreAllocatedOverlapped.cs +++ b/src/System.Private.CoreLib/src/System/Threading/ClrThreadPoolPreAllocatedOverlapped.cs @@ -97,7 +97,7 @@ namespace System.Threading { _overlapped._boundHandle = null; _overlapped._completed = false; - *_overlapped._nativeOverlapped = default(NativeOverlapped); + *_overlapped._nativeOverlapped = default; } } } diff --git a/src/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs b/src/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs index d0a8d34..297afa1 100644 --- a/src/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs +++ b/src/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs @@ -158,7 +158,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(SR.ManualResetEventSlim_ctor_TooManyWaiters, NumWaitersState_MaxValue)); + throw new InvalidOperationException(string.Format(SR.ManualResetEventSlim_ctor_TooManyWaiters, NumWaitersState_MaxValue)); UpdateStateAtomically(value << NumWaitersState_ShiftCount, NumWaitersState_BitMask); } @@ -213,7 +213,7 @@ namespace System.Threading { throw new ArgumentOutOfRangeException( nameof(spinCount), - String.Format(SR.ManualResetEventSlim_ctor_SpinCountOutOfRange, SpinCountState_MaxValue)); + string.Format(SR.ManualResetEventSlim_ctor_SpinCountOutOfRange, SpinCountState_MaxValue)); } // We will suppress default spin because the user specified a count. diff --git a/src/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs b/src/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs index 997dbb9..ac57e9e 100644 --- a/src/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs +++ b/src/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs @@ -78,10 +78,10 @@ namespace System.Threading // A pre-completed task with Result==true private readonly static Task s_trueTask = - new Task(false, true, (TaskCreationOptions)InternalTaskOptions.DoNotDispose, default(CancellationToken)); + new Task(false, true, (TaskCreationOptions)InternalTaskOptions.DoNotDispose, default); // A pre-completed task with Result==false private readonly static Task s_falseTask = - new Task(false, false, (TaskCreationOptions)InternalTaskOptions.DoNotDispose, default(CancellationToken)); + new Task(false, false, (TaskCreationOptions)InternalTaskOptions.DoNotDispose, default); // No maximum constant private const int NO_MAXIMUM = Int32.MaxValue; @@ -517,7 +517,7 @@ namespace System.Threading /// A task that will complete when the semaphore has been entered. public Task WaitAsync() { - return WaitAsync(Timeout.Infinite, default(CancellationToken)); + return WaitAsync(Timeout.Infinite, default); } /// @@ -554,7 +554,7 @@ namespace System.Threading /// public Task WaitAsync(int millisecondsTimeout) { - return WaitAsync(millisecondsTimeout, default(CancellationToken)); + return WaitAsync(millisecondsTimeout, default); } /// @@ -582,7 +582,7 @@ namespace System.Threading /// public Task WaitAsync(TimeSpan timeout) { - return WaitAsync(timeout, default(CancellationToken)); + return WaitAsync(timeout, default); } /// @@ -743,7 +743,7 @@ namespace System.Threading // completes due to the asyncWaiter completing, so we use our own token that we can explicitly // cancel, and we chain the caller's supplied token into it. using (var cts = cancellationToken.CanBeCanceled ? - CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, default(CancellationToken)) : + CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, default) : new CancellationTokenSource()) { var waitCompleted = Task.WhenAny(asyncWaiter, Task.Delay(millisecondsTimeout, cts.Token)); diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs index 0e4ed9b..d1bdd13 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs @@ -150,7 +150,7 @@ namespace System.Threading.Tasks s_TracerFactory = (WFD.IAsyncCausalityTracerStatics)factory; EventRegistrationToken token = s_TracerFactory.add_TracingStatusChanged(new EventHandler(TracingStatusChangedHandler)); - Debug.Assert(token != default(EventRegistrationToken), "EventRegistrationToken is null"); + Debug.Assert(token != default, "EventRegistrationToken is null"); } catch (Exception ex) { diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs index 4615d43..1eaa85a 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs @@ -85,7 +85,7 @@ namespace System.Threading.Tasks /// cref="System.Threading.Tasks.TaskScheduler.Current">TaskScheduler.Current). /// public TaskFactory() - : this(default(CancellationToken), TaskCreationOptions.None, TaskContinuationOptions.None, null) + : this(default, TaskCreationOptions.None, TaskContinuationOptions.None, null) { } @@ -130,7 +130,7 @@ namespace System.Threading.Tasks /// cref="System.Threading.Tasks.TaskScheduler.Current">TaskScheduler.Current). /// public TaskFactory(TaskScheduler scheduler) // null means to use TaskScheduler.Current - : this(default(CancellationToken), TaskCreationOptions.None, TaskContinuationOptions.None, scheduler) + : this(default, TaskCreationOptions.None, TaskContinuationOptions.None, scheduler) { } @@ -161,7 +161,7 @@ namespace System.Threading.Tasks /// cref="System.Threading.Tasks.TaskScheduler.Current">TaskScheduler.Current). /// public TaskFactory(TaskCreationOptions creationOptions, TaskContinuationOptions continuationOptions) - : this(default(CancellationToken), creationOptions, continuationOptions, null) + : this(default, creationOptions, continuationOptions, null) { } @@ -520,7 +520,7 @@ namespace System.Threading.Tasks Exception ex = null; OperationCanceledException oce = null; - TResult result = default(TResult); + TResult result = default; try { @@ -690,7 +690,7 @@ namespace System.Threading.Tasks FromAsyncCoreLogic(asyncResult, endFunction, endAction, promise, requiresSynchronization: true); }), (object)null, null, - default(CancellationToken), TaskCreationOptions.None, InternalTaskOptions.None, null); + default, TaskCreationOptions.None, InternalTaskOptions.None, null); if (AsyncCausalityTracer.LoggingOn) AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Verbose, t.Id, "TaskFactory.FromAsync Callback", 0); @@ -827,7 +827,7 @@ namespace System.Threading.Tasks } // Make sure we don't leave promise "dangling". - promise.TrySetResult(default(TResult)); + promise.TrySetResult(default); throw; } @@ -948,7 +948,7 @@ namespace System.Threading.Tasks } // Make sure we don't leave promise "dangling". - promise.TrySetResult(default(TResult)); + promise.TrySetResult(default); throw; } @@ -1077,7 +1077,7 @@ namespace System.Threading.Tasks } // Make sure we don't leave promise "dangling". - promise.TrySetResult(default(TResult)); + promise.TrySetResult(default); throw; } @@ -1214,7 +1214,7 @@ namespace System.Threading.Tasks } // Make sure we don't leave the promise "dangling". - promise.TrySetResult(default(TResult)); + promise.TrySetResult(default); throw; } @@ -1305,7 +1305,7 @@ namespace System.Threading.Tasks // Grab the relevant state and then null it out so that the task doesn't hold onto the state unnecessarily var thisRef = promise.m_thisRef; var endMethod = promise.m_endMethod; - promise.m_thisRef = default(TInstance); + promise.m_thisRef = default; promise.m_endMethod = null; if (endMethod == null) ThrowHelper.ThrowArgumentException(ExceptionResource.InvalidOperation_WrongAsyncResultOrEndCalledMultiple, ExceptionArgument.asyncResult); @@ -1374,7 +1374,7 @@ namespace System.Threading.Tasks TaskCreationOptions tco; InternalTaskOptions dontcare; Task.CreationOptionsFromContinuationOptions(continuationOptions, out tco, out dontcare); - return new Task(true, default(TResult), tco, ct); + return new Task(true, default, tco, ct); } // @@ -1745,7 +1745,7 @@ namespace System.Threading.Tasks (completedTasks, state) => { completedTasks.NotifyDebuggerOfWaitCompletionIfNecessary(); - ((Action)state)(completedTasks.Result); return default(TResult); + ((Action)state)(completedTasks.Result); return default; }, continuationAction, scheduler, cancellationToken, continuationOptions); } @@ -2062,7 +2062,7 @@ namespace System.Threading.Tasks return starter.ContinueWith( //the following delegate avoids closure capture as much as possible //completedTask.Result is the winning task; state == continuationAction - (completedTask, state) => { ((Action)state)(completedTask.Result); return default(TResult); }, + (completedTask, state) => { ((Action)state)(completedTask.Result); return default; }, continuationAction, scheduler, cancellationToken, continuationOptions); } } @@ -2133,7 +2133,7 @@ namespace System.Threading.Tasks var action = (Action>)state; var arg = (Task)wrappedWinner.Result; action(arg); - return default(TResult); + return default; }; // ContinueWith delegate for TaskFactory.ContinueWhenAllImpl(non-null continuationFunction) @@ -2152,7 +2152,7 @@ namespace System.Threading.Tasks wrappedAntecedents.NotifyDebuggerOfWaitCompletionIfNecessary(); var action = (Action[]>)state; action(wrappedAntecedents.Result); - return default(TResult); + return default; }; } } diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/ProducerConsumerQueues.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/ProducerConsumerQueues.cs index 1994c49..13347ec 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Tasks/ProducerConsumerQueues.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/ProducerConsumerQueues.cs @@ -204,7 +204,7 @@ namespace System.Threading.Tasks if (first != segment.m_state.m_lastCopy) { result = array[first]; - array[first] = default(T); // Clear the slot to release the element + array[first] = default; // Clear the slot to release the element segment.m_state.m_first = (first + 1) & (array.Length - 1); return true; } @@ -239,12 +239,12 @@ namespace System.Threading.Tasks if (first == segment.m_state.m_last) { - result = default(T); + result = default; return false; } result = array[first]; - array[first] = default(T); // Clear the slot to release the element + array[first] = default; // Clear the slot to release the element segment.m_state.m_first = (first + 1) & (segment.m_array.Length - 1); segment.m_state.m_lastCopy = segment.m_state.m_last; // Refresh m_lastCopy to ensure that m_first has not passed m_lastCopy diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs index 8a288ed..4b98612 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs @@ -347,7 +347,7 @@ namespace System.Threading.Tasks } } - TaskConstructorCore(null, state, default(CancellationToken), creationOptions, InternalTaskOptions.PromiseTask, null); + TaskConstructorCore(null, state, default, creationOptions, InternalTaskOptions.PromiseTask, null); } /// @@ -356,7 +356,7 @@ namespace System.Threading.Tasks /// The delegate that represents the code to execute in the Task. /// The argument is null. public Task(Action action) - : this(action, null, null, default(CancellationToken), TaskCreationOptions.None, InternalTaskOptions.None, null) + : this(action, null, null, default, TaskCreationOptions.None, InternalTaskOptions.None, null) { } @@ -391,7 +391,7 @@ namespace System.Threading.Tasks /// cref="T:System.Threading.Tasks.TaskCreationOptions"/>. /// public Task(Action action, TaskCreationOptions creationOptions) - : this(action, null, Task.InternalCurrentIfAttached(creationOptions), default(CancellationToken), creationOptions, InternalTaskOptions.None, null) + : this(action, null, Task.InternalCurrentIfAttached(creationOptions), default, creationOptions, InternalTaskOptions.None, null) { } @@ -429,7 +429,7 @@ namespace System.Threading.Tasks /// The argument is null. /// public Task(Action action, object state) - : this(action, state, null, default(CancellationToken), TaskCreationOptions.None, InternalTaskOptions.None, null) + : this(action, state, null, default, TaskCreationOptions.None, InternalTaskOptions.None, null) { } @@ -467,7 +467,7 @@ namespace System.Threading.Tasks /// cref="T:System.Threading.Tasks.TaskCreationOptions"/>. /// public Task(Action action, object state, TaskCreationOptions creationOptions) - : this(action, state, Task.InternalCurrentIfAttached(creationOptions), default(CancellationToken), creationOptions, InternalTaskOptions.None, null) + : this(action, state, Task.InternalCurrentIfAttached(creationOptions), default, creationOptions, InternalTaskOptions.None, null) { } @@ -1132,7 +1132,7 @@ namespace System.Threading.Tasks // Also if we queued the task above, the task may not be done yet. if (waitForCompletion && !IsCompleted) { - SpinThenBlockingWait(Timeout.Infinite, default(CancellationToken)); + SpinThenBlockingWait(Timeout.Infinite, default); } } catch (Exception e) @@ -1414,7 +1414,7 @@ namespace System.Threading.Tasks get { var props = Volatile.Read(ref m_contingentProperties); - return (props == null) ? default(CancellationToken) : props.m_cancellationToken; + return (props == null) ? default : props.m_cancellationToken; } } @@ -1533,7 +1533,7 @@ namespace System.Threading.Tasks public static TaskFactory Factory { get; } = new TaskFactory(); /// Gets a task that's already been completed successfully. - public static Task CompletedTask { get; } = new Task(false, (TaskCreationOptions)InternalTaskOptions.DoNotDispose, default(CancellationToken)); + public static Task CompletedTask { get; } = new Task(false, (TaskCreationOptions)InternalTaskOptions.DoNotDispose, default); /// /// Provides an event that can be used to wait for completion. @@ -2697,7 +2697,7 @@ namespace System.Threading.Tasks #if DEBUG bool waitResult = #endif - Wait(Timeout.Infinite, default(CancellationToken)); + Wait(Timeout.Infinite, default); #if DEBUG Debug.Assert(waitResult, "expected wait to succeed"); @@ -2731,7 +2731,7 @@ namespace System.Threading.Tasks ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.timeout); } - return Wait((int)totalMilliseconds, default(CancellationToken)); + return Wait((int)totalMilliseconds, default); } @@ -2773,7 +2773,7 @@ namespace System.Threading.Tasks /// public bool Wait(int millisecondsTimeout) { - return Wait(millisecondsTimeout, default(CancellationToken)); + return Wait(millisecondsTimeout, default); } @@ -3142,11 +3142,11 @@ namespace System.Threading.Tasks RecordInternalCancellationRequest(); Debug.Assert((Options & (TaskCreationOptions)InternalTaskOptions.PromiseTask) != 0, "Task.RecordInternalCancellationRequest(CancellationToken) only valid for promise-style task"); - Debug.Assert(m_contingentProperties.m_cancellationToken == default(CancellationToken)); + Debug.Assert(m_contingentProperties.m_cancellationToken == default); // Store the supplied cancellation token as this task's token. // Waiting on this task will then result in an OperationCanceledException containing this token. - if (tokenToRecord != default(CancellationToken)) + if (tokenToRecord != default) { m_contingentProperties.m_cancellationToken = tokenToRecord; } @@ -3401,7 +3401,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Action continuationAction) { - return ContinueWith(continuationAction, TaskScheduler.Current, default(CancellationToken), TaskContinuationOptions.None); + return ContinueWith(continuationAction, TaskScheduler.Current, default, TaskContinuationOptions.None); } /// @@ -3453,7 +3453,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Action continuationAction, TaskScheduler scheduler) { - return ContinueWith(continuationAction, scheduler, default(CancellationToken), TaskContinuationOptions.None); + return ContinueWith(continuationAction, scheduler, default, TaskContinuationOptions.None); } /// @@ -3486,7 +3486,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Action continuationAction, TaskContinuationOptions continuationOptions) { - return ContinueWith(continuationAction, TaskScheduler.Current, default(CancellationToken), continuationOptions); + return ContinueWith(continuationAction, TaskScheduler.Current, default, continuationOptions); } /// @@ -3587,7 +3587,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Action continuationAction, Object state) { - return ContinueWith(continuationAction, state, TaskScheduler.Current, default(CancellationToken), TaskContinuationOptions.None); + return ContinueWith(continuationAction, state, TaskScheduler.Current, default, TaskContinuationOptions.None); } /// @@ -3641,7 +3641,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Action continuationAction, Object state, TaskScheduler scheduler) { - return ContinueWith(continuationAction, state, scheduler, default(CancellationToken), TaskContinuationOptions.None); + return ContinueWith(continuationAction, state, scheduler, default, TaskContinuationOptions.None); } /// @@ -3675,7 +3675,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Action continuationAction, Object state, TaskContinuationOptions continuationOptions) { - return ContinueWith(continuationAction, state, TaskScheduler.Current, default(CancellationToken), continuationOptions); + return ContinueWith(continuationAction, state, TaskScheduler.Current, default, continuationOptions); } /// @@ -3780,7 +3780,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Func continuationFunction) { - return ContinueWith(continuationFunction, TaskScheduler.Current, default(CancellationToken), + return ContinueWith(continuationFunction, TaskScheduler.Current, default, TaskContinuationOptions.None); } @@ -3840,7 +3840,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Func continuationFunction, TaskScheduler scheduler) { - return ContinueWith(continuationFunction, scheduler, default(CancellationToken), TaskContinuationOptions.None); + return ContinueWith(continuationFunction, scheduler, default, TaskContinuationOptions.None); } /// @@ -3876,7 +3876,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Func continuationFunction, TaskContinuationOptions continuationOptions) { - return ContinueWith(continuationFunction, TaskScheduler.Current, default(CancellationToken), continuationOptions); + return ContinueWith(continuationFunction, TaskScheduler.Current, default, continuationOptions); } /// @@ -3983,7 +3983,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Func continuationFunction, Object state) { - return ContinueWith(continuationFunction, state, TaskScheduler.Current, default(CancellationToken), + return ContinueWith(continuationFunction, state, TaskScheduler.Current, default, TaskContinuationOptions.None); } @@ -4045,7 +4045,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Func continuationFunction, Object state, TaskScheduler scheduler) { - return ContinueWith(continuationFunction, state, scheduler, default(CancellationToken), TaskContinuationOptions.None); + return ContinueWith(continuationFunction, state, scheduler, default, TaskContinuationOptions.None); } /// @@ -4082,7 +4082,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Func continuationFunction, Object state, TaskContinuationOptions continuationOptions) { - return ContinueWith(continuationFunction, state, TaskScheduler.Current, default(CancellationToken), continuationOptions); + return ContinueWith(continuationFunction, state, TaskScheduler.Current, default, continuationOptions); } /// @@ -4490,7 +4490,7 @@ namespace System.Threading.Tasks #if DEBUG bool waitResult = #endif - WaitAllCore(tasks, Timeout.Infinite, default(CancellationToken)); + WaitAllCore(tasks, Timeout.Infinite, default); #if DEBUG Debug.Assert(waitResult, "expected wait to succeed"); @@ -4535,7 +4535,7 @@ namespace System.Threading.Tasks ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.timeout); } - return WaitAllCore(tasks, (int)totalMilliseconds, default(CancellationToken)); + return WaitAllCore(tasks, (int)totalMilliseconds, default); } /// @@ -4567,7 +4567,7 @@ namespace System.Threading.Tasks [MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger public static bool WaitAll(Task[] tasks, int millisecondsTimeout) { - return WaitAllCore(tasks, millisecondsTimeout, default(CancellationToken)); + return WaitAllCore(tasks, millisecondsTimeout, default); } /// @@ -4883,7 +4883,7 @@ namespace System.Threading.Tasks [MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger public static int WaitAny(params Task[] tasks) { - int waitResult = WaitAnyCore(tasks, Timeout.Infinite, default(CancellationToken)); + int waitResult = WaitAnyCore(tasks, Timeout.Infinite, default); Debug.Assert(tasks.Length == 0 || waitResult != -1, "expected wait to succeed"); return waitResult; } @@ -4922,7 +4922,7 @@ namespace System.Threading.Tasks ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.timeout); } - return WaitAnyCore(tasks, (int)totalMilliseconds, default(CancellationToken)); + return WaitAnyCore(tasks, (int)totalMilliseconds, default); } /// @@ -4979,7 +4979,7 @@ namespace System.Threading.Tasks [MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger public static int WaitAny(Task[] tasks, int millisecondsTimeout) { - return WaitAnyCore(tasks, millisecondsTimeout, default(CancellationToken)); + return WaitAnyCore(tasks, millisecondsTimeout, default); } /// @@ -5130,7 +5130,7 @@ namespace System.Threading.Tasks { if (!cancellationToken.IsCancellationRequested) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.cancellationToken); - return new Task(true, default(TResult), TaskCreationOptions.None, cancellationToken); + return new Task(true, default, TaskCreationOptions.None, cancellationToken); } /// Creates a that's completed due to cancellation with the specified exception. @@ -5162,7 +5162,7 @@ namespace System.Threading.Tasks /// public static Task Run(Action action) { - return Task.InternalStartNew(null, action, null, default(CancellationToken), TaskScheduler.Default, + return Task.InternalStartNew(null, action, null, default, TaskScheduler.Default, TaskCreationOptions.DenyChildAttach, InternalTaskOptions.None); } @@ -5194,7 +5194,7 @@ namespace System.Threading.Tasks /// public static Task Run(Func function) { - return Task.StartNew(null, function, default(CancellationToken), + return Task.StartNew(null, function, default, TaskCreationOptions.DenyChildAttach, InternalTaskOptions.None, TaskScheduler.Default); } @@ -5227,7 +5227,7 @@ namespace System.Threading.Tasks /// public static Task Run(Func function) { - return Run(function, default(CancellationToken)); + return Run(function, default); } @@ -5275,7 +5275,7 @@ namespace System.Threading.Tasks /// public static Task Run(Func> function) { - return Run(function, default(CancellationToken)); + return Run(function, default); } /// @@ -5326,7 +5326,7 @@ namespace System.Threading.Tasks /// public static Task Delay(TimeSpan delay) { - return Delay(delay, default(CancellationToken)); + return Delay(delay, default); } /// @@ -5370,7 +5370,7 @@ namespace System.Threading.Tasks /// public static Task Delay(int millisecondsDelay) { - return Delay(millisecondsDelay, default(CancellationToken)); + return Delay(millisecondsDelay, default); } /// @@ -5467,7 +5467,7 @@ namespace System.Threading.Tasks { RemoveFromActiveTasks(this.Id); } - setSucceeded = TrySetResult(default(VoidTaskResult)); + setSucceeded = TrySetResult(default); } // If we set the value, also clean up. @@ -5705,7 +5705,7 @@ namespace System.Threading.Tasks { RemoveFromActiveTasks(this.Id); } - TrySetResult(default(VoidTaskResult)); + TrySetResult(default); } } Debug.Assert(m_count >= 0, "Count should never go below 0"); @@ -5849,7 +5849,7 @@ namespace System.Threading.Tasks { Debug.Assert(tasks != null, "Expected a non-null tasks array"); return (tasks.Length == 0) ? // take shortcut if there are no tasks upon which to wait - new Task(false, new TResult[0], TaskCreationOptions.None, default(CancellationToken)) : + new Task(false, new TResult[0], TaskCreationOptions.None, default) : new WhenAllPromise(tasks); } @@ -6081,7 +6081,7 @@ namespace System.Threading.Tasks Task intermediate = WhenAny((Task[])tasks); // Return a continuation task with the correct result type - return intermediate.ContinueWith(Task.TaskWhenAnyCast, default(CancellationToken), + return intermediate.ContinueWith(Task.TaskWhenAnyCast, default, TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.DenyChildAttach, TaskScheduler.Default); } @@ -6110,7 +6110,7 @@ namespace System.Threading.Tasks Task intermediate = WhenAny((IEnumerable)tasks); // Return a continuation task with the correct result type - return intermediate.ContinueWith(Task.TaskWhenAnyCast, default(CancellationToken), + return intermediate.ContinueWith(Task.TaskWhenAnyCast, default, TaskContinuationOptions.ExecuteSynchronously | TaskContinuationOptions.DenyChildAttach, TaskScheduler.Default); } #endregion @@ -6672,7 +6672,7 @@ namespace System.Threading.Tasks RemoveFromActiveTasks(this.Id); } - result = TrySetResult(taskTResult != null ? taskTResult.Result : default(TResult)); + result = TrySetResult(taskTResult != null ? taskTResult.Result : default); break; } return result; @@ -6688,7 +6688,7 @@ namespace System.Threading.Tasks // If the inner task is null, the proxy should be canceled. if (task == null) { - TrySetCanceled(default(CancellationToken)); + TrySetCanceled(default); _state = STATE_DONE; // ... and record that we are done } diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs index 3f72500..dc63a67 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskContinuation.cs @@ -29,7 +29,7 @@ namespace System.Threading.Tasks public ContinuationTaskFromTask( Task antecedent, Delegate action, object state, TaskCreationOptions creationOptions, InternalTaskOptions internalOptions) : - base(action, state, Task.InternalCurrentIfAttached(creationOptions), default(CancellationToken), creationOptions, internalOptions, null) + base(action, state, Task.InternalCurrentIfAttached(creationOptions), default, creationOptions, internalOptions, null) { Debug.Assert(action is Action || action is Action, "Invalid delegate type in ContinuationTaskFromTask"); @@ -76,7 +76,7 @@ namespace System.Threading.Tasks public ContinuationResultTaskFromTask( Task antecedent, Delegate function, object state, TaskCreationOptions creationOptions, InternalTaskOptions internalOptions) : - base(function, state, Task.InternalCurrentIfAttached(creationOptions), default(CancellationToken), creationOptions, internalOptions, null) + base(function, state, Task.InternalCurrentIfAttached(creationOptions), default, creationOptions, internalOptions, null) { Debug.Assert(function is Func || function is Func, "Invalid delegate type in ContinuationResultTaskFromTask"); @@ -123,7 +123,7 @@ namespace System.Threading.Tasks public ContinuationTaskFromResultTask( Task antecedent, Delegate action, object state, TaskCreationOptions creationOptions, InternalTaskOptions internalOptions) : - base(action, state, Task.InternalCurrentIfAttached(creationOptions), default(CancellationToken), creationOptions, internalOptions, null) + base(action, state, Task.InternalCurrentIfAttached(creationOptions), default, creationOptions, internalOptions, null) { Debug.Assert(action is Action> || action is Action, object>, "Invalid delegate type in ContinuationTaskFromResultTask"); @@ -170,7 +170,7 @@ namespace System.Threading.Tasks public ContinuationResultTaskFromResultTask( Task antecedent, Delegate function, object state, TaskCreationOptions creationOptions, InternalTaskOptions internalOptions) : - base(function, state, Task.InternalCurrentIfAttached(creationOptions), default(CancellationToken), creationOptions, internalOptions, null) + base(function, state, Task.InternalCurrentIfAttached(creationOptions), default, creationOptions, internalOptions, null) { Debug.Assert(function is Func, TResult> || function is Func, object, TResult>, "Invalid delegate type in ContinuationResultTaskFromResultTask"); @@ -557,7 +557,7 @@ namespace System.Threading.Tasks Debug.Assert(scheduler != null); return new Task( - action, state, null, default(CancellationToken), + action, state, null, default, TaskCreationOptions.None, InternalTaskOptions.QueuedByRuntime, scheduler) { CapturedContext = m_capturedContext diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskFactory.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskFactory.cs index 875d47b..94c449d 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskFactory.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskFactory.cs @@ -75,7 +75,7 @@ namespace System.Threading.Tasks /// cref="System.Threading.Tasks.TaskScheduler.Current">TaskScheduler.Current). /// public TaskFactory() - : this(default(CancellationToken), TaskCreationOptions.None, TaskContinuationOptions.None, null) + : this(default, TaskCreationOptions.None, TaskContinuationOptions.None, null) { } @@ -120,7 +120,7 @@ namespace System.Threading.Tasks /// cref="System.Threading.Tasks.TaskScheduler.Current">TaskScheduler.Current). /// public TaskFactory(TaskScheduler scheduler) // null means to use TaskScheduler.Current - : this(default(CancellationToken), TaskCreationOptions.None, TaskContinuationOptions.None, scheduler) + : this(default, TaskCreationOptions.None, TaskContinuationOptions.None, scheduler) { } @@ -151,7 +151,7 @@ namespace System.Threading.Tasks /// cref="System.Threading.Tasks.TaskScheduler.Current">TaskScheduler.Current). /// public TaskFactory(TaskCreationOptions creationOptions, TaskContinuationOptions continuationOptions) - : this(default(CancellationToken), creationOptions, continuationOptions, null) + : this(default, creationOptions, continuationOptions, null) { } diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/future.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/future.cs index f9199d3..352572b 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Tasks/future.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/future.cs @@ -95,7 +95,7 @@ namespace System.Threading.Tasks // Construct a pre-completed Task internal Task(TResult result) : - base(false, TaskCreationOptions.None, default(CancellationToken)) + base(false, TaskCreationOptions.None, default) { m_result = result; } @@ -127,7 +127,7 @@ namespace System.Threading.Tasks /// The argument is null. /// public Task(Func function) - : this(function, null, default(CancellationToken), + : this(function, null, default, TaskCreationOptions.None, InternalTaskOptions.None, null) { } @@ -172,7 +172,7 @@ namespace System.Threading.Tasks /// cref="T:System.Threading.Tasks.TaskCreationOptions"/>. /// public Task(Func function, TaskCreationOptions creationOptions) - : this(function, Task.InternalCurrentIfAttached(creationOptions), default(CancellationToken), creationOptions, InternalTaskOptions.None, null) + : this(function, Task.InternalCurrentIfAttached(creationOptions), default, creationOptions, InternalTaskOptions.None, null) { } @@ -215,7 +215,7 @@ namespace System.Threading.Tasks /// The argument is null. /// public Task(Func function, object state) - : this(function, state, null, default(CancellationToken), + : this(function, state, null, default, TaskCreationOptions.None, InternalTaskOptions.None, null) { } @@ -261,7 +261,7 @@ namespace System.Threading.Tasks /// cref="T:System.Threading.Tasks.TaskCreationOptions"/>. /// public Task(Func function, object state, TaskCreationOptions creationOptions) - : this(function, state, Task.InternalCurrentIfAttached(creationOptions), default(CancellationToken), + : this(function, state, Task.InternalCurrentIfAttached(creationOptions), default, creationOptions, InternalTaskOptions.None, null) { } @@ -484,7 +484,7 @@ namespace System.Threading.Tasks internal TResult GetResultCore(bool waitCompletionNotification) { // If the result has not been calculated yet, wait for it. - if (!IsCompleted) InternalWait(Timeout.Infinite, default(CancellationToken)); // won't throw if task faulted or canceled; that's handled below + if (!IsCompleted) InternalWait(Timeout.Infinite, default); // won't throw if task faulted or canceled; that's handled below // Notify the debugger of the wait completion if it's requested such a notification if (waitCompletionNotification) NotifyDebuggerOfWaitCompletionIfNecessary(); @@ -663,7 +663,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Action> continuationAction) { - return ContinueWith(continuationAction, TaskScheduler.Current, default(CancellationToken), TaskContinuationOptions.None); + return ContinueWith(continuationAction, TaskScheduler.Current, default, TaskContinuationOptions.None); } @@ -717,7 +717,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Action> continuationAction, TaskScheduler scheduler) { - return ContinueWith(continuationAction, scheduler, default(CancellationToken), TaskContinuationOptions.None); + return ContinueWith(continuationAction, scheduler, default, TaskContinuationOptions.None); } /// @@ -750,7 +750,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Action> continuationAction, TaskContinuationOptions continuationOptions) { - return ContinueWith(continuationAction, TaskScheduler.Current, default(CancellationToken), continuationOptions); + return ContinueWith(continuationAction, TaskScheduler.Current, default, continuationOptions); } /// @@ -852,7 +852,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Action, Object> continuationAction, Object state) { - return ContinueWith(continuationAction, state, TaskScheduler.Current, default(CancellationToken), TaskContinuationOptions.None); + return ContinueWith(continuationAction, state, TaskScheduler.Current, default, TaskContinuationOptions.None); } @@ -908,7 +908,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Action, Object> continuationAction, Object state, TaskScheduler scheduler) { - return ContinueWith(continuationAction, state, scheduler, default(CancellationToken), TaskContinuationOptions.None); + return ContinueWith(continuationAction, state, scheduler, default, TaskContinuationOptions.None); } /// @@ -942,7 +942,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Action, Object> continuationAction, Object state, TaskContinuationOptions continuationOptions) { - return ContinueWith(continuationAction, state, TaskScheduler.Current, default(CancellationToken), continuationOptions); + return ContinueWith(continuationAction, state, TaskScheduler.Current, default, continuationOptions); } /// @@ -1048,7 +1048,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Func, TNewResult> continuationFunction) { - return ContinueWith(continuationFunction, TaskScheduler.Current, default(CancellationToken), TaskContinuationOptions.None); + return ContinueWith(continuationFunction, TaskScheduler.Current, default, TaskContinuationOptions.None); } @@ -1107,7 +1107,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Func, TNewResult> continuationFunction, TaskScheduler scheduler) { - return ContinueWith(continuationFunction, scheduler, default(CancellationToken), TaskContinuationOptions.None); + return ContinueWith(continuationFunction, scheduler, default, TaskContinuationOptions.None); } /// @@ -1149,7 +1149,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Func, TNewResult> continuationFunction, TaskContinuationOptions continuationOptions) { - return ContinueWith(continuationFunction, TaskScheduler.Current, default(CancellationToken), continuationOptions); + return ContinueWith(continuationFunction, TaskScheduler.Current, default, continuationOptions); } /// @@ -1264,7 +1264,7 @@ namespace System.Threading.Tasks /// public Task ContinueWith(Func, Object, TNewResult> continuationFunction, Object state) { - return ContinueWith(continuationFunction, state, TaskScheduler.Current, default(CancellationToken), TaskContinuationOptions.None); + return ContinueWith(continuationFunction, state, TaskScheduler.Current, default, TaskContinuationOptions.None); } @@ -1327,7 +1327,7 @@ namespace System.Threading.Tasks public Task ContinueWith(Func, Object, TNewResult> continuationFunction, Object state, TaskScheduler scheduler) { - return ContinueWith(continuationFunction, state, scheduler, default(CancellationToken), TaskContinuationOptions.None); + return ContinueWith(continuationFunction, state, scheduler, default, TaskContinuationOptions.None); } /// @@ -1371,7 +1371,7 @@ namespace System.Threading.Tasks public Task ContinueWith(Func, Object, TNewResult> continuationFunction, Object state, TaskContinuationOptions continuationOptions) { - return ContinueWith(continuationFunction, state, TaskScheduler.Current, default(CancellationToken), continuationOptions); + return ContinueWith(continuationFunction, state, TaskScheduler.Current, default, continuationOptions); } /// @@ -1544,7 +1544,7 @@ namespace System.Threading.Tasks m_task = task; } - public TResult Result { get { return m_task.Status == TaskStatus.RanToCompletion ? m_task.Result : default(TResult); } } + public TResult Result { get { return m_task.Status == TaskStatus.RanToCompletion ? m_task.Result : default; } } public object AsyncState { get { return m_task.AsyncState; } } public TaskCreationOptions CreationOptions { get { return m_task.CreationOptions; } } public Exception Exception { get { return m_task.Exception; } } diff --git a/src/System.Private.CoreLib/src/System/Threading/ThreadLocal.cs b/src/System.Private.CoreLib/src/System/Threading/ThreadLocal.cs index 6c823d5..909810a 100644 --- a/src/System.Private.CoreLib/src/System/Threading/ThreadLocal.cs +++ b/src/System.Private.CoreLib/src/System/Threading/ThreadLocal.cs @@ -211,7 +211,7 @@ namespace System.Threading // And clear the references from the slot table to the linked slot and the value so that // both can get garbage collected. - slotArray[id].Value.Value = default(T); + slotArray[id].Value.Value = default; slotArray[id].Value = null; } } @@ -331,7 +331,7 @@ namespace System.Threading T value; if (m_valueFactory == null) { - value = default(T); + value = default; } else { @@ -530,7 +530,7 @@ namespace System.Threading LinkedSlot slot; if (slotArray == null || id >= slotArray.Length || (slot = slotArray[id].Value) == null || !m_initialized) - return default(T); + return default; return slot.Value; } } diff --git a/src/System.Private.CoreLib/src/System/TypeLoadException.cs b/src/System.Private.CoreLib/src/System/TypeLoadException.cs index 4f31747..1b52cc4 100644 --- a/src/System.Private.CoreLib/src/System/TypeLoadException.cs +++ b/src/System.Private.CoreLib/src/System/TypeLoadException.cs @@ -70,7 +70,7 @@ namespace System String format = null; GetTypeLoadExceptionMessage(ResourceId, JitHelpers.GetStringHandleOnStack(ref format)); - _message = String.Format(CultureInfo.CurrentCulture, format, ClassName, AssemblyName, MessageArg); + _message = string.Format(CultureInfo.CurrentCulture, format, ClassName, AssemblyName, MessageArg); } } } @@ -80,7 +80,7 @@ namespace System get { if (ClassName == null) - return String.Empty; + return string.Empty; return ClassName; } -- 2.7.4