Skip to content

Commit 8918adf

Browse files
authored
Enable IDE0060 (Remove unused parameter) analyzer (#72667)
1 parent 134968a commit 8918adf

File tree

527 files changed

+1680
-1947
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

527 files changed

+1680
-1947
lines changed

.editorconfig

-1
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,3 @@ indent_size = 2
187187
end_of_line = lf
188188
[*.{cmd,bat}]
189189
end_of_line = crlf
190-

eng/CodeAnalysis.src.globalconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,7 @@ dotnet_diagnostic.IDE0058.severity = silent
14851485
dotnet_diagnostic.IDE0059.severity = warning
14861486

14871487
# IDE0060: Remove unused parameter
1488-
dotnet_diagnostic.IDE0060.severity = silent
1488+
dotnet_diagnostic.IDE0060.severity = warning
14891489
dotnet_code_quality_unused_parameters = non_public
14901490

14911491
# IDE0061: Use expression body for local functions

src/coreclr/System.Private.CoreLib/src/Internal/Runtime/InteropServices/InMemoryAssemblyLoader.PlatformNotSupported.cs

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using System.Runtime.InteropServices;
66
using System.Runtime.Loader;
77

8+
#pragma warning disable IDE0060
9+
810
namespace Internal.Runtime.InteropServices
911
{
1012
/// <summary>

src/coreclr/System.Private.CoreLib/src/System/Buffer.CoreCLR.cs

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ internal static void BulkMoveWithWriteBarrier(ref byte destination, ref byte sou
3838
_BulkMoveWithWriteBarrier(ref destination, ref source, byteCount);
3939
}
4040

41+
#pragma warning disable IDE0060 // https://github.com/dotnet/roslyn-analyzers/issues/6228
4142
// Non-inlinable wrapper around the loop for copying large blocks in chunks
4243
[MethodImpl(MethodImplOptions.NoInlining)]
4344
private static void _BulkMoveWithWriteBarrier(ref byte destination, ref byte source, nuint byteCount)
@@ -72,6 +73,7 @@ private static void _BulkMoveWithWriteBarrier(ref byte destination, ref byte sou
7273
}
7374
__BulkMoveWithWriteBarrier(ref destination, ref source, byteCount);
7475
}
76+
#pragma warning restore IDE0060 // https://github.com/dotnet/roslyn-analyzers/issues/6228
7577

7678
[MethodImpl(MethodImplOptions.InternalCall)]
7779
private static extern void __BulkMoveWithWriteBarrier(ref byte destination, ref byte source, nuint byteCount);

src/coreclr/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.CoreCLR.cs

+2
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ public static string GetTypeInfoName(ITypeInfo typeInfo)
311311
return strTypeLibName;
312312
}
313313

314+
#pragma warning disable IDE0060
314315
// This method is identical to Type.GetTypeFromCLSID. Since it's interop specific, we expose it
315316
// on Marshal for more consistent API surface.
316317
internal static Type? GetTypeFromCLSID(Guid clsid, string? server, bool throwOnError)
@@ -327,6 +328,7 @@ public static string GetTypeInfoName(ITypeInfo typeInfo)
327328
GetTypeFromCLSID(clsid, server, ObjectHandleOnStack.Create(ref type));
328329
return type;
329330
}
331+
#pragma warning restore IDE0060
330332

331333
[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "MarshalNative_GetTypeFromCLSID", StringMarshalling = StringMarshalling.Utf16)]
332334
private static partial void GetTypeFromCLSID(in Guid clsid, string? server, ObjectHandleOnStack retType);

src/coreclr/System.Private.CoreLib/src/System/RuntimeType.CoreCLR.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3774,7 +3774,7 @@ private CheckValueStatus TryChangeType(
37743774
CorElementType dstElementType = GetUnderlyingType(this);
37753775
if (dstElementType != srcElementType)
37763776
{
3777-
value = InvokeUtils.ConvertOrWiden(srcType, srcElementType, value, this, dstElementType);
3777+
value = InvokeUtils.ConvertOrWiden(srcType, value, this, dstElementType);
37783778
}
37793779
}
37803780

@@ -3929,7 +3929,7 @@ private void CreateInstanceCheckThis()
39293929
}
39303930

