Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions src/Common/src/Internal/Cryptography/HashProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ public void AppendHashData(byte[] data, int offset, int count)
// an invalid number of bytes read. Since our implementations of AppendHashDataCore
// end up using unsafe code, we want to be sure the arguments are valid.
if (data == null)
throw new ArgumentNullException("data", SR.ArgumentNull_Buffer);
throw new ArgumentNullException(nameof(data), SR.ArgumentNull_Buffer);
if (offset < 0)
throw new ArgumentOutOfRangeException("offset", SR.ArgumentOutOfRange_NeedNonNegNum);
throw new ArgumentOutOfRangeException(nameof(offset), SR.ArgumentOutOfRange_NeedNonNegNum);
if (count < 0)
throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum);
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum);
if (data.Length - offset < count)
throw new ArgumentException(SR.Argument_InvalidOffLen);

Expand Down
28 changes: 14 additions & 14 deletions src/Common/src/Internal/Cryptography/UniversalCryptoTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,23 @@ public void Dispose()
public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
{
if (inputBuffer == null)
throw new ArgumentNullException("inputBuffer");
throw new ArgumentNullException(nameof(inputBuffer));
if (inputOffset < 0)
throw new ArgumentOutOfRangeException("inputOffset");
throw new ArgumentOutOfRangeException(nameof(inputOffset));
if (inputOffset > inputBuffer.Length)
throw new ArgumentOutOfRangeException("inputOffset");
throw new ArgumentOutOfRangeException(nameof(inputOffset));
if (inputCount <= 0)
throw new ArgumentOutOfRangeException("inputCount");
throw new ArgumentOutOfRangeException(nameof(inputCount));
if (inputCount % InputBlockSize != 0)
throw new ArgumentOutOfRangeException("inputCount", SR.Cryptography_MustTransformWholeBlock);
throw new ArgumentOutOfRangeException(nameof(inputCount), SR.Cryptography_MustTransformWholeBlock);
if (inputCount > inputBuffer.Length - inputOffset)
throw new ArgumentOutOfRangeException("inputCount", SR.Cryptography_TransformBeyondEndOfBuffer);
throw new ArgumentOutOfRangeException(nameof(inputCount), SR.Cryptography_TransformBeyondEndOfBuffer);
if (outputBuffer == null)
throw new ArgumentNullException("outputBuffer");
throw new ArgumentNullException(nameof(outputBuffer));
if (outputOffset > outputBuffer.Length)
throw new ArgumentOutOfRangeException("outputOffset");
throw new ArgumentOutOfRangeException(nameof(outputOffset));
if (inputCount > outputBuffer.Length - outputOffset)
throw new ArgumentOutOfRangeException("outputOffset", SR.Cryptography_TransformBeyondEndOfBuffer);
throw new ArgumentOutOfRangeException(nameof(outputOffset), SR.Cryptography_TransformBeyondEndOfBuffer);

int numBytesWritten = UncheckedTransformBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
Debug.Assert(numBytesWritten >= 0 && numBytesWritten <= inputCount);
Expand All @@ -87,15 +87,15 @@ public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, b
public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
{
if (inputBuffer == null)
throw new ArgumentNullException("inputBuffer");
throw new ArgumentNullException(nameof(inputBuffer));
if (inputOffset < 0)
throw new ArgumentOutOfRangeException("inputOffset");
throw new ArgumentOutOfRangeException(nameof(inputOffset));
if (inputCount < 0)
throw new ArgumentOutOfRangeException("inputCount");
throw new ArgumentOutOfRangeException(nameof(inputCount));
if (inputOffset > inputBuffer.Length)
throw new ArgumentOutOfRangeException("inputOffset");
throw new ArgumentOutOfRangeException(nameof(inputOffset));
if (inputCount > inputBuffer.Length - inputOffset)
throw new ArgumentOutOfRangeException("inputCount", SR.Cryptography_TransformBeyondEndOfBuffer);
throw new ArgumentOutOfRangeException(nameof(inputCount), SR.Cryptography_TransformBeyondEndOfBuffer);

byte[] output = UncheckedTransformFinalBlock(inputBuffer, inputOffset, inputCount);
return output;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static MethodBase BindToMethod(MethodBase[] match, ref object[] args)
{
if (match == null || match.Length == 0)
{
throw new ArgumentException(SR.Arg_EmptyArray, "match");
throw new ArgumentException(SR.Arg_EmptyArray, nameof(match));
}

MethodBase[] candidates = (MethodBase[])match.Clone();
Expand Down Expand Up @@ -720,12 +720,12 @@ public static PropertyInfo SelectProperty(PropertyInfo[] match, Type returnType,
if (indexes != null && !Contract.ForAll(indexes, delegate (Type t) { return t != null; }))
{
Exception e; // Written this way to pass the Code Contracts style requirements.
e = new ArgumentNullException("indexes");
e = new ArgumentNullException(nameof(indexes));
throw e;
}
if (match == null || match.Length == 0)
{
throw new ArgumentException(SR.Arg_EmptyArray, "match");
throw new ArgumentException(SR.Arg_EmptyArray, nameof(match));
}

PropertyInfo[] candidates = (PropertyInfo[])match.Clone();
Expand Down
12 changes: 6 additions & 6 deletions src/Common/src/Interop/OSX/Interop.libproc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ private static unsafe extern int proc_pidinfo(
// Negative PIDs are invalid
if (pid < 0)
{
throw new ArgumentOutOfRangeException("pid");
throw new ArgumentOutOfRangeException(nameof(pid));
}

// Get the process information for the specified pid
Expand All @@ -336,13 +336,13 @@ private static unsafe extern int proc_pidinfo(
// Negative PIDs are invalid
if (pid < 0)
{
throw new ArgumentOutOfRangeException("pid");
throw new ArgumentOutOfRangeException(nameof(pid));
}

// Negative TIDs are invalid
if (thread < 0)
{
throw new ArgumentOutOfRangeException("thread");
throw new ArgumentOutOfRangeException(nameof(thread));
}

// Get the thread information for the specified thread in the specified process
Expand All @@ -357,7 +357,7 @@ private static unsafe extern int proc_pidinfo(
// Negative PIDs are invalid
if (pid < 0)
{
throw new ArgumentOutOfRangeException("pid");
throw new ArgumentOutOfRangeException(nameof(pid));
}

int result = 0;
Expand Down Expand Up @@ -429,7 +429,7 @@ internal static unsafe string proc_pidpath(int pid)
// Negative PIDs are invalid
if (pid < 0)
{
throw new ArgumentOutOfRangeException("pid", SR.NegativePidNotSupported);
throw new ArgumentOutOfRangeException(nameof(pid), SR.NegativePidNotSupported);
}

// The path is a fixed buffer size, so use that and trim it after
Expand Down Expand Up @@ -474,7 +474,7 @@ internal static unsafe rusage_info_v3 proc_pid_rusage(int pid)
// Negative PIDs are invalid
if (pid < 0)
{
throw new ArgumentOutOfRangeException("pid", SR.NegativePidNotSupported);
throw new ArgumentOutOfRangeException(nameof(pid), SR.NegativePidNotSupported);
}

rusage_info_v3 info = new rusage_info_v3();
Expand Down
2 changes: 1 addition & 1 deletion src/Common/src/Interop/Unix/System.Native/Interop.FdSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal static unsafe void FD_ZERO(uint* fdset)

private static void ThrowInvalidFileDescriptor(int fd)
{
throw new ArgumentOutOfRangeException("fd", fd, SR.net_InvalidSocketHandle);
throw new ArgumentOutOfRangeException(nameof(fd), fd, SR.net_InvalidSocketHandle);
}
}
}
2 changes: 1 addition & 1 deletion src/Common/src/Interop/Windows/sspicli/SSPIAuthType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public unsafe int QueryContextAttributes(SafeDeleteContext context, Interop.Sspi
}
else
{
throw new ArgumentException(SR.Format(SR.SSPIInvalidHandleType, handleType.FullName), "handleType");
throw new ArgumentException(SR.Format(SR.SSPIInvalidHandleType, handleType.FullName), nameof(handleType));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public unsafe int QueryContextAttributes(SafeDeleteContext phContext, Interop.Ss
}
else
{
throw new ArgumentException(SR.Format(SR.SSPIInvalidHandleType, handleType.FullName), "handleType");
throw new ArgumentException(SR.Format(SR.SSPIInvalidHandleType, handleType.FullName), nameof(handleType));
}
}
fixed (byte* bufferPtr = buffer)
Expand Down
2 changes: 1 addition & 1 deletion src/Common/src/Interop/Windows/sspicli/SSPIWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ public static object QueryContextAttributes(SSPIInterface secModule, SafeDeleteC
break;

default:
throw new ArgumentException(SR.Format(SR.net_invalid_enum, "ContextAttribute"), "contextAttribute");
throw new ArgumentException(SR.Format(SR.net_invalid_enum, "ContextAttribute"), nameof(contextAttribute));
}

SafeHandle sspiHandle = null;
Expand Down
4 changes: 2 additions & 2 deletions src/Common/src/Interop/Windows/sspicli/SecuritySafeHandles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ internal unsafe static int InitializeSecurityContext(

if (inCredentials == null)
{
throw new ArgumentNullException("inCredentials");
throw new ArgumentNullException(nameof(inCredentials));
}

Interop.SspiCli.SecurityBufferDescriptor inSecurityBufferDescriptor = null;
Expand Down Expand Up @@ -877,7 +877,7 @@ internal unsafe static int AcceptSecurityContext(

if (inCredentials == null)
{
throw new ArgumentNullException("inCredentials");
throw new ArgumentNullException(nameof(inCredentials));
}

Interop.SspiCli.SecurityBufferDescriptor inSecurityBufferDescriptor = null;
Expand Down
10 changes: 5 additions & 5 deletions src/Common/src/System/Collections/Generic/LowLevelDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public TValue this[TKey key]
get
{
if (key == null)
throw new ArgumentNullException("key");
throw new ArgumentNullException(nameof(key));

Entry entry = Find(key);
if (entry == null)
Expand All @@ -68,7 +68,7 @@ public TValue this[TKey key]
set
{
if (key == null)
throw new ArgumentNullException("key");
throw new ArgumentNullException(nameof(key));

_version++;
Entry entry = Find(key);
Expand All @@ -83,7 +83,7 @@ public bool TryGetValue(TKey key, out TValue value)
{
value = default(TValue);
if (key == null)
throw new ArgumentNullException("key");
throw new ArgumentNullException(nameof(key));
Entry entry = Find(key);
if (entry != null)
{
Expand All @@ -96,7 +96,7 @@ public bool TryGetValue(TKey key, out TValue value)
public void Add(TKey key, TValue value)
{
if (key == null)
throw new ArgumentNullException("key");
throw new ArgumentNullException(nameof(key));
Entry entry = Find(key);
if (entry != null)
throw new ArgumentException(SR.Format(SR.Argument_AddingDuplicate, key));
Expand All @@ -114,7 +114,7 @@ public void Clear(int capacity = DefaultSize)
public bool Remove(TKey key)
{
if (key == null)
throw new ArgumentNullException("key");
throw new ArgumentNullException(nameof(key));
int bucket = GetBucket(key);
Entry prev = null;
Entry entry = _buckets[bucket];
Expand Down
18 changes: 9 additions & 9 deletions src/Common/src/System/Collections/Generic/LowLevelList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public LowLevelList()
//
public LowLevelList(int capacity)
{
if (capacity < 0) throw new ArgumentOutOfRangeException("capacity");
if (capacity < 0) throw new ArgumentOutOfRangeException(nameof(capacity));
Contract.EndContractBlock();

if (capacity == 0)
Expand All @@ -80,7 +80,7 @@ public LowLevelList(int capacity)
public LowLevelList(IEnumerable<T> collection)
{
if (collection == null)
throw new ArgumentNullException("collection");
throw new ArgumentNullException(nameof(collection));
Contract.EndContractBlock();

ICollection<T> c = collection as ICollection<T>;
Expand Down Expand Up @@ -130,7 +130,7 @@ public int Capacity
{
if (value < _size)
{
throw new ArgumentOutOfRangeException("value");
throw new ArgumentOutOfRangeException(nameof(value));
}
Contract.EndContractBlock();

Expand Down Expand Up @@ -312,7 +312,7 @@ public int IndexOf(T item)
public int IndexOf(T item, int index)
{
if (index > _size)
throw new ArgumentOutOfRangeException("index");
throw new ArgumentOutOfRangeException(nameof(index));
Contract.Ensures(Contract.Result<int>() >= -1);
Contract.Ensures(Contract.Result<int>() < Count);
Contract.EndContractBlock();
Expand All @@ -328,7 +328,7 @@ public void Insert(int index, T item)
// Note that insertions at the end are legal.
if ((uint)index > (uint)_size)
{
throw new ArgumentOutOfRangeException("index");
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
if (_size == _items.Length) EnsureCapacity(_size + 1);
Expand All @@ -350,12 +350,12 @@ public void InsertRange(int index, IEnumerable<T> collection)
{
if (collection == null)
{
throw new ArgumentNullException("collection");
throw new ArgumentNullException(nameof(collection));
}

if ((uint)index > (uint)_size)
{
throw new ArgumentOutOfRangeException("index");
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();

Expand Down Expand Up @@ -422,7 +422,7 @@ public int RemoveAll(Predicate<T> match)
{
if (match == null)
{
throw new ArgumentNullException("match");
throw new ArgumentNullException(nameof(match));
}
Contract.Ensures(Contract.Result<int>() >= 0);
Contract.Ensures(Contract.Result<int>() <= Contract.OldValue(Count));
Expand Down Expand Up @@ -461,7 +461,7 @@ public void RemoveAt(int index)
{
if ((uint)index >= (uint)_size)
{
throw new ArgumentOutOfRangeException("index");
throw new ArgumentOutOfRangeException(nameof(index));
}
Contract.EndContractBlock();
_size--;
Expand Down
4 changes: 2 additions & 2 deletions src/Common/src/System/Globalization/IdnMapping.Unix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private string GetAsciiCore(string unicode)
buf = new char[realLen];
}

throw new ArgumentException(SR.Argument_IdnIllegalName, "unicode");
throw new ArgumentException(SR.Argument_IdnIllegalName, nameof(unicode));
}

private string GetUnicodeCore(string ascii)
Expand All @@ -57,7 +57,7 @@ private string GetUnicodeCore(string ascii)
buf = new char[realLen];
}

throw new ArgumentException(SR.Argument_IdnIllegalName, "ascii");
throw new ArgumentException(SR.Argument_IdnIllegalName, nameof(ascii));
}

// -----------------------------
Expand Down
Loading