ThrowValueNullException();
}
}
- else if (default(TValue)! != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ else if (default(TValue) != null)
{
ThrowValueNullException();
}
// Because of the lack of typeof(T).IsValueType we need two pieces of information
// to determine this. default(T) will return a non null for Value Types, except those
// using Nullable<>, that is why we need a second condition.
- if (default(TSource)! != null || Nullable.GetUnderlyingType(typeof(TSource)) != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(TSource) != null || Nullable.GetUnderlyingType(typeof(TSource)) != null)
{
// Marshal.SizeOf fails for value types that don't have explicit layouts. We
// just fall back to some arbitrary constant in that case. Is there a better way?
{
internal static bool IsValueType<T>()
{
- if (default(T)! != null)
+ if (default(T) != null)
{
return true;
}
{
// Non-null values are fine. Only accept nulls if T is a class or Nullable<U>.
// Note that default(T) is not equal to null for value types except when T is Nullable<U>.
- return ((value is T) || (value == null && default(T)! == null));
+ return ((value is T) || (value == null && default(T) == null));
}
/// <summary>
{
int hashCode = item == null ? 0 : InternalGetHashCode(item.GetHashCode());
- if (default(T)! != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) != null)
{
// see note at "HashSet" level describing why "- 1" appears in for loop
for (int i = buckets[hashCode % buckets.Length] - 1; i >= 0; i = slots[i].next)
hashCode = item == null ? 0 : InternalGetHashCode(item.GetHashCode());
bucket = hashCode % _buckets!.Length;
- if (default(T)! != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) != null)
{
for (i = _buckets[bucket] - 1; i >= 0; last = i, i = slots[i].next)
{
hashCode = value == null ? 0 : InternalGetHashCode(value.GetHashCode());
bucket = hashCode % _buckets!.Length;
- if (default(T)! != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) != null)
{
for (int i = _buckets[bucket] - 1; i >= 0; i = slots[i].next)
{
{
int hashCode = item == null ? 0 : InternalGetHashCode(item.GetHashCode());
- if (default(T)! != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) != null)
{
// see note at "HashSet" level describing why "- 1" appears in for loop
for (int i = buckets[hashCode % buckets.Length] - 1; i >= 0; i = slots[i].next)
throw new ArgumentNullException(nameof(key));
}
- if (value == null && !(default(TValue)! == null)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (value == null && !(default(TValue) == null))
throw new ArgumentNullException(nameof(value));
try
throw new ArgumentNullException(nameof(key));
}
- if (value == null && !(default(TValue)! == null)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (value == null && !(default(TValue) == null))
throw new ArgumentNullException(nameof(value));
try
if (key == null)
throw new ArgumentNullException(nameof(key));
- if (value == null && !(default(TValue)! == null)) // null is an invalid value for Value types // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (value == null && !(default(TValue) == null)) // null is an invalid value for Value types
throw new ArgumentNullException(nameof(value));
if (!(key is TKey))
throw new ArgumentNullException(nameof(key));
}
- if (value == null && !(default(TValue)! == null)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (value == null && !(default(TValue) == null))
throw new ArgumentNullException(nameof(value));
TKey tempKey = (TKey)key;
private static bool IsCompatibleObject(object? value)
{
- return ((value is T) || (value == null && default(T)! == null));
+ return ((value is T) || (value == null && default(T) == null));
}
private static void ValidateNullValue(object? value, string argument)
{
- if (value == null && default(T)! != null)
+ if (value == null && default(T) != null)
{
throw Error.InvalidNullValue(typeof(T), argument);
}
AssociativeAggregationOperator<T, Pair<bool, T>, T> aggregation =
new AssociativeAggregationOperator<T, Pair<bool, T>, T>(source, new Pair<bool, T>(false, default!), null,
- true, intermediateReduce, finalReduce, resultSelector, default(T)! != null, QueryAggregationOptions.AssociativeCommutative);
+ true, intermediateReduce, finalReduce, resultSelector, default(T) != null, QueryAggregationOptions.AssociativeCommutative);
return aggregation.Aggregate();
}
// the existing accumulated result is equal to the sign requested by the function factory,
// we will return a new pair that contains the current element as the best item. We will
// ignore null elements (for reference and nullable types) in the input stream.
- if ((default(T)! != null || element != null) &&
+ if ((default(T) != null || element != null) &&
(!accumulator.First || Util.Sign(comparer.Compare(element, accumulator.Second)) == sign))
{
return new Pair<bool, T>(true, element);
if (element.First &&
(!accumulator.First || Util.Sign(comparer.Compare(element.Second, accumulator.Second)) == sign))
{
- Debug.Assert(default(T)! != null || element.Second != null, "nulls unexpected in final reduce");
+ Debug.Assert(default(T) != null || element.Second != null, "nulls unexpected in final reduce");
return new Pair<bool, T>(true, element.Second);
}
// empty sequences. Else, we will just return the element, which may be null for other types.
return delegate (Pair<bool, T> accumulator)
{
- Debug.Assert(accumulator.First || default(T)! == null,
+ Debug.Assert(accumulator.First || default(T) == null,
"for non-null types we expect an exception to be thrown before getting here");
return accumulator.Second;
};
// Because of the lack of typeof(T).IsValueType we need two pieces of information
// to determine this. default(T) will return a non null for Value Types, except those
// using Nullable<>, that is why we need a second condition.
- if (default(T)! != null || Nullable.GetUnderlyingType(typeof(T)) != null)
+ if (default(T) != null || Nullable.GetUnderlyingType(typeof(T)) != null)
{
// Marshal.SizeOf fails for value types that don't have explicit layouts. We
// just fall back to some arbitrary constant in that case. Is there a better way?
}
else
{
- if (default(TValue)! != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(TValue) != null)
{
// ValueType: Devirtualize with EqualityComparer<TValue>.Default intrinsic
for (int i = 0; i < _count; i++)
int i = GetBucket(hashCode);
Entry[]? entries = _entries;
uint collisionCount = 0;
- if (default(TKey)! != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(TKey) != null)
{
// ValueType: Devirtualize with EqualityComparer<TValue>.Default intrinsic
if (comparer == null)
{
- if (default(TKey)! != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(TKey) != null)
{
// ValueType: Devirtualize with EqualityComparer<TValue>.Default intrinsic
while (true)
_version++;
// Value types never rehash
- if (default(TKey)! == null && collisionCount > HashHelpers.HashCollisionThreshold && comparer is NonRandomizedStringEqualityComparer) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(TKey) == null && collisionCount > HashHelpers.HashCollisionThreshold && comparer is NonRandomizedStringEqualityComparer)
{
// If we hit the collision threshold we'll need to switch to the comparer which is using randomized string hashing
// i.e. EqualityComparer<string>.Default.
private void Resize(int newSize, bool forceNewHashCodes)
{
// Value types never rehash
- Debug.Assert(!forceNewHashCodes || default(TKey)! == null); // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ Debug.Assert(!forceNewHashCodes || default(TKey) == null);
Debug.Assert(_entries != null, "_entries should be non-null");
Debug.Assert(newSize >= _entries.Length);
int count = _count;
Array.Copy(_entries, entries, count);
- if (default(TKey)! == null && forceNewHashCodes) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(TKey) == null && forceNewHashCodes)
{
for (int i = 0; i < count; i++)
{
{
// Non-null values are fine. Only accept nulls if T is a class or Nullable<U>.
// Note that default(T) is not equal to null for value types except when T is Nullable<U>.
- return (value is T) || (value == null && default(T)! == null); // default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ return (value is T) || (value == null && default(T) == null);
}
object? IList.this[int index]
{
// Non-null values are fine. Only accept nulls if T is a class or Nullable<U>.
// Note that default(T) is not equal to null for value types except when T is Nullable<U>.
- return (value is T) || (value == null && default(T)! == null);
+ return (value is T) || (value == null && default(T) == null);
}
}
}
{
// Non-null values are fine. Only accept nulls if T is a class or Nullable<U>.
// Note that default(T) is not equal to null for value types except when T is Nullable<U>.
- return (value is T) || (value == null && default(T)! == null);
+ return (value is T) || (value == null && default(T) == null);
}
bool IList.Contains(object? value)
this = default;
return; // returns default
}
- if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) == null && array.GetType() != typeof(T[]))
ThrowHelper.ThrowArrayTypeMismatchException();
_object = array;
this = default;
return; // returns default
}
- if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) == null && array.GetType() != typeof(T[]))
ThrowHelper.ThrowArrayTypeMismatchException();
if ((uint)start > (uint)array.Length)
ThrowHelper.ThrowArgumentOutOfRangeException();
this = default;
return; // returns default
}
- if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) == null && array.GetType() != typeof(T[]))
ThrowHelper.ThrowArrayTypeMismatchException();
#if BIT64
// See comment in Span<T>.Slice for how this works.
ThrowHelper.ThrowArgumentOutOfRangeException();
return default;
}
- if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) == null && array.GetType() != typeof(T[]))
ThrowHelper.ThrowArrayTypeMismatchException();
if ((uint)start > (uint)array.Length)
ThrowHelper.ThrowArgumentOutOfRangeException();
return default;
}
- if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) == null && array.GetType() != typeof(T[]))
ThrowHelper.ThrowArrayTypeMismatchException();
int actualIndex = startIndex.GetOffset(array.Length);
return default;
}
- if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) == null && array.GetType() != typeof(T[]))
ThrowHelper.ThrowArrayTypeMismatchException();
(int start, int length) = range.GetOffsetAndLength(array.Length);
// The null tests here ensure that the jit can optimize away the interface
// tests when TAwaiter is a ref type.
- if ((null != (object)default(TAwaiter)!) && (awaiter is ITaskAwaiter)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if ((null != (object?)default(TAwaiter)) && (awaiter is ITaskAwaiter))
{
ref TaskAwaiter ta = ref Unsafe.As<TAwaiter, TaskAwaiter>(ref awaiter); // relies on TaskAwaiter/TaskAwaiter<T> having the same layout
TaskAwaiter.UnsafeOnCompletedInternal(ta.m_task, box, continueOnCapturedContext: true);
}
- else if ((null != (object)default(TAwaiter)!) && (awaiter is IConfiguredTaskAwaiter)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ else if ((null != (object?)default(TAwaiter)) && (awaiter is IConfiguredTaskAwaiter))
{
ref ConfiguredTaskAwaitable.ConfiguredTaskAwaiter ta = ref Unsafe.As<TAwaiter, ConfiguredTaskAwaitable.ConfiguredTaskAwaiter>(ref awaiter);
TaskAwaiter.UnsafeOnCompletedInternal(ta.m_task, box, ta.m_continueOnCapturedContext);
}
- else if ((null != (object)default(TAwaiter)!) && (awaiter is IStateMachineBoxAwareAwaiter)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ else if ((null != (object?)default(TAwaiter)) && (awaiter is IStateMachineBoxAwareAwaiter))
{
try
{
// find a cached value, since static fields (even if readonly and integral types)
// require special access helpers in this NGEN'd and domain-neutral.
- if (null != (object)default(TResult)!) // help the JIT avoid the value type branches for ref types // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (null != (object?)default(TResult)) // help the JIT avoid the value type branches for ref types
{
// Special case simple value types:
// - Boolean
(int offset, int length) = range.GetOffsetAndLength(array.Length);
- if (default(T)! != null || typeof(T[]) == array.GetType()) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) != null || typeof(T[]) == array.GetType())
{
// We know the type of the array to be exactly T[].
ThrowHelper.ThrowArgumentOutOfRangeException();
return default;
}
- if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) == null && array.GetType() != typeof(T[]))
ThrowHelper.ThrowArrayTypeMismatchException();
if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start))
ThrowHelper.ThrowArgumentOutOfRangeException();
this = default;
return; // returns default
}
- if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) == null && array.GetType() != typeof(T[]))
ThrowHelper.ThrowArrayTypeMismatchException();
_pointer = new ByReference<T>(ref MemoryMarshal.GetArrayDataReference(array));
this = default;
return; // returns default
}
- if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) == null && array.GetType() != typeof(T[]))
ThrowHelper.ThrowArrayTypeMismatchException();
#if BIT64
// See comment in Span<T>.Slice for how this works.
IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations
- if (default(T)! != null || (object)value != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) != null || (object)value != null)
{
while (length >= 8)
{
Debug.Assert(length >= 0);
IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations
- if (default(T)! != null || (object)value != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) != null || (object)value != null)
{
while (length >= 8)
{
T lookUp;
int index = 0;
- if (default(T)! != null || ((object)value0 != null && (object)value1 != null)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) != null || ((object)value0 != null && (object)value1 != null))
{
while ((length - index) >= 8)
{
T lookUp;
int index = 0;
- if (default(T)! != null || ((object)value0 != null && (object)value1 != null && (object)value2 != null)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) != null || ((object)value0 != null && (object)value1 != null && (object)value2 != null))
{
while ((length - index) >= 8)
{
{
Debug.Assert(length >= 0);
- if (default(T)! != null || (object)value != null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) != null || (object)value != null)
{
while (length >= 8)
{
Debug.Assert(length >= 0);
T lookUp;
- if (default(T)! != null || ((object)value0 != null && (object)value1 != null)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) != null || ((object)value0 != null && (object)value1 != null))
{
while (length >= 8)
{
Debug.Assert(length >= 0);
T lookUp;
- if (default(T)! != null || ((object)value0 != null && (object)value1 != null)) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (default(T) != null || ((object)value0 != null && (object)value1 != null))
{
while (length >= 8)
{
internal static void IfNullAndNullsAreIllegalThenThrow<T>(object? value, ExceptionArgument argName)
{
// Note that default(T) is not equal to null for value types except when T is Nullable<U>.
- if (!(default(T)! == null) && value == null) // TODO-NULLABLE: default(T) == null warning (https://github.com/dotnet/roslyn/issues/34757)
+ if (!(default(T) == null) && value == null)
ThrowHelper.ThrowArgumentNullException(argName);
}