39313931
// fast path??
3932-
instance = CreateInstanceLocal(this, nonPublic: true, wrapExceptions: wrapExceptions);
3932+
instance = CreateInstanceLocal(wrapExceptions: wrapExceptions);
39333933
}
39343934
else
39353935
{
@@ -3943,7 +3943,7 @@ private void CreateInstanceCheckThis()
39433943

39443944
[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2082:UnrecognizedReflectionPattern",
39453945
Justification = "Implementation detail of Activator that linker intrinsically recognizes")]
3946-
object? CreateInstanceLocal(Type type, bool nonPublic, bool wrapExceptions)
3946+
object? CreateInstanceLocal(bool wrapExceptions)
39473947
{
39483948
return Activator.CreateInstance(this, nonPublic: true, wrapExceptions: wrapExceptions);
39493949
}

src/coreclr/nativeaot/Common/src/System/Collections/Concurrent/ConcurrentUnifierWKeyed.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public V GetOrAdd(K key)
161161
return heyIWasHereFirst;
162162
if (!_container.HasCapacity)
163163
_container.Resize(); // This overwrites the _container field.
164-
_container.Add(key, hashCode, value);
164+
_container.Add(hashCode, value);
165165
return value;
166166
}
167167
}
@@ -218,7 +218,7 @@ public bool TryGetValue(K key, int hashCode, out V value)
218218
return false;
219219
}
220220

