From 72fa6910997c541c3f0231ee5c3065850f2c68cc Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Thu, 23 Dec 2021 16:19:51 +0100 Subject: [PATCH 1/7] Remove unused parameters in SPC and remove related dead code --- eng/CodeAnalysis.src.globalconfig | 3 ++- .../ComActivator.PlatformNotSupported.cs | 9 +++---- .../src/System/Array.CoreCLR.cs | 8 +++--- .../System/Diagnostics/StackFrame.CoreCLR.cs | 2 +- .../src/System/MulticastDelegate.cs | 8 +++--- .../System/Reflection/Emit/PropertyBuilder.cs | 1 - .../src/System/Reflection/Emit/TypeBuilder.cs | 1 - .../src/System/RuntimeType.CoreCLR.cs | 4 +-- .../TypeInfos/RuntimeTypeInfo.BindingFlags.cs | 4 +-- .../Win32/SafeHandles/SafeFileHandle.Unix.cs | 9 +++---- .../Buffers/Text/Utf8Parser/ParserHelpers.cs | 2 +- .../src/System/ByReference.cs | 2 +- .../src/System/Collections/Hashtable.cs | 2 +- .../src/System/DateTime.Unix.cs | 6 ++--- .../src/System/DefaultBinder.cs | 4 +-- .../src/System/Environment.NoRegistry.cs | 6 ++--- .../src/System/Globalization/Calendar.cs | 2 +- .../System/Globalization/CalendarData.Icu.cs | 2 +- .../System/Globalization/CalendarData.Unix.cs | 2 +- .../System/Globalization/CultureData.Icu.cs | 2 +- .../System/Globalization/CultureData.Unix.cs | 7 ++--- .../src/System/Globalization/CultureData.cs | 2 +- .../src/System/Globalization/DateTimeParse.cs | 2 +- .../src/System/IO/FileSystem.Unix.cs | 26 +++++-------------- .../IO/Strategies/FileStreamHelpers.Unix.cs | 4 +-- .../src/System/Resources/ResourceSet.cs | 2 +- .../Runtime/InteropServices/Marshal.NoCom.cs | 2 +- .../Runtime/InteropServices/Marshal.Unix.cs | 2 +- .../System/Runtime/InteropServices/Marshal.cs | 2 +- .../Loader/LibraryNameVariation.Unix.cs | 2 +- .../Loader/LibraryNameVariation.Windows.cs | 3 +-- .../System/Runtime/MemoryFailPoint.Unix.cs | 4 +-- .../src/System/Runtime/MemoryFailPoint.cs | 6 ++--- .../src/System/Text/Rune.cs | 2 +- .../System/Threading/EventWaitHandle.Unix.cs | 2 +- .../src/System/Threading/Semaphore.Unix.cs | 2 +- .../System/Threading/ThreadPool.Portable.cs | 11 ++++---- .../System/Threading/ThreadPoolWorkQueue.cs | 4 +-- .../System/Threading/TimerQueue.Portable.cs | 2 +- ...TimeZoneInfo.FullGlobalizationData.Unix.cs | 2 +- .../src/System/TimeZoneInfo.Unix.cs | 20 ++++++-------- .../src/System/Array.Mono.cs | 8 +++--- .../src/System/Diagnostics/StackFrame.Mono.cs | 2 +- .../src/System/IO/FileLoadException.Mono.cs | 2 +- .../src/System/MissingMemberException.Mono.cs | 2 +- .../Reflection/Emit/AssemblyBuilder.Mono.cs | 2 +- .../Emit/ConstructorBuilder.Mono.cs | 6 ++--- .../Reflection/Emit/EventBuilder.Mono.cs | 6 ++--- .../Reflection/Emit/MethodBuilder.Mono.cs | 6 ++--- .../Reflection/Emit/ModuleBuilder.Mono.cs | 6 ++--- .../Reflection/Emit/ParameterBuilder.Mono.cs | 2 +- .../Reflection/Emit/PropertyBuilder.Mono.cs | 2 +- .../Reflection/Emit/TypeBuilder.Mono.cs | 6 ++--- .../src/System/Reflection/MethodBase.Mono.cs | 2 +- .../Reflection/RuntimeMethodInfo.Mono.cs | 4 +-- .../System/Reflection/RuntimePropertyInfo.cs | 2 +- .../Runtime/CompilerServices/JitHelpers.cs | 4 +-- .../InteropServices/ObjectiveCMarshal.Mono.cs | 1 + .../Loader/AssemblyLoadContext.Mono.cs | 2 +- .../src/System/RuntimeFieldHandle.cs | 2 +- .../src/System/RuntimeMethodHandle.cs | 2 +- .../src/System/RuntimeType.Mono.cs | 6 ++--- .../src/System/RuntimeTypeHandle.cs | 7 +++-- .../LowLevelLifoSemaphore.Unix.Mono.cs | 2 +- .../Threading/PreAllocatedOverlapped.cs | 2 +- .../src/System/Threading/ThreadPool.Mono.cs | 2 +- .../PrepareForReadyToRunCompilation.cs | 4 +-- 67 files changed, 127 insertions(+), 153 deletions(-) diff --git a/eng/CodeAnalysis.src.globalconfig b/eng/CodeAnalysis.src.globalconfig index 400c8c432c21b..4633198ba0c53 100644 --- a/eng/CodeAnalysis.src.globalconfig +++ b/eng/CodeAnalysis.src.globalconfig @@ -774,7 +774,7 @@ dotnet_diagnostic.CA5383.severity = none # CA5384: Do Not Use Digital Signature Algorithm (DSA) dotnet_diagnostic.CA5384.severity = warning -# CA5385: Use Rivest–Shamir–Adleman (RSA) Algorithm With Sufficient Key Size +# CA5385: Use Rivest-Shamir-Adleman (RSA) Algorithm With Sufficient Key Size dotnet_diagnostic.CA5385.severity = warning # CA5386: Avoid hardcoding SecurityProtocolType value @@ -1448,6 +1448,7 @@ dotnet_diagnostic.IDE0059.severity = suggestion # IDE0060: Remove unused parameter dotnet_diagnostic.IDE0060.severity = silent +dotnet_code_quality_unused_parameters = non_public # IDE0061: Use expression body for local functions dotnet_diagnostic.IDE0061.severity = silent diff --git a/src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.PlatformNotSupported.cs b/src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.PlatformNotSupported.cs index 1bb64cf6f4cf3..66e05d83cef95 100644 --- a/src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.PlatformNotSupported.cs +++ b/src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.PlatformNotSupported.cs @@ -11,25 +11,22 @@ public static class ComActivator /// /// Internal entry point for unmanaged COM activation API from native code /// - /// Pointer to a instance [UnmanagedCallersOnly] - private static unsafe int GetClassFactoryForTypeInternal(ComActivationContextInternal* pCxtInt) + private static unsafe int GetClassFactoryForTypeInternal(ComActivationContextInternal* _) => throw new PlatformNotSupportedException(); /// /// Internal entry point for registering a managed COM server API from native code /// - /// Pointer to a instance [UnmanagedCallersOnly] - private static unsafe int RegisterClassForTypeInternal(ComActivationContextInternal* pCxtInt) + private static unsafe int RegisterClassForTypeInternal(ComActivationContextInternal* _) => throw new PlatformNotSupportedException(); /// /// Internal entry point for unregistering a managed COM server API from native code /// - /// Pointer to a instance [UnmanagedCallersOnly] - private static unsafe int UnregisterClassForTypeInternal(ComActivationContextInternal* pCxtInt) + private static unsafe int UnregisterClassForTypeInternal(ComActivationContextInternal* _) => throw new PlatformNotSupportedException(); } } diff --git a/src/coreclr/System.Private.CoreLib/src/System/Array.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Array.CoreCLR.cs index 482752ba46ffb..4bec553850702 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Array.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Array.CoreCLR.cs @@ -521,7 +521,7 @@ internal void set_Item(int index, T value) _this[index] = value; } - private void Add(T value) + private void Add(T _) { // Not meaningful for arrays. ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); @@ -556,20 +556,20 @@ private int IndexOf(T value) return Array.IndexOf(_this, value, 0, _this.Length); } - private void Insert(int index, T value) + private void Insert(int _, T _1) { // Not meaningful for arrays ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } - private bool Remove(T value) + private bool Remove(T _) { // Not meaningful for arrays ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); return default; } - private void RemoveAt(int index) + private void RemoveAt(int _) { // Not meaningful for arrays ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); diff --git a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/StackFrame.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/StackFrame.CoreCLR.cs index ab53609931660..038780f826157 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/StackFrame.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/StackFrame.CoreCLR.cs @@ -52,7 +52,7 @@ private void BuildStackFrame(int skipFrames, bool needFileInfo) } } - private static bool AppendStackFrameWithoutMethodBase(StringBuilder sb) => false; + private static bool AppendStackFrameWithoutMethodBase(StringBuilder _) => false; [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "StackFrame_GetMethodDescFromNativeIP")] private static partial RuntimeMethodHandleInternal GetMethodDescFromNativeIP(IntPtr ip); diff --git a/src/coreclr/System.Private.CoreLib/src/System/MulticastDelegate.cs b/src/coreclr/System.Private.CoreLib/src/System/MulticastDelegate.cs index 6abac717392c3..36a7405fe71c2 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/MulticastDelegate.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/MulticastDelegate.cs @@ -595,7 +595,7 @@ private void CtorRTClosed(object target, IntPtr methodPtr) } [System.Diagnostics.DebuggerNonUserCode] - private void CtorOpened(object target, IntPtr methodPtr, IntPtr shuffleThunk) + private void CtorOpened(object _, IntPtr methodPtr, IntPtr shuffleThunk) { this._target = this; this._methodPtr = shuffleThunk; @@ -603,7 +603,7 @@ private void CtorOpened(object target, IntPtr methodPtr, IntPtr shuffleThunk) } [System.Diagnostics.DebuggerNonUserCode] - private void CtorVirtualDispatch(object target, IntPtr methodPtr, IntPtr shuffleThunk) + private void CtorVirtualDispatch(object _, IntPtr methodPtr, IntPtr shuffleThunk) { this._target = this; this._methodPtr = shuffleThunk; @@ -619,7 +619,7 @@ private void CtorCollectibleClosedStatic(object target, IntPtr methodPtr, IntPtr } [System.Diagnostics.DebuggerNonUserCode] - private void CtorCollectibleOpened(object target, IntPtr methodPtr, IntPtr shuffleThunk, IntPtr gchandle) + private void CtorCollectibleOpened(object _, IntPtr methodPtr, IntPtr shuffleThunk, IntPtr gchandle) { this._target = this; this._methodPtr = shuffleThunk; @@ -628,7 +628,7 @@ private void CtorCollectibleOpened(object target, IntPtr methodPtr, IntPtr shuff } [System.Diagnostics.DebuggerNonUserCode] - private void CtorCollectibleVirtualDispatch(object target, IntPtr methodPtr, IntPtr shuffleThunk, IntPtr gchandle) + private void CtorCollectibleVirtualDispatch(object _, IntPtr methodPtr, IntPtr shuffleThunk, IntPtr gchandle) { this._target = this; this._methodPtr = shuffleThunk; diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/PropertyBuilder.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/PropertyBuilder.cs index ae6e704b2a5c8..52796111d4369 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/PropertyBuilder.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/PropertyBuilder.cs @@ -28,7 +28,6 @@ public sealed class PropertyBuilder : PropertyInfo internal PropertyBuilder( ModuleBuilder mod, // the module containing this PropertyBuilder string name, // property name - SignatureHelper sig, // property signature descriptor info PropertyAttributes attr, // property attribute such as DefaultProperty, Bindable, DisplayBind, etc Type returnType, // return type of the property. int prToken, // the metadata token for this property diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs index 36fe011d10d4f..1c123e373276c 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs @@ -1830,7 +1830,6 @@ private PropertyBuilder DefinePropertyNoLock(string name, PropertyAttributes att return new PropertyBuilder( m_module, name, - sigHelper, attributes, returnType, prToken, diff --git a/src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs index 3752e61158624..8f0b1c193190a 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs @@ -2804,7 +2804,7 @@ public override InterfaceMapping GetInterfaceMap([DynamicallyAccessedMembers(Dyn } if ((bindingAttr & BindingFlags.ExactBinding) != 0) - return System.DefaultBinder.ExactBinding(candidates.ToArray(), types, modifiers) as ConstructorInfo; + return System.DefaultBinder.ExactBinding(candidates.ToArray(), types) as ConstructorInfo; binder ??= DefaultBinder; return binder.SelectMethod(bindingAttr, candidates.ToArray(), types, modifiers) as ConstructorInfo; @@ -2842,7 +2842,7 @@ public override InterfaceMapping GetInterfaceMap([DynamicallyAccessedMembers(Dyn } if ((bindingAttr & BindingFlags.ExactBinding) != 0) - return System.DefaultBinder.ExactPropertyBinding(candidates.ToArray(), returnType, types, modifiers); + return System.DefaultBinder.ExactPropertyBinding(candidates.ToArray(), returnType, types); binder ??= DefaultBinder; return binder.SelectProperty(bindingAttr, candidates.ToArray(), returnType, types, modifiers); diff --git a/src/coreclr/nativeaot/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.BindingFlags.cs b/src/coreclr/nativeaot/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.BindingFlags.cs index 45c95cfecb5c7..76a79f8efd9d9 100644 --- a/src/coreclr/nativeaot/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.BindingFlags.cs +++ b/src/coreclr/nativeaot/System.Private.Reflection.Core/src/System/Reflection/Runtime/TypeInfos/RuntimeTypeInfo.BindingFlags.cs @@ -39,7 +39,7 @@ protected sealed override ConstructorInfo GetConstructorImpl(BindingFlags bindin } if ((bindingAttr & BindingFlags.ExactBinding) != 0) - return System.DefaultBinder.ExactBinding(candidates.ToArray(), types, modifiers) as ConstructorInfo; + return System.DefaultBinder.ExactBinding(candidates.ToArray(), types) as ConstructorInfo; if (binder == null) binder = DefaultBinder; @@ -173,7 +173,7 @@ protected sealed override PropertyInfo GetPropertyImpl(string name, BindingFlags } if ((bindingAttr & BindingFlags.ExactBinding) != 0) - return System.DefaultBinder.ExactPropertyBinding(candidates.ToArray(), returnType, types, modifiers); + return System.DefaultBinder.ExactPropertyBinding(candidates.ToArray(), returnType, types); if (binder == null) binder = DefaultBinder; diff --git a/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs b/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs index 32e242e0d8e4c..9836da002e852 100644 --- a/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs @@ -175,8 +175,7 @@ internal static SafeFileHandle OpenReadOnly(string fullPath, FileOptions options } internal static SafeFileHandle Open(string fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize, - Interop.Sys.Permissions openPermissions = DefaultOpenPermissions, - Func? createOpenException = null) + Interop.Sys.Permissions openPermissions = DefaultOpenPermissions) { long fileLength; Interop.Sys.Permissions filePermissions; @@ -311,7 +310,7 @@ private bool Init(string path, FileMode mode, FileAccess access, FileShare share if ((access & FileAccess.Write) == 0) { // Stat the file descriptor to avoid race conditions. - FStatCheckIO(this, path, ref status, ref statusHasValue); + FStatCheckIO(path, ref status, ref statusHasValue); if ((status.Mode & Interop.Sys.FileTypes.S_IFMT) == Interop.Sys.FileTypes.S_IFDIR) { @@ -361,7 +360,7 @@ private bool Init(string path, FileMode mode, FileAccess access, FileShare share if (_isLocked && ((options & FileOptions.DeleteOnClose) != 0) && share == FileShare.None && mode == FileMode.OpenOrCreate) { - FStatCheckIO(this, path, ref status, ref statusHasValue); + FStatCheckIO(path, ref status, ref statusHasValue); Interop.Sys.FileStatus pathStatus; if (Interop.Sys.Stat(path, out pathStatus) < 0) @@ -476,7 +475,7 @@ private bool CanLockTheFile(Interop.Sys.LockOperations lockOperation, FileAccess } } - private void FStatCheckIO(SafeFileHandle handle, string path, ref Interop.Sys.FileStatus status, ref bool statusHasValue) + private void FStatCheckIO(string path, ref Interop.Sys.FileStatus status, ref bool statusHasValue) { if (!statusHasValue) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/ParserHelpers.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/ParserHelpers.cs index 46e39795302c3..7a25cbc607870 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/ParserHelpers.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/ParserHelpers.cs @@ -58,7 +58,7 @@ public static bool TryParseThrowFormatException(out T value, out int bytesCon // [DoesNotReturn] [StackTraceHidden] - public static bool TryParseThrowFormatException(ReadOnlySpan source, out T value, out int bytesConsumed) where T : struct + public static bool TryParseThrowFormatException(ReadOnlySpan _, out T value, out int bytesConsumed) where T : struct { // The parameters to this method are ordered the same as our callers' parameters // allowing the JIT to avoid unnecessary register swapping or spilling. diff --git a/src/libraries/System.Private.CoreLib/src/System/ByReference.cs b/src/libraries/System.Private.CoreLib/src/System/ByReference.cs index 64848ce992987..4c40010215994 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ByReference.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ByReference.cs @@ -17,7 +17,7 @@ internal readonly ref struct ByReference #pragma warning restore CA1823, 169 [Intrinsic] - public ByReference(ref T value) + public ByReference(ref T _) { // Implemented as a JIT intrinsic - This default implementation is for // completeness and to provide a concrete error if called via reflection diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs index 01b9cdb3c737a..e59225c5a71c1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Hashtable.cs @@ -223,7 +223,7 @@ protected IComparer? comparer // Note: this constructor is a bogus constructor that does nothing // and is for use only with SyncHashtable. - internal Hashtable(bool trash) + internal Hashtable(bool _) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/DateTime.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/DateTime.Unix.cs index 2fd3e7368e5f4..776e928b785a3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/DateTime.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/DateTime.Unix.cs @@ -15,10 +15,10 @@ public static DateTime UtcNow } } - private static DateTime FromFileTimeLeapSecondsAware(ulong fileTime) => default; - private static ulong ToFileTimeLeapSecondsAware(long ticks) => default; + private static DateTime FromFileTimeLeapSecondsAware(ulong _) => default; + private static ulong ToFileTimeLeapSecondsAware(long _) => default; // IsValidTimeWithLeapSeconds is not expected to be called at all for now on non-Windows platforms - internal static bool IsValidTimeWithLeapSeconds(int year, int month, int day, int hour, int minute, DateTimeKind kind) => false; + internal static bool IsValidTimeWithLeapSeconds(int _, int _1, int _2, int _3, int _4, DateTimeKind _5) => false; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/DefaultBinder.cs b/src/libraries/System.Private.CoreLib/src/System/DefaultBinder.cs index 9cd5f01a951e3..5cfe0bc211f07 100644 --- a/src/libraries/System.Private.CoreLib/src/System/DefaultBinder.cs +++ b/src/libraries/System.Private.CoreLib/src/System/DefaultBinder.cs @@ -773,7 +773,7 @@ public sealed override void ReorderArgumentArray(ref object?[] args, object stat // Return any exact bindings that may exist. (This method is not defined on the // Binder and is used by RuntimeType.) - public static MethodBase? ExactBinding(MethodBase[] match, Type[] types, ParameterModifier[]? modifiers) + public static MethodBase? ExactBinding(MethodBase[] match, Type[] types) { if (match == null) throw new ArgumentNullException(nameof(match)); @@ -816,7 +816,7 @@ public sealed override void ReorderArgumentArray(ref object?[] args, object stat // Return any exact bindings that may exist. (This method is not defined on the // Binder and is used by RuntimeType.) - public static PropertyInfo? ExactPropertyBinding(PropertyInfo[] match, Type? returnType, Type[]? types, ParameterModifier[]? modifiers) + public static PropertyInfo? ExactPropertyBinding(PropertyInfo[] match, Type? returnType, Type[]? types) { if (match == null) throw new ArgumentNullException(nameof(match)); diff --git a/src/libraries/System.Private.CoreLib/src/System/Environment.NoRegistry.cs b/src/libraries/System.Private.CoreLib/src/System/Environment.NoRegistry.cs index fac6cf0fc5064..9c5c5bc5669d0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Environment.NoRegistry.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Environment.NoRegistry.cs @@ -9,10 +9,10 @@ public static partial class Environment { // Systems without the Windows registry pretend that it's always empty. - private static string? GetEnvironmentVariableFromRegistry(string variable, bool fromMachine) => null; + private static string? GetEnvironmentVariableFromRegistry(string _, bool _1) => null; - private static void SetEnvironmentVariableFromRegistry(string variable, string? value, bool fromMachine) { } + static partial void SetEnvironmentVariableFromRegistry(string variable, string? value, bool fromMachine); - private static IDictionary GetEnvironmentVariablesFromRegistry(bool fromMachine) => new Hashtable(); + private static IDictionary GetEnvironmentVariablesFromRegistry(bool _) => new Hashtable(); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/Calendar.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/Calendar.cs index 5daaf13004675..dea0a31497ec4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/Calendar.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/Calendar.cs @@ -713,7 +713,7 @@ internal static long TimeToTicks(int hour, int minute, int second, int milliseco internal static int GetSystemTwoDigitYearSetting(CalendarId CalID, int defaultYearValue) { - int twoDigitYearMax = GlobalizationMode.UseNls ? CalendarData.NlsGetTwoDigitYearMax(CalID) : CalendarData.IcuGetTwoDigitYearMax(CalID); + int twoDigitYearMax = GlobalizationMode.UseNls ? CalendarData.NlsGetTwoDigitYearMax(CalID) : CalendarData.IcuGetTwoDigitYearMax(); return twoDigitYearMax >= 0 ? twoDigitYearMax : defaultYearValue; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Icu.cs index efece6f4d571a..c798860855a0d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Icu.cs @@ -81,7 +81,7 @@ private bool IcuLoadCalendarDataFromSystem(string localeName, CalendarId calenda return result; } - internal static int IcuGetTwoDigitYearMax(CalendarId calendarId) + internal static int IcuGetTwoDigitYearMax() { Debug.Assert(!GlobalizationMode.UseNls); diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Unix.cs index 22f473247620e..1e79cc573ac00 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Unix.cs @@ -8,7 +8,7 @@ internal sealed partial class CalendarData private bool LoadCalendarDataFromSystemCore(string localeName, CalendarId calendarId) => IcuLoadCalendarDataFromSystem(localeName, calendarId); - internal static int GetCalendarsCore(string localeName, bool useUserOverride, CalendarId[] calendars) => + internal static int GetCalendarsCore(string localeName, bool _, CalendarId[] calendars) => IcuGetCalendars(localeName, calendars); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs index 0d2035b9b40e1..d0c7d564781c6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs @@ -205,7 +205,7 @@ private unsafe string IcuGetTimeFormatString(bool shortFormat) } // no support to lookup by region name, other than the hard-coded list in CultureData - private static CultureData? IcuGetCultureDataFromRegionName(string? regionName) => null; + private static CultureData? IcuGetCultureDataFromRegionName() => null; private string IcuGetLanguageDisplayName(string cultureName) => IcuGetLocaleInfo(cultureName, LocaleStringData.LocalizedDisplayName, CultureInfo.CurrentUICulture.Name); diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Unix.cs index fd59f95c76d50..2a253d5367be3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Unix.cs @@ -9,11 +9,8 @@ internal sealed partial class CultureData { private bool InitCultureDataCore() => InitIcuCultureDataCore(); - private void InitUserOverride(bool useUserOverride) - { - // Unix doesn't support user overrides - _bUseOverrides = false; - } + // Unix doesn't support user overrides + partial void InitUserOverride(bool useUserOverride); private static string? LCIDToLocaleName(int culture) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs index 6b0c66fbd361a..bf3b1af55c050 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs @@ -469,7 +469,7 @@ internal sealed partial class CultureData // If not found in the hard coded table we'll have to find a culture that works for us if (!GlobalizationMode.Invariant && (retVal == null || retVal.IsNeutralCulture)) { - retVal = GlobalizationMode.UseNls ? NlsGetCultureDataFromRegionName(cultureName) : IcuGetCultureDataFromRegionName(cultureName); + retVal = GlobalizationMode.UseNls ? NlsGetCultureDataFromRegionName(cultureName) : IcuGetCultureDataFromRegionName(); } // If we found one we can use, then cache it for next time diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs index a7ebe4c496f64..e3c00df884979 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs @@ -5227,7 +5227,7 @@ private static string Hex(char c) return "\\u" + ((int)c).ToString("x4", CultureInfo.InvariantCulture); } - private static void Trace(string s) + private static void Trace(string _) { // Internal.Console.WriteLine(s); } diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs index 566d3686ce5e1..258a4c3f7b96e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs @@ -22,29 +22,17 @@ public static void CopyFile(string sourceFullPath, string destFullPath, bool ove Interop.Sys.Permissions filePermissions; using SafeFileHandle src = SafeFileHandle.OpenReadOnly(sourceFullPath, FileOptions.None, out fileLength, out filePermissions); using SafeFileHandle dst = SafeFileHandle.Open(destFullPath, overwrite ? FileMode.Create : FileMode.CreateNew, - FileAccess.ReadWrite, FileShare.None, FileOptions.None, preallocationSize: 0, openPermissions: filePermissions, - (Interop.ErrorInfo error, Interop.Sys.OpenFlags flags, string path) => CreateOpenException(error, flags, path)); + FileAccess.ReadWrite, FileShare.None, FileOptions.None, preallocationSize: 0, openPermissions: filePermissions); Interop.CheckIo(Interop.Sys.CopyFile(src, dst, fileLength)); - - static Exception? CreateOpenException(Interop.ErrorInfo error, Interop.Sys.OpenFlags flags, string path) - { - // If the destination path points to a directory, we throw to match Windows behaviour. - if (error.Error == Interop.Error.EEXIST && DirectoryExists(path)) - { - return new IOException(SR.Format(SR.Arg_FileIsDirectory_Name, path)); - } - - return null; // Let SafeFileHandle create the exception for this error. - } } - public static void Encrypt(string path) + public static void Encrypt(string _) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_FileEncryption); } - public static void Decrypt(string path) + public static void Decrypt(string _) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_FileEncryption); } @@ -107,7 +95,7 @@ private static void LinkOrCopyFile (string sourceFullPath, string destFullPath) } - public static void ReplaceFile(string sourceFullPath, string destFullPath, string? destBackupFullPath, bool ignoreMetadataErrors) + public static void ReplaceFile(string sourceFullPath, string destFullPath, string? destBackupFullPath, bool _1) { // Unix rename works in more cases, we limit to what is allowed by Windows File.Replace. // These checks are not atomic, the file could change after a check was performed and before it is renamed. @@ -605,7 +593,7 @@ public static string[] GetLogicalDrives() return DriveInfoInternal.GetLogicalDrives(); } - internal static string? GetLinkTarget(ReadOnlySpan linkPath, bool isDirectory) => Interop.Sys.ReadLink(linkPath); + internal static string? GetLinkTarget(ReadOnlySpan linkPath, bool _) => Interop.Sys.ReadLink(linkPath); internal static void CreateSymbolicLink(string path, string pathToTarget, bool isDirectory) { @@ -618,7 +606,7 @@ internal static void CreateSymbolicLink(string path, string pathToTarget, bool i ValueStringBuilder sb = new(Interop.DefaultPathBufferSize); sb.Append(linkPath); - string? linkTarget = GetLinkTarget(linkPath, isDirectory: false /* Irrelevant in Unix */); + string? linkTarget = Interop.Sys.ReadLink(linkPath); if (linkTarget == null) { sb.Dispose(); @@ -651,7 +639,7 @@ internal static void CreateSymbolicLink(string path, string pathToTarget, bool i } GetLinkTargetFullPath(ref sb, current); - current = GetLinkTarget(sb.AsSpan(), isDirectory: false); + current = Interop.Sys.ReadLink(sb.AsSpan()); visitCount++; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/FileStreamHelpers.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/FileStreamHelpers.Unix.cs index 0f91702c00cc6..b516c838cb513 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/FileStreamHelpers.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/FileStreamHelpers.Unix.cs @@ -8,7 +8,7 @@ namespace System.IO.Strategies // this type defines a set of stateless FileStream/FileStreamStrategy helper methods internal static partial class FileStreamHelpers { - private static OSFileStreamStrategy ChooseStrategyCore(SafeFileHandle handle, FileAccess access, bool isAsync) => + private static OSFileStreamStrategy ChooseStrategyCore(SafeFileHandle handle, FileAccess access, bool _) => new UnixFileStreamStrategy(handle, access); private static FileStreamStrategy ChooseStrategyCore(string path, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize) => @@ -28,7 +28,7 @@ internal static long CheckFileCall(long result, string? path, bool ignoreNotSupp return result; } - internal static long Seek(SafeFileHandle handle, long offset, SeekOrigin origin, bool closeInvalidHandle = false) => + internal static long Seek(SafeFileHandle handle, long offset, SeekOrigin origin) => CheckFileCall(Interop.Sys.LSeek(handle, offset, (Interop.Sys.SeekWhence)(int)origin), handle.Path); // SeekOrigin values are the same as Interop.libc.SeekWhence values internal static void ThrowInvalidArgument(SafeFileHandle handle) => diff --git a/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceSet.cs b/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceSet.cs index 4cc4f920f8aed..e60466ae0a4a3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceSet.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Resources/ResourceSet.cs @@ -32,7 +32,7 @@ protected ResourceSet() // For RuntimeResourceSet, ignore the Table parameter - it's a wasted // allocation. - internal ResourceSet(bool junk) + internal ResourceSet(bool _) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NoCom.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NoCom.cs index 9229f26f57a48..21da623e8170e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NoCom.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NoCom.cs @@ -162,7 +162,7 @@ public static int GetEndComSlot(Type t) throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - internal static Type? GetTypeFromCLSID(Guid clsid, string? server, bool throwOnError) + internal static Type? GetTypeFromCLSID(Guid _, string? _1, bool throwOnError) { if (throwOnError) throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Unix.cs index 49ef8223c370f..d5859c453749e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Unix.cs @@ -160,7 +160,7 @@ public static unsafe void FreeBSTR(IntPtr ptr) } } - internal static Type? GetTypeFromProgID(string progID, string? server, bool throwOnError) + internal static Type? GetTypeFromProgID(string progID, string? _, bool throwOnError) { if (progID == null) throw new ArgumentNullException(nameof(progID)); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs index b2e9302a8dd78..9f95fb2869433 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs @@ -675,7 +675,7 @@ public static IntPtr GetHINSTANCE(Module m) } #if !CORECLR - private static Exception? GetExceptionForHRInternal(int errorCode, IntPtr errorInfo) + private static Exception? GetExceptionForHRInternal(int errorCode, IntPtr _) { switch (errorCode) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/LibraryNameVariation.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/LibraryNameVariation.Unix.cs index cf1efef3fab2e..6b183f0aa41b2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/LibraryNameVariation.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/LibraryNameVariation.Unix.cs @@ -15,7 +15,7 @@ internal partial struct LibraryNameVariation private const string LibraryNameSuffix = ".so"; #endif - internal static IEnumerable DetermineLibraryNameVariations(string libName, bool isRelativePath, bool forOSLoader = false) + internal static IEnumerable DetermineLibraryNameVariations(string libName, bool isRelativePath) { // This is a copy of the logic in DetermineLibNameVariations in dllimport.cpp in CoreCLR diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/LibraryNameVariation.Windows.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/LibraryNameVariation.Windows.cs index a62fbb28ef35d..bbc4aacc08e49 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/LibraryNameVariation.Windows.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Loader/LibraryNameVariation.Windows.cs @@ -9,7 +9,7 @@ internal partial struct LibraryNameVariation { private const string LibraryNameSuffix = ".dll"; - internal static IEnumerable DetermineLibraryNameVariations(string libName, bool isRelativePath, bool forOSLoader = false) + internal static IEnumerable DetermineLibraryNameVariations(string libName, bool isRelativePath) { // This is a copy of the logic in DetermineLibNameVariations in dllimport.cpp in CoreCLR @@ -17,7 +17,6 @@ internal static IEnumerable DetermineLibraryNameVariations // Follow LoadLibrary rules if forOSLoader is true if (isRelativePath && - (!forOSLoader || libName.Contains('.') && !libName.EndsWith('.')) && !libName.EndsWith(".dll", StringComparison.OrdinalIgnoreCase) && !libName.EndsWith(".exe", StringComparison.OrdinalIgnoreCase)) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.Unix.cs index 6fd120d9386be..fc29727fe5008 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.Unix.cs @@ -24,14 +24,14 @@ private static bool CheckForAvailableMemory(out ulong availPageFile, out ulong t // returns whether there is enough space. In all cases, we update // our last known free address space, hopefully avoiding needing to // probe again. - private static void CheckForFreeAddressSpace(ulong size, bool shouldThrow) + private static void CheckForFreeAddressSpace(ulong _, bool _1) { // Unreachable until CheckForAvailableMemory is implemented } // Allocate a specified number of bytes, commit them and free them. This should enlarge // page file if necessary and possible. - private static void GrowPageFileIfNecessaryAndPossible(UIntPtr numBytes) + private static void GrowPageFileIfNecessaryAndPossible(UIntPtr _) { // Unreachable until CheckForAvailableMemory is implemented } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.cs index caa22ddd23eb9..79535d873867d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.cs @@ -286,7 +286,7 @@ public MemoryFailPoint(int sizeInMegabytes) ~MemoryFailPoint() { - Dispose(false); + Disposing(); } // Applications must call Dispose, which conceptually "releases" the @@ -298,11 +298,11 @@ public MemoryFailPoint(int sizeInMegabytes) // memory, apps will help their performance greatly by calling Dispose. public void Dispose() { - Dispose(true); + Disposing(); GC.SuppressFinalize(this); } - private void Dispose(bool disposing) + private void Disposing() { // This is just bookkeeping to ensure multiple threads can really // get enough memory, and this does not actually reserve memory diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/Rune.cs b/src/libraries/System.Private.CoreLib/src/System/Text/Rune.cs index ee364f6ac9e27..b4e226b64d1fb 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/Rune.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/Rune.cs @@ -112,7 +112,7 @@ public Rune(uint value) } // non-validating ctor - private Rune(uint scalarValue, bool unused) + private Rune(uint scalarValue, bool _) { UnicodeDebug.AssertIsValidScalar(scalarValue); _value = scalarValue; diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Unix.cs index eb9b4b171d413..0d90682a0dbf5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Unix.cs @@ -19,7 +19,7 @@ private void CreateEventCore(bool initialState, EventResetMode mode, string? nam createdNew = true; } - private static OpenExistingResult OpenExistingWorker(string name, out EventWaitHandle? result) + private static OpenExistingResult OpenExistingWorker(string _, out EventWaitHandle? _1) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Semaphore.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Semaphore.Unix.cs index 61975a86ebb3f..64193d8daa4c6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Semaphore.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Semaphore.Unix.cs @@ -21,7 +21,7 @@ private void CreateSemaphoreCore(int initialCount, int maximumCount, string? nam createdNew = true; } - private static OpenExistingResult OpenExistingWorker(string name, out Semaphore? result) + private static OpenExistingResult OpenExistingWorker(string _, out Semaphore? _1) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.cs index 854e27ef12f08..46a2afa6a99bb 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.cs @@ -34,11 +34,11 @@ public static partial class ThreadPool // Threadpool specific initialization of a new thread. Used by OS-provided threadpools. No-op for portable threadpool. internal static void InitializeForThreadPoolThread() { } - internal static bool CanSetMinIOCompletionThreads(int ioCompletionThreads) => true; - internal static void SetMinIOCompletionThreads(int ioCompletionThreads) { } + internal static bool CanSetMinIOCompletionThreads(int _) => true; + internal static void SetMinIOCompletionThreads(int _) { } - internal static bool CanSetMaxIOCompletionThreads(int ioCompletionThreads) => true; - internal static void SetMaxIOCompletionThreads(int ioCompletionThreads) { } + internal static bool CanSetMaxIOCompletionThreads(int _) => true; + internal static void SetMaxIOCompletionThreads(int _) { } public static bool SetMaxThreads(int workerThreads, int completionPortThreads) => PortableThreadPool.ThreadPoolInstance.SetMaxThreads(workerThreads, completionPortThreads); @@ -90,9 +90,8 @@ public static void GetAvailableThreads(out int workerThreads, out int completion /// /// Called from the gate thread periodically to perform runtime-specific gate activities /// - /// CPU utilization as a percentage since the last call /// True if the runtime still needs to perform gate activities, false otherwise - internal static bool PerformRuntimeSpecificGateActivities(int cpuUtilization) => false; + internal static bool PerformRuntimeSpecificGateActivities(int _) => false; internal static void NotifyWorkItemProgress() => PortableThreadPool.ThreadPoolInstance.NotifyWorkItemProgress(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs index 6a4b728728a56..e4f31d374a7f9 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs @@ -787,14 +787,14 @@ private static void DispatchWorkItemWithWorkerTracking(object workItem, Thread c bool reportedStatus = false; try { - ThreadPool.ReportThreadStatus(isWorking: true); + ThreadPool.ReportThreadStatus(true); reportedStatus = true; DispatchWorkItem(workItem, currentThread); } finally { if (reportedStatus) - ThreadPool.ReportThreadStatus(isWorking: false); + ThreadPool.ReportThreadStatus(false); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Portable.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Portable.cs index c1e8918803e7e..93ae706cd1378 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Portable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Portable.cs @@ -23,7 +23,7 @@ internal sealed partial class TimerQueue : IThreadPoolWorkItem private bool _isScheduled; private long _scheduledDueTimeMs; - private TimerQueue(int id) + private TimerQueue(int _) { } diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.FullGlobalizationData.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.FullGlobalizationData.Unix.cs index e0c284b6c5352..87e583ac675f4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.FullGlobalizationData.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.FullGlobalizationData.Unix.cs @@ -60,7 +60,7 @@ private static string GetUtcStandardDisplayName() } // Helper function to get the full display name for the UTC static time zone instance - private static string GetUtcFullDisplayName(string timeZoneId, string standardDisplayName) + private static string GetUtcFullDisplayName(string _, string standardDisplayName) { return $"(UTC) {standardDisplayName}"; } diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs index f0b865a3a4857..1516a29741357 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs @@ -54,14 +54,12 @@ private TimeZoneInfo(byte[] data, string id, bool dstDisabled) byte[] typeOfLocalTime; TZifType[] transitionType; string zoneAbbreviations; - bool[] StandardTime; - bool[] GmtTime; string? futureTransitionsPosixFormat; string? standardAbbrevName = null; string? daylightAbbrevName = null; // parse the raw TZif bytes; this method can throw ArgumentException when the data is malformed. - TZif_ParseRaw(data, out t, out dts, out typeOfLocalTime, out transitionType, out zoneAbbreviations, out StandardTime, out GmtTime, out futureTransitionsPosixFormat); + TZif_ParseRaw(data, out t, out dts, out typeOfLocalTime, out transitionType, out zoneAbbreviations, out futureTransitionsPosixFormat); // find the best matching baseUtcOffset and display strings based on the current utcNow value. // NOTE: read the Standard and Daylight display strings from the tzfile now in case they can't be loaded later @@ -118,7 +116,7 @@ private TimeZoneInfo(byte[] data, string id, bool dstDisabled) if (!dstDisabled) { // only create the adjustment rule if DST is enabled - TZif_GenerateAdjustmentRules(out _adjustmentRules, _baseUtcOffset, dts, typeOfLocalTime, transitionType, StandardTime, GmtTime, futureTransitionsPosixFormat); + TZif_GenerateAdjustmentRules(out _adjustmentRules, _baseUtcOffset, dts, typeOfLocalTime, transitionType, futureTransitionsPosixFormat); } ValidateTimeZoneInfo(_id, _baseUtcOffset, _adjustmentRules, out _supportsDaylightSavingTime); @@ -467,7 +465,7 @@ internal static TimeSpan GetDateTimeNowUtcOffsetFromUtc(DateTime time, out bool // // private static void TZif_GenerateAdjustmentRules(out AdjustmentRule[]? rules, TimeSpan baseUtcOffset, DateTime[] dts, byte[] typeOfLocalTime, - TZifType[] transitionType, bool[] StandardTime, bool[] GmtTime, string? futureTransitionsPosixFormat) + TZifType[] transitionType, string? futureTransitionsPosixFormat) { rules = null; @@ -478,7 +476,7 @@ private static void TZif_GenerateAdjustmentRules(out AdjustmentRule[]? rules, Ti while (index <= dts.Length) { - TZif_GenerateAdjustmentRule(ref index, baseUtcOffset, rulesList, dts, typeOfLocalTime, transitionType, StandardTime, GmtTime, futureTransitionsPosixFormat); + TZif_GenerateAdjustmentRule(ref index, baseUtcOffset, rulesList, dts, typeOfLocalTime, transitionType, futureTransitionsPosixFormat); } rules = rulesList.ToArray(); @@ -490,7 +488,7 @@ private static void TZif_GenerateAdjustmentRules(out AdjustmentRule[]? rules, Ti } private static void TZif_GenerateAdjustmentRule(ref int index, TimeSpan timeZoneBaseUtcOffset, List rulesList, DateTime[] dts, - byte[] typeOfLocalTime, TZifType[] transitionTypes, bool[] StandardTime, bool[] GmtTime, string? futureTransitionsPosixFormat) + byte[] typeOfLocalTime, TZifType[] transitionTypes, string? futureTransitionsPosixFormat) { // To generate AdjustmentRules, use the following approach: // The first AdjustmentRule will go from DateTime.MinValue to the first transition time greater than DateTime.MinValue. @@ -1117,7 +1115,7 @@ private static DateTime TZif_UnixTimeToDateTime(long unixTime) => DateTimeOffset.FromUnixTimeSeconds(unixTime).UtcDateTime; private static void TZif_ParseRaw(byte[] data, out TZifHead t, out DateTime[] dts, out byte[] typeOfLocalTime, out TZifType[] transitionType, - out string zoneAbbreviations, out bool[] StandardTime, out bool[] GmtTime, out string? futureTransitionsPosixFormat) + out string zoneAbbreviations, out string? futureTransitionsPosixFormat) { futureTransitionsPosixFormat = null; @@ -1143,8 +1141,6 @@ private static void TZif_ParseRaw(byte[] data, out TZifHead t, out DateTime[] dt dts = new DateTime[t.TimeCount]; typeOfLocalTime = new byte[t.TimeCount]; transitionType = new TZifType[t.TypeCount]; - StandardTime = new bool[t.TypeCount]; - GmtTime = new bool[t.TypeCount]; // read in the UTC transition points and convert them to Windows // @@ -1196,7 +1192,7 @@ private static void TZif_ParseRaw(byte[] data, out TZifHead t, out DateTime[] dt // for (int i = 0; i < t.IsStdCount && i < t.TypeCount && index < data.Length; i++) { - StandardTime[i] = (data[index++] != 0); + index++; } // read in the GMT Time table. There should be a 1:1 mapping between Type-Index and GMT Time table @@ -1208,7 +1204,7 @@ private static void TZif_ParseRaw(byte[] data, out TZifHead t, out DateTime[] dt // for (int i = 0; i < t.IsGmtCount && i < t.TypeCount && index < data.Length; i++) { - GmtTime[i] = (data[index++] != 0); + index++; } if (t.Version != TZVersion.V1) diff --git a/src/mono/System.Private.CoreLib/src/System/Array.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Array.Mono.cs index a8bf7fdc42bfc..da9e4c86d6e42 100644 --- a/src/mono/System.Private.CoreLib/src/System/Array.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Array.Mono.cs @@ -542,12 +542,12 @@ internal void InternalArray__ICollection_Clear() ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_ReadOnlyCollection); } - internal void InternalArray__ICollection_Add(T item) + internal void InternalArray__ICollection_Add(T _) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } - internal bool InternalArray__ICollection_Remove(T item) + internal bool InternalArray__ICollection_Remove(T _) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); return default; @@ -579,12 +579,12 @@ internal int InternalArray__IReadOnlyCollection_get_Count() return Length; } - internal void InternalArray__Insert(int index, T item) + internal void InternalArray__Insert(int _, T _1) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } - internal void InternalArray__RemoveAt(int index) + internal void InternalArray__RemoveAt(int _) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } diff --git a/src/mono/System.Private.CoreLib/src/System/Diagnostics/StackFrame.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Diagnostics/StackFrame.Mono.cs index c4d73bb865da0..d8fb2d699cd3a 100644 --- a/src/mono/System.Private.CoreLib/src/System/Diagnostics/StackFrame.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Diagnostics/StackFrame.Mono.cs @@ -45,7 +45,7 @@ private void BuildStackFrame(int skipFrames, bool needFileInfo) } } - private static bool AppendStackFrameWithoutMethodBase(StringBuilder sb) => false; + private static bool AppendStackFrameWithoutMethodBase(StringBuilder _) => false; [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern bool get_frame_info(int skipFrames, bool needFileInfo, diff --git a/src/mono/System.Private.CoreLib/src/System/IO/FileLoadException.Mono.cs b/src/mono/System.Private.CoreLib/src/System/IO/FileLoadException.Mono.cs index e0c8ed4c89953..536155d125021 100644 --- a/src/mono/System.Private.CoreLib/src/System/IO/FileLoadException.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/IO/FileLoadException.Mono.cs @@ -5,7 +5,7 @@ namespace System.IO { public partial class FileLoadException { - internal static string FormatFileLoadExceptionMessage(string? fileName, int hResult) + internal static string FormatFileLoadExceptionMessage(string? _, int _1) { return ""; } diff --git a/src/mono/System.Private.CoreLib/src/System/MissingMemberException.Mono.cs b/src/mono/System.Private.CoreLib/src/System/MissingMemberException.Mono.cs index 4d604107756e3..525fc50678ea8 100644 --- a/src/mono/System.Private.CoreLib/src/System/MissingMemberException.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/MissingMemberException.Mono.cs @@ -5,7 +5,7 @@ namespace System { public partial class MissingMemberException { - internal static string FormatSignature(byte[] signature) + internal static string FormatSignature(byte[] _) { return ""; } diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.Mono.cs index 919015e8567e3..a46c70e9b9aa9 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.Mono.cs @@ -227,7 +227,7 @@ private AssemblyBuilder(AssemblyName n, AssemblyBuilderAccess access) basic_init(this); // Netcore only allows one module per assembly - manifest_module = new ModuleBuilder(this, "RefEmit_InMemoryManifestModule", false); + manifest_module = new ModuleBuilder(this, "RefEmit_InMemoryManifestModule"); modules = new ModuleBuilder[] { manifest_module }; } diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.Mono.cs index 2eb1774be89b2..ce0837233379d 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.Mono.cs @@ -78,7 +78,7 @@ internal ConstructorBuilder(TypeBuilder tb, MethodAttributes attributes, Calling type = tb; this.paramModReq = paramModReq; this.paramModOpt = paramModOpt; - table_idx = get_next_table_index(this, 0x06, 1); + table_idx = get_next_table_index(0x06, 1); ((ModuleBuilder)tb.Module).RegisterToken(this, MetadataToken); } @@ -348,9 +348,9 @@ internal void ResolveUserTypes() } } - internal override int get_next_table_index(object obj, int table, int count) + internal override int get_next_table_index(int table, int count) { - return type.get_next_table_index(obj, table, count); + return type.get_next_table_index(table, count); } private void RejectIfCreated() diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/EventBuilder.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/EventBuilder.Mono.cs index 5865a42bd77f5..2f546df6acd3d 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/EventBuilder.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/EventBuilder.Mono.cs @@ -62,12 +62,12 @@ internal EventBuilder(TypeBuilder tb, string eventName, EventAttributes eventAtt attrs = eventAttrs; type = eventType; typeb = tb; - table_idx = get_next_table_index(this, 0x14, 1); + table_idx = get_next_table_index(0x14, 1); } - internal int get_next_table_index(object obj, int table, int count) + internal int get_next_table_index(int table, int count) { - return typeb.get_next_table_index(obj, table, count); + return typeb.get_next_table_index(table, count); } public void AddOtherMethod(MethodBuilder mdBuilder) diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.Mono.cs index d090eaca09f16..40b157c5b3e9d 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.Mono.cs @@ -99,7 +99,7 @@ internal MethodBuilder(TypeBuilder tb, string name, MethodAttributes attributes, Array.Copy(parameterTypes, this.parameters, parameterTypes.Length); } type = tb; - table_idx = get_next_table_index(this, 0x06, 1); + table_idx = get_next_table_index(0x06, 1); ((ModuleBuilder)tb.Module).RegisterToken(this, MetadataToken); } @@ -505,9 +505,9 @@ public override int GetHashCode() return name.GetHashCode(); } - internal override int get_next_table_index(object obj, int table, int count) + internal override int get_next_table_index(int table, int count) { - return type.get_next_table_index(obj, table, count); + return type.get_next_table_index(table, count); } private static void ExtendArray([NotNull] ref T[]? array, T elem) diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.Mono.cs index 66816f9ce5bbf..89316d484eee6 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.Mono.cs @@ -87,13 +87,13 @@ public partial class ModuleBuilder : Module private static extern void set_wrappers_type(ModuleBuilder mb, Type? ab); [DynamicDependency(nameof(table_indexes))] // Automatically keeps all previous fields too due to StructLayout - internal ModuleBuilder(AssemblyBuilder assb, string name, bool emitSymbolInfo) + internal ModuleBuilder(AssemblyBuilder assb, string name) { this.name = this.scopename = name; this.fqname = name; this.assembly = this.assemblyb = assb; guid = Guid.NewGuid().ToByteArray(); - table_idx = get_next_table_index(this, 0x00, 1); + table_idx = get_next_table_index(0x00, 1); name_cache = new Dictionary(); us_string_cache = new Dictionary(512); @@ -472,7 +472,7 @@ public EnumBuilder DefineEnum(string name, TypeAttributes visibility, Type under return result; } - internal int get_next_table_index(object obj, int table, int count) + internal int get_next_table_index(int table, int count) { if (table_indexes == null) { diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/ParameterBuilder.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/ParameterBuilder.Mono.cs index 337fd78991bda..11abfa207e419 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/ParameterBuilder.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/ParameterBuilder.Mono.cs @@ -64,7 +64,7 @@ internal ParameterBuilder(MethodBase mb, int pos, ParameterAttributes attributes if (mb is DynamicMethod) table_idx = 0; else - table_idx = mb.get_next_table_index(this, 0x08, 1); + table_idx = mb.get_next_table_index(0x08, 1); } public virtual int Attributes diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/PropertyBuilder.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/PropertyBuilder.Mono.cs index d24191a1719c0..40c8b7408cc53 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/PropertyBuilder.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/PropertyBuilder.Mono.cs @@ -77,7 +77,7 @@ internal PropertyBuilder(TypeBuilder tb, string name, PropertyAttributes attribu Array.Copy(parameterTypes, this.parameters, this.parameters.Length); } typeb = tb; - table_idx = tb.get_next_table_index(this, 0x17, 1); + table_idx = tb.get_next_table_index(0x17, 1); } public override PropertyAttributes Attributes diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs index 1e73f98f1505f..632fa6b7d866c 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.Mono.cs @@ -144,7 +144,7 @@ internal TypeBuilder(ModuleBuilder mb, string fullname, TypeAttributes attr, [Dy this.parent = typeof(object); // skip . ? - table_idx = mb.get_next_table_index(this, 0x02, 1); + table_idx = mb.get_next_table_index(0x02, 1); this.fullname = GetFullName(); } @@ -1653,9 +1653,9 @@ public void SetParent([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes this.parent = ResolveUserType(this.parent); } - internal int get_next_table_index(object obj, int table, int count) + internal int get_next_table_index(int table, int count) { - return pmodule.get_next_table_index(obj, table, count); + return pmodule.get_next_table_index(table, count); } [ComVisible(true)] diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/MethodBase.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/MethodBase.Mono.cs index de50a21603cc7..3b92f8d5ad792 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/MethodBase.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/MethodBase.Mono.cs @@ -70,7 +70,7 @@ internal virtual Type[] GetParameterTypes() return parameterTypes; } - internal virtual int get_next_table_index(object obj, int table, int count) + internal virtual int get_next_table_index(int table, int count) { throw new NotImplementedException(); } diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.Mono.cs index 7946ad08d88af..b375ae9af1248 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.Mono.cs @@ -180,7 +180,7 @@ private string FormatNameAndSig() StringBuilder sbName = new StringBuilder(Name); if (IsGenericMethod) - sbName.Append(RuntimeMethodHandle.ConstructInstantiation(this, TypeNameFormatFlags.FormatBasic)); + sbName.Append(RuntimeMethodHandle.ConstructInstantiation(this)); sbName.Append('('); RuntimeParameterInfo.FormatParameters(sbName, GetParametersNoCopy(), CallingConvention); @@ -211,7 +211,7 @@ public override string ToString() sbName.Append(Name); if (IsGenericMethod) - sbName.Append(RuntimeMethodHandle.ConstructInstantiation(this, TypeNameFormatFlags.FormatBasic)); + sbName.Append(RuntimeMethodHandle.ConstructInstantiation(this)); sbName.Append('('); AppendParameters(ref sbName, GetParameterTypes(), CallingConvention); diff --git a/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimePropertyInfo.cs b/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimePropertyInfo.cs index 49b93940f4034..4e3ae13938785 100644 --- a/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimePropertyInfo.cs +++ b/src/mono/System.Private.CoreLib/src/System/Reflection/RuntimePropertyInfo.cs @@ -352,7 +352,7 @@ public override object[] GetCustomAttributes(Type attributeType, bool inherit) return getter((T)obj!); } - private static object? StaticGetterAdapterFrame(StaticGetter getter, object? obj) + private static object? StaticGetterAdapterFrame(StaticGetter getter, object? _) { return getter(); } diff --git a/src/mono/System.Private.CoreLib/src/System/Runtime/CompilerServices/JitHelpers.cs b/src/mono/System.Private.CoreLib/src/System/Runtime/CompilerServices/JitHelpers.cs index 791aae4af8f74..d6e295d357ca1 100644 --- a/src/mono/System.Private.CoreLib/src/System/Runtime/CompilerServices/JitHelpers.cs +++ b/src/mono/System.Private.CoreLib/src/System/Runtime/CompilerServices/JitHelpers.cs @@ -6,9 +6,9 @@ namespace System.Runtime.CompilerServices internal static class JitHelpers { [Intrinsic] - public static bool EnumEquals(T x, T y) where T : struct, Enum => throw new NotImplementedException(); + public static bool EnumEquals(T _1, T _2) where T : struct, Enum => throw new NotImplementedException(); [Intrinsic] - public static int EnumCompareTo(T x, T y) where T : struct, Enum => throw new NotImplementedException(); + public static int EnumCompareTo(T _1, T _2) where T : struct, Enum => throw new NotImplementedException(); } } diff --git a/src/mono/System.Private.CoreLib/src/System/Runtime/InteropServices/ObjectiveCMarshal.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Runtime/InteropServices/ObjectiveCMarshal.Mono.cs index ad7f39b64d743..e8973dbbcca82 100644 --- a/src/mono/System.Private.CoreLib/src/System/Runtime/InteropServices/ObjectiveCMarshal.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Runtime/InteropServices/ObjectiveCMarshal.Mono.cs @@ -9,6 +9,7 @@ namespace System.Runtime.InteropServices.ObjectiveC { public static partial class ObjectiveCMarshal { +#pragma warning disable IDE0060 // Remove when implemented /// /// Sets a pending exception to be thrown the next time the runtime is entered from an Objective-C msgSend P/Invoke. /// diff --git a/src/mono/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.Mono.cs index f646ccb652f0b..e805c22cf74c3 100644 --- a/src/mono/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.Mono.cs @@ -36,7 +36,7 @@ private IntPtr InitializeAssemblyLoadContext(IntPtr thisHandlePtr, bool represen [RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")] [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod - private Assembly InternalLoadFromPath(string? assemblyPath, string? nativeImagePath) + private Assembly InternalLoadFromPath(string? assemblyPath, string? _) { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; diff --git a/src/mono/System.Private.CoreLib/src/System/RuntimeFieldHandle.cs b/src/mono/System.Private.CoreLib/src/System/RuntimeFieldHandle.cs index 46724b64c5d70..7066dbc7ee563 100644 --- a/src/mono/System.Private.CoreLib/src/System/RuntimeFieldHandle.cs +++ b/src/mono/System.Private.CoreLib/src/System/RuntimeFieldHandle.cs @@ -71,7 +71,7 @@ public override int GetHashCode() [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern void SetValueInternal(FieldInfo fi, object? obj, object? value); - internal static void SetValue(RuntimeFieldInfo field, object? obj, object? value, RuntimeType? fieldType, FieldAttributes fieldAttr, RuntimeType? declaringType, ref bool domainInitialized) + internal static void SetValue(RuntimeFieldInfo field, object? obj, object? value, RuntimeType? _, FieldAttributes _1, RuntimeType? _2, ref bool _3) { SetValueInternal(field, obj, value); } diff --git a/src/mono/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs b/src/mono/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs index 73d66fd9bcfcf..c80a621fec553 100644 --- a/src/mono/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs +++ b/src/mono/System.Private.CoreLib/src/System/RuntimeMethodHandle.cs @@ -66,7 +66,7 @@ public override int GetHashCode() return !left.Equals(right); } - internal static string ConstructInstantiation(RuntimeMethodInfo method, TypeNameFormatFlags format) + internal static string ConstructInstantiation(RuntimeMethodInfo method) { var sb = new StringBuilder(); Type[]? gen_params = method.GetGenericArguments(); diff --git a/src/mono/System.Private.CoreLib/src/System/RuntimeType.Mono.cs b/src/mono/System.Private.CoreLib/src/System/RuntimeType.Mono.cs index 95e19d9fb365b..24dd81e678af8 100644 --- a/src/mono/System.Private.CoreLib/src/System/RuntimeType.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/RuntimeType.Mono.cs @@ -151,7 +151,7 @@ public void Add(T item) throw new ArgumentNullException(nameof(typeName)); return RuntimeTypeHandle.GetTypeByName( - typeName, throwOnError, ignoreCase, ref stackMark, false); + typeName, throwOnError, ignoreCase, ref stackMark); } private static void SplitName(string? fullname, out string? name, out string? ns) @@ -833,7 +833,7 @@ public override MemberInfo[] GetMembers(BindingFlags bindingAttr) } if ((bindingAttr & BindingFlags.ExactBinding) != 0) - return System.DefaultBinder.ExactBinding(candidates.ToArray(), types, modifiers) as ConstructorInfo; + return System.DefaultBinder.ExactBinding(candidates.ToArray(), types) as ConstructorInfo; if (binder == null) binder = DefaultBinder; @@ -873,7 +873,7 @@ public override MemberInfo[] GetMembers(BindingFlags bindingAttr) } if ((bindingAttr & BindingFlags.ExactBinding) != 0) - return System.DefaultBinder.ExactPropertyBinding(candidates.ToArray(), returnType, types, modifiers); + return System.DefaultBinder.ExactPropertyBinding(candidates.ToArray(), returnType, types); if (binder == null) binder = DefaultBinder; diff --git a/src/mono/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs b/src/mono/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs index 34f47d66757c0..0f62df86e8c2f 100644 --- a/src/mono/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs +++ b/src/mono/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs @@ -201,12 +201,12 @@ internal static bool IsComObject(RuntimeType type, bool isGenericCOM) return isGenericCOM ? false : IsComObject(type); } - internal static bool IsContextful(RuntimeType type) + internal static bool IsContextful(RuntimeType _) { return false; } - internal static bool IsEquivalentTo(RuntimeType rtType1, RuntimeType rtType2) + internal static bool IsEquivalentTo(RuntimeType _1, RuntimeType _2) { // refence check is done earlier and we don't recognize anything else return false; @@ -287,8 +287,7 @@ internal static bool IsTypeDefinition(RuntimeType type) private static extern RuntimeType internal_from_name(string name, ref StackCrawlMark stackMark, Assembly? callerAssembly, bool throwOnError, bool ignoreCase); [RequiresUnreferencedCode("Types might be removed")] - internal static RuntimeType? GetTypeByName(string typeName, bool throwOnError, bool ignoreCase, ref StackCrawlMark stackMark, - bool loadTypeFromPartialName) + internal static RuntimeType? GetTypeByName(string typeName, bool throwOnError, bool ignoreCase, ref StackCrawlMark stackMark) { if (typeName == null) throw new ArgumentNullException(nameof(typeName)); diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Unix.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Unix.Mono.cs index bbb9c407786c0..54f9003c76302 100644 --- a/src/mono/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Unix.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Unix.Mono.cs @@ -12,7 +12,7 @@ internal sealed unsafe partial class LowLevelLifoSemaphore : IDisposable [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern IntPtr InitInternal(); - private void Create(int maximumSignalCount) + private void Create(int _) { lifo_semaphore = InitInternal(); } diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/PreAllocatedOverlapped.cs b/src/mono/System.Private.CoreLib/src/System/Threading/PreAllocatedOverlapped.cs index a1d410e30bd53..d8033bdb5a34a 100644 --- a/src/mono/System.Private.CoreLib/src/System/Threading/PreAllocatedOverlapped.cs +++ b/src/mono/System.Private.CoreLib/src/System/Threading/PreAllocatedOverlapped.cs @@ -10,6 +10,6 @@ public PreAllocatedOverlapped(IOCompletionCallback callback, object? state, obje [CLSCompliantAttribute(false)] public static PreAllocatedOverlapped UnsafeCreate(IOCompletionCallback callback, object? state, object? pinData) => new PreAllocatedOverlapped(callback, state, pinData); public void Dispose() { } - internal bool IsUserObject(byte[]? buffer) => false; + internal bool IsUserObject(byte[]? _) => false; } } diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Mono.cs index 15aabc85edf74..0899e12b30b9e 100644 --- a/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Mono.cs @@ -8,7 +8,7 @@ namespace System.Threading { public static partial class ThreadPool { - internal static void ReportThreadStatus(bool isWorking) + internal static void ReportThreadStatus(bool _) { } diff --git a/src/tasks/Crossgen2Tasks/PrepareForReadyToRunCompilation.cs b/src/tasks/Crossgen2Tasks/PrepareForReadyToRunCompilation.cs index 40235b9092bc4..cc99fcf567c2c 100644 --- a/src/tasks/Crossgen2Tasks/PrepareForReadyToRunCompilation.cs +++ b/src/tasks/Crossgen2Tasks/PrepareForReadyToRunCompilation.cs @@ -417,7 +417,7 @@ private static Eligibility GetInputFileEligibility(ITaskItem file, bool composit } // save these most expensive checks for last. We don't want to scan all references for IL code - if (ReferencesWinMD(mdReader) || !HasILCode(pereader, mdReader)) + if (ReferencesWinMD(mdReader) || !HasILCode(mdReader)) { // Forwarder assemblies are not separately compiled via R2R, but when performing composite compilation, they are included in the bundle if (excludeFromComposite || !compositeCompile) @@ -488,7 +488,7 @@ private static bool ReferencesWinMD(MetadataReader mdReader) return false; } - private static bool HasILCode(PEReader peReader, MetadataReader mdReader) + private static bool HasILCode(MetadataReader mdReader) { foreach (var methoddefHandle in mdReader.MethodDefinitions) { From ac474eaa12f85a06af6578d58d6dc69936639c73 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Tue, 28 Dec 2021 11:48:51 +0100 Subject: [PATCH 2/7] Feedback --- .../src/System/MulticastDelegate.cs | 10 ++++++---- .../src/System/ByReference.cs | 4 +++- .../src/System/DateTime.Unix.cs | 13 ++++++++++--- .../src/System/Environment.NoRegistry.cs | 8 ++++++-- .../src/System/Globalization/DateTimeParse.cs | 4 ++-- .../src/System/Runtime/MemoryFailPoint.Unix.cs | 6 ++++-- .../System/Runtime/CompilerServices/JitHelpers.cs | 6 ++++-- 7 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/src/System/MulticastDelegate.cs b/src/coreclr/System.Private.CoreLib/src/System/MulticastDelegate.cs index 36a7405fe71c2..4166d91f4f02e 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/MulticastDelegate.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/MulticastDelegate.cs @@ -571,6 +571,7 @@ protected override MethodInfo GetMethodImpl() private static void ThrowNullThisInDelegateToInstance() => throw new ArgumentException(SR.Arg_DlgtNullInst); +#pragma warning disable IDE0060 [System.Diagnostics.DebuggerNonUserCode] private void CtorClosed(object target, IntPtr methodPtr) { @@ -595,7 +596,7 @@ private void CtorRTClosed(object target, IntPtr methodPtr) } [System.Diagnostics.DebuggerNonUserCode] - private void CtorOpened(object _, IntPtr methodPtr, IntPtr shuffleThunk) + private void CtorOpened(object target, IntPtr methodPtr, IntPtr shuffleThunk) { this._target = this; this._methodPtr = shuffleThunk; @@ -603,7 +604,7 @@ private void CtorOpened(object _, IntPtr methodPtr, IntPtr shuffleThunk) } [System.Diagnostics.DebuggerNonUserCode] - private void CtorVirtualDispatch(object _, IntPtr methodPtr, IntPtr shuffleThunk) + private void CtorVirtualDispatch(object target, IntPtr methodPtr, IntPtr shuffleThunk) { this._target = this; this._methodPtr = shuffleThunk; @@ -619,7 +620,7 @@ private void CtorCollectibleClosedStatic(object target, IntPtr methodPtr, IntPtr } [System.Diagnostics.DebuggerNonUserCode] - private void CtorCollectibleOpened(object _, IntPtr methodPtr, IntPtr shuffleThunk, IntPtr gchandle) + private void CtorCollectibleOpened(object target, IntPtr methodPtr, IntPtr shuffleThunk, IntPtr gchandle) { this._target = this; this._methodPtr = shuffleThunk; @@ -628,12 +629,13 @@ private void CtorCollectibleOpened(object _, IntPtr methodPtr, IntPtr shuffleThu } [System.Diagnostics.DebuggerNonUserCode] - private void CtorCollectibleVirtualDispatch(object _, IntPtr methodPtr, IntPtr shuffleThunk, IntPtr gchandle) + private void CtorCollectibleVirtualDispatch(object target, IntPtr methodPtr, IntPtr shuffleThunk, IntPtr gchandle) { this._target = this; this._methodPtr = shuffleThunk; this._methodPtrAux = GetCallStub(methodPtr); this._methodBase = System.Runtime.InteropServices.GCHandle.InternalGet(gchandle); } +#pragma warning restore IDE0060 } } diff --git a/src/libraries/System.Private.CoreLib/src/System/ByReference.cs b/src/libraries/System.Private.CoreLib/src/System/ByReference.cs index 4c40010215994..bb58fc3579a45 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ByReference.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ByReference.cs @@ -16,14 +16,16 @@ internal readonly ref struct ByReference private readonly IntPtr _value; #pragma warning restore CA1823, 169 +#pragma warning disable IDE0060 [Intrinsic] - public ByReference(ref T _) + public ByReference(ref T value) { // Implemented as a JIT intrinsic - This default implementation is for // completeness and to provide a concrete error if called via reflection // or if intrinsic is missed. throw new PlatformNotSupportedException(); } +#pragma warning restore IDE0060 #pragma warning disable CA1822 // Mark members as static public ref T Value diff --git a/src/libraries/System.Private.CoreLib/src/System/DateTime.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/DateTime.Unix.cs index 776e928b785a3..0c35b864ff4c6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/DateTime.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/DateTime.Unix.cs @@ -15,10 +15,17 @@ public static DateTime UtcNow } } - private static DateTime FromFileTimeLeapSecondsAware(ulong _) => default; - private static ulong ToFileTimeLeapSecondsAware(long _) => default; +#pragma warning disable IDE0060 + + // Never called + private static DateTime FromFileTimeLeapSecondsAware(ulong fileTime) => default; + + // Never called + private static ulong ToFileTimeLeapSecondsAware(long ticks) => default; // IsValidTimeWithLeapSeconds is not expected to be called at all for now on non-Windows platforms - internal static bool IsValidTimeWithLeapSeconds(int _, int _1, int _2, int _3, int _4, DateTimeKind _5) => false; + internal static bool IsValidTimeWithLeapSeconds(int year, int month, int day, int hour, int minute, DateTimeKind kind) => false; + +#pragma warning restore IDE0060 } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Environment.NoRegistry.cs b/src/libraries/System.Private.CoreLib/src/System/Environment.NoRegistry.cs index 9c5c5bc5669d0..a9977ef2db04b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Environment.NoRegistry.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Environment.NoRegistry.cs @@ -9,10 +9,14 @@ public static partial class Environment { // Systems without the Windows registry pretend that it's always empty. - private static string? GetEnvironmentVariableFromRegistry(string _, bool _1) => null; +#pragma warning disable IDE0060 + private static string? GetEnvironmentVariableFromRegistry(string variable, bool fromMachine) => null; +#pragma warning restore IDE0060 static partial void SetEnvironmentVariableFromRegistry(string variable, string? value, bool fromMachine); - private static IDictionary GetEnvironmentVariablesFromRegistry(bool _) => new Hashtable(); +#pragma warning disable IDE0060 + private static IDictionary GetEnvironmentVariablesFromRegistry(bool fromMachine) => new Hashtable(); +#pragma warning restore IDE0060 } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs index e3c00df884979..3f29d4b0859a6 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs @@ -5227,9 +5227,9 @@ private static string Hex(char c) return "\\u" + ((int)c).ToString("x4", CultureInfo.InvariantCulture); } - private static void Trace(string _) + private static void Trace(string s) { - // Internal.Console.WriteLine(s); + Internal.Console.WriteLine(s); } // for testing; do not make this readonly diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.Unix.cs index fc29727fe5008..2f0cb43e786f5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/MemoryFailPoint.Unix.cs @@ -20,20 +20,22 @@ private static bool CheckForAvailableMemory(out ulong availPageFile, out ulong t return false; } +#pragma warning disable IDE0060 // Based on the shouldThrow parameter, this will throw an exception, or // returns whether there is enough space. In all cases, we update // our last known free address space, hopefully avoiding needing to // probe again. - private static void CheckForFreeAddressSpace(ulong _, bool _1) + private static void CheckForFreeAddressSpace(ulong size, bool shouldThrow) { // Unreachable until CheckForAvailableMemory is implemented } // Allocate a specified number of bytes, commit them and free them. This should enlarge // page file if necessary and possible. - private static void GrowPageFileIfNecessaryAndPossible(UIntPtr _) + private static void GrowPageFileIfNecessaryAndPossible(UIntPtr numBytes) { // Unreachable until CheckForAvailableMemory is implemented } +#pragma warning restore IDE0060 } } diff --git a/src/mono/System.Private.CoreLib/src/System/Runtime/CompilerServices/JitHelpers.cs b/src/mono/System.Private.CoreLib/src/System/Runtime/CompilerServices/JitHelpers.cs index d6e295d357ca1..7dbf6f02b5bc9 100644 --- a/src/mono/System.Private.CoreLib/src/System/Runtime/CompilerServices/JitHelpers.cs +++ b/src/mono/System.Private.CoreLib/src/System/Runtime/CompilerServices/JitHelpers.cs @@ -5,10 +5,12 @@ namespace System.Runtime.CompilerServices { internal static class JitHelpers { +#pragma warning disable IDE0060 [Intrinsic] - public static bool EnumEquals(T _1, T _2) where T : struct, Enum => throw new NotImplementedException(); + public static bool EnumEquals(T x, T y) where T : struct, Enum => throw new NotImplementedException(); [Intrinsic] - public static int EnumCompareTo(T _1, T _2) where T : struct, Enum => throw new NotImplementedException(); + public static int EnumCompareTo(T x, T y) where T : struct, Enum => throw new NotImplementedException(); +#pragma warning restore IDE0060 } } From 93cb169be236a69f10fe476624a27b1198dc6e38 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Tue, 28 Dec 2021 15:03:10 +0100 Subject: [PATCH 3/7] More updates --- .../System/Diagnostics/StackFrame.CoreCLR.cs | 4 +++- .../System/Globalization/CalendarData.Unix.cs | 4 +++- .../src/System/IO/FileSystem.Unix.cs | 15 ++++++++++----- .../IO/Strategies/FileStreamHelpers.Unix.cs | 4 +++- .../Runtime/InteropServices/Marshal.NoCom.cs | 4 +++- .../Runtime/InteropServices/Marshal.Unix.cs | 4 +++- .../System/Runtime/InteropServices/Marshal.cs | 4 +++- .../System/Threading/EventWaitHandle.Unix.cs | 4 +++- .../src/System/Threading/Semaphore.Unix.cs | 4 +++- .../src/System/Threading/ThreadPool.Portable.cs | 17 ++++++++++++----- .../src/System/Threading/ThreadPoolWorkQueue.cs | 4 ++-- .../src/System/Threading/TimerQueue.Portable.cs | 4 +++- .../TimeZoneInfo.FullGlobalizationData.Unix.cs | 4 +++- .../src/System/Diagnostics/StackFrame.Mono.cs | 4 +++- .../src/System/IO/FileLoadException.Mono.cs | 4 +++- .../src/System/MissingMemberException.Mono.cs | 4 +++- .../Runtime/Loader/AssemblyLoadContext.Mono.cs | 4 +++- .../src/System/RuntimeTypeHandle.cs | 9 +++------ .../LowLevelLifoSemaphore.Unix.Mono.cs | 4 +++- .../System/Threading/PreAllocatedOverlapped.cs | 1 - .../src/System/Threading/ThreadPool.Mono.cs | 4 +++- 21 files changed, 75 insertions(+), 35 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/StackFrame.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/StackFrame.CoreCLR.cs index 038780f826157..48397813c6126 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/StackFrame.CoreCLR.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/Diagnostics/StackFrame.CoreCLR.cs @@ -52,7 +52,9 @@ private void BuildStackFrame(int skipFrames, bool needFileInfo) } } - private static bool AppendStackFrameWithoutMethodBase(StringBuilder _) => false; +#pragma warning disable IDE0060 + private static bool AppendStackFrameWithoutMethodBase(StringBuilder sb) => false; +#pragma warning restore IDE0060 [GeneratedDllImport(RuntimeHelpers.QCall, EntryPoint = "StackFrame_GetMethodDescFromNativeIP")] private static partial RuntimeMethodHandleInternal GetMethodDescFromNativeIP(IntPtr ip); diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Unix.cs index 1e79cc573ac00..fede23f8e2576 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CalendarData.Unix.cs @@ -8,7 +8,9 @@ internal sealed partial class CalendarData private bool LoadCalendarDataFromSystemCore(string localeName, CalendarId calendarId) => IcuLoadCalendarDataFromSystem(localeName, calendarId); - internal static int GetCalendarsCore(string localeName, bool _, CalendarId[] calendars) => +#pragma warning disable IDE0060 + internal static int GetCalendarsCore(string localeName, bool useUserOverride, CalendarId[] calendars) => IcuGetCalendars(localeName, calendars); +#pragma warning restore IDE0060 } } diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs index 258a4c3f7b96e..543ba46eb3f99 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs @@ -27,15 +27,17 @@ public static void CopyFile(string sourceFullPath, string destFullPath, bool ove Interop.CheckIo(Interop.Sys.CopyFile(src, dst, fileLength)); } - public static void Encrypt(string _) +#pragma warning disable IDE0060 + public static void Encrypt(string path) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_FileEncryption); } - public static void Decrypt(string _) + public static void Decrypt(string path) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_FileEncryption); } +#pragma warning restore IDE0060 private static void LinkOrCopyFile (string sourceFullPath, string destFullPath) { @@ -94,8 +96,8 @@ private static void LinkOrCopyFile (string sourceFullPath, string destFullPath) } } - - public static void ReplaceFile(string sourceFullPath, string destFullPath, string? destBackupFullPath, bool _1) +#pragma warning disable IDE0060 + public static void ReplaceFile(string sourceFullPath, string destFullPath, string? destBackupFullPath, bool ignoreMetadataErrors /* unused */) { // Unix rename works in more cases, we limit to what is allowed by Windows File.Replace. // These checks are not atomic, the file could change after a check was performed and before it is renamed. @@ -160,6 +162,7 @@ public static void ReplaceFile(string sourceFullPath, string destFullPath, strin // Finally, rename the source to the destination, overwriting the destination. Interop.CheckIo(Interop.Sys.Rename(sourceFullPath, destFullPath)); } +#pragma warning restore IDE0060 public static void MoveFile(string sourceFullPath, string destFullPath) { @@ -593,7 +596,9 @@ public static string[] GetLogicalDrives() return DriveInfoInternal.GetLogicalDrives(); } - internal static string? GetLinkTarget(ReadOnlySpan linkPath, bool _) => Interop.Sys.ReadLink(linkPath); +#pragma warning disable IDE0060 + internal static string? GetLinkTarget(ReadOnlySpan linkPath, bool isDirectory) => Interop.Sys.ReadLink(linkPath); +#pragma warning restore IDE0060 internal static void CreateSymbolicLink(string path, string pathToTarget, bool isDirectory) { diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/FileStreamHelpers.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/FileStreamHelpers.Unix.cs index b516c838cb513..73d2f2e4082b3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/FileStreamHelpers.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/FileStreamHelpers.Unix.cs @@ -8,8 +8,10 @@ namespace System.IO.Strategies // this type defines a set of stateless FileStream/FileStreamStrategy helper methods internal static partial class FileStreamHelpers { - private static OSFileStreamStrategy ChooseStrategyCore(SafeFileHandle handle, FileAccess access, bool _) => +#pragma warning disable IDE0060 + private static OSFileStreamStrategy ChooseStrategyCore(SafeFileHandle handle, FileAccess access, bool isAsync) => new UnixFileStreamStrategy(handle, access); +#pragma warning restore IDE0060 private static FileStreamStrategy ChooseStrategyCore(string path, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize) => new UnixFileStreamStrategy(path, mode, access, share, options, preallocationSize); diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NoCom.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NoCom.cs index 21da623e8170e..a4dff7658a05e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NoCom.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NoCom.cs @@ -162,13 +162,15 @@ public static int GetEndComSlot(Type t) throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - internal static Type? GetTypeFromCLSID(Guid _, string? _1, bool throwOnError) +#pragma warning disable IDE0060 + internal static Type? GetTypeFromCLSID(Guid clsid, string? server, bool throwOnError) { if (throwOnError) throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); return null; } +#pragma warning restore IDE0060 [SupportedOSPlatform("windows")] public static string GetTypeInfoName(ITypeInfo typeInfo) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Unix.cs index d5859c453749e..75fb3295a9b1e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.Unix.cs @@ -160,7 +160,8 @@ public static unsafe void FreeBSTR(IntPtr ptr) } } - internal static Type? GetTypeFromProgID(string progID, string? _, bool throwOnError) +#pragma warning disable IDE0060 + internal static Type? GetTypeFromProgID(string progID, string? server, bool throwOnError) { if (progID == null) throw new ArgumentNullException(nameof(progID)); @@ -170,6 +171,7 @@ public static unsafe void FreeBSTR(IntPtr ptr) return null; } +#pragma warning restore IDE0060 /// /// Get the last system error on the current thread diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs index 9f95fb2869433..1eda021d0dd2d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs @@ -675,7 +675,8 @@ public static IntPtr GetHINSTANCE(Module m) } #if !CORECLR - private static Exception? GetExceptionForHRInternal(int errorCode, IntPtr _) +#pragma warning disable IDE0060 + private static Exception? GetExceptionForHRInternal(int errorCode, IntPtr errorInfo) { switch (errorCode) { @@ -904,6 +905,7 @@ public static IntPtr GetHINSTANCE(Module m) return new COMException("", errorCode); } } +#pragma warning restore IDE0060 #endif /// diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Unix.cs index 0d90682a0dbf5..bb7db725084c8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/EventWaitHandle.Unix.cs @@ -19,10 +19,12 @@ private void CreateEventCore(bool initialState, EventResetMode mode, string? nam createdNew = true; } - private static OpenExistingResult OpenExistingWorker(string _, out EventWaitHandle? _1) +#pragma warning disable IDE0060 + private static OpenExistingResult OpenExistingWorker(string name, out EventWaitHandle? result) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); } +#pragma warning restore IDE0060 public bool Reset() { diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Semaphore.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Semaphore.Unix.cs index 64193d8daa4c6..bb2a1d6441645 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Semaphore.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Semaphore.Unix.cs @@ -21,10 +21,12 @@ private void CreateSemaphoreCore(int initialCount, int maximumCount, string? nam createdNew = true; } - private static OpenExistingResult OpenExistingWorker(string _, out Semaphore? _1) +#pragma warning disable IDE0060 + private static OpenExistingResult OpenExistingWorker(string name, out Semaphore? result) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); } +#pragma warning restore IDE0060 private int ReleaseCore(int releaseCount) { diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.cs index 46a2afa6a99bb..8773286bb6405 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPool.Portable.cs @@ -34,11 +34,15 @@ public static partial class ThreadPool // Threadpool specific initialization of a new thread. Used by OS-provided threadpools. No-op for portable threadpool. internal static void InitializeForThreadPoolThread() { } - internal static bool CanSetMinIOCompletionThreads(int _) => true; - internal static void SetMinIOCompletionThreads(int _) { } +#pragma warning disable IDE0060 + internal static bool CanSetMinIOCompletionThreads(int ioCompletionThreads) => true; + internal static bool CanSetMaxIOCompletionThreads(int ioCompletionThreads) => true; +#pragma warning restore IDE0060 - internal static bool CanSetMaxIOCompletionThreads(int _) => true; - internal static void SetMaxIOCompletionThreads(int _) { } + [Conditional("unnecessary")] + internal static void SetMinIOCompletionThreads(int ioCompletionThreads) { } + [Conditional("unnecessary")] + internal static void SetMaxIOCompletionThreads(int ioCompletionThreads) { } public static bool SetMaxThreads(int workerThreads, int completionPortThreads) => PortableThreadPool.ThreadPoolInstance.SetMaxThreads(workerThreads, completionPortThreads); @@ -90,8 +94,11 @@ public static void GetAvailableThreads(out int workerThreads, out int completion /// /// Called from the gate thread periodically to perform runtime-specific gate activities /// + /// CPU utilization as a percentage since the last call /// True if the runtime still needs to perform gate activities, false otherwise - internal static bool PerformRuntimeSpecificGateActivities(int _) => false; +#pragma warning disable IDE0060 + internal static bool PerformRuntimeSpecificGateActivities(int cpuUtilization) => false; +#pragma warning restore IDE0060 internal static void NotifyWorkItemProgress() => PortableThreadPool.ThreadPoolInstance.NotifyWorkItemProgress(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs index e4f31d374a7f9..6a4b728728a56 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/ThreadPoolWorkQueue.cs @@ -787,14 +787,14 @@ private static void DispatchWorkItemWithWorkerTracking(object workItem, Thread c bool reportedStatus = false; try { - ThreadPool.ReportThreadStatus(true); + ThreadPool.ReportThreadStatus(isWorking: true); reportedStatus = true; DispatchWorkItem(workItem, currentThread); } finally { if (reportedStatus) - ThreadPool.ReportThreadStatus(false); + ThreadPool.ReportThreadStatus(isWorking: false); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Portable.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Portable.cs index 93ae706cd1378..f53047e3f692a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Portable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/TimerQueue.Portable.cs @@ -23,9 +23,11 @@ internal sealed partial class TimerQueue : IThreadPoolWorkItem private bool _isScheduled; private long _scheduledDueTimeMs; - private TimerQueue(int _) +#pragma warning disable IDE0060 + private TimerQueue(int id) { } +#pragma warning restore IDE0060 private static List InitializeScheduledTimerManager_Locked() { diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.FullGlobalizationData.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.FullGlobalizationData.Unix.cs index 87e583ac675f4..2b381382072e7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.FullGlobalizationData.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.FullGlobalizationData.Unix.cs @@ -59,11 +59,13 @@ private static string GetUtcStandardDisplayName() return standardDisplayName; } +#pragma warning disable IDE0060 // Helper function to get the full display name for the UTC static time zone instance - private static string GetUtcFullDisplayName(string _, string standardDisplayName) + private static string GetUtcFullDisplayName(string timeZoneId, string standardDisplayName) { return $"(UTC) {standardDisplayName}"; } +#pragma warning restore IDE0060 // Helper function that retrieves various forms of time zone display names from ICU private static unsafe void GetDisplayName(string timeZoneId, Interop.Globalization.TimeZoneDisplayNameType nameType, string uiCulture, ref string? displayName) diff --git a/src/mono/System.Private.CoreLib/src/System/Diagnostics/StackFrame.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Diagnostics/StackFrame.Mono.cs index d8fb2d699cd3a..0251fe2d6f011 100644 --- a/src/mono/System.Private.CoreLib/src/System/Diagnostics/StackFrame.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Diagnostics/StackFrame.Mono.cs @@ -45,7 +45,9 @@ private void BuildStackFrame(int skipFrames, bool needFileInfo) } } - private static bool AppendStackFrameWithoutMethodBase(StringBuilder _) => false; +#pragma warning disable IDE0060 + private static bool AppendStackFrameWithoutMethodBase(StringBuilder sb) => false; +#pragma warning restore IDE0060 [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern bool get_frame_info(int skipFrames, bool needFileInfo, diff --git a/src/mono/System.Private.CoreLib/src/System/IO/FileLoadException.Mono.cs b/src/mono/System.Private.CoreLib/src/System/IO/FileLoadException.Mono.cs index 536155d125021..b6b7a9c028ca9 100644 --- a/src/mono/System.Private.CoreLib/src/System/IO/FileLoadException.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/IO/FileLoadException.Mono.cs @@ -5,9 +5,11 @@ namespace System.IO { public partial class FileLoadException { - internal static string FormatFileLoadExceptionMessage(string? _, int _1) +#pragma warning disable IDE0060 + internal static string FormatFileLoadExceptionMessage(string? fileName, int hResult) { return ""; } +#pragma warning restore IDE0060 } } diff --git a/src/mono/System.Private.CoreLib/src/System/MissingMemberException.Mono.cs b/src/mono/System.Private.CoreLib/src/System/MissingMemberException.Mono.cs index 525fc50678ea8..be56bc7fe746a 100644 --- a/src/mono/System.Private.CoreLib/src/System/MissingMemberException.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/MissingMemberException.Mono.cs @@ -5,9 +5,11 @@ namespace System { public partial class MissingMemberException { - internal static string FormatSignature(byte[] _) +#pragma warning disable IDE0060 + internal static string FormatSignature(byte[] signature) { return ""; } +#pragma warning restore IDE0060 } } diff --git a/src/mono/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.Mono.cs index e805c22cf74c3..32924c5486dbd 100644 --- a/src/mono/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.Mono.cs @@ -36,7 +36,8 @@ private IntPtr InitializeAssemblyLoadContext(IntPtr thisHandlePtr, bool represen [RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")] [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod - private Assembly InternalLoadFromPath(string? assemblyPath, string? _) +#pragma warning disable IDE0060 + private Assembly InternalLoadFromPath(string? assemblyPath, string? nativeImagePath) { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; @@ -44,6 +45,7 @@ private Assembly InternalLoadFromPath(string? assemblyPath, string? _) // TODO: Handle nativeImagePath return InternalLoadFile(NativeALC, assemblyPath, ref stackMark); } +#pragma warning restore IDE0060 [RequiresUnreferencedCode("Types and members the loaded assembly depends on might be removed")] internal Assembly InternalLoad(byte[] arrAssembly, byte[]? arrSymbols) diff --git a/src/mono/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs b/src/mono/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs index 0f62df86e8c2f..4db8544e4b8a1 100644 --- a/src/mono/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs +++ b/src/mono/System.Private.CoreLib/src/System/RuntimeTypeHandle.cs @@ -201,16 +201,13 @@ internal static bool IsComObject(RuntimeType type, bool isGenericCOM) return isGenericCOM ? false : IsComObject(type); } - internal static bool IsContextful(RuntimeType _) - { - return false; - } - - internal static bool IsEquivalentTo(RuntimeType _1, RuntimeType _2) +#pragma warning disable IDE0060 + internal static bool IsEquivalentTo(RuntimeType rtType1, RuntimeType rtType2) { // refence check is done earlier and we don't recognize anything else return false; } +#pragma warning restore IDE0060 internal static bool IsInterface(RuntimeType type) { diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Unix.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Unix.Mono.cs index 54f9003c76302..180f802ed84ca 100644 --- a/src/mono/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Unix.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Threading/LowLevelLifoSemaphore.Unix.Mono.cs @@ -12,10 +12,12 @@ internal sealed unsafe partial class LowLevelLifoSemaphore : IDisposable [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern IntPtr InitInternal(); - private void Create(int _) +#pragma warning disable IDE0060 + private void Create(int maximumSignalCount) { lifo_semaphore = InitInternal(); } +#pragma warning restore IDE0060 [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern void DeleteInternal(IntPtr semaphore); diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/PreAllocatedOverlapped.cs b/src/mono/System.Private.CoreLib/src/System/Threading/PreAllocatedOverlapped.cs index d8033bdb5a34a..caad4d140aa40 100644 --- a/src/mono/System.Private.CoreLib/src/System/Threading/PreAllocatedOverlapped.cs +++ b/src/mono/System.Private.CoreLib/src/System/Threading/PreAllocatedOverlapped.cs @@ -10,6 +10,5 @@ public PreAllocatedOverlapped(IOCompletionCallback callback, object? state, obje [CLSCompliantAttribute(false)] public static PreAllocatedOverlapped UnsafeCreate(IOCompletionCallback callback, object? state, object? pinData) => new PreAllocatedOverlapped(callback, state, pinData); public void Dispose() { } - internal bool IsUserObject(byte[]? _) => false; } } diff --git a/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Mono.cs b/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Mono.cs index 0899e12b30b9e..067b197071868 100644 --- a/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Mono.cs +++ b/src/mono/System.Private.CoreLib/src/System/Threading/ThreadPool.Mono.cs @@ -3,12 +3,14 @@ using System.Runtime.InteropServices; using System.Runtime.Versioning; +using System.Diagnostics; namespace System.Threading { public static partial class ThreadPool { - internal static void ReportThreadStatus(bool _) + [Conditional("unnecessary")] + internal static void ReportThreadStatus(bool isWorking) { } From 061f53c68b40b7769d92b1b47a76f48f2cabde25 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Mon, 3 Jan 2022 18:35:52 +0100 Subject: [PATCH 4/7] PR feedback --- .../src/System/Globalization/DateTimeParse.cs | 4 +++- .../src/System/TimeZoneInfo.Unix.cs | 10 ++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs index 3f29d4b0859a6..001d0f3e544a7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs @@ -5227,10 +5227,12 @@ private static string Hex(char c) return "\\u" + ((int)c).ToString("x4", CultureInfo.InvariantCulture); } +#pragma warning disable IDE0060 private static void Trace(string s) { - Internal.Console.WriteLine(s); + //Internal.Console.WriteLine(s); } +#pragma warning restore IDE0060 // for testing; do not make this readonly private static bool s_tracingEnabled; diff --git a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs index 1516a29741357..c0a435253897e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/TimeZoneInfo.Unix.cs @@ -1190,10 +1190,7 @@ private static void TZif_ParseRaw(byte[] data, out TZifHead t, out DateTime[] dt // FALSE = transition time is wall clock time // ABSENT = transition time is wall clock time // - for (int i = 0; i < t.IsStdCount && i < t.TypeCount && index < data.Length; i++) - { - index++; - } + index += (int)Math.Min(t.IsStdCount, t.TypeCount); // read in the GMT Time table. There should be a 1:1 mapping between Type-Index and GMT Time table // entries. @@ -1202,10 +1199,7 @@ private static void TZif_ParseRaw(byte[] data, out TZifHead t, out DateTime[] dt // FALSE = transition time is local time // ABSENT = transition time is local time // - for (int i = 0; i < t.IsGmtCount && i < t.TypeCount && index < data.Length; i++) - { - index++; - } + index += (int)Math.Min(t.IsGmtCount, t.TypeCount); if (t.Version != TZVersion.V1) { From 140fa481a644fe3b0b0df7578fa5a7bd08b3d758 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Tue, 4 Jan 2022 12:23:28 +0100 Subject: [PATCH 5/7] Feedback --- .../ComActivator.PlatformNotSupported.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.PlatformNotSupported.cs b/src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.PlatformNotSupported.cs index 66e05d83cef95..4492eac6d3ada 100644 --- a/src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.PlatformNotSupported.cs +++ b/src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/ComActivator.PlatformNotSupported.cs @@ -4,6 +4,8 @@ using System; using System.Runtime.InteropServices; +#pragma warning disable IDE0060 + namespace Internal.Runtime.InteropServices { public static class ComActivator @@ -11,22 +13,25 @@ public static class ComActivator /// /// Internal entry point for unmanaged COM activation API from native code /// + /// Pointer to a instance [UnmanagedCallersOnly] - private static unsafe int GetClassFactoryForTypeInternal(ComActivationContextInternal* _) + private static unsafe int GetClassFactoryForTypeInternal(ComActivationContextInternal* pCxtInt) => throw new PlatformNotSupportedException(); /// /// Internal entry point for registering a managed COM server API from native code /// + /// Pointer to a instance [UnmanagedCallersOnly] - private static unsafe int RegisterClassForTypeInternal(ComActivationContextInternal* _) + private static unsafe int RegisterClassForTypeInternal(ComActivationContextInternal* pCxtInt) => throw new PlatformNotSupportedException(); /// /// Internal entry point for unregistering a managed COM server API from native code /// + /// Pointer to a instance [UnmanagedCallersOnly] - private static unsafe int UnregisterClassForTypeInternal(ComActivationContextInternal* _) + private static unsafe int UnregisterClassForTypeInternal(ComActivationContextInternal* pCxtInt) => throw new PlatformNotSupportedException(); } } From c18a9cc1d1385fba1092b1f7d40a5f947c92875e Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Mon, 31 Jan 2022 11:27:07 +0100 Subject: [PATCH 6/7] Update after merge with main --- .../src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs | 7 +++---- .../src/System/Runtime/CompilerServices/RuntimeHelpers.cs | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs b/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs index c324457b7de4b..a40d4cc6c73f5 100644 --- a/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeFileHandle.Unix.cs @@ -181,11 +181,10 @@ internal static SafeFileHandle OpenReadOnly(string fullPath, FileOptions options } internal static SafeFileHandle Open(string fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize, - Interop.Sys.Permissions openPermissions = DefaultOpenPermissions) + Interop.Sys.Permissions openPermissions = DefaultOpenPermissions, + Func? createOpenException = null) { - long fileLength; - Interop.Sys.Permissions filePermissions; - return Open(fullPath, mode, access, share, options, preallocationSize, openPermissions, out fileLength, out filePermissions, createOpenException); + return Open(fullPath, mode, access, share, options, preallocationSize, openPermissions, out _, out _, createOpenException); } private static SafeFileHandle Open(string fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize, diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs index 498055ad6a1c5..2ba70cb274a4d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs @@ -121,11 +121,12 @@ internal static bool IsPrimitiveType(this CorElementType et) // The following intrinsics return true if input is a compile-time constant // Feel free to add more overloads on demand - +#pragma warning disable IDE0060 [Intrinsic] internal static bool IsKnownConstant(string? t) => false; [Intrinsic] internal static bool IsKnownConstant(char t) => false; +#pragma warning restore IDE0060 } } From b102a8b0e537d9bb97429487c6891c74765c30e9 Mon Sep 17 00:00:00 2001 From: Marek Safar Date: Mon, 31 Jan 2022 11:33:44 +0100 Subject: [PATCH 7/7] Revert removal of used code after merge --- .../src/System/IO/FileSystem.Unix.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs index 0a9e8b6d3b4e1..4126cd5bd8636 100644 --- a/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Unix.cs @@ -22,9 +22,21 @@ public static void CopyFile(string sourceFullPath, string destFullPath, bool ove Interop.Sys.Permissions filePermissions; using SafeFileHandle src = SafeFileHandle.OpenReadOnly(sourceFullPath, FileOptions.None, out fileLength, out filePermissions); using SafeFileHandle dst = SafeFileHandle.Open(destFullPath, overwrite ? FileMode.Create : FileMode.CreateNew, - FileAccess.ReadWrite, FileShare.None, FileOptions.None, preallocationSize: 0, openPermissions: filePermissions); + FileAccess.ReadWrite, FileShare.None, FileOptions.None, preallocationSize: 0, openPermissions: filePermissions, + (Interop.ErrorInfo error, Interop.Sys.OpenFlags flags, string path) => CreateOpenException(error, flags, path)); Interop.CheckIo(Interop.Sys.CopyFile(src, dst, fileLength)); + + static Exception? CreateOpenException(Interop.ErrorInfo error, Interop.Sys.OpenFlags flags, string path) + { + // If the destination path points to a directory, we throw to match Windows behaviour. + if (error.Error == Interop.Error.EEXIST && DirectoryExists(path)) + { + return new IOException(SR.Format(SR.Arg_FileIsDirectory_Name, path)); + } + + return null; // Let SafeFileHandle create the exception for this error. + } } #pragma warning disable IDE0060