// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
namespace System
{
internal interface ISpanFormattable
{
- bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider provider);
+ bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format, IFormatProvider? provider);
}
}
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Buffers;
using System.Diagnostics;
using System.Runtime.CompilerServices;
// The highest order bit of _index is used to discern whether _object is a pre-pinned array.
// (_index < 0) => _object is a pre-pinned array, so Pin() will not allocate a new GCHandle
// (else) => Pin() needs to allocate a new GCHandle to pin the object.
- private readonly object _object;
+ private readonly object? _object;
private readonly int _index;
private readonly int _length;
/// <remarks>Returns default when <paramref name="array"/> is null.</remarks>
/// <exception cref="System.ArrayTypeMismatchException">Thrown when <paramref name="array"/> is covariant and array's type is not exactly T[].</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public Memory(T[] array)
+ public Memory(T[]? array)
{
if (array == null)
{
this = default;
return; // returns default
}
- if (default(T) == null && array.GetType() != typeof(T[]))
+ if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
ThrowHelper.ThrowArrayTypeMismatchException();
_object = array;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- internal Memory(T[] array, int start)
+ internal Memory(T[]? array, int start)
{
if (array == null)
{
this = default;
return; // returns default
}
- if (default(T) == null && array.GetType() != typeof(T[]))
+ if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
ThrowHelper.ThrowArrayTypeMismatchException();
if ((uint)start > (uint)array.Length)
ThrowHelper.ThrowArgumentOutOfRangeException();
/// Thrown when the specified <paramref name="start"/> or end index is not in the range (<0 or >=Length).
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public Memory(T[] array, int start, int length)
+ public Memory(T[]? array, int start, int length)
{
if (array == null)
{
this = default;
return; // returns default
}
- if (default(T) == null && array.GetType() != typeof(T[]))
+ if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
ThrowHelper.ThrowArrayTypeMismatchException();
#if BIT64
// See comment in Span<T>.Slice for how this works.
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- internal Memory(object obj, int start, int length)
+ internal Memory(object? obj, int start, int length)
{
// No validation performed in release builds; caller must provide any necessary validation.
/// <summary>
/// Defines an implicit conversion of an array to a <see cref="Memory{T}"/>
/// </summary>
- public static implicit operator Memory<T>(T[] array) => new Memory<T>(array);
+ public static implicit operator Memory<T>(T[]? array) => new Memory<T>(array);
/// <summary>
/// Defines an implicit conversion of a <see cref="ArraySegment{T}"/> to a <see cref="Memory{T}"/>
// Copy this field into a local so that it can't change out from under us mid-operation.
- object tmpObject = _object;
+ object? tmpObject = _object;
if (tmpObject != null)
{
if (typeof(T) == typeof(char) && tmpObject.GetType() == typeof(string))
// is torn. This is ok since the caller is expecting to use raw pointers,
// and we're not required to keep this as safe as the other Span-based APIs.
- object tmpObject = _object;
+ object? tmpObject = _object;
if (tmpObject != null)
{
if (typeof(T) == typeof(char) && tmpObject is string s)
/// Returns true if the object is Memory or ReadOnlyMemory and if both objects point to the same array and have the same length.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (obj is ReadOnlyMemory<T>)
{
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Diagnostics;
using System.Globalization;
using System.Runtime.CompilerServices;
if (GlobalizationMode.Invariant)
TextInfo.ToLowerAsciiInvariant(source, destination);
else
- culture.TextInfo.ChangeCaseToLower(source, destination);
+ culture!.TextInfo.ChangeCaseToLower(source, destination); // TODO-NULLABLE: https://github.com/dotnet/csharplang/issues/538
return source.Length;
}
if (GlobalizationMode.Invariant)
TextInfo.ToUpperAsciiInvariant(source, destination);
else
- culture.TextInfo.ChangeCaseToUpper(source, destination);
+ culture!.TextInfo.ChangeCaseToUpper(source, destination); // TODO-NULLABLE: https://github.com/dotnet/csharplang/issues/538
return source.Length;
}
/// Creates a new span over the portion of the target array.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Span<T> AsSpan<T>(this T[] array, int start)
+ public static Span<T> AsSpan<T>(this T[]? array, int start)
{
if (array == null)
{
ThrowHelper.ThrowArgumentOutOfRangeException();
return default;
}
- if (default(T) == null && array.GetType() != typeof(T[]))
+ if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
ThrowHelper.ThrowArrayTypeMismatchException();
if ((uint)start > (uint)array.Length)
ThrowHelper.ThrowArgumentOutOfRangeException();
/// Creates a new span over the portion of the target array.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Span<T> AsSpan<T>(this T[] array, Index startIndex)
+ public static Span<T> AsSpan<T>(this T[]? array, Index startIndex)
{
if (array == null)
{
return default;
}
- if (default(T) == null && array.GetType() != typeof(T[]))
+ if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
ThrowHelper.ThrowArrayTypeMismatchException();
int actualIndex = startIndex.GetOffset(array.Length);
/// Creates a new span over the portion of the target array.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Span<T> AsSpan<T>(this T[] array, Range range)
+ public static Span<T> AsSpan<T>(this T[]? array, Range range)
{
if (array == null)
{
return default;
}
- if (default(T) == null && array.GetType() != typeof(T[]))
+ if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
ThrowHelper.ThrowArrayTypeMismatchException();
(int start, int length) = range.GetOffsetAndLength(array.Length);
/// <param name="text">The target string.</param>
/// <remarks>Returns default when <paramref name="text"/> is null.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ReadOnlySpan<char> AsSpan(this string text)
+ public static ReadOnlySpan<char> AsSpan(this string? text)
{
if (text == null)
return default;
/// Thrown when the specified <paramref name="start"/> index is not in range (<0 or >text.Length).
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ReadOnlySpan<char> AsSpan(this string text, int start)
+ public static ReadOnlySpan<char> AsSpan(this string? text, int start)
{
if (text == null)
{
/// Thrown when the specified <paramref name="start"/> index or <paramref name="length"/> is not in range.
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ReadOnlySpan<char> AsSpan(this string text, int start, int length)
+ public static ReadOnlySpan<char> AsSpan(this string? text, int start, int length)
{
if (text == null)
{
/// <summary>Creates a new <see cref="ReadOnlyMemory{T}"/> over the portion of the target string.</summary>
/// <param name="text">The target string.</param>
/// <remarks>Returns default when <paramref name="text"/> is null.</remarks>
- public static ReadOnlyMemory<char> AsMemory(this string text)
+ public static ReadOnlyMemory<char> AsMemory(this string? text)
{
if (text == null)
return default;
/// <exception cref="System.ArgumentOutOfRangeException">
/// Thrown when the specified <paramref name="start"/> index is not in range (<0 or >text.Length).
/// </exception>
- public static ReadOnlyMemory<char> AsMemory(this string text, int start)
+ public static ReadOnlyMemory<char> AsMemory(this string? text, int start)
{
if (text == null)
{
/// <summary>Creates a new <see cref="ReadOnlyMemory{T}"/> over the portion of the target string.</summary>
/// <param name="text">The target string.</param>
/// <param name="startIndex">The index at which to begin this slice.</param>
- public static ReadOnlyMemory<char> AsMemory(this string text, Index startIndex)
+ public static ReadOnlyMemory<char> AsMemory(this string? text, Index startIndex)
{
if (text == null)
{
/// <exception cref="System.ArgumentOutOfRangeException">
/// Thrown when the specified <paramref name="start"/> index or <paramref name="length"/> is not in range.
/// </exception>
- public static ReadOnlyMemory<char> AsMemory(this string text, int start, int length)
+ public static ReadOnlyMemory<char> AsMemory(this string? text, int start, int length)
{
if (text == null)
{
/// <summary>Creates a new <see cref="ReadOnlyMemory{T}"/> over the portion of the target string.</summary>
/// <param name="text">The target string.</param>
/// <param name="range">The range used to indicate the start and length of the sliced string.</param>
- public static ReadOnlyMemory<char> AsMemory(this string text, Range range)
+ public static ReadOnlyMemory<char> AsMemory(this string? text, Range range)
{
if (text == null)
{
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Diagnostics;
namespace System
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
/// Creates a new span over the target array.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Span<T> AsSpan<T>(this T[] array)
+ public static Span<T> AsSpan<T>(this T[]? array)
{
return new Span<T>(array);
}
/// Thrown when the specified <paramref name="start"/> or end index is not in the range (<0 or >=Length).
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Span<T> AsSpan<T>(this T[] array, int start, int length)
+ public static Span<T> AsSpan<T>(this T[]? array, int start, int length)
{
return new Span<T>(array, start, length);
}
/// <summary>
/// Creates a new memory over the target array.
/// </summary>
- public static Memory<T> AsMemory<T>(this T[] array) => new Memory<T>(array);
+ public static Memory<T> AsMemory<T>(this T[]? array) => new Memory<T>(array);
/// <summary>
/// Creates a new memory over the portion of the target array beginning
/// <exception cref="System.ArgumentOutOfRangeException">
/// Thrown when the specified <paramref name="start"/> or end index is not in the range (<0 or >=array.Length).
/// </exception>
- public static Memory<T> AsMemory<T>(this T[] array, int start) => new Memory<T>(array, start);
+ public static Memory<T> AsMemory<T>(this T[]? array, int start) => new Memory<T>(array, start);
/// <summary>
/// Creates a new memory over the portion of the target array starting from
/// 'startIndex' to the end of the array.
/// </summary>
- public static Memory<T> AsMemory<T>(this T[] array, Index startIndex)
+ public static Memory<T> AsMemory<T>(this T[]? array, Index startIndex)
{
if (array == null)
{
/// <exception cref="System.ArgumentOutOfRangeException">
/// Thrown when the specified <paramref name="start"/> or end index is not in the range (<0 or >=Length).
/// </exception>
- public static Memory<T> AsMemory<T>(this T[] array, int start, int length) => new Memory<T>(array, start, length);
+ public static Memory<T> AsMemory<T>(this T[]? array, int start, int length) => new Memory<T>(array, start, length);
/// <summary>
/// Creates a new memory over the portion of the target array beginning at inclusive start index of the range
/// and ending at the exclusive end index of the range.
/// </summary>
- public static Memory<T> AsMemory<T>(this T[] array, Range range)
+ public static Memory<T> AsMemory<T>(this T[]? array, Range range)
{
if (array == null)
{
/// </exception>
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static void CopyTo<T>(this T[] source, Span<T> destination)
+ public static void CopyTo<T>(this T[]? source, Span<T> destination)
{
new ReadOnlySpan<T>(source).CopyTo(destination);
}
/// </exception>
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static void CopyTo<T>(this T[] source, Memory<T> destination)
+ public static void CopyTo<T>(this T[]? source, Memory<T> destination)
{
source.CopyTo(destination.Span);
}
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Buffers;
using System.Diagnostics;
using System.Runtime.CompilerServices;
// The highest order bit of _index is used to discern whether _object is a pre-pinned array.
// (_index < 0) => _object is a pre-pinned array, so Pin() will not allocate a new GCHandle
// (else) => Pin() needs to allocate a new GCHandle to pin the object.
- private readonly object _object;
+ private readonly object? _object;
private readonly int _index;
private readonly int _length;
/// <remarks>Returns default when <paramref name="array"/> is null.</remarks>
/// <exception cref="System.ArrayTypeMismatchException">Thrown when <paramref name="array"/> is covariant and array's type is not exactly T[].</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public ReadOnlyMemory(T[] array)
+ public ReadOnlyMemory(T[]? array)
{
if (array == null)
{
/// Thrown when the specified <paramref name="start"/> or end index is not in the range (<0 or >=Length).
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public ReadOnlyMemory(T[] array, int start, int length)
+ public ReadOnlyMemory(T[]? array, int start, int length)
{
if (array == null)
{
/// <param name="start">The index at which to begin the memory.</param>
/// <param name="length">The number of items in the memory.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- internal ReadOnlyMemory(object obj, int start, int length)
+ internal ReadOnlyMemory(object? obj, int start, int length)
{
// No validation performed in release builds; caller must provide any necessary validation.
/// <summary>
/// Defines an implicit conversion of an array to a <see cref="ReadOnlyMemory{T}"/>
/// </summary>
- public static implicit operator ReadOnlyMemory<T>(T[] array) => new ReadOnlyMemory<T>(array);
+ public static implicit operator ReadOnlyMemory<T>(T[]? array) => new ReadOnlyMemory<T>(array);
/// <summary>
/// Defines an implicit conversion of a <see cref="ArraySegment{T}"/> to a <see cref="ReadOnlyMemory{T}"/>
// Copy this field into a local so that it can't change out from under us mid-operation.
- object tmpObject = _object;
+ object? tmpObject = _object;
if (tmpObject != null)
{
if (typeof(T) == typeof(char) && tmpObject.GetType() == typeof(string))
// is torn. This is ok since the caller is expecting to use raw pointers,
// and we're not required to keep this as safe as the other Span-based APIs.
- object tmpObject = _object;
+ object? tmpObject = _object;
if (tmpObject != null)
{
if (typeof(T) == typeof(char) && tmpObject is string s)
/// <summary>Determines whether the specified object is equal to the current object.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (obj is ReadOnlyMemory<T> readOnlyMemory)
{
/// <param name="length">The count.</param>
/// <returns>The object.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- internal object GetObjectStartLength(out int start, out int length)
+ internal object? GetObjectStartLength(out int start, out int length)
{
start = _index;
length = _length;
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
/// <param name="array">The target array.</param>
/// <remarks>Returns default when <paramref name="array"/> is null.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public ReadOnlySpan(T[] array)
+ public ReadOnlySpan(T[]? array)
{
if (array == null)
{
/// Thrown when the specified <paramref name="start"/> or end index is not in the range (<0 or >=Length).
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public ReadOnlySpan(T[] array, int start, int length)
+ public ReadOnlySpan(T[]? array, int start, int length)
{
if (array == null)
{
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
/// </summary>
[Obsolete("Equals() on ReadOnlySpan will always throw an exception. Use == instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
throw new NotSupportedException(SR.NotSupported_CannotCallEqualsOnSpan);
}
/// <summary>
/// Defines an implicit conversion of an array to a <see cref="ReadOnlySpan{T}"/>
/// </summary>
- public static implicit operator ReadOnlySpan<T>(T[] array) => new ReadOnlySpan<T>(array);
+ public static implicit operator ReadOnlySpan<T>(T[]? array) => new ReadOnlySpan<T>(array);
/// <summary>
/// Defines an implicit conversion of a <see cref="ArraySegment{T}"/> to a <see cref="ReadOnlySpan{T}"/>
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Runtime.CompilerServices;
using Internal.Runtime.CompilerServices;
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Buffers;
using System.Runtime.CompilerServices;
using System.Collections.Generic;
/// </summary>
public static bool TryGetArray<T>(ReadOnlyMemory<T> memory, out ArraySegment<T> segment)
{
- object obj = memory.GetObjectStartLength(out int index, out int length);
+ object? obj = memory.GetObjectStartLength(out int index, out int length);
// As an optimization, we skip the "is string?" check below if typeof(T) is not char,
// as Memory<T> / ROM<T> can't possibly contain a string instance in this case.
/// <param name="memory">The memory to get the manager for.</param>
/// <param name="manager">The returned manager of the <see cref="ReadOnlyMemory{T}"/>.</param>
/// <returns>A <see cref="bool"/> indicating if it was successful.</returns>
- public static bool TryGetMemoryManager<T, TManager>(ReadOnlyMemory<T> memory, out TManager manager)
+ public static bool TryGetMemoryManager<T, TManager>(ReadOnlyMemory<T> memory, out TManager? manager) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/26761
where TManager : MemoryManager<T>
{
- TManager localManager; // Use register for null comparison rather than byref
+ TManager? localManager; // Use register for null comparison rather than byref
manager = localManager = memory.GetObjectStartLength(out _, out _) as TManager;
- return manager != null;
+ return localManager != null;
}
/// <summary>
/// <param name="start">The offset from the start of the <paramref name="manager" /> that the <paramref name="memory" /> represents.</param>
/// <param name="length">The length of the <paramref name="manager" /> that the <paramref name="memory" /> represents.</param>
/// <returns>A <see cref="bool"/> indicating if it was successful.</returns>
- public static bool TryGetMemoryManager<T, TManager>(ReadOnlyMemory<T> memory, out TManager manager, out int start, out int length)
+ public static bool TryGetMemoryManager<T, TManager>(ReadOnlyMemory<T> memory, out TManager? manager, out int start, out int length) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/26761
where TManager : MemoryManager<T>
{
- TManager localManager; // Use register for null comparison rather than byref
+ TManager? localManager; // Use register for null comparison rather than byref
manager = localManager = memory.GetObjectStartLength(out start, out length) as TManager;
Debug.Assert(length >= 0);
- if (manager == null)
+ if (localManager == null)
{
start = default;
length = default;
/// <param name="start">The starting location in <paramref name="text"/>.</param>
/// <param name="length">The number of items in <paramref name="text"/>.</param>
/// <returns></returns>
- public static bool TryGetString(ReadOnlyMemory<char> memory, out string text, out int start, out int length)
+ public static bool TryGetString(ReadOnlyMemory<char> memory, out string? text, out int start, out int length)
{
if (memory.GetObjectStartLength(out int offset, out int count) is string s)
{
/// Thrown when the specified <paramref name="start"/> or end index is not in the range (<0 or >=Length).
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static Memory<T> CreateFromPinnedArray<T>(T[] array, int start, int length)
+ public static Memory<T> CreateFromPinnedArray<T>(T[]? array, int start, int length)
{
if (array == null)
{
ThrowHelper.ThrowArgumentOutOfRangeException();
return default;
}
- if (default(T) == null && array.GetType() != typeof(T[]))
+ if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
ThrowHelper.ThrowArrayTypeMismatchException();
if ((uint)start > (uint)array.Length || (uint)length > (uint)(array.Length - start))
ThrowHelper.ThrowArgumentOutOfRangeException();
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
/// <remarks>Returns default when <paramref name="array"/> is null.</remarks>
/// <exception cref="System.ArrayTypeMismatchException">Thrown when <paramref name="array"/> is covariant and array's type is not exactly T[].</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public Span(T[] array)
+ public Span(T[]? array)
{
if (array == null)
{
this = default;
return; // returns default
}
- if (default(T) == null && array.GetType() != typeof(T[]))
+ if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
ThrowHelper.ThrowArrayTypeMismatchException();
_pointer = new ByReference<T>(ref Unsafe.As<byte, T>(ref array.GetRawSzArrayData()));
/// Thrown when the specified <paramref name="start"/> or end index is not in the range (<0 or >=Length).
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public Span(T[] array, int start, int length)
+ public Span(T[]? array, int start, int length)
{
if (array == null)
{
this = default;
return; // returns default
}
- if (default(T) == null && array.GetType() != typeof(T[]))
+ if (default(T)! == null && array.GetType() != typeof(T[])) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
ThrowHelper.ThrowArrayTypeMismatchException();
#if BIT64
// See comment in Span<T>.Slice for how this works.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
/// </summary>
[Obsolete("Equals() on Span will always throw an exception. Use == instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
throw new NotSupportedException(SR.NotSupported_CannotCallEqualsOnSpan);
}
/// <summary>
/// Defines an implicit conversion of an array to a <see cref="Span{T}"/>
/// </summary>
- public static implicit operator Span<T>(T[] array) => new Span<T>(array);
+ public static implicit operator Span<T>(T[]? array) => new Span<T>(array);
/// <summary>
/// Defines an implicit conversion of a <see cref="ArraySegment{T}"/> to a <see cref="Span{T}"/>
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Diagnostics;
namespace System
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Diagnostics;
using System.Numerics;
using System.Runtime.CompilerServices;
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Diagnostics;
using System.Numerics;
using System.Runtime.CompilerServices;
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Diagnostics;
using System.Runtime.CompilerServices; // Do not remove. This is necessary for netstandard, since this file is mirrored into corefx
IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations
- if (default(T) != null || (object)value != null)
+ if (default(T)! != null || (object)value != null) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
{
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)
+ if (default(T)! != null || (object)value != null) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
{
while (length >= 8)
{
T lookUp;
int index = 0;
- if (default(T) != null || ((object)value0 != null && (object)value1 != null))
+ if (default(T)! != null || ((object)value0 != null && (object)value1 != null)) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
{
while ((length - index) >= 8)
{
lookUp = Unsafe.Add(ref searchSpace, index);
if ((object)lookUp is null)
{
- if ((object)value0 is null || (object)value1 is null)
+ if ((object?)value0 is null || (object?)value1 is null)
{
goto Found;
}
T lookUp;
int index = 0;
- if (default(T) != null || ((object)value0 != null && (object)value1 != null && (object)value2 != null))
+ if (default(T)! != null || ((object)value0 != null && (object)value1 != null && (object)value2 != null)) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
{
while ((length - index) >= 8)
{
lookUp = Unsafe.Add(ref searchSpace, index);
if ((object)lookUp is null)
{
- if ((object)value0 is null || (object)value1 is null || (object)value2 is null)
+ if ((object?)value0 is null || (object?)value1 is null || (object?)value2 is null)
{
goto Found;
}
{
Debug.Assert(length >= 0);
- if (default(T) != null || (object)value != null)
+ if (default(T)! != null || (object)value != null) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
{
while (length >= 8)
{
Debug.Assert(length >= 0);
T lookUp;
- if (default(T) != null || ((object)value0 != null && (object)value1 != null))
+ if (default(T)! != null || ((object)value0 != null && (object)value1 != null)) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
{
while (length >= 8)
{
lookUp = Unsafe.Add(ref searchSpace, length);
if ((object)lookUp is null)
{
- if ((object)value0 is null || (object)value1 is null)
+ if ((object?)value0 is null || (object?)value1 is null)
{
goto Found;
}
Debug.Assert(length >= 0);
T lookUp;
- if (default(T) != null || ((object)value0 != null && (object)value1 != null))
+ if (default(T)! != null || ((object)value0 != null && (object)value1 != null)) // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/34757
{
while (length >= 8)
{
lookUp = Unsafe.Add(ref searchSpace, length);
if ((object)lookUp is null)
{
- if ((object)value0 is null || (object)value1 is null || (object)value2 is null)
+ if ((object?)value0 is null || (object?)value1 is null || (object?)value2 is null)
{
goto Found;
}
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#nullable enable
using System.Diagnostics;
using System.Runtime;