221-
public void Add(K key, int hashCode, V value)
221+
public void Add(int hashCode, V value)
222222
{
223223
Debug.Assert(_owner._lock.IsAcquired);
224224

src/coreclr/nativeaot/Runtime.Base/src/System/AttributeUsageAttribute.cs

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace System
1616
[AttributeUsage(AttributeTargets.Class, Inherited = true)]
1717
public sealed class AttributeUsageAttribute : Attribute
1818
{
19+
#pragma warning disable IDE0060
1920
//Constructors
2021
public AttributeUsageAttribute(AttributeTargets validOn)
2122
{
@@ -24,6 +25,7 @@ public AttributeUsageAttribute(AttributeTargets validOn)
2425
public AttributeUsageAttribute(AttributeTargets validOn, bool allowMultiple, bool inherited)
2526
{
2627
}
28+
#pragma warning restore IDE0060
2729

2830
//Properties.
2931
// Allowing the set properties as it allows a more readable syntax in the specifiers (and are commonly used)

src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/ExceptionHandling.cs

+5
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,14 @@ private struct EHEnum
7272
private IntPtr _dummy; // For alignment
7373
}
7474

75+
#pragma warning disable IDE0060
7576
// This is a fail-fast function used by the runtime as a last resort that will terminate the process with
7677
// as little effort as possible. No guarantee is made about the semantics of this fail-fast.
7778
internal static void FallbackFailFast(RhFailFastReason reason, object unhandledException)
7879
{
7980
InternalCalls.RhpFallbackFailFast();
8081
}
82+
#pragma warning restore IDE0060
8183

8284
// Given an address pointing somewhere into a managed module, get the classlib-defined fail-fast
8385
// function and invoke it. Any failure to find and invoke the function, or if it returns, results in
@@ -921,6 +923,7 @@ private static void InvokeSecondPass(ref ExInfo exInfo, uint idxStart, uint idxL
921923
}
922924
}
923925

926+
#pragma warning disable IDE0060
924927
[UnmanagedCallersOnly(EntryPoint = "RhpFailFastForPInvokeExceptionPreemp", CallConvs = new Type[] { typeof(CallConvCdecl) })]
925928
public static void RhpFailFastForPInvokeExceptionPreemp(IntPtr PInvokeCallsiteReturnAddr, void* pExceptionRecord, void* pContextRecord)
926929
{
@@ -931,5 +934,7 @@ public static void RhpFailFastForPInvokeExceptionCoop(IntPtr classlibBreadcrumb,
931934
{
932935
FailFastViaClasslib(RhFailFastReason.UnhandledExceptionFromPInvoke, null, classlibBreadcrumb);
933936
}
937+
#pragma warning restore IDE0060
938+
934939
} // static class EH
935940
}

src/coreclr/nativeaot/System.Private.CoreLib/src/System/ComAwareWeakReference.NativeAot.cs

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
using System;
55

66
#if FEATURE_COMINTEROP || FEATURE_COMWRAPPERS
7+
8+
#pragma warning disable IDE0060
9+
710
namespace System
811
{
912
internal sealed partial class ComAwareWeakReference

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Delegate.cs

+1-45
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
namespace System
1717
{
18-
[DebuggerDisplay("Target method(s) = {GetTargetMethodsDescriptionForDebugger()}")]
1918
public abstract partial class Delegate : ICloneable, ISerializable
2019
{
2120
// V1 API: Create closed instance delegates. Method name matching is case sensitive.
@@ -218,7 +217,7 @@ private void InitializeClosedStaticThunk(object firstParameter, IntPtr functionP
218217
}
219218

220219
// This function is known to the compiler backend.
221-
private void InitializeOpenStaticThunk(object firstParameter, IntPtr functionPointer, IntPtr functionPointerThunk)
220+
private void InitializeOpenStaticThunk(object _ /*firstParameter*/, IntPtr functionPointer, IntPtr functionPointerThunk)
222221
{
223222
// This sort of delegate is invoked by calling the thunk function pointer with the arguments to the delegate + a reference to the delegate object itself.
224223
m_firstParameter = this;
@@ -422,48 +421,5 @@ internal static Delegate CreateDelegate(EETypePtr delegateEEType, IntPtr ldftnRe
422421
}
423422
return del;
424423
}
425-
426-
private string GetTargetMethodsDescriptionForDebugger()
427-
{
428-
if (m_functionPointer == GetThunk(MulticastThunk))
429-
{
430-
// Multi-cast delegates return the Target of the last delegate in the list
431-
Delegate[] invocationList = (Delegate[])m_helperObject;
432-
int invocationCount = (int)m_extraFunctionPointerOrData;
433-
StringBuilder builder = new StringBuilder();
434-
for (int c = 0; c < invocationCount; c++)
435-
{
436-
if (c != 0)
437-
builder.Append(", ");
438-
439-
builder.Append(invocationList[c].GetTargetMethodsDescriptionForDebugger());
440-
}
441-
442-
return builder.ToString();
443-
}
444-
else
445-
{
446-
RuntimeTypeHandle typeOfFirstParameterIfInstanceDelegate;
447-
IntPtr functionPointer = GetFunctionPointer(out typeOfFirstParameterIfInstanceDelegate, out bool _, out bool _);
448-
if (!FunctionPointerOps.IsGenericMethodPointer(functionPointer))
449-
{
450-
return DebuggerFunctionPointerFormattingHook(functionPointer, typeOfFirstParameterIfInstanceDelegate);
451-
}
452-
else
453-
{
454-
unsafe
455-
{
456-
GenericMethodDescriptor* pointerDef = FunctionPointerOps.ConvertToGenericDescriptor(functionPointer);
457-
return DebuggerFunctionPointerFormattingHook(pointerDef->InstantiationArgument, typeOfFirstParameterIfInstanceDelegate);
458-
}
459-
}
460-
}
461-
}
462-
463-
private static string DebuggerFunctionPointerFormattingHook(IntPtr functionPointer, RuntimeTypeHandle typeOfFirstParameterIfInstanceDelegate)
464-
{
465-
// This method will be hooked by the debugger and the debugger will cause it to return a description for the function pointer
466-
throw new NotSupportedException();
467-
}
468424
}
469425
}

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Enum.NativeAot.cs

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace System
1616
{
1717
public abstract partial class Enum : ValueType, IComparable, IFormattable, IConvertible
1818
{
19+
#pragma warning disable IDE0060
1920
internal static EnumInfo GetEnumInfo(Type enumType, bool getNames = true)
2021
{
2122
Debug.Assert(enumType != null);
@@ -24,6 +25,7 @@ internal static EnumInfo GetEnumInfo(Type enumType, bool getNames = true)
2425

2526
return ReflectionAugments.ReflectionCoreCallbacks.GetEnumInfo(enumType);
2627
}
28+
#pragma warning restore
2729

2830
private static object InternalBoxEnum(Type enumType, long value)
2931
{

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Environment.NativeAot.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static void FailFast(string message) =>
4343
public static void FailFast(string message, Exception exception) =>
4444
RuntimeExceptionHelpers.FailFast(message, exception);
4545

46-
internal static void FailFast(string message, Exception exception, string errorSource)
46+
internal static void FailFast(string message, Exception exception, string _ /*errorSource*/)
4747
{
4848
// TODO: errorSource originates from CoreCLR (See: https://github.com/dotnet/coreclr/pull/15895)
4949
// For now, we ignore errorSource but we should distinguish the way FailFast prints exception message using errorSource

src/coreclr/nativeaot/System.Private.CoreLib/src/System/IO/FileLoadException.NativeAot.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace System.IO
55
{
66
public partial class FileLoadException
77
{
8-
internal static string FormatFileLoadExceptionMessage(string? fileName, int hResult)
8+
internal static string FormatFileLoadExceptionMessage(string? fileName, int _ /*hResult*/)
99
{
1010
return fileName == null ? SR.IO_FileLoad : SR.Format(SR.IO_FileLoad_FileName, fileName);
1111
}

src/coreclr/nativeaot/System.Private.CoreLib/src/System/InvokeUtils.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ private static Exception CreateChangeTypeException(EETypePtr srcEEType, EETypePt
244244
case CheckArgumentSemantics.SetFieldDirect:
245245
return CreateChangeTypeArgumentException(srcEEType, dstEEType);
246246
case CheckArgumentSemantics.ArraySet:
247-
return CreateChangeTypeInvalidCastException(srcEEType, dstEEType);
247+
return CreateChangeTypeInvalidCastException();
248248
default:
249249
Debug.Fail("Unexpected CheckArgumentSemantics value: " + semantics);
250250
throw new InvalidOperationException();
@@ -259,7 +259,7 @@ internal static ArgumentException CreateChangeTypeArgumentException(EETypePtr sr
259259
return new ArgumentException(SR.Format(SR.Arg_ObjObjEx, Type.GetTypeFromHandle(new RuntimeTypeHandle(srcEEType)), destinationTypeName));
260260
}
261261

262-
private static InvalidCastException CreateChangeTypeInvalidCastException(EETypePtr srcEEType, EETypePtr dstEEType)
262+
private static InvalidCastException CreateChangeTypeInvalidCastException()
263263
{
264264
return new InvalidCastException(SR.InvalidCast_StoreArrayElement);
265265
}

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/Runtime/General/TypeUnifier.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ private sealed class ArrayTypeTable : ConcurrentUnifierWKeyed<UnificationKey, Ru
253253
{
254254
protected sealed override RuntimeArrayTypeInfo Factory(UnificationKey key)
255255
{
256-
ValidateElementType(key.ElementType, key.TypeHandle, multiDim: false, rank: 1);
256+
ValidateElementType(key.ElementType, multiDim: false, rank: 1);
257257

258258
return new RuntimeArrayTypeInfo(key, multiDim: false, rank: 1);
259259
}
@@ -270,7 +270,7 @@ public MultiDimArrayTypeTable(int rank)
270270

271271
protected sealed override RuntimeArrayTypeInfo Factory(UnificationKey key)
272272
{
273-
ValidateElementType(key.ElementType, key.TypeHandle, multiDim: true, rank: _rank);
273+
ValidateElementType(key.ElementType, multiDim: true, rank: _rank);
274274

275275
return new RuntimeArrayTypeInfo(key, multiDim: true, rank: _rank);
276276
}
@@ -292,7 +292,7 @@ protected sealed override MultiDimArrayTypeTable Factory(int rank)
292292
public static readonly TypeTableForMultiDimArrayTypeTables Table = new TypeTableForMultiDimArrayTypeTables();
293293
}
294294

295-
private static void ValidateElementType(RuntimeTypeInfo elementType, RuntimeTypeHandle typeHandle, bool multiDim, int rank)
295+
private static void ValidateElementType(RuntimeTypeInfo elementType, bool multiDim, int rank)
296296
{
297297
Debug.Assert(multiDim || rank == 1);
298298

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.NativeAot.cs

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public static void InitializeArray(Array array, RuntimeFieldHandle fldHandle)
2525
throw new PlatformNotSupportedException();
2626
}
2727

28+
#pragma warning disable IDE0060
2829
private static unsafe void* GetSpanDataFrom(
2930
RuntimeFieldHandle fldHandle,
3031
RuntimeTypeHandle targetTypeHandle,
@@ -36,6 +37,7 @@ public static void InitializeArray(Array array, RuntimeFieldHandle fldHandle)
3637
// https://github.com/dotnet/corert/issues/364
3738
throw new PlatformNotSupportedException();
3839
}
40+
#pragma warning disable IDE0060
3941

4042
[RequiresUnreferencedCode("Trimmer can't guarantee existence of class constructor")]
4143
public static void RunClassConstructor(RuntimeTypeHandle type)

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/ComWrappers.NativeAot.cs

+2
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ public object GetOrRegisterObjectForComInstance(IntPtr externalComObject, Create
465465
return (ComInterfaceDispatch*)comObject;
466466
}
467467

468+
#pragma warning disable IDE0060
468469
/// <summary>
469470
/// Get the currently registered managed object or creates a new managed object and registers it.
470471
/// </summary>
@@ -541,6 +542,7 @@ private unsafe bool TryGetOrCreateObjectForComInstanceInternal(
541542

542543
return true;
543544
}
545+
#pragma warning restore IDE0060
544546

545547
private void RemoveRCWFromCache(IntPtr comPointer)
546548
{

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.NativeAot.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,8 @@ public static unsafe void StructureToPtr(object structure, IntPtr ptr, bool fDel
197197
}
198198
}
199199

200-
private static void PrelinkCore(MethodInfo m)
201-
{
202-
// This method is effectively a no-op for NativeAOT, everything pre-generated.
203-
}
200+
// This method is effectively a no-op for NativeAOT, everything pre-generated.
201+
static partial void PrelinkCore(MethodInfo m);
204202

205203
internal static Delegate GetDelegateForFunctionPointerInternal(IntPtr ptr, Type t)
206204
{

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeLibrary.NativeAot.Unix.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public static partial class NativeLibrary
99
{
1010
private const int LoadWithAlteredSearchPathFlag = 0;
1111

12-
private static IntPtr LoadLibraryHelper(string libraryName, int flags, ref LoadLibErrorTracker errorTracker)
12+
private static IntPtr LoadLibraryHelper(string libraryName, int _ /*flags*/, ref LoadLibErrorTracker errorTracker)
1313
{
1414
// do the Dos/Unix conversion
1515
libraryName = libraryName.Replace('\\', '/');

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/JitInfo.NativeAot.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ public static partial class JitInfo
99

1010
public static long GetCompiledMethodCount(bool currentThread = false) => 0;
1111

12-
private static long GetCompilationTimeInTicks(bool currentThread = false) => 0;
12+
private static long GetCompilationTimeInTicks(bool _ /*currentThread*/ = false) => 0;
1313
}
1414
}

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.NativeAot.cs

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public Assembly LoadFromAssemblyName(AssemblyName assemblyName)
1818
return Assembly.Load(assemblyName);
1919
}
2020

21+
#pragma warning disable IDE0060
2122
private static IntPtr InitializeAssemblyLoadContext(IntPtr ptrAssemblyLoadContext, bool fRepresentsTPALoadContext, bool isCollectible)
2223
{
2324
return IntPtr.Zero;
@@ -46,6 +47,7 @@ private static Assembly InternalLoadFromPath(string? assemblyPath, string? nativ
4647
// so it won't actually work properly when multiple assemblies with the same identity get loaded.
4748
return ReflectionAugments.ReflectionCoreCallbacks.Load(assemblyPath);
4849
}
50+
#pragma warning restore IDE0060
4951

5052
#pragma warning disable CA1822
5153
internal Assembly InternalLoad(ReadOnlySpan<byte> arrAssembly, ReadOnlySpan<byte> arrSymbols)

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Thread.NativeAot.Unix.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private void PlatformSpecificInitializeExistingThread()
2828
_stopped = new ManualResetEvent(false);
2929
}
3030

31-
#pragma warning disable CA1822
31+
#pragma warning disable CA1822, IDE0060
3232
private ThreadPriority GetPriorityLive()
3333
{
3434
return ThreadPriority.Normal;
@@ -38,7 +38,7 @@ private bool SetPriorityLive(ThreadPriority priority)
3838
{
3939
return true;
4040
}
41-
#pragma warning restore CA1822
41+
#pragma warning restore CA1822, IDE0060
4242

4343
[UnmanagedCallersOnly]
4444
private static void OnThreadExit()

0 commit comments

Comments
 (0)