Skip to content
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
5 changes: 1 addition & 4 deletions src/coreclr/System.Private.CoreLib/src/System/GC.CoreCLR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,7 @@ public static int GetGeneration(WeakReference wo)
object? obj = GCHandle.InternalGet(wo.WeakHandle);
KeepAlive(wo);

if (obj is null)
{
throw new ArgumentNullException(nameof(wo));
}
ArgumentNullException.ThrowIfNull(obj, nameof(wo));

return GetGeneration(obj);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ private void AddOneArgTypeHelper(Type clsArgument, Type[]? requiredCustomModifie
{
for (int i = 0; i < optionalCustomModifiers.Length; i++)
{
Type t = optionalCustomModifiers[i] ??
throw new ArgumentNullException(nameof(optionalCustomModifiers));
Type t = optionalCustomModifiers[i];
ArgumentNullException.ThrowIfNull(t, nameof(optionalCustomModifiers));

if (t.HasElementType)
throw new ArgumentException(SR.Argument_ArraysInvalid, nameof(optionalCustomModifiers));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1879,7 +1879,7 @@ private static object CreateCustomAttributeInstance(RuntimeModule module, Runtim
{
if (module is null)
{
throw new ArgumentNullException(SR.Arg_InvalidHandle);
throw new ArgumentNullException(null, SR.Arg_InvalidHandle);
}

object? result = null;
Expand Down Expand Up @@ -1909,7 +1909,7 @@ private static void GetPropertyOrFieldData(
{
if (module is null)
{
throw new ArgumentNullException(SR.Arg_InvalidHandle);
throw new ArgumentNullException(null, SR.Arg_InvalidHandle);
}

string? nameLocal = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public TValue this[TKey key]
{
get
{
if (key == null)
throw new ArgumentNullException(nameof(key));
ArgumentNullException.ThrowIfNull(key);

Entry entry = Find(key);
if (entry == null)
Expand All @@ -59,8 +58,7 @@ public TValue this[TKey key]
}
set
{
if (key == null)
throw new ArgumentNullException(nameof(key));
ArgumentNullException.ThrowIfNull(key);

_version++;
Entry entry = Find(key);
Expand All @@ -73,9 +71,9 @@ public TValue this[TKey key]

public bool TryGetValue(TKey key, out TValue? value)
{
ArgumentNullException.ThrowIfNull(key);

value = default(TValue);
if (key == null)
throw new ArgumentNullException(nameof(key));
Entry entry = Find(key);
if (entry != null)
{
Expand All @@ -87,8 +85,8 @@ public bool TryGetValue(TKey key, out TValue? value)

public void Add(TKey key, TValue value)
{
if (key == null)
throw new ArgumentNullException(nameof(key));
ArgumentNullException.ThrowIfNull(key);

Entry entry = Find(key);
if (entry != null)
throw new ArgumentException(SR.Format(SR.Argument_AddingDuplicate, key));
Expand All @@ -105,8 +103,8 @@ public void Clear(int capacity = DefaultSize)

public bool Remove(TKey key)
{
if (key == null)
throw new ArgumentNullException(nameof(key));
ArgumentNullException.ThrowIfNull(key);

int bucket = GetBucket(key);
Entry? prev = null;
Entry? entry = _buckets[bucket];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ public static int GetGeneration(WeakReference wo)
object? obj = RuntimeImports.RhHandleGet(wo.WeakHandle);
KeepAlive(wo);

if (obj == null)
{
throw new ArgumentNullException(nameof(wo));
}
ArgumentNullException.ThrowIfNull(obj, nameof(wo));

return RuntimeImports.RhGetGeneration(obj);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,7 @@ public static unsafe void StringBuilderToAnsiString(System.Text.StringBuilder st

public static unsafe void AnsiStringToStringBuilder(byte* newBuffer, System.Text.StringBuilder stringBuilder)
{
if (newBuffer == null)
throw new ArgumentNullException(nameof(newBuffer));
ArgumentNullException.ThrowIfNull(newBuffer);

int lenAnsi;
int lenUnicode;
Expand Down Expand Up @@ -435,8 +434,7 @@ public static unsafe void WideCharArrayToAnsiCharArray(char[] managedArray, byte
return;

// Desktop CLR crash (AV at runtime) - we can do better in .NET Native
if (pNative == null)
throw new ArgumentNullException(nameof(pNative));
ArgumentNullException.ThrowIfNull(pNative);

int lenUnicode = managedArray.Length;
fixed (char* pManaged = managedArray)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@
<data name="ConcurrentDictionary_KeyAlreadyExisted" xml:space="preserve">
<value>The key already existed in the dictionary.</value>
</data>
<data name="ConcurrentDictionary_ItemKeyIsNull" xml:space="preserve">
<value>TKey is a reference type and item.Key is null.</value>
</data>
<data name="ConcurrentDictionary_TypeOfKeyIncorrect" xml:space="preserve">
<value>The key was of an incorrect type for this dictionary.</value>
</data>
Expand Down
Loading