Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused private parameters in SPC #63015

Merged
merged 9 commits into from
Feb 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion eng/CodeAnalysis.src.globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ dotnet_diagnostic.CA5383.severity = none
# CA5384: Do Not Use Digital Signature Algorithm (DSA)
dotnet_diagnostic.CA5384.severity = warning

# CA5385: Use RivestShamirAdleman (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
Expand Down Expand Up @@ -1448,6 +1448,7 @@ dotnet_diagnostic.IDE0059.severity = warning

# 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System;
using System.Runtime.InteropServices;

#pragma warning disable IDE0060

namespace Internal.Runtime.InteropServices
{
public static class ComActivator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ internal void set_Item<T>(int index, T value)
_this[index] = value;
}

private void Add<T>(T value)
private void Add<T>(T _)
{
// Not meaningful for arrays.
ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection);
Expand Down Expand Up @@ -556,20 +556,20 @@ private int IndexOf<T>(T value)
return Array.IndexOf(_this, value, 0, _this.Length);
}

private void Insert<T>(int index, T value)
private void Insert<T>(int _, T _1)
adamsitnik marked this conversation as resolved.
Show resolved Hide resolved
{
// Not meaningful for arrays
ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection);
}

private bool Remove<T>(T value)
private bool Remove<T>(T _)
{
// Not meaningful for arrays
ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection);
return default;
}

private void RemoveAt<T>(int index)
private void RemoveAt<T>(int _)
{
// Not meaningful for arrays
ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ private void BuildStackFrame(int skipFrames, bool needFileInfo)
}
}

#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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -635,5 +636,6 @@ private void CtorCollectibleVirtualDispatch(object target, IntPtr methodPtr, Int
this._methodPtrAux = GetCallStub(methodPtr);
this._methodBase = System.Runtime.InteropServices.GCHandle.InternalGet(gchandle);
}
#pragma warning restore IDE0060
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,6 @@ private PropertyBuilder DefinePropertyNoLock(string name, PropertyAttributes att
return new PropertyBuilder(
m_module,
name,
sigHelper,
attributes,
returnType,
prToken,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2800,7 +2800,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;
Expand Down Expand Up @@ -2836,7 +2836,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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,7 @@ internal static SafeFileHandle Open(string fullPath, FileMode mode, FileAccess a
Interop.Sys.Permissions openPermissions = DefaultOpenPermissions,
Func<Interop.ErrorInfo, Interop.Sys.OpenFlags, string, Exception?>? 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,
Expand Down Expand Up @@ -317,7 +315,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)
{
Expand Down Expand Up @@ -367,7 +365,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)
Expand Down Expand Up @@ -482,7 +480,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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static bool TryParseThrowFormatException<T>(out T value, out int bytesCon
//
[DoesNotReturn]
[StackTraceHidden]
public static bool TryParseThrowFormatException<T>(ReadOnlySpan<byte> source, out T value, out int bytesConsumed) where T : struct
public static bool TryParseThrowFormatException<T>(ReadOnlySpan<byte> _, 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ internal readonly ref struct ByReference<T>
private readonly IntPtr _value;
#pragma warning restore CA1823, 169

#pragma warning disable IDE0060
[Intrinsic]
public ByReference(ref T value)
{
Expand All @@ -24,6 +25,7 @@ public ByReference(ref T value)
// or if intrinsic is missed.
throw new PlatformNotSupportedException();
}
#pragma warning restore IDE0060

#pragma warning disable CA1822 // Mark members as static
public ref T Value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 _)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ public static DateTime UtcNow
}
}

#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 year, int month, int day, int hour, int minute, DateTimeKind kind) => false;

#pragma warning restore IDE0060
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,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)
{
MethodBase[] aExactMatches = new MethodBase[match.Length];
int cExactMatches = 0;
Expand Down Expand Up @@ -807,7 +807,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)
{
PropertyInfo? bestMatch = null;
int typesLength = (types != null) ? types.Length : 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ public static partial class Environment
{
// Systems without the Windows registry pretend that it's always empty.

#pragma warning disable IDE0060
private static string? GetEnvironmentVariableFromRegistry(string variable, bool fromMachine) => null;
#pragma warning restore IDE0060

private static void SetEnvironmentVariableFromRegistry(string variable, string? value, bool fromMachine) { }
static partial void SetEnvironmentVariableFromRegistry(string variable, string? value, bool fromMachine);

#pragma warning disable IDE0060
private static IDictionary GetEnvironmentVariablesFromRegistry(bool fromMachine) => new Hashtable();
#pragma warning restore IDE0060
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ internal sealed partial class CalendarData
private bool LoadCalendarDataFromSystemCore(string localeName, CalendarId calendarId) =>
IcuLoadCalendarDataFromSystem(localeName, calendarId);

#pragma warning disable IDE0060
internal static int GetCalendarsCore(string localeName, bool useUserOverride, CalendarId[] calendars) =>
IcuGetCalendars(localeName, calendars);
#pragma warning restore IDE0060
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
eerhardt marked this conversation as resolved.
Show resolved Hide resolved
}
// Unix doesn't support user overrides
partial void InitUserOverride(bool useUserOverride);

private static string? LCIDToLocaleName(int culture)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5223,10 +5223,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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static void CopyFile(string sourceFullPath, string destFullPath, bool ove
}
}

#pragma warning disable IDE0060
public static void Encrypt(string path)
{
throw new PlatformNotSupportedException(SR.PlatformNotSupported_FileEncryption);
Expand All @@ -48,6 +49,7 @@ public static void Decrypt(string path)
{
throw new PlatformNotSupportedException(SR.PlatformNotSupported_FileEncryption);
}
#pragma warning restore IDE0060

private static void LinkOrCopyFile (string sourceFullPath, string destFullPath)
{
Expand Down Expand Up @@ -106,8 +108,8 @@ private static void LinkOrCopyFile (string sourceFullPath, string destFullPath)
}
}


public static void ReplaceFile(string sourceFullPath, string destFullPath, string? destBackupFullPath, bool ignoreMetadataErrors)
#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.
Expand Down Expand Up @@ -172,6 +174,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)
{
Expand Down Expand Up @@ -597,7 +600,9 @@ public static string[] GetLogicalDrives()
return DriveInfoInternal.GetLogicalDrives();
}

#pragma warning disable IDE0060
internal static string? GetLinkTarget(ReadOnlySpan<char> linkPath, bool isDirectory) => Interop.Sys.ReadLink(linkPath);
#pragma warning restore IDE0060

internal static void CreateSymbolicLink(string path, string pathToTarget, bool isDirectory)
{
Expand All @@ -610,7 +615,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();
Expand Down Expand Up @@ -643,7 +648,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++;
}
}
Expand Down
Loading