- **DO** add `[NotNullIfNotNull(string)]` if nullable ref argument will be non-`null` upon exit, when an other argument passed evaluated to non-`null`, pass that argument name as string. Example: `public void Exchange([NotNullIfNotNull("value")] ref object? location, object? value);`.
- **DO** add `[return: NotNullIfNotNull(string)]` if a method would not return `null` in case an argument passed evaluated to non-`null`, pass that argument name as string. Example: `[return: NotNullIfNotNull("name")] public string? FormatName(string? name);`
- **DO** add `[MemberNotNull(string fieldName)]` to a helper method which initializes member field(s), passing in the field name. Example: `[MemberNotNull("_buffer")] private void InitializeBuffer()`. This will help to avoid spurious warnings at call sites that call the initialization method and then proceed to use the specified field. Note that there are two constructors to `MemberNotNull`; one that takes a single `string`, and one that takes a `params string[]`. When the number of fields initialized is small (e.g. <= 3), it's preferable to use multiple `[MemberNotNull(string)]` attributes on the method rather than one `[MemberNotNull(string, string, string, ...)]` attribute, as the latter is not CLS compliant and will likely require `#pragma warning disable` and `#pragma warning restore` around the line to suppress warnings.
+- **AVOID** using `[MaybeNull]`, not because it's problematic, but because there's almost always a better option, such as `T?` (as of this writing, in all of the dotnet/runtime there are only 7 occurrences of `[MaybeNull]`). One example of where it's applicable is `AsyncLocal<T>.Value`; `[DisallowNull]` can't be used here, because `null` is valid if `T` is nullable, and `T?` shouldn't be used because `Value` shouldn't be set to `null` if `T` isn't nullable. Another is in the relatively rare case where a public or protected field is exposed, may begin life as null, but shouldn't be explicitly set to null.
## Code Review Guidance
<DotNetFinalVersionKind Condition="'$(StabilizePackageVersion)' == 'true'">release</DotNetFinalVersionKind>
<!-- Opt-in/out repo features -->
<UsingToolMicrosoftNetCompilers>true</UsingToolMicrosoftNetCompilers>
+ <!-- TODO: Upgrade compiler version to enable T?; remove this once the employed SDK uses a new enough version. -->
+ <MicrosoftNetCompilersToolsetVersion>3.8.0-2.20379.3</MicrosoftNetCompilersToolsetVersion>
<UsingToolIbcOptimization>true</UsingToolIbcOptimization>
<UsingToolXliff>false</UsingToolXliff>
<UsingToolNetFrameworkReferenceAssemblies>true</UsingToolNetFrameworkReferenceAssemblies>
/// If pinned is set to true, <typeparamref name="T"/> must not be a reference type or a type that contains object references.
/// </remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)] // forced to ensure no perf drop for small memory buffers (hot path)
- public static T[] AllocateUninitializedArray<T>(int length, bool pinned = false)
+ public static T[] AllocateUninitializedArray<T>(int length, bool pinned = false) // T[] rather than T?[] to match `new T[length]` behavior
{
if (!pinned)
{
/// <remarks>
/// If pinned is set to true, <typeparamref name="T"/> must not be a reference type or a type that contains object references.
/// </remarks>
- public static T[] AllocateArray<T>(int length, bool pinned = false)
+ public static T[] AllocateArray<T>(int length, bool pinned = false) // T[] rather than T?[] to match `new T[length]` behavior
{
GC_ALLOC_FLAGS flags = GC_ALLOC_FLAGS.GC_ALLOC_NO_FLAGS;
}
[SupportedOSPlatform("windows")]
- public static TWrapper CreateWrapperOfType<T, TWrapper>([AllowNull] T o)
+ public static TWrapper CreateWrapperOfType<T, TWrapper>(T? o)
{
return (TWrapper)CreateWrapperOfType(o, typeof(TWrapper))!;
}
public static extern void GetNativeVariantForObject(object? obj, /* VARIANT * */ IntPtr pDstNativeVariant);
[SupportedOSPlatform("windows")]
- public static void GetNativeVariantForObject<T>([AllowNull] T obj, IntPtr pDstNativeVariant)
+ public static void GetNativeVariantForObject<T>(T? obj, IntPtr pDstNativeVariant)
{
GetNativeVariantForObject((object?)obj, pDstNativeVariant);
}
public static extern object? GetObjectForNativeVariant(/* VARIANT * */ IntPtr pSrcNativeVariant);
[SupportedOSPlatform("windows")]
- [return: MaybeNull]
- public static T GetObjectForNativeVariant<T>(IntPtr pSrcNativeVariant)
+ public static T? GetObjectForNativeVariant<T>(IntPtr pSrcNativeVariant)
{
- return (T)GetObjectForNativeVariant(pSrcNativeVariant)!;
+ return (T?)GetObjectForNativeVariant(pSrcNativeVariant);
}
[SupportedOSPlatform("windows")]
}
}
- [return: MaybeNull]
- internal T FindItem<T>(int tag, Func<T, bool> filterMethod) where T : class
+ internal T? FindItem<T>(int tag, Func<T, bool> filterMethod) where T : class
{
bool lockObtained = false;
try
{
ThrowIfDisposed();
- return default!;
+ return Task.CompletedTask;
}
public override ValueTask DisposeAsync()
/// <summary>The exception representing the failed async operation, if it failed.</summary>
private ExceptionDispatchInfo? _error;
/// <summary>The result of the async operation, if it succeeded.</summary>
- [AllowNull] private TResult _result = default;
+ private TResult? _result;
#if DEBUG
private bool _resultSet;
#endif
}
// The operation completed successfully. Clear and return the result.
- TResult result = _result;
+ TResult result = _result!;
_result = default(TResult);
#if DEBUG
_resultSet = false;
public static T GetRequiredService<T>(this System.IServiceProvider provider) where T : notnull { throw null; }
public static System.Collections.Generic.IEnumerable<object?> GetServices(this System.IServiceProvider provider, System.Type serviceType) { throw null; }
public static System.Collections.Generic.IEnumerable<T> GetServices<T>(this System.IServiceProvider provider) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T GetService<T>(this System.IServiceProvider provider) { throw null; }
+ public static T? GetService<T>(this System.IServiceProvider provider) { throw null; }
}
}
namespace Microsoft.Extensions.DependencyInjection.Extensions
/// <typeparam name="T">The type of service object to get.</typeparam>
/// <param name="provider">The <see cref="IServiceProvider"/> to retrieve the service object from.</param>
/// <returns>A service object of type <typeparamref name="T"/> or null if there is no such service.</returns>
- [return: MaybeNull]
- public static T GetService<T>(this IServiceProvider provider)
+ public static T? GetService<T>(this IServiceProvider provider)
{
if (provider == null)
{
throw new ArgumentNullException(nameof(provider));
}
- return (T)provider.GetService(typeof(T));
+ return (T?)provider.GetService(typeof(T));
}
/// <summary>
public static decimal ToDecimal(string? Value) { throw null; }
public static double ToDouble(object? Value) { throw null; }
public static double ToDouble(string? Value) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
[return: System.Diagnostics.CodeAnalysis.NotNullIfNotNull("Value")]
- public static T ToGenericParameter<T>(object? Value) { throw null; }
+ public static T? ToGenericParameter<T>(object? Value) { throw null; }
public static int ToInteger(object? Value) { throw null; }
public static int ToInteger(string? Value) { throw null; }
public static long ToLong(object? Value) { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
public T Take() { throw null; }
public T Take(System.Threading.CancellationToken cancellationToken) { throw null; }
- public static int TakeFromAny(System.Collections.Concurrent.BlockingCollection<T>[] collections, [System.Diagnostics.CodeAnalysis.MaybeNullAttribute] out T item) { throw null; }
- public static int TakeFromAny(System.Collections.Concurrent.BlockingCollection<T>[] collections, [System.Diagnostics.CodeAnalysis.MaybeNullAttribute] out T item, System.Threading.CancellationToken cancellationToken) { throw null; }
+ public static int TakeFromAny(System.Collections.Concurrent.BlockingCollection<T>[] collections, out T? item) { throw null; }
+ public static int TakeFromAny(System.Collections.Concurrent.BlockingCollection<T>[] collections, out T? item, System.Threading.CancellationToken cancellationToken) { throw null; }
public T[] ToArray() { throw null; }
public bool TryAdd(T item) { throw null; }
public bool TryAdd(T item, int millisecondsTimeout) { throw null; }
public bool TryTake([System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out T item, int millisecondsTimeout) { throw null; }
public bool TryTake([System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out T item, int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; }
public bool TryTake([System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out T item, System.TimeSpan timeout) { throw null; }
- public static int TryTakeFromAny(System.Collections.Concurrent.BlockingCollection<T>[] collections, [System.Diagnostics.CodeAnalysis.MaybeNullAttribute] out T item) { throw null; }
- public static int TryTakeFromAny(System.Collections.Concurrent.BlockingCollection<T>[] collections, [System.Diagnostics.CodeAnalysis.MaybeNullAttribute] out T item, int millisecondsTimeout) { throw null; }
- public static int TryTakeFromAny(System.Collections.Concurrent.BlockingCollection<T>[] collections, [System.Diagnostics.CodeAnalysis.MaybeNullAttribute] out T item, int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; }
- public static int TryTakeFromAny(System.Collections.Concurrent.BlockingCollection<T>[] collections, [System.Diagnostics.CodeAnalysis.MaybeNullAttribute] out T item, System.TimeSpan timeout) { throw null; }
+ public static int TryTakeFromAny(System.Collections.Concurrent.BlockingCollection<T>[] collections, out T? item) { throw null; }
+ public static int TryTakeFromAny(System.Collections.Concurrent.BlockingCollection<T>[] collections, out T? item, int millisecondsTimeout) { throw null; }
+ public static int TryTakeFromAny(System.Collections.Concurrent.BlockingCollection<T>[] collections, out T? item, int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) { throw null; }
+ public static int TryTakeFromAny(System.Collections.Concurrent.BlockingCollection<T>[] collections, out T? item, System.TimeSpan timeout) { throw null; }
}
public partial class ConcurrentBag<T> : System.Collections.Concurrent.IProducerConsumerCollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.ICollection, System.Collections.IEnumerable
{
/// <exception cref="System.ArgumentOutOfRangeException">The count of <paramref name="collections"/> is greater than the maximum size of
/// 62 for STA and 63 for MTA.</exception>
/// <remarks>A call to TakeFromAny may block until an item is available to be removed.</remarks>
- public static int TakeFromAny(BlockingCollection<T>[] collections, [MaybeNull] out T item)
+ public static int TakeFromAny(BlockingCollection<T>[] collections, out T? item)
{
return TakeFromAny(collections, out item, CancellationToken.None);
}
/// <exception cref="System.ArgumentOutOfRangeException">The count of <paramref name="collections"/> is greater than the maximum size of
/// 62 for STA and 63 for MTA.</exception>
/// <remarks>A call to TakeFromAny may block until an item is available to be removed.</remarks>
- public static int TakeFromAny(BlockingCollection<T>[] collections, [MaybeNull] out T item, CancellationToken cancellationToken)
+ public static int TakeFromAny(BlockingCollection<T>[] collections, out T? item, CancellationToken cancellationToken)
{
int returnValue = TryTakeFromAnyCore(collections, out item, Timeout.Infinite, true, cancellationToken);
Debug.Assert(returnValue >= 0 && returnValue < collections.Length,
/// <exception cref="System.ArgumentOutOfRangeException">The count of <paramref name="collections"/> is greater than the maximum size of
/// 62 for STA and 63 for MTA.</exception>
/// <remarks>A call to TryTakeFromAny may block until an item is available to be removed.</remarks>
- public static int TryTakeFromAny(BlockingCollection<T>[] collections, [MaybeNull] out T item)
+ public static int TryTakeFromAny(BlockingCollection<T>[] collections, out T? item)
{
return TryTakeFromAny(collections, out item, 0);
}
/// <exception cref="System.ArgumentOutOfRangeException">The count of <paramref name="collections"/> is greater than the maximum size of
/// 62 for STA and 63 for MTA.</exception>
/// <remarks>A call to TryTakeFromAny may block until an item is available to be removed.</remarks>
- public static int TryTakeFromAny(BlockingCollection<T>[] collections, [MaybeNull] out T item, TimeSpan timeout)
+ public static int TryTakeFromAny(BlockingCollection<T>[] collections, out T? item, TimeSpan timeout)
{
ValidateTimeout(timeout);
return TryTakeFromAnyCore(collections, out item, (int)timeout.TotalMilliseconds, false, CancellationToken.None);
/// <exception cref="System.ArgumentOutOfRangeException">The count of <paramref name="collections"/> is greater than the maximum size of
/// 62 for STA and 63 for MTA.</exception>
/// <remarks>A call to TryTakeFromAny may block until an item is available to be removed.</remarks>
- public static int TryTakeFromAny(BlockingCollection<T>[] collections, [MaybeNull] out T item, int millisecondsTimeout)
+ public static int TryTakeFromAny(BlockingCollection<T>[] collections, out T? item, int millisecondsTimeout)
{
ValidateMillisecondsTimeout(millisecondsTimeout);
return TryTakeFromAnyCore(collections, out item, millisecondsTimeout, false, CancellationToken.None);
/// <exception cref="System.ArgumentOutOfRangeException">The count of <paramref name="collections"/> is greater than the maximum size of
/// 62 for STA and 63 for MTA.</exception>
/// <remarks>A call to TryTakeFromAny may block until an item is available to be removed.</remarks>
- public static int TryTakeFromAny(BlockingCollection<T>[] collections, [MaybeNull] out T item, int millisecondsTimeout, CancellationToken cancellationToken)
+ public static int TryTakeFromAny(BlockingCollection<T>[] collections, out T? item, int millisecondsTimeout, CancellationToken cancellationToken)
{
ValidateMillisecondsTimeout(millisecondsTimeout);
return TryTakeFromAnyCore(collections, out item, millisecondsTimeout, false, cancellationToken);
/// <exception cref="System.ArgumentException">If the collections argument is a 0-length array or contains a
/// null element. Also, if at least one of the collections has been marked complete for adds.</exception>
/// <exception cref="System.ObjectDisposedException">If at least one of the collections has been disposed.</exception>
- private static int TryTakeFromAnyCore(BlockingCollection<T>[] collections, [MaybeNull] out T item, int millisecondsTimeout, bool isTakeOperation, CancellationToken externalCancellationToken)
+ private static int TryTakeFromAnyCore(BlockingCollection<T>[] collections, out T? item, int millisecondsTimeout, bool isTakeOperation, CancellationToken externalCancellationToken)
{
ValidateCollectionsArray(collections, false);
/// <exception cref="System.ArgumentException">If the collections argument is a 0-length array or contains a
/// null element. Also, if at least one of the collections has been marked complete for adds.</exception>
/// <exception cref="System.ObjectDisposedException">If at least one of the collections has been disposed.</exception>
- private static int TryTakeFromAnyCoreSlow(BlockingCollection<T>[] collections, [MaybeNull] out T item, int millisecondsTimeout, bool isTakeOperation, CancellationToken externalCancellationToken)
+ private static int TryTakeFromAnyCoreSlow(BlockingCollection<T>[] collections, out T? item, int millisecondsTimeout, bool isTakeOperation, CancellationToken externalCancellationToken)
{
const int OPERATION_FAILED = -1;
private sealed class Enumerator : IEnumerator<T>
{
private readonly T[] _array;
- [AllowNull] private T _current = default;
+ private T? _current;
private int _index;
public Enumerator(T[] array)
return false;
}
- public T Current => _current;
+ public T Current => _current!;
object? IEnumerator.Current
{
/// <param name="value">The variable into which the removed value, if found, is stored.</param>
/// <param name="matchValue">Whether removal of the key is conditional on its value.</param>
/// <param name="oldValue">The conditional value to compare against if <paramref name="matchValue"/> is true</param>
- private bool TryRemoveInternal(TKey key, [MaybeNullWhen(false)] out TValue value, bool matchValue, [AllowNull] TValue oldValue)
+ private bool TryRemoveInternal(TKey key, [MaybeNullWhen(false)] out TValue value, bool matchValue, TValue? oldValue)
{
IEqualityComparer<TKey>? comparer = _comparer;
int hashcode = comparer is null ? key.GetHashCode() : comparer.GetHashCode(key);
bool valuesMatch = EqualityComparer<TValue>.Default.Equals(oldValue, curr._value);
if (!valuesMatch)
{
- value = default!;
+ value = default;
return false;
}
}
public static System.Collections.Immutable.ImmutableDictionary<TKey, TValue> Create<TKey, TValue>() where TKey : notnull { throw null; }
public static System.Collections.Immutable.ImmutableDictionary<TKey, TValue> Create<TKey, TValue>(System.Collections.Generic.IEqualityComparer<TKey>? keyComparer) where TKey : notnull { throw null; }
public static System.Collections.Immutable.ImmutableDictionary<TKey, TValue> Create<TKey, TValue>(System.Collections.Generic.IEqualityComparer<TKey>? keyComparer, System.Collections.Generic.IEqualityComparer<TValue>? valueComparer) where TKey : notnull { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TValue GetValueOrDefault<TKey, TValue>(this System.Collections.Immutable.IImmutableDictionary<TKey, TValue> dictionary, TKey key) where TKey : notnull { throw null; }
+ public static TValue? GetValueOrDefault<TKey, TValue>(this System.Collections.Immutable.IImmutableDictionary<TKey, TValue> dictionary, TKey key) where TKey : notnull { throw null; }
public static TValue GetValueOrDefault<TKey, TValue>(this System.Collections.Immutable.IImmutableDictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue) where TKey : notnull { throw null; }
public static System.Collections.Immutable.ImmutableDictionary<TKey, TValue> ToImmutableDictionary<TKey, TValue>(this System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TValue>> source) where TKey : notnull { throw null; }
public static System.Collections.Immutable.ImmutableDictionary<TKey, TValue> ToImmutableDictionary<TKey, TValue>(this System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TValue>> source, System.Collections.Generic.IEqualityComparer<TKey>? keyComparer) where TKey : notnull { throw null; }
public bool ContainsKey(TKey key) { throw null; }
public bool ContainsValue(TValue value) { throw null; }
public System.Collections.Immutable.ImmutableDictionary<TKey, TValue>.Enumerator GetEnumerator() { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public TValue GetValueOrDefault(TKey key) { throw null; }
+ public TValue? GetValueOrDefault(TKey key) { throw null; }
public TValue GetValueOrDefault(TKey key, TValue defaultValue) { throw null; }
public bool Remove(System.Collections.Generic.KeyValuePair<TKey, TValue> item) { throw null; }
public bool Remove(TKey key) { throw null; }
public void CopyTo(T[] array) { }
public void CopyTo(T[] array, int arrayIndex) { }
public bool Exists(System.Predicate<T> match) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public T Find(System.Predicate<T> match) { throw null; }
+ public T? Find(System.Predicate<T> match) { throw null; }
public System.Collections.Immutable.ImmutableList<T> FindAll(System.Predicate<T> match) { throw null; }
public int FindIndex(int startIndex, int count, System.Predicate<T> match) { throw null; }
public int FindIndex(int startIndex, System.Predicate<T> match) { throw null; }
public int FindIndex(System.Predicate<T> match) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public T FindLast(System.Predicate<T> match) { throw null; }
+ public T? FindLast(System.Predicate<T> match) { throw null; }
public int FindLastIndex(int startIndex, int count, System.Predicate<T> match) { throw null; }
public int FindLastIndex(int startIndex, System.Predicate<T> match) { throw null; }
public int FindLastIndex(System.Predicate<T> match) { throw null; }
public void CopyTo(T[] array) { }
public void CopyTo(T[] array, int arrayIndex) { }
public bool Exists(System.Predicate<T> match) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public T Find(System.Predicate<T> match) { throw null; }
+ public T? Find(System.Predicate<T> match) { throw null; }
public System.Collections.Immutable.ImmutableList<T> FindAll(System.Predicate<T> match) { throw null; }
public int FindIndex(int startIndex, int count, System.Predicate<T> match) { throw null; }
public int FindIndex(int startIndex, System.Predicate<T> match) { throw null; }
public int FindIndex(System.Predicate<T> match) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public T FindLast(System.Predicate<T> match) { throw null; }
+ public T? FindLast(System.Predicate<T> match) { throw null; }
public int FindLastIndex(int startIndex, int count, System.Predicate<T> match) { throw null; }
public int FindLastIndex(int startIndex, System.Predicate<T> match) { throw null; }
public int FindLastIndex(System.Predicate<T> match) { throw null; }
public bool ContainsKey(TKey key) { throw null; }
public bool ContainsValue(TValue value) { throw null; }
public System.Collections.Immutable.ImmutableSortedDictionary<TKey, TValue>.Enumerator GetEnumerator() { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public TValue GetValueOrDefault(TKey key) { throw null; }
+ public TValue? GetValueOrDefault(TKey key) { throw null; }
public TValue GetValueOrDefault(TKey key, TValue defaultValue) { throw null; }
public bool Remove(System.Collections.Generic.KeyValuePair<TKey, TValue> item) { throw null; }
public bool Remove(TKey key) { throw null; }
public bool IsEmpty { get { throw null; } }
public T this[int index] { get { throw null; } }
public System.Collections.Generic.IComparer<T> KeyComparer { get { throw null; } }
- [System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public T Max { get { throw null; } }
- [System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public T Min { get { throw null; } }
+ public T? Max { get { throw null; } }
+ public T? Min { get { throw null; } }
bool System.Collections.Generic.ICollection<T>.IsReadOnly { get { throw null; } }
T System.Collections.Generic.IList<T>.this[int index] { get { throw null; } set { } }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
public int Count { get { throw null; } }
public T this[int index] { get { throw null; } }
public System.Collections.Generic.IComparer<T> KeyComparer { get { throw null; } set { } }
- [System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public T Max { get { throw null; } }
- [System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public T Min { get { throw null; } }
+ public T? Max { get { throw null; } }
+ public T? Min { get { throw null; } }
bool System.Collections.Generic.ICollection<T>.IsReadOnly { get { throw null; } }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
{
public static partial class ImmutableArrayExtensions
{
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T Aggregate<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, System.Func<T, T, T> func) { throw null; }
+ public static T? Aggregate<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, System.Func<T, T, T> func) { throw null; }
public static TAccumulate Aggregate<TAccumulate, T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, TAccumulate seed, System.Func<TAccumulate, T, TAccumulate> func) { throw null; }
public static TResult Aggregate<TAccumulate, TResult, T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, TAccumulate seed, System.Func<TAccumulate, T, TAccumulate> func, System.Func<TAccumulate, TResult> resultSelector) { throw null; }
public static bool All<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, System.Func<T, bool> predicate) { throw null; }
public static bool Any<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray) { throw null; }
public static bool Any<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, System.Func<T, bool> predicate) { throw null; }
public static bool Any<T>(this System.Collections.Immutable.ImmutableArray<T>.Builder builder) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T ElementAtOrDefault<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, int index) { throw null; }
+ public static T? ElementAtOrDefault<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, int index) { throw null; }
public static T ElementAt<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, int index) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T FirstOrDefault<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T FirstOrDefault<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, System.Func<T, bool> predicate) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T FirstOrDefault<T>(this System.Collections.Immutable.ImmutableArray<T>.Builder builder) { throw null; }
+ public static T? FirstOrDefault<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray) { throw null; }
+ public static T? FirstOrDefault<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, System.Func<T, bool> predicate) { throw null; }
+ public static T? FirstOrDefault<T>(this System.Collections.Immutable.ImmutableArray<T>.Builder builder) { throw null; }
public static T First<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray) { throw null; }
public static T First<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, System.Func<T, bool> predicate) { throw null; }
public static T First<T>(this System.Collections.Immutable.ImmutableArray<T>.Builder builder) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T LastOrDefault<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T LastOrDefault<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, System.Func<T, bool> predicate) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T LastOrDefault<T>(this System.Collections.Immutable.ImmutableArray<T>.Builder builder) { throw null; }
+ public static T? LastOrDefault<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray) { throw null; }
+ public static T? LastOrDefault<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, System.Func<T, bool> predicate) { throw null; }
+ public static T? LastOrDefault<T>(this System.Collections.Immutable.ImmutableArray<T>.Builder builder) { throw null; }
public static T Last<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray) { throw null; }
public static T Last<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, System.Func<T, bool> predicate) { throw null; }
public static T Last<T>(this System.Collections.Immutable.ImmutableArray<T>.Builder builder) { throw null; }
public static bool SequenceEqual<TDerived, TBase>(this System.Collections.Immutable.ImmutableArray<TBase> immutableArray, System.Collections.Generic.IEnumerable<TDerived> items, System.Collections.Generic.IEqualityComparer<TBase>? comparer = null) where TDerived : TBase { throw null; }
public static bool SequenceEqual<TDerived, TBase>(this System.Collections.Immutable.ImmutableArray<TBase> immutableArray, System.Collections.Immutable.ImmutableArray<TDerived> items, System.Collections.Generic.IEqualityComparer<TBase>? comparer = null) where TDerived : TBase { throw null; }
public static bool SequenceEqual<TDerived, TBase>(this System.Collections.Immutable.ImmutableArray<TBase> immutableArray, System.Collections.Immutable.ImmutableArray<TDerived> items, System.Func<TBase, TBase, bool> predicate) where TDerived : TBase { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T SingleOrDefault<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T SingleOrDefault<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, System.Func<T, bool> predicate) { throw null; }
+ public static T? SingleOrDefault<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray) { throw null; }
+ public static T? SingleOrDefault<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, System.Func<T, bool> predicate) { throw null; }
public static T Single<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray) { throw null; }
public static T Single<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray, System.Func<T, bool> predicate) { throw null; }
public static T[] ToArray<T>(this System.Collections.Immutable.ImmutableArray<T> immutableArray) { throw null; }
return true;
}
- item = default(T)!;
+ item = default;
return false;
}
/// The first element that matches the conditions defined by the specified predicate,
/// if found; otherwise, the default value for type <typeparamref name="T"/>.
/// </returns>
- [return: MaybeNull]
- T Find(Predicate<T> match);
+ T? Find(Predicate<T> match);
/// <summary>
/// Retrieves all the elements that match the conditions defined by the specified
/// The last element that matches the conditions defined by the specified predicate,
/// if found; otherwise, the default value for type <typeparamref name="T"/>.
/// </returns>
- [return: MaybeNull]
- T FindLast(Predicate<T> match);
+ T? FindLast(Predicate<T> match);
/// <summary>
/// Searches for an element that matches the conditions defined by the specified
/// <param name="dictionary">The dictionary to retrieve the value from.</param>
/// <param name="key">The key to search for.</param>
/// <returns>The value for the key, or the default value of type <typeparamref name="TValue"/> if no matching key was found.</returns>
- [return: MaybeNull]
- public static TValue GetValueOrDefault<TKey, TValue>(this IImmutableDictionary<TKey, TValue> dictionary, TKey key) where TKey : notnull
+ public static TValue? GetValueOrDefault<TKey, TValue>(this IImmutableDictionary<TKey, TValue> dictionary, TKey key) where TKey : notnull
{
return GetValueOrDefault(dictionary, key, default(TValue)!);
}
/// </summary>
/// <param name="key">The key to search for.</param>
/// <returns>The value for the key, or the default value of type <typeparamref name="TValue"/> if no matching key was found.</returns>
- [return: MaybeNull]
- public TValue GetValueOrDefault(TKey key)
+ public TValue? GetValueOrDefault(TKey key)
{
return this.GetValueOrDefault(key, default(TValue)!);
}
{
if (this.IsEmpty)
{
- value = default(TValue)!;
+ value = default;
return false;
}
var index = _additionalElements.IndexOf(kv, comparers.KeyOnlyComparer);
if (index < 0)
{
- value = default(TValue)!;
+ value = default;
return false;
}
return bucket.TryGetValue(key, origin.Comparers, out value!);
}
- value = default(TValue)!;
+ value = default;
return false;
}
if (priorCollection.IsEmpty)
{
- value = default(T)!;
+ value = default;
return false;
}
if (priorCollection.IsEmpty)
{
- value = default(T)!;
+ value = default;
return false;
}
/// The first element that matches the conditions defined by the specified predicate,
/// if found; otherwise, the default value for type T.
/// </returns>
- [return: MaybeNull]
- public T Find(Predicate<T> match) => _root.Find(match);
+ public T? Find(Predicate<T> match) => _root.Find(match);
/// <summary>
/// Retrieves all the elements that match the conditions defined by the specified
/// The last element that matches the conditions defined by the specified predicate,
/// if found; otherwise, the default value for type T.
/// </returns>
- [return: MaybeNull]
- public T FindLast(Predicate<T> match) => _root.FindLast(match);
+ public T? FindLast(Predicate<T> match) => _root.FindLast(match);
/// <summary>
/// Searches for an element that matches the conditions defined by the specified
/// The first element that matches the conditions defined by the specified predicate,
/// if found; otherwise, the default value for type <typeparamref name="T"/>.
/// </returns>
- [return: MaybeNull]
- internal T Find(Predicate<T> match)
+ internal T? Find(Predicate<T> match)
{
Requires.NotNull(match, nameof(match));
}
}
- return default(T)!;
+ return default;
}
/// <summary>
/// The last element that matches the conditions defined by the specified predicate,
/// if found; otherwise, the default value for type <typeparamref name="T"/>.
/// </returns>
- [return: MaybeNull]
- internal T FindLast(Predicate<T> match)
+ internal T? FindLast(Predicate<T> match)
{
Requires.NotNull(match, nameof(match));
}
}
- return default(T)!;
+ return default;
}
/// <summary>
/// The first element that matches the conditions defined by the specified predicate,
/// if found; otherwise, the default value for type <typeparamref name="T"/>.
/// </returns>
- [return: MaybeNull]
- public T Find(Predicate<T> match) => _root.Find(match);
+ public T? Find(Predicate<T> match) => _root.Find(match);
/// <summary>
/// Retrieves all the elements that match the conditions defined by the specified
/// The last element that matches the conditions defined by the specified predicate,
/// if found; otherwise, the default value for type <typeparamref name="T"/>.
/// </returns>
- [return: MaybeNull]
- public T FindLast(Predicate<T> match) => _root.FindLast(match);
+ public T? FindLast(Predicate<T> match) => _root.FindLast(match);
/// <summary>
/// Searches for an element that matches the conditions defined by the specified
/// </summary>
/// <param name="key">The key to search for.</param>
/// <returns>The value for the key, or the default value for type <typeparamref name="TValue"/> if no matching key was found.</returns>
- [return: MaybeNull]
- public TValue GetValueOrDefault(TKey key)
+ public TValue? GetValueOrDefault(TKey key)
{
return this.GetValueOrDefault(key, default(TValue)!);
}
var match = this.Search(key, keyComparer);
if (match.IsEmpty)
{
- value = default(TValue)!;
+ value = default;
return false;
}
else
/// Gets the maximum value in the collection, as defined by the comparer.
/// </summary>
/// <value>The maximum value in the set.</value>
- [MaybeNull]
- public T Max
+ public T? Max
{
get { return _root.Max; }
}
/// Gets the minimum value in the collection, as defined by the comparer.
/// </summary>
/// <value>The minimum value in the set.</value>
- [MaybeNull]
- public T Min
+ public T? Min
{
get { return _root.Min; }
}
/// Gets the maximum value in the collection, as defined by the comparer.
/// </summary>
/// <value>The maximum value in the set.</value>
- [MaybeNull]
- internal T Max
+ internal T? Max
{
get
{
if (this.IsEmpty)
{
- return default(T)!;
+ return default;
}
Node n = this;
/// Gets the minimum value in the collection, as defined by the comparer.
/// </summary>
/// <value>The minimum value in the set.</value>
- [MaybeNull]
- internal T Min
+ internal T? Min
{
get
{
if (this.IsEmpty)
{
- return default(T)!;
+ return default;
}
Node n = this;
/// Gets the maximum value in the collection, as defined by the comparer.
/// </summary>
/// <value>The maximum value in the set.</value>
- [MaybeNull]
- public T Max
+ public T? Max
{
get { return _root.Max; }
}
/// Gets the minimum value in the collection, as defined by the comparer.
/// </summary>
/// <value>The minimum value in the set.</value>
- [MaybeNull]
- public T Min
+ public T? Min
{
get { return _root.Min; }
}
/// <summary>
/// The element on the top of the stack.
/// </summary>
- [MaybeNull]
- private readonly T _head = default!;
+ private readonly T? _head;
/// <summary>
/// A stack that contains the rest of the elements (under the top element).
}
else
{
- value = default(T)!;
+ value = default;
return false;
}
}
/// <summary>
/// The value associated with this node.
/// </summary>
- [MaybeNull]
- private readonly TValue _value = default!;
+ private readonly TValue? _value;
/// <summary>
/// A value indicating whether this node has been frozen (made immutable).
/// </summary>
/// <param name="key">The key.</param>
/// <returns>The value.</returns>
- [return: MaybeNull]
- internal TValue GetValueOrDefault(int key)
+ internal TValue? GetValueOrDefault(int key)
{
SortedInt32KeyNode<TValue> node = this;
while (true)
{
if (node.IsEmpty)
{
- return default(TValue)!;
+ return default;
}
if (key == node._key)
{
if (node.IsEmpty)
{
- value = default(TValue)!;
+ value = default;
return false;
}
/// Applies an accumulator function over a sequence.
/// </summary>
/// <typeparam name="T">The type of element contained by the collection.</typeparam>
- [return: MaybeNull]
- public static T Aggregate<T>(this ImmutableArray<T> immutableArray, Func<T, T, T> func)
+ public static T? Aggregate<T>(this ImmutableArray<T> immutableArray, Func<T, T, T> func)
{
Requires.NotNull(func, nameof(func));
if (immutableArray.Length == 0)
{
- return default(T)!;
+ return default;
}
var result = immutableArray[0];
/// Returns the element at a specified index in a sequence or a default value if the index is out of range.
/// </summary>
/// <typeparam name="T">The type of element contained by the collection.</typeparam>
- [return: MaybeNull]
- public static T ElementAtOrDefault<T>(this ImmutableArray<T> immutableArray, int index)
+ public static T? ElementAtOrDefault<T>(this ImmutableArray<T> immutableArray, int index)
{
if (index < 0 || index >= immutableArray.Length)
{
- return default(T)!;
+ return default;
}
return immutableArray[index];
/// </summary>
/// <typeparam name="T">The type of element contained by the collection.</typeparam>
/// <param name="immutableArray"></param>
- [return: MaybeNull]
- public static T FirstOrDefault<T>(this ImmutableArray<T> immutableArray)
+ public static T? FirstOrDefault<T>(this ImmutableArray<T> immutableArray)
{
- return immutableArray.array!.Length > 0 ? immutableArray.array[0] : default(T)!;
+ return immutableArray.array!.Length > 0 ? immutableArray.array[0] : default;
}
/// <summary>
/// Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.
/// </summary>
/// <typeparam name="T">The type of element contained by the collection.</typeparam>
- [return: MaybeNull]
- public static T FirstOrDefault<T>(this ImmutableArray<T> immutableArray, Func<T, bool> predicate)
+ public static T? FirstOrDefault<T>(this ImmutableArray<T> immutableArray, Func<T, bool> predicate)
{
Requires.NotNull(predicate, nameof(predicate));
}
}
- return default(T)!;
+ return default;
}
/// <summary>
/// </summary>
/// <typeparam name="T">The type of element contained by the collection.</typeparam>
/// <param name="immutableArray"></param>
- [return: MaybeNull]
- public static T LastOrDefault<T>(this ImmutableArray<T> immutableArray)
+ public static T? LastOrDefault<T>(this ImmutableArray<T> immutableArray)
{
immutableArray.ThrowNullRefIfNotInitialized();
return immutableArray.array!.LastOrDefault()!;
/// Returns the last element of a sequence that satisfies a condition or a default value if no such element is found.
/// </summary>
/// <typeparam name="T">The type of element contained by the collection.</typeparam>
- [return: MaybeNull]
- public static T LastOrDefault<T>(this ImmutableArray<T> immutableArray, Func<T, bool> predicate)
+ public static T? LastOrDefault<T>(this ImmutableArray<T> immutableArray, Func<T, bool> predicate)
{
Requires.NotNull(predicate, nameof(predicate));
}
}
- return default(T)!;
+ return default;
}
/// <summary>
{
Requires.NotNull(predicate, nameof(predicate));
- var first = true;
- var result = default(T)!;
+ bool first = true;
+ T? result = default;
foreach (var v in immutableArray.array!)
{
if (predicate(v))
Enumerable.Empty<T>().Single(); // throw the same exception as LINQ would
}
- return result;
+ return result!;
}
/// <summary>
/// </summary>
/// <typeparam name="T">The type of element contained by the collection.</typeparam>
/// <param name="immutableArray"></param>
- [return: MaybeNull]
- public static T SingleOrDefault<T>(this ImmutableArray<T> immutableArray)
+ public static T? SingleOrDefault<T>(this ImmutableArray<T> immutableArray)
{
immutableArray.ThrowNullRefIfNotInitialized();
return immutableArray.array!.SingleOrDefault()!;
/// Returns the only element of a sequence that satisfies a specified condition or a default value if no such element exists; this method throws an exception if more than one element satisfies the condition.
/// </summary>
/// <typeparam name="T">The type of element contained by the collection.</typeparam>
- [return: MaybeNull]
- public static T SingleOrDefault<T>(this ImmutableArray<T> immutableArray, Func<T, bool> predicate)
+ public static T? SingleOrDefault<T>(this ImmutableArray<T> immutableArray, Func<T, bool> predicate)
{
Requires.NotNull(predicate, nameof(predicate));
- var first = true;
- var result = default(T)!;
+ bool first = true;
+ T? result = default;
foreach (var v in immutableArray.array!)
{
if (predicate(v))
/// <summary>
/// Returns the first element in the collection, or the default value if the collection is empty.
/// </summary>
- [return: MaybeNull]
- public static T FirstOrDefault<T>(this ImmutableArray<T>.Builder builder)
+ public static T? FirstOrDefault<T>(this ImmutableArray<T>.Builder builder)
{
Requires.NotNull(builder, nameof(builder));
- return builder.Any() ? builder[0] : default(T)!;
+ return builder.Any() ? builder[0] : default;
}
/// <summary>
/// <summary>
/// Returns the last element in the collection, or the default value if the collection is empty.
/// </summary>
- [return: MaybeNull]
- public static T LastOrDefault<T>(this ImmutableArray<T>.Builder builder)
+ public static T? LastOrDefault<T>(this ImmutableArray<T>.Builder builder)
{
Requires.NotNull(builder, nameof(builder));
- return builder.Any() ? builder[builder.Count - 1] : default(T)!;
+ return builder.Any() ? builder[builder.Count - 1] : default;
}
/// <summary>
{
public static partial class CollectionExtensions
{
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TValue GetValueOrDefault<TKey, TValue>(this System.Collections.Generic.IReadOnlyDictionary<TKey, TValue> dictionary, TKey key) { throw null; }
+ public static TValue? GetValueOrDefault<TKey, TValue>(this System.Collections.Generic.IReadOnlyDictionary<TKey, TValue> dictionary, TKey key) { throw null; }
public static TValue GetValueOrDefault<TKey, TValue>(this System.Collections.Generic.IReadOnlyDictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue) { throw null; }
public static bool Remove<TKey, TValue>(this System.Collections.Generic.IDictionary<TKey, TValue> dictionary, TKey key, [System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute(false)] out TValue value) { throw null; }
public static bool TryAdd<TKey, TValue>(this System.Collections.Generic.IDictionary<TKey, TValue> dictionary, TKey key, TValue value) { throw null; }
{
protected Comparer() { }
public static System.Collections.Generic.Comparer<T> Default { get { throw null; } }
- public abstract int Compare([System.Diagnostics.CodeAnalysis.AllowNullAttribute] T x, [System.Diagnostics.CodeAnalysis.AllowNullAttribute] T y);
+ public abstract int Compare(T? x, T? y);
public static System.Collections.Generic.Comparer<T> Create(System.Comparison<T> comparison) { throw null; }
int System.Collections.IComparer.Compare(object? x, object? y) { throw null; }
}
{
protected EqualityComparer() { }
public static System.Collections.Generic.EqualityComparer<T> Default { get { throw null; } }
- public abstract bool Equals([System.Diagnostics.CodeAnalysis.AllowNullAttribute] T x, [System.Diagnostics.CodeAnalysis.AllowNullAttribute] T y);
+ public abstract bool Equals(T? x, T? y);
public abstract int GetHashCode([System.Diagnostics.CodeAnalysis.DisallowNullAttribute] T obj);
bool System.Collections.IEqualityComparer.Equals(object? x, object? y) { throw null; }
int System.Collections.IEqualityComparer.GetHashCode(object obj) { throw null; }
public void CopyTo(T[] array) { }
public void CopyTo(T[] array, int arrayIndex) { }
public bool Exists(System.Predicate<T> match) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public T Find(System.Predicate<T> match) { throw null; }
+ public T? Find(System.Predicate<T> match) { throw null; }
public System.Collections.Generic.List<T> FindAll(System.Predicate<T> match) { throw null; }
public int FindIndex(int startIndex, int count, System.Predicate<T> match) { throw null; }
public int FindIndex(int startIndex, System.Predicate<T> match) { throw null; }
public int FindIndex(System.Predicate<T> match) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public T FindLast(System.Predicate<T> match) { throw null; }
+ public T? FindLast(System.Predicate<T> match) { throw null; }
public int FindLastIndex(int startIndex, int count, System.Predicate<T> match) { throw null; }
public int FindLastIndex(int startIndex, System.Predicate<T> match) { throw null; }
public int FindLastIndex(System.Predicate<T> match) { throw null; }
protected SortedSet(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
public System.Collections.Generic.IComparer<T> Comparer { get { throw null; } }
public int Count { get { throw null; } }
- [System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public T Max { get { throw null; } }
- [System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public T Min { get { throw null; } }
+ public T? Max { get { throw null; } }
+ public T? Min { get { throw null; } }
bool System.Collections.Generic.ICollection<T>.IsReadOnly { get { throw null; } }
bool System.Collections.ICollection.IsSynchronized { get { throw null; } }
object System.Collections.ICollection.SyncRoot { get { throw null; } }
public void ExceptWith(System.Collections.Generic.IEnumerable<T> other) { }
public System.Collections.Generic.SortedSet<T>.Enumerator GetEnumerator() { throw null; }
protected virtual void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { }
- public virtual System.Collections.Generic.SortedSet<T> GetViewBetween(T lowerValue, T upperValue) { throw null; }
+ public virtual System.Collections.Generic.SortedSet<T> GetViewBetween(T? lowerValue, T? upperValue) { throw null; }
public virtual void IntersectWith(System.Collections.Generic.IEnumerable<T> other) { }
public bool IsProperSubsetOf(System.Collections.Generic.IEnumerable<T> other) { throw null; }
public bool IsProperSupersetOf(System.Collections.Generic.IEnumerable<T> other) { throw null; }
{
public static class CollectionExtensions
{
- [return: MaybeNull]
- public static TValue GetValueOrDefault<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key)
+ public static TValue? GetValueOrDefault<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key)
{
return dictionary.GetValueOrDefault(key, default!);
}
return true;
}
- value = default(TValue)!;
+ value = default;
return false;
}
}
private readonly LinkedList<T> _list;
private LinkedListNode<T>? _node;
private readonly int _version;
- [AllowNull] private T _current;
+ private T? _current;
private int _index;
internal Enumerator(LinkedList<T> list)
_index = 0;
}
- public T Current
- {
- get { return _current; }
- }
+ public T Current => _current!;
object? IEnumerator.Current
{
private readonly Queue<T> _q;
private readonly int _version;
private int _index; // -1 = not started, -2 = ended/disposed
- [AllowNull] private T _currentElement;
+ private T? _currentElement;
internal Enumerator(Queue<T> q)
{
{
if (_index < 0)
ThrowEnumerationNotStartedOrEnded();
- return _currentElement;
+ return _currentElement!;
}
}
TreeSet<KeyValuePair<TKey, TValue>>.Node? node = _set.FindNode(new KeyValuePair<TKey, TValue>(key, default(TValue)!));
if (node == null)
{
- value = default(TValue)!;
+ value = default;
return false;
}
value = node.Item.Value;
return true;
}
- value = default(TValue)!;
+ value = default;
return false;
}
private struct Enumerator : IEnumerator<KeyValuePair<TKey, TValue>>, IDictionaryEnumerator
{
private readonly SortedList<TKey, TValue> _sortedList;
- [AllowNull] private TKey _key;
- [AllowNull] private TValue _value;
+ private TKey? _key;
+ private TValue? _value;
private int _index;
private readonly int _version;
private readonly int _getEnumeratorRetType; // What should Enumerator.Current return?
throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen);
}
- return _key;
+ return _key!;
}
}
throw new InvalidOperationException(SR.InvalidOperation_EnumOpCantHappen);
}
- return new DictionaryEntry(_key, _value);
+ return new DictionaryEntry(_key!, _value);
}
}
- public KeyValuePair<TKey, TValue> Current
- {
- get
- {
- return new KeyValuePair<TKey, TValue>(_key, _value);
- }
- }
+ public KeyValuePair<TKey, TValue> Current => new KeyValuePair<TKey, TValue>(_key!, _value!);
object? IEnumerator.Current
{
if (_getEnumeratorRetType == DictEntry)
{
- return new DictionaryEntry(_key, _value);
+ return new DictionaryEntry(_key!, _value);
}
else
{
- return new KeyValuePair<TKey, TValue>(_key, _value);
+ return new KeyValuePair<TKey, TValue>(_key!, _value!);
}
}
}
private readonly SortedList<TKey, TValue> _sortedList;
private int _index;
private readonly int _version;
- [AllowNull] private TKey _currentKey = default!;
+ private TKey? _currentKey;
internal SortedListKeyEnumerator(SortedList<TKey, TValue> sortedList)
{
return false;
}
- public TKey Current
- {
- get
- {
- return _currentKey;
- }
- }
+ public TKey Current => _currentKey!;
object? IEnumerator.Current
{
private readonly SortedList<TKey, TValue> _sortedList;
private int _index;
private readonly int _version;
- [AllowNull] private TValue _currentValue = default!;
+ private TValue? _currentValue;
internal SortedListValueEnumerator(SortedList<TKey, TValue> sortedList)
{
return false;
}
- public TValue Current
- {
- get
- {
- return _currentValue;
- }
- }
+ public TValue Current => _currentValue!;
object? IEnumerator.Current
{
internal sealed class TreeSubSet : SortedSet<T>, ISerializable, IDeserializationCallback
{
private readonly SortedSet<T> _underlying;
- [MaybeNull, AllowNull]
- private readonly T _min;
- [MaybeNull, AllowNull]
- private readonly T _max;
+ private readonly T? _min;
+ private readonly T? _max;
// keeps track of whether the count variable is up to date
// up to date -> _countVersion = _underlying.version
// not up to date -> _countVersion < _underlying.version
}
#endif
- public TreeSubSet(SortedSet<T> Underlying, [AllowNull] T Min, [AllowNull] T Max, bool lowerBoundActive, bool upperBoundActive)
+ public TreeSubSet(SortedSet<T> Underlying, T? Min, T? Max, bool lowerBoundActive, bool upperBoundActive)
: base(Underlying.Comparer)
{
_underlying = Underlying;
get
{
Node? current = root;
- T result = default(T)!;
+ T? result = default;
while (current != null)
{
}
}
- return result;
+ return result!;
}
}
get
{
Node? current = root;
- T result = default(T)!;
+ T? result = default;
while (current != null)
{
}
}
- return result;
+ return result!;
}
}
// This passes functionality down to the underlying tree, clipping edges if necessary
// There's nothing gained by having a nested subset. May as well draw it from the base
// Cannot increase the bounds of the subset, can only decrease it
- public override SortedSet<T> GetViewBetween([AllowNull] T lowerValue, [AllowNull] T upperValue)
+ public override SortedSet<T> GetViewBetween(T? lowerValue, T? upperValue)
{
if (_lBoundActive && Comparer.Compare(_min, lowerValue) > 0)
{
return -1;
}
- internal Node? FindRange([AllowNull] T from, [AllowNull] T to) => FindRange(from, to, lowerBoundActive: true, upperBoundActive: true);
+ internal Node? FindRange(T? from, T? to) => FindRange(from, to, lowerBoundActive: true, upperBoundActive: true);
- internal Node? FindRange([AllowNull] T from, [AllowNull] T to, bool lowerBoundActive, bool upperBoundActive)
+ internal Node? FindRange(T? from, T? to, bool lowerBoundActive, bool upperBoundActive)
{
Node? current = root;
while (current != null)
#region ISorted members
- [MaybeNull]
- public T Min => MinInternal;
+ public T? Min => MinInternal;
- [MaybeNull]
- internal virtual T MinInternal
+ internal virtual T? MinInternal
{
get
{
if (root == null)
{
- return default(T)!;
+ return default;
}
Node current = root;
}
}
- [MaybeNull]
- public T Max => MaxInternal;
+ public T? Max => MaxInternal;
- [MaybeNull]
- internal virtual T MaxInternal
+ internal virtual T? MaxInternal
{
get
{
if (root == null)
{
- return default(T)!;
+ return default;
}
Node current = root;
}
}
- public virtual SortedSet<T> GetViewBetween([AllowNull] T lowerValue, [AllowNull] T upperValue)
+ public virtual SortedSet<T> GetViewBetween(T? lowerValue, T? upperValue)
{
if (Comparer.Compare(lowerValue, upperValue) > 0)
{
actualValue = node.Item;
return true;
}
- actualValue = default(T)!;
+ actualValue = default;
return false;
}
private readonly Stack<T> _stack;
private readonly int _version;
private int _index;
- [AllowNull] private T _currentElement;
+ private T? _currentElement;
internal Enumerator(Stack<T> stack)
{
{
if (_index < 0)
ThrowEnumerationNotStartedOrEnded();
- return _currentElement;
+ return _currentElement!;
}
}
protected ExportProvider() { }
public event System.EventHandler<System.ComponentModel.Composition.Hosting.ExportsChangeEventArgs>? ExportsChanged { add { } remove { } }
public event System.EventHandler<System.ComponentModel.Composition.Hosting.ExportsChangeEventArgs>? ExportsChanging { add { } remove { } }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public T GetExportedValueOrDefault<T>() { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public T GetExportedValueOrDefault<T>(string? contractName) { throw null; }
+ public T? GetExportedValueOrDefault<T>() { throw null; }
+ public T? GetExportedValueOrDefault<T>(string? contractName) { throw null; }
public System.Collections.Generic.IEnumerable<T> GetExportedValues<T>() { throw null; }
public System.Collections.Generic.IEnumerable<T> GetExportedValues<T>(string? contractName) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public T GetExportedValue<T>() { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public T GetExportedValue<T>(string? contractName) { throw null; }
+ public T? GetExportedValue<T>() { throw null; }
+ public T? GetExportedValue<T>(string? contractName) { throw null; }
public System.Collections.Generic.IEnumerable<System.ComponentModel.Composition.Primitives.Export> GetExports(System.ComponentModel.Composition.Primitives.ImportDefinition definition) { throw null; }
public System.Collections.Generic.IEnumerable<System.ComponentModel.Composition.Primitives.Export> GetExports(System.ComponentModel.Composition.Primitives.ImportDefinition definition, System.ComponentModel.Composition.Hosting.AtomicComposition? atomicComposition) { throw null; }
public System.Collections.Generic.IEnumerable<System.Lazy<object, object>> GetExports(System.Type type, System.Type? metadataViewType, string? contractName) { throw null; }
internal struct CompositionResult<T>
{
private readonly IEnumerable<CompositionError>? _errors;
- [AllowNull] private readonly T _value;
+ private readonly T? _value;
public CompositionResult(T value)
: this(value, null)
{
}
- internal CompositionResult([AllowNull] T value, IEnumerable<CompositionError>? errors)
+ internal CompositionResult(T? value, IEnumerable<CompositionError>? errors)
{
_errors = errors;
_value = value;
{
ThrowOnErrors();
- return _value;
+ return _value!;
}
}
return _outerAtomicComposition.TryGetValueInternal<T>(key, localAtomicCompositionOnly, out value);
}
- value = default(T)!;
+ value = default;
return false;
}
/// An error occurred during composition. <see cref="CompositionException.Errors"/> will
/// contain a collection of errors that occurred.
/// </exception>
- [return: MaybeNull]
- public T GetExportedValue<T>()
+ public T? GetExportedValue<T>()
{
return GetExportedValue<T>((string?)null);
}
/// An error occurred during composition. <see cref="CompositionException.Errors"/> will
/// contain a collection of errors that occurred.
/// </exception>
- [return: MaybeNull]
- public T GetExportedValue<T>(string? contractName)
+ public T? GetExportedValue<T>(string? contractName)
{
return GetExportedValueCore<T>(contractName, ImportCardinality.ExactlyOne);
}
/// An error occurred during composition. <see cref="CompositionException.Errors"/> will
/// contain a collection of errors that occurred.
/// </exception>
- [return: MaybeNull]
- public T GetExportedValueOrDefault<T>()
+ public T? GetExportedValueOrDefault<T>()
{
return GetExportedValueOrDefault<T>((string?)null);
}
/// An error occurred during composition. <see cref="CompositionException.Errors"/> will
/// contain a collection of errors that occurred.
/// </exception>
- [return: MaybeNull]
- public T GetExportedValueOrDefault<T>(string? contractName)
+ public T? GetExportedValueOrDefault<T>(string? contractName)
{
return GetExportedValueCore<T>(contractName, ImportCardinality.ZeroOrOne);
}
return result;
}
- [return: MaybeNull]
- private T GetExportedValueCore<T>(string? contractName, ImportCardinality cardinality)
+ private T? GetExportedValueCore<T>(string? contractName, ImportCardinality cardinality)
{
if (!cardinality.IsAtMostOne())
{
Export? export = GetExportsCore(typeof(T), (Type?)null, contractName, cardinality).SingleOrDefault();
- return (export != null) ? ExportServices.GetCastedExportedValue<T>(export) : default(T)!;
+ return (export != null) ? ExportServices.GetCastedExportedValue<T>(export) : default;
}
private IEnumerable<Lazy<T>> GetExportsCore<T>(string? contractName)
return new ReadOnlyDictionary<string, object?>(metadata);
}
- [return: MaybeNull]
- public static T GetValue<T>(this IDictionary<string, object?> metadata, string key)
+ public static T? GetValue<T>(this IDictionary<string, object?> metadata, string key)
{
if (metadata == null)
{
throw new ArgumentNullException(nameof(metadata));
}
- if (!metadata.TryGetValue(key, out object? untypedValue))
+ if (metadata.TryGetValue(key, out object? untypedValue) && untypedValue is T t)
{
- return default(T)!;
+ return t;
}
- if (untypedValue is T)
- {
- return (T)untypedValue;
- }
- else
- {
- return default(T)!;
- }
+ return default;
}
}
}
{
throw new Exception(SR.Diagnostic_InternalExceptionMessage);
}
- return MemberType.GetHashCode() ^ _accessors[0]!.GetHashCode(); // TODO-NULLABLE https://github.com/dotnet/roslyn/issues/34644
+ return MemberType.GetHashCode() ^ _accessors[0]!.GetHashCode(); // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644)
}
}
}
public static partial class DataRowExtensions
{
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T Field<T>(this System.Data.DataRow row, System.Data.DataColumn column) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T Field<T>(this System.Data.DataRow row, System.Data.DataColumn column, System.Data.DataRowVersion version) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T Field<T>(this System.Data.DataRow row, int columnIndex) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T Field<T>(this System.Data.DataRow row, int columnIndex, System.Data.DataRowVersion version) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T Field<T>(this System.Data.DataRow row, string columnName) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T Field<T>(this System.Data.DataRow row, string columnName, System.Data.DataRowVersion version) { throw null; }
- public static void SetField<T>(this System.Data.DataRow row, System.Data.DataColumn column, [System.Diagnostics.CodeAnalysis.AllowNullAttribute] T value) { }
- public static void SetField<T>(this System.Data.DataRow row, int columnIndex, [System.Diagnostics.CodeAnalysis.AllowNullAttribute] T value) { }
- public static void SetField<T>(this System.Data.DataRow row, string columnName, [System.Diagnostics.CodeAnalysis.AllowNullAttribute] T value) { }
+ public static T? Field<T>(this System.Data.DataRow row, System.Data.DataColumn column) { throw null; }
+ public static T? Field<T>(this System.Data.DataRow row, System.Data.DataColumn column, System.Data.DataRowVersion version) { throw null; }
+ public static T? Field<T>(this System.Data.DataRow row, int columnIndex) { throw null; }
+ public static T? Field<T>(this System.Data.DataRow row, int columnIndex, System.Data.DataRowVersion version) { throw null; }
+ public static T? Field<T>(this System.Data.DataRow row, string columnName) { throw null; }
+ public static T? Field<T>(this System.Data.DataRow row, string columnName, System.Data.DataRowVersion version) { throw null; }
+ public static void SetField<T>(this System.Data.DataRow row, System.Data.DataColumn column, T? value) { }
+ public static void SetField<T>(this System.Data.DataRow row, int columnIndex, T? value) { }
+ public static void SetField<T>(this System.Data.DataRow row, string columnName, T? value) { }
}
[System.FlagsAttribute]
public enum DataRowState
[System.ComponentModel.BrowsableAttribute(false)]
public bool IsSynchronized { get { throw null; } }
public virtual System.Data.DataViewSetting this[System.Data.DataTable table] { get { throw null; } set { } }
- [System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public virtual System.Data.DataViewSetting this[int index] { get { throw null; } set { } }
+ [System.Diagnostics.CodeAnalysis.DisallowNullAttribute]
+ public virtual System.Data.DataViewSetting? this[int index] { get { throw null; } set { } }
public virtual System.Data.DataViewSetting? this[string tableName] { get { throw null; } }
[System.ComponentModel.BrowsableAttribute(false)]
public object SyncRoot { get { throw null; } }
public static partial class TypedTableBaseExtensions
{
public static System.Data.EnumerableRowCollection<TRow> AsEnumerable<TRow>(this System.Data.TypedTableBase<TRow> source) where TRow : System.Data.DataRow { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TRow ElementAtOrDefault<TRow>(this System.Data.TypedTableBase<TRow> source, int index) where TRow : System.Data.DataRow { throw null; }
+ public static TRow? ElementAtOrDefault<TRow>(this System.Data.TypedTableBase<TRow> source, int index) where TRow : System.Data.DataRow { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderByDescending<TRow, TKey>(this System.Data.TypedTableBase<TRow> source, System.Func<TRow, TKey> keySelector) where TRow : System.Data.DataRow { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderByDescending<TRow, TKey>(this System.Data.TypedTableBase<TRow> source, System.Func<TRow, TKey> keySelector, System.Collections.Generic.IComparer<TKey> comparer) where TRow : System.Data.DataRow { throw null; }
public static System.Data.OrderedEnumerableRowCollection<TRow> OrderBy<TRow, TKey>(this System.Data.TypedTableBase<TRow> source, System.Func<TRow, TKey> keySelector) where TRow : System.Data.DataRow { throw null; }
BaseSchemaName = GetDbColumnValue<string?>(SchemaTableColumn.BaseSchemaName);
BaseServerName = GetDbColumnValue<string?>(SchemaTableOptionalColumn.BaseServerName);
BaseTableName = GetDbColumnValue<string?>(SchemaTableColumn.BaseTableName);
- ColumnName = GetDbColumnValue<string>(SchemaTableColumn.ColumnName);
+ ColumnName = GetDbColumnValue<string>(SchemaTableColumn.ColumnName)!;
ColumnOrdinal = GetDbColumnValue<int?>(SchemaTableColumn.ColumnOrdinal);
ColumnSize = GetDbColumnValue<int?>(SchemaTableColumn.ColumnSize);
IsAliased = GetDbColumnValue<bool?>(SchemaTableColumn.IsAliased);
DataTypeName = GetDbColumnValue<string?>("DataTypeName");
}
- // The following may return null, but local methods can't be annotated for that yet ([MaybeNull])
- private T GetDbColumnValue<T>(string columnName) => _schemaColumns.Contains(columnName) && _schemaRow[columnName] is T value ? value : default!;
+ private T? GetDbColumnValue<T>(string columnName) => _schemaColumns.Contains(columnName) && _schemaRow[columnName] is T value ? value : default;
}
public static ReadOnlyCollection<DbColumn> GetColumnSchema(this DbDataReader reader)
{
internal sealed class SqlInt64Storage : DataStorage
{
- private SqlInt64[] _values = default!;
+ private SqlInt64[] _values = default!; // Late-initialized
public SqlInt64Storage(DataColumn column)
: base(column, typeof(SqlInt64), SqlInt64.Null, SqlInt64.Null, StorageType.SqlInt64)
/// <param name="row">The input DataRow</param>
/// <param name="columnName">The input column name specifying which row value to retrieve.</param>
/// <returns>The DataRow value for the column specified.</returns>
- [return: MaybeNull]
- public static T Field<T>(this DataRow row, string columnName)
+ public static T? Field<T>(this DataRow row, string columnName)
{
DataSetUtil.CheckArgumentNull(row, nameof(row));
return UnboxT<T>.s_unbox(row[columnName]);
/// <param name="row">The input DataRow</param>
/// <param name="column">The input DataColumn specifying which row value to retrieve.</param>
/// <returns>The DataRow value for the column specified.</returns>
- [return: MaybeNull]
- public static T Field<T>(this DataRow row, DataColumn column)
+ public static T? Field<T>(this DataRow row, DataColumn column)
{
DataSetUtil.CheckArgumentNull(row, nameof(row));
return UnboxT<T>.s_unbox(row[column]);
/// <param name="row">The input DataRow</param>
/// <param name="columnIndex">The input ordinal specifying which row value to retrieve.</param>
/// <returns>The DataRow value for the column specified.</returns>
- [return: MaybeNull]
- public static T Field<T>(this DataRow row, int columnIndex)
+ public static T? Field<T>(this DataRow row, int columnIndex)
{
DataSetUtil.CheckArgumentNull(row, nameof(row));
return UnboxT<T>.s_unbox(row[columnIndex]);
/// <param name="columnIndex">The input ordinal specifying which row value to retrieve.</param>
/// <param name="version">The DataRow version for which row value to retrieve.</param>
/// <returns>The DataRow value for the column specified.</returns>
- [return: MaybeNull]
- public static T Field<T>(this DataRow row, int columnIndex, DataRowVersion version)
+ public static T? Field<T>(this DataRow row, int columnIndex, DataRowVersion version)
{
DataSetUtil.CheckArgumentNull(row, nameof(row));
return UnboxT<T>.s_unbox(row[columnIndex, version]);
/// <param name="columnName">The input column name specifying which row value to retrieve.</param>
/// <param name="version">The DataRow version for which row value to retrieve.</param>
/// <returns>The DataRow value for the column specified.</returns>
- [return: MaybeNull]
- public static T Field<T>(this DataRow row, string columnName, DataRowVersion version)
+ public static T? Field<T>(this DataRow row, string columnName, DataRowVersion version)
{
DataSetUtil.CheckArgumentNull(row, nameof(row));
return UnboxT<T>.s_unbox(row[columnName, version]);
/// <param name="column">The input DataColumn specifying which row value to retrieve.</param>
/// <param name="version">The DataRow version for which row value to retrieve.</param>
/// <returns>The DataRow value for the column specified.</returns>
- [return: MaybeNull]
- public static T Field<T>(this DataRow row, DataColumn column, DataRowVersion version)
+ public static T? Field<T>(this DataRow row, DataColumn column, DataRowVersion version)
{
DataSetUtil.CheckArgumentNull(row, nameof(row));
return UnboxT<T>.s_unbox(row[column, version]);
/// <param name="row">The input DataRow.</param>
/// <param name="columnIndex">The input ordinal specifying which row value to set.</param>
/// <param name="value">The new row value for the specified column.</param>
- public static void SetField<T>(this DataRow row, int columnIndex, [AllowNull] T value)
+ public static void SetField<T>(this DataRow row, int columnIndex, T? value)
{
DataSetUtil.CheckArgumentNull(row, nameof(row));
row[columnIndex] = (object?)value ?? DBNull.Value;
/// <param name="row">The input DataRow.</param>
/// <param name="columnName">The input column name specifying which row value to retrieve.</param>
/// <param name="value">The new row value for the specified column.</param>
- public static void SetField<T>(this DataRow row, string columnName, [AllowNull] T value)
+ public static void SetField<T>(this DataRow row, string columnName, T? value)
{
DataSetUtil.CheckArgumentNull(row, nameof(row));
row[columnName] = (object?)value ?? DBNull.Value;
/// <param name="row">The input DataRow.</param>
/// <param name="column">The input DataColumn specifying which row value to retrieve.</param>
/// <param name="value">The new row value for the specified column.</param>
- public static void SetField<T>(this DataRow row, DataColumn column, [AllowNull] T value)
+ public static void SetField<T>(this DataRow row, DataColumn column, T? value)
{
DataSetUtil.CheckArgumentNull(row, nameof(row));
row[column] = (object?)value ?? DBNull.Value;
private static class UnboxT<T>
{
- internal static readonly Converter<object, T> s_unbox = Create();
+ internal static readonly Converter<object, T?> s_unbox = Create();
- private static Converter<object, T> Create()
+ private static Converter<object, T?> Create()
{
if (typeof(T).IsValueType)
{
return ReferenceField;
}
- [return: MaybeNull]
- private static T ReferenceField(object value)
+ private static T? ReferenceField(object value)
=> value == DBNull.Value ? default : (T)value;
private static T ValueField(object value)
? throw DataSetUtil.InvalidCast(SR.Format(SR.DataSetLinq_NonNullableCast, typeof(T)))
: (T)value;
- [return: MaybeNull]
private static Nullable<TElem> NullableField<TElem>(object value) where TElem : struct
=> value == DBNull.Value ? default : new Nullable<TElem>((TElem)value);
}
}
}
- [MaybeNull]
- public virtual DataViewSetting this[int index]
+ [DisallowNull]
+ public virtual DataViewSetting? this[int index]
{
get
{
internal const int DefaultPageSize = 32; /* 512 = 2^9 32 million nodes*/
internal const int NIL = 0; // 0th page, 0th slot for each tree till CLR static & generics issue is fixed
- private TreePage?[] _pageTable = default!; // initial size 4, then doubles (grows) - it never shrinks. Late-initialized to non-null in InitTree.
- private int[] _pageTableMap = default!; // Late-initialized to non-null in InitTree
+ private TreePage?[] _pageTable; // initial size 4, then doubles (grows) - it never shrinks.
+ private int[] _pageTableMap;
private int _inUsePageCount; // contains count of allocated pages per tree, its <= the capacity of pageTable
private int _nextFreePageLine; // used for keeping track of position of last used free page in pageTable
public int root;
private int _inUseSatelliteTreeCount; // total number of satellite associated with this tree.
private readonly TreeAccessMethod _accessMethod;
- protected abstract int CompareNode([AllowNull] K record1, [AllowNull] K record2);
- protected abstract int CompareSateliteTreeNode([AllowNull] K record1, [AllowNull] K record2);
+ protected abstract int CompareNode(K? record1, K? record2);
+ protected abstract int CompareSateliteTreeNode(K? record1, K? record2);
protected RBTree(TreeAccessMethod accessMethod)
{
InitTree();
}
+ [MemberNotNull(nameof(_pageTable))]
+ [MemberNotNull(nameof(_pageTableMap))]
private void InitTree()
{
root = NIL;
* Use bitmap associated with page to allocate a slot.
* mark the slot as used and return its index.
*/
- private int GetNewNode([AllowNull] K key)
+ private int GetNewNode(K? key)
{
// find page with free slots, if none, allocate a new page
TreePage? page = null;
return root_id;
}
- private int SearchSubTree(int root_id, [AllowNull] K key)
+ private int SearchSubTree(int root_id, K? key)
{
if (root_id != NIL && _accessMethod != TreeAccessMethod.KEY_SEARCH_AND_INDEX)
{
// Begin: List of methods for making it easy to work with ArrayList
- public int Add([AllowNull] K item) //Insert (int record)
+ public int Add(K? item) //Insert (int record)
{
int nodeId = GetNewNode(item);
RBInsert(NIL, nodeId, NIL, -1, false);
internal int _parentId;
internal int _nextId; // multiple records associated with same key
internal int _subTreeSize; // number of nodes in subtree rooted at the current node
- [AllowNull, MaybeNull]
- internal K _keyOfNode;
+ internal K? _keyOfNode;
internal NodeColor _nodeColor;
}
private readonly RBTree<K> _tree;
private readonly int _version;
private int _index, _mainTreeNodeId;
- [AllowNull, MaybeNull]
- private K _current;
+ private K? _current;
internal RBTreeEnumerator(RBTree<K> tree)
{
/// Note: Comparison is done in the order it was Added.
/// </summary>
/// <returns>Comparison result of the combined Sort comparer expression</returns>
- public int Compare([AllowNull] List<object> a, [AllowNull] List<object> b)
+ public int Compare(List<object>? a, List<object>? b)
{
Debug.Assert(a != null && b != null && a.Count == Count);
return new EnumerableRowCollection<TRow>(source as DataTable);
}
- [return: MaybeNull]
- public static TRow ElementAtOrDefault<TRow>(this TypedTableBase<TRow> source, int index) where TRow : DataRow
+ public static TRow? ElementAtOrDefault<TRow>(this TypedTableBase<TRow> source, int index) where TRow : DataRow
{
if ((index >= 0) && (index < source.Rows.Count))
{
using System.Data.SqlTypes;
using System.Data.Common;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Text;
internal XmlWriter _xmlw = default!; // Late-initialized
private bool _fBefore;
private bool _fErrors;
- internal Hashtable _rowsOrder = default!; // Always initialized in DoAssignments
+ internal Hashtable _rowsOrder;
private readonly ArrayList _tables = new ArrayList();
private readonly bool _writeHierarchy;
}
}
-
+ [MemberNotNull(nameof(_rowsOrder))]
private void DoAssignments(ArrayList tables)
{
int rows = 0;
}
}
- [return: MaybeNull]
- internal T FindItem<T>(int tag, Func<T, bool> filterMethod) where T : class
+ internal T? FindItem<T>(int tag, Func<T, bool> filterMethod) where T : class
{
bool lockObtained = false;
try
private Queue<string>? _pending;
private Interop.Sys.DirectoryEntry _entry;
- private TResult _current = default!;
+ private TResult? _current;
// Used for creating full paths
private char[]? _pathBuffer;
private readonly object _lock = new object();
private Interop.NtDll.FILE_FULL_DIR_INFORMATION* _entry;
- private TResult _current = default!;
+ private TResult? _current;
private IntPtr _buffer;
private int _bufferLength;
/// <param name="error">The native error code.</param>
protected virtual bool ContinueOnError(int error) => false;
- public TResult Current => _current;
+ public TResult Current => _current!;
object? IEnumerator.Current => Current;
{
private readonly int _threadId;
internal int state;
- [MaybeNull, AllowNull]
- internal TSource current = default;
+ internal TSource? current;
public Iterator()
{
_threadId = Environment.CurrentManagedThreadId;
}
- public TSource Current
- {
- get { return current!; }
- }
+ public TSource Current => current!;
protected abstract Iterator<TSource> Clone();
protected virtual void Dispose(bool disposing)
{
- current = default(TSource)!;
+ current = default;
state = -1;
}
return true;
}
- value = default(TValue)!;
+ value = default;
return false;
}
Debug.Assert(_method is DynamicMethod);
#endif
{
- return Expression.Field(Expression.Constant(new StrongBox<T>(default(T)!)), "Value");
+ return Expression.Field(Expression.Constant(new StrongBox<T>()), "Value");
}
#if FEATURE_COMPILE_TO_METHODBUILDER
else
}
}
}
- value = default(TValue)!;
+ value = default;
return false;
}
public static System.Linq.ParallelQuery<TSource> DefaultIfEmpty<TSource>(this System.Linq.ParallelQuery<TSource> source, TSource defaultValue) { throw null; }
public static System.Linq.ParallelQuery<TSource> Distinct<TSource>(this System.Linq.ParallelQuery<TSource> source) { throw null; }
public static System.Linq.ParallelQuery<TSource> Distinct<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Collections.Generic.IEqualityComparer<TSource>? comparer) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TSource ElementAtOrDefault<TSource>(this System.Linq.ParallelQuery<TSource> source, int index) { throw null; }
+ public static TSource? ElementAtOrDefault<TSource>(this System.Linq.ParallelQuery<TSource> source, int index) { throw null; }
public static TSource ElementAt<TSource>(this System.Linq.ParallelQuery<TSource> source, int index) { throw null; }
public static System.Linq.ParallelQuery<TResult> Empty<TResult>() { throw null; }
[System.ObsoleteAttribute("The second data source of a binary operator must be of type System.Linq.ParallelQuery<T> rather than System.Collections.Generic.IEnumerable<T>. To fix this problem, use the AsParallel() extension method to convert the right data source to System.Linq.ParallelQuery<T>.")]
public static System.Linq.ParallelQuery<TSource> Except<TSource>(this System.Linq.ParallelQuery<TSource> first, System.Collections.Generic.IEnumerable<TSource> second, System.Collections.Generic.IEqualityComparer<TSource>? comparer) { throw null; }
public static System.Linq.ParallelQuery<TSource> Except<TSource>(this System.Linq.ParallelQuery<TSource> first, System.Linq.ParallelQuery<TSource> second) { throw null; }
public static System.Linq.ParallelQuery<TSource> Except<TSource>(this System.Linq.ParallelQuery<TSource> first, System.Linq.ParallelQuery<TSource> second, System.Collections.Generic.IEqualityComparer<TSource>? comparer) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TSource FirstOrDefault<TSource>(this System.Linq.ParallelQuery<TSource> source) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TSource FirstOrDefault<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
+ public static TSource? FirstOrDefault<TSource>(this System.Linq.ParallelQuery<TSource> source) { throw null; }
+ public static TSource? FirstOrDefault<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
public static TSource First<TSource>(this System.Linq.ParallelQuery<TSource> source) { throw null; }
public static TSource First<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
public static void ForAll<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Action<TSource> action) { }
public static System.Linq.ParallelQuery<TResult> Join<TOuter, TInner, TKey, TResult>(this System.Linq.ParallelQuery<TOuter> outer, System.Collections.Generic.IEnumerable<TInner> inner, System.Func<TOuter, TKey> outerKeySelector, System.Func<TInner, TKey> innerKeySelector, System.Func<TOuter, TInner, TResult> resultSelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer) { throw null; }
public static System.Linq.ParallelQuery<TResult> Join<TOuter, TInner, TKey, TResult>(this System.Linq.ParallelQuery<TOuter> outer, System.Linq.ParallelQuery<TInner> inner, System.Func<TOuter, TKey> outerKeySelector, System.Func<TInner, TKey> innerKeySelector, System.Func<TOuter, TInner, TResult> resultSelector) { throw null; }
public static System.Linq.ParallelQuery<TResult> Join<TOuter, TInner, TKey, TResult>(this System.Linq.ParallelQuery<TOuter> outer, System.Linq.ParallelQuery<TInner> inner, System.Func<TOuter, TKey> outerKeySelector, System.Func<TInner, TKey> innerKeySelector, System.Func<TOuter, TInner, TResult> resultSelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TSource LastOrDefault<TSource>(this System.Linq.ParallelQuery<TSource> source) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TSource LastOrDefault<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
+ public static TSource? LastOrDefault<TSource>(this System.Linq.ParallelQuery<TSource> source) { throw null; }
+ public static TSource? LastOrDefault<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
public static TSource Last<TSource>(this System.Linq.ParallelQuery<TSource> source) { throw null; }
public static TSource Last<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
public static long LongCount<TSource>(this System.Linq.ParallelQuery<TSource> source) { throw null; }
public static long? Max(this System.Linq.ParallelQuery<long?> source) { throw null; }
public static float? Max(this System.Linq.ParallelQuery<float?> source) { throw null; }
public static float Max(this System.Linq.ParallelQuery<float> source) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TSource Max<TSource>(this System.Linq.ParallelQuery<TSource> source) { throw null; }
+ public static TSource? Max<TSource>(this System.Linq.ParallelQuery<TSource> source) { throw null; }
public static decimal Max<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, decimal> selector) { throw null; }
public static double Max<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, double> selector) { throw null; }
public static int Max<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, int> selector) { throw null; }
public static long? Max<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, long?> selector) { throw null; }
public static float? Max<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, float?> selector) { throw null; }
public static float Max<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, float> selector) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TResult Max<TSource, TResult>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, TResult> selector) { throw null; }
+ public static TResult? Max<TSource, TResult>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, TResult> selector) { throw null; }
public static decimal Min(this System.Linq.ParallelQuery<decimal> source) { throw null; }
public static double Min(this System.Linq.ParallelQuery<double> source) { throw null; }
public static int Min(this System.Linq.ParallelQuery<int> source) { throw null; }
public static long? Min(this System.Linq.ParallelQuery<long?> source) { throw null; }
public static float? Min(this System.Linq.ParallelQuery<float?> source) { throw null; }
public static float Min(this System.Linq.ParallelQuery<float> source) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TSource Min<TSource>(this System.Linq.ParallelQuery<TSource> source) { throw null; }
+ public static TSource? Min<TSource>(this System.Linq.ParallelQuery<TSource> source) { throw null; }
public static decimal Min<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, decimal> selector) { throw null; }
public static double Min<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, double> selector) { throw null; }
public static int Min<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, int> selector) { throw null; }
public static long? Min<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, long?> selector) { throw null; }
public static float? Min<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, float?> selector) { throw null; }
public static float Min<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, float> selector) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TResult Min<TSource, TResult>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, TResult> selector) { throw null; }
+ public static TResult? Min<TSource, TResult>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, TResult> selector) { throw null; }
public static System.Linq.ParallelQuery<TResult> OfType<TResult>(this System.Linq.ParallelQuery source) { throw null; }
public static System.Linq.OrderedParallelQuery<TSource> OrderByDescending<TSource, TKey>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, TKey> keySelector) { throw null; }
public static System.Linq.OrderedParallelQuery<TSource> OrderByDescending<TSource, TKey>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, TKey> keySelector, System.Collections.Generic.IComparer<TKey>? comparer) { throw null; }
public static bool SequenceEqual<TSource>(this System.Linq.ParallelQuery<TSource> first, System.Collections.Generic.IEnumerable<TSource> second, System.Collections.Generic.IEqualityComparer<TSource>? comparer) { throw null; }
public static bool SequenceEqual<TSource>(this System.Linq.ParallelQuery<TSource> first, System.Linq.ParallelQuery<TSource> second) { throw null; }
public static bool SequenceEqual<TSource>(this System.Linq.ParallelQuery<TSource> first, System.Linq.ParallelQuery<TSource> second, System.Collections.Generic.IEqualityComparer<TSource>? comparer) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TSource SingleOrDefault<TSource>(this System.Linq.ParallelQuery<TSource> source) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TSource SingleOrDefault<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
+ public static TSource? SingleOrDefault<TSource>(this System.Linq.ParallelQuery<TSource> source) { throw null; }
+ public static TSource? SingleOrDefault<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
public static TSource Single<TSource>(this System.Linq.ParallelQuery<TSource> source) { throw null; }
public static TSource Single<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
public static System.Linq.ParallelQuery<TSource> SkipWhile<TSource>(this System.Linq.ParallelQuery<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
// Helper method to find the minimum or maximum element in the source.
//
- [return: MaybeNull]
- private static T Reduce(IEnumerable<T> source, int sign)
+ private static T? Reduce(IEnumerable<T> source, int sign)
{
Debug.Assert(source != null);
Debug.Assert(sign == -1 || sign == 1);
// Helper method to find the minimum element in the source.
//
- [return: MaybeNull]
- internal static T ReduceMin(IEnumerable<T> source)
+ internal static T? ReduceMin(IEnumerable<T> source)
{
return Reduce(source, -1);
}
// Helper method to find the maximum element in the source.
//
- [return: MaybeNull]
- internal static T ReduceMax(IEnumerable<T> source)
+ internal static T? ReduceMax(IEnumerable<T> source)
{
return Reduce(source, 1);
}
}
}
- internal class EmptyEnumerator<T> : QueryOperatorEnumerator<T, int>, IEnumerator<T>
+ internal sealed class EmptyEnumerator<T> : QueryOperatorEnumerator<T, int>, IEnumerator<T>
{
internal override bool MoveNext([MaybeNullWhen(false), AllowNull] ref T currentElement, ref int currentKey)
{
{
internal int hashCode;
internal int next;
- [MaybeNull, AllowNull] internal TElement value;
+ internal TElement? value;
}
}
}
private IntValueEvent? _consumerEvent; // The consumer event.
private readonly bool[] _done; // Tracks which channels are done.
private int _channelIndex; // The next channel from which we'll dequeue.
- [MaybeNull, AllowNull] private T _currentElement = default; // The remembered element from the previous MoveNext.
+ private T? _currentElement; // The remembered element from the previous MoveNext.
//-----------------------------------------------------------------------------------
// Allocates a new enumerator over a set of one-to-one channels.
{
private readonly SynchronousChannel<T>[] _channels; // The channel array we will enumerate, from left-to-right.
private int _channelIndex; // The current channel index. This moves through the array as we enumerate.
- private T _currentElement = default!; // The last element remembered during enumeration.
+ private T? _currentElement; // The last element remembered during enumeration.
//-----------------------------------------------------------------------------------
// Instantiates a new enumerator for a set of channels.
throw new InvalidOperationException(SR.PLINQ_CommonEnumerator_Current_NotStarted);
}
- return _currentElement;
+ return _currentElement!;
}
}
internal struct ConcatKey<TLeftKey, TRightKey>
{
- [MaybeNull, AllowNull]
- private readonly TLeftKey _leftKey;
- [MaybeNull, AllowNull]
- private readonly TRightKey _rightKey;
+ private readonly TLeftKey? _leftKey;
+ private readonly TRightKey? _rightKey;
private readonly bool _isLeft;
private ConcatKey([AllowNull] TLeftKey leftKey, [AllowNull] TRightKey rightKey, bool isLeft)
_comparer = comparer;
}
- public int Compare([AllowNull] T x, [AllowNull] T y)
+ public int Compare(T? x, T? y)
{
return _comparer.Compare(y, x);
}
/// <exception cref="System.OperationCanceledException">
/// The query was canceled.
/// </exception>
- [return: MaybeNull]
- public static TSource Min<TSource>(this ParallelQuery<TSource> source)
+ public static TSource? Min<TSource>(this ParallelQuery<TSource> source)
{
if (source == null) throw new ArgumentNullException(nameof(source));
return AggregationMinMaxHelpers<TSource>.ReduceMin(source);
/// <exception cref="System.OperationCanceledException">
/// The query was canceled.
/// </exception>
- [return: MaybeNull]
- public static TResult Min<TSource, TResult>(this ParallelQuery<TSource> source, Func<TSource, TResult> selector)
+ public static TResult? Min<TSource, TResult>(this ParallelQuery<TSource> source, Func<TSource, TResult> selector)
{
return source.Select<TSource, TResult>(selector).Min<TResult>();
}
/// <exception cref="System.OperationCanceledException">
/// The query was canceled.
/// </exception>
- [return: MaybeNull]
- public static TSource Max<TSource>(this ParallelQuery<TSource> source)
+ public static TSource? Max<TSource>(this ParallelQuery<TSource> source)
{
if (source == null) throw new ArgumentNullException(nameof(source));
return AggregationMinMaxHelpers<TSource>.ReduceMax(source);
/// <exception cref="System.OperationCanceledException">
/// The query was canceled.
/// </exception>
- [return: MaybeNull]
- public static TResult Max<TSource, TResult>(this ParallelQuery<TSource> source, Func<TSource, TResult> selector)
+ public static TResult? Max<TSource, TResult>(this ParallelQuery<TSource> source, Func<TSource, TResult> selector)
{
return source.Select<TSource, TResult>(selector).Max<TResult>();
}
// defaultIfEmpty - whether to return a default value (true) or throw an
// exception if the output of the query operator is empty
//
- [return: MaybeNull]
- private static TSource GetOneWithPossibleDefault<TSource>(
+ private static TSource? GetOneWithPossibleDefault<TSource>(
QueryOperator<TSource> queryOp, bool throwIfTwo, bool defaultIfEmpty)
{
Debug.Assert(queryOp != null, "expected query operator");
if (defaultIfEmpty)
{
- return default(TSource)!;
+ return default;
}
else
{
/// <exception cref="System.OperationCanceledException">
/// The query was canceled.
/// </exception>
- [return: MaybeNull]
- public static TSource FirstOrDefault<TSource>(this ParallelQuery<TSource> source)
+ public static TSource? FirstOrDefault<TSource>(this ParallelQuery<TSource> source)
{
if (source == null) throw new ArgumentNullException(nameof(source));
/// <exception cref="System.OperationCanceledException">
/// The query was canceled.
/// </exception>
- [return: MaybeNull]
- public static TSource FirstOrDefault<TSource>(this ParallelQuery<TSource> source, Func<TSource, bool> predicate)
+ public static TSource? FirstOrDefault<TSource>(this ParallelQuery<TSource> source, Func<TSource, bool> predicate)
{
if (source == null) throw new ArgumentNullException(nameof(source));
if (predicate == null) throw new ArgumentNullException(nameof(predicate));
/// <exception cref="System.OperationCanceledException">
/// The query was canceled.
/// </exception>
- [return: MaybeNull]
- public static TSource LastOrDefault<TSource>(this ParallelQuery<TSource> source)
+ public static TSource? LastOrDefault<TSource>(this ParallelQuery<TSource> source)
{
// @PERF: optimize for seekable data sources. E.g. if an array, we can
// seek directly to the last element.
/// <exception cref="System.OperationCanceledException">
/// The query was canceled.
/// </exception>
- [return: MaybeNull]
- public static TSource LastOrDefault<TSource>(this ParallelQuery<TSource> source, Func<TSource, bool> predicate)
+ public static TSource? LastOrDefault<TSource>(this ParallelQuery<TSource> source, Func<TSource, bool> predicate)
{
if (source == null) throw new ArgumentNullException(nameof(source));
if (predicate == null) throw new ArgumentNullException(nameof(predicate));
/// <exception cref="System.OperationCanceledException">
/// The query was canceled.
/// </exception>
- [return: MaybeNull]
- public static TSource SingleOrDefault<TSource>(this ParallelQuery<TSource> source)
+ public static TSource? SingleOrDefault<TSource>(this ParallelQuery<TSource> source)
{
// @PERF: optimize for ICollection-typed data sources, i.e. we can just
// check the Count property and avoid costly fork/join/synchronization.
/// <exception cref="System.OperationCanceledException">
/// The query was canceled.
/// </exception>
- [return: MaybeNull]
- public static TSource SingleOrDefault<TSource>(this ParallelQuery<TSource> source, Func<TSource, bool> predicate)
+ public static TSource? SingleOrDefault<TSource>(this ParallelQuery<TSource> source, Func<TSource, bool> predicate)
{
if (source == null) throw new ArgumentNullException(nameof(source));
if (predicate == null) throw new ArgumentNullException(nameof(predicate));
/// <exception cref="System.ArgumentNullException">
/// <paramref name="source"/> is a null reference (Nothing in Visual Basic).
/// </exception>
- public static ParallelQuery<TSource> DefaultIfEmpty<TSource>(this ParallelQuery<TSource> source)
+ public static ParallelQuery<TSource?> DefaultIfEmpty<TSource>(this ParallelQuery<TSource> source)
{
- return DefaultIfEmpty<TSource>(source, default!);
+ return DefaultIfEmpty<TSource>(source, default!)!;
}
/// <summary>
/// <exception cref="System.OperationCanceledException">
/// The query was canceled.
/// </exception>
- [return: MaybeNull]
- public static TSource ElementAtOrDefault<TSource>(this ParallelQuery<TSource> source, int index)
+ public static TSource? ElementAtOrDefault<TSource>(this ParallelQuery<TSource> source, int index)
{
if (source == null) throw new ArgumentNullException(nameof(source));
}
}
- return default(TSource)!;
+ return default;
}
}
}
public static System.Linq.IQueryable<TSource> DefaultIfEmpty<TSource>(this System.Linq.IQueryable<TSource> source, TSource defaultValue) { throw null; }
public static System.Linq.IQueryable<TSource> Distinct<TSource>(this System.Linq.IQueryable<TSource> source) { throw null; }
public static System.Linq.IQueryable<TSource> Distinct<TSource>(this System.Linq.IQueryable<TSource> source, System.Collections.Generic.IEqualityComparer<TSource>? comparer) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TSource ElementAtOrDefault<TSource>(this System.Linq.IQueryable<TSource> source, int index) { throw null; }
+ public static TSource? ElementAtOrDefault<TSource>(this System.Linq.IQueryable<TSource> source, int index) { throw null; }
public static TSource ElementAt<TSource>(this System.Linq.IQueryable<TSource> source, int index) { throw null; }
public static System.Linq.IQueryable<TSource> Except<TSource>(this System.Linq.IQueryable<TSource> source1, System.Collections.Generic.IEnumerable<TSource> source2) { throw null; }
public static System.Linq.IQueryable<TSource> Except<TSource>(this System.Linq.IQueryable<TSource> source1, System.Collections.Generic.IEnumerable<TSource> source2, System.Collections.Generic.IEqualityComparer<TSource>? comparer) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TSource FirstOrDefault<TSource>(this System.Linq.IQueryable<TSource> source) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TSource FirstOrDefault<TSource>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<System.Func<TSource, bool>> predicate) { throw null; }
+ public static TSource? FirstOrDefault<TSource>(this System.Linq.IQueryable<TSource> source) { throw null; }
+ public static TSource? FirstOrDefault<TSource>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<System.Func<TSource, bool>> predicate) { throw null; }
public static TSource First<TSource>(this System.Linq.IQueryable<TSource> source) { throw null; }
public static TSource First<TSource>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<System.Func<TSource, bool>> predicate) { throw null; }
public static System.Linq.IQueryable<System.Linq.IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<System.Func<TSource, TKey>> keySelector) { throw null; }
public static System.Linq.IQueryable<TSource> Intersect<TSource>(this System.Linq.IQueryable<TSource> source1, System.Collections.Generic.IEnumerable<TSource> source2, System.Collections.Generic.IEqualityComparer<TSource>? comparer) { throw null; }
public static System.Linq.IQueryable<TResult> Join<TOuter, TInner, TKey, TResult>(this System.Linq.IQueryable<TOuter> outer, System.Collections.Generic.IEnumerable<TInner> inner, System.Linq.Expressions.Expression<System.Func<TOuter, TKey>> outerKeySelector, System.Linq.Expressions.Expression<System.Func<TInner, TKey>> innerKeySelector, System.Linq.Expressions.Expression<System.Func<TOuter, TInner, TResult>> resultSelector) { throw null; }
public static System.Linq.IQueryable<TResult> Join<TOuter, TInner, TKey, TResult>(this System.Linq.IQueryable<TOuter> outer, System.Collections.Generic.IEnumerable<TInner> inner, System.Linq.Expressions.Expression<System.Func<TOuter, TKey>> outerKeySelector, System.Linq.Expressions.Expression<System.Func<TInner, TKey>> innerKeySelector, System.Linq.Expressions.Expression<System.Func<TOuter, TInner, TResult>> resultSelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TSource LastOrDefault<TSource>(this System.Linq.IQueryable<TSource> source) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TSource LastOrDefault<TSource>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<System.Func<TSource, bool>> predicate) { throw null; }
+ public static TSource? LastOrDefault<TSource>(this System.Linq.IQueryable<TSource> source) { throw null; }
+ public static TSource? LastOrDefault<TSource>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<System.Func<TSource, bool>> predicate) { throw null; }
public static TSource Last<TSource>(this System.Linq.IQueryable<TSource> source) { throw null; }
public static TSource Last<TSource>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<System.Func<TSource, bool>> predicate) { throw null; }
public static long LongCount<TSource>(this System.Linq.IQueryable<TSource> source) { throw null; }
public static long LongCount<TSource>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<System.Func<TSource, bool>> predicate) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TSource Max<TSource>(this System.Linq.IQueryable<TSource> source) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TResult Max<TSource, TResult>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<System.Func<TSource, TResult>> selector) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TSource Min<TSource>(this System.Linq.IQueryable<TSource> source) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TResult Min<TSource, TResult>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<System.Func<TSource, TResult>> selector) { throw null; }
+ public static TSource? Max<TSource>(this System.Linq.IQueryable<TSource> source) { throw null; }
+ public static TResult? Max<TSource, TResult>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<System.Func<TSource, TResult>> selector) { throw null; }
+ public static TSource? Min<TSource>(this System.Linq.IQueryable<TSource> source) { throw null; }
+ public static TResult? Min<TSource, TResult>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<System.Func<TSource, TResult>> selector) { throw null; }
public static System.Linq.IQueryable<TResult> OfType<TResult>(this System.Linq.IQueryable source) { throw null; }
public static System.Linq.IOrderedQueryable<TSource> OrderByDescending<TSource, TKey>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<System.Func<TSource, TKey>> keySelector) { throw null; }
public static System.Linq.IOrderedQueryable<TSource> OrderByDescending<TSource, TKey>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<System.Func<TSource, TKey>> keySelector, System.Collections.Generic.IComparer<TKey>? comparer) { throw null; }
public static System.Linq.IQueryable<TResult> Select<TSource, TResult>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<System.Func<TSource, TResult>> selector) { throw null; }
public static bool SequenceEqual<TSource>(this System.Linq.IQueryable<TSource> source1, System.Collections.Generic.IEnumerable<TSource> source2) { throw null; }
public static bool SequenceEqual<TSource>(this System.Linq.IQueryable<TSource> source1, System.Collections.Generic.IEnumerable<TSource> source2, System.Collections.Generic.IEqualityComparer<TSource>? comparer) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TSource SingleOrDefault<TSource>(this System.Linq.IQueryable<TSource> source) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TSource SingleOrDefault<TSource>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<System.Func<TSource, bool>> predicate) { throw null; }
+ public static TSource? SingleOrDefault<TSource>(this System.Linq.IQueryable<TSource> source) { throw null; }
+ public static TSource? SingleOrDefault<TSource>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<System.Func<TSource, bool>> predicate) { throw null; }
public static TSource Single<TSource>(this System.Linq.IQueryable<TSource> source) { throw null; }
public static TSource Single<TSource>(this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<System.Func<TSource, bool>> predicate) { throw null; }
public static System.Linq.IQueryable<TSource> SkipLast<TSource>(this System.Linq.IQueryable<TSource> source, int count) { throw null; }
public static MethodInfo ElementAtOrDefault_TSource_2(Type TSource) =>
(s_ElementAtOrDefault_TSource_2 ??
- (s_ElementAtOrDefault_TSource_2 = new Func<IQueryable<object>, int, object>(Queryable.ElementAtOrDefault).GetMethodInfo().GetGenericMethodDefinition()))
+ (s_ElementAtOrDefault_TSource_2 = new Func<IQueryable<object>, int, object?>(Queryable.ElementAtOrDefault).GetMethodInfo().GetGenericMethodDefinition()))
.MakeGenericMethod(TSource);
private static MethodInfo? s_Except_TSource_2;
public static MethodInfo FirstOrDefault_TSource_1(Type TSource) =>
(s_FirstOrDefault_TSource_1 ??
- (s_FirstOrDefault_TSource_1 = new Func<IQueryable<object>, object>(Queryable.FirstOrDefault).GetMethodInfo().GetGenericMethodDefinition()))
+ (s_FirstOrDefault_TSource_1 = new Func<IQueryable<object>, object?>(Queryable.FirstOrDefault).GetMethodInfo().GetGenericMethodDefinition()))
.MakeGenericMethod(TSource);
private static MethodInfo? s_FirstOrDefault_TSource_2;
public static MethodInfo FirstOrDefault_TSource_2(Type TSource) =>
(s_FirstOrDefault_TSource_2 ??
- (s_FirstOrDefault_TSource_2 = new Func<IQueryable<object>, Expression<Func<object, bool>>, object>(Queryable.FirstOrDefault).GetMethodInfo().GetGenericMethodDefinition()))
+ (s_FirstOrDefault_TSource_2 = new Func<IQueryable<object>, Expression<Func<object, bool>>, object?>(Queryable.FirstOrDefault).GetMethodInfo().GetGenericMethodDefinition()))
.MakeGenericMethod(TSource);
private static MethodInfo? s_GroupBy_TSource_TKey_2;
public static MethodInfo LastOrDefault_TSource_1(Type TSource) =>
(s_LastOrDefault_TSource_1 ??
- (s_LastOrDefault_TSource_1 = new Func<IQueryable<object>, object>(Queryable.LastOrDefault).GetMethodInfo().GetGenericMethodDefinition()))
+ (s_LastOrDefault_TSource_1 = new Func<IQueryable<object>, object?>(Queryable.LastOrDefault).GetMethodInfo().GetGenericMethodDefinition()))
.MakeGenericMethod(TSource);
private static MethodInfo? s_LastOrDefault_TSource_2;
public static MethodInfo LastOrDefault_TSource_2(Type TSource) =>
(s_LastOrDefault_TSource_2 ??
- (s_LastOrDefault_TSource_2 = new Func<IQueryable<object>, Expression<Func<object, bool>>, object>(Queryable.LastOrDefault).GetMethodInfo().GetGenericMethodDefinition()))
+ (s_LastOrDefault_TSource_2 = new Func<IQueryable<object>, Expression<Func<object, bool>>, object?>(Queryable.LastOrDefault).GetMethodInfo().GetGenericMethodDefinition()))
.MakeGenericMethod(TSource);
private static MethodInfo? s_LongCount_TSource_1;
public static MethodInfo Max_TSource_1(Type TSource) =>
(s_Max_TSource_1 ??
- (s_Max_TSource_1 = new Func<IQueryable<object>, object>(Queryable.Max).GetMethodInfo().GetGenericMethodDefinition()))
+ (s_Max_TSource_1 = new Func<IQueryable<object>, object?>(Queryable.Max).GetMethodInfo().GetGenericMethodDefinition()))
.MakeGenericMethod(TSource);
private static MethodInfo? s_Max_TSource_TResult_2;
public static MethodInfo Max_TSource_TResult_2(Type TSource, Type TResult) =>
(s_Max_TSource_TResult_2 ??
- (s_Max_TSource_TResult_2 = new Func<IQueryable<object>, Expression<Func<object, object>>, object>(Queryable.Max).GetMethodInfo().GetGenericMethodDefinition()))
+ (s_Max_TSource_TResult_2 = new Func<IQueryable<object>, Expression<Func<object, object>>, object?>(Queryable.Max).GetMethodInfo().GetGenericMethodDefinition()))
.MakeGenericMethod(TSource, TResult);
private static MethodInfo? s_Min_TSource_1;
public static MethodInfo Min_TSource_1(Type TSource) =>
(s_Min_TSource_1 ??
- (s_Min_TSource_1 = new Func<IQueryable<object>, object>(Queryable.Min).GetMethodInfo().GetGenericMethodDefinition()))
+ (s_Min_TSource_1 = new Func<IQueryable<object>, object?>(Queryable.Min).GetMethodInfo().GetGenericMethodDefinition()))
.MakeGenericMethod(TSource);
private static MethodInfo? s_Min_TSource_TResult_2;
public static MethodInfo Min_TSource_TResult_2(Type TSource, Type TResult) =>
(s_Min_TSource_TResult_2 ??
- (s_Min_TSource_TResult_2 = new Func<IQueryable<object>, Expression<Func<object, object>>, object>(Queryable.Min).GetMethodInfo().GetGenericMethodDefinition()))
+ (s_Min_TSource_TResult_2 = new Func<IQueryable<object>, Expression<Func<object, object>>, object?>(Queryable.Min).GetMethodInfo().GetGenericMethodDefinition()))
.MakeGenericMethod(TSource, TResult);
private static MethodInfo? s_OfType_TResult_1;
public static MethodInfo SingleOrDefault_TSource_1(Type TSource) =>
(s_SingleOrDefault_TSource_1 ??
- (s_SingleOrDefault_TSource_1 = new Func<IQueryable<object>, object>(Queryable.SingleOrDefault).GetMethodInfo().GetGenericMethodDefinition()))
+ (s_SingleOrDefault_TSource_1 = new Func<IQueryable<object>, object?>(Queryable.SingleOrDefault).GetMethodInfo().GetGenericMethodDefinition()))
.MakeGenericMethod(TSource);
private static MethodInfo? s_SingleOrDefault_TSource_2;
public static MethodInfo SingleOrDefault_TSource_2(Type TSource) =>
(s_SingleOrDefault_TSource_2 ??
- (s_SingleOrDefault_TSource_2 = new Func<IQueryable<object>, Expression<Func<object, bool>>, object>(Queryable.SingleOrDefault).GetMethodInfo().GetGenericMethodDefinition()))
+ (s_SingleOrDefault_TSource_2 = new Func<IQueryable<object>, Expression<Func<object, bool>>, object?>(Queryable.SingleOrDefault).GetMethodInfo().GetGenericMethodDefinition()))
.MakeGenericMethod(TSource);
private static MethodInfo? s_Skip_TSource_2;
));
}
- [return: MaybeNull]
- public static TSource FirstOrDefault<TSource>(this IQueryable<TSource> source)
+ public static TSource? FirstOrDefault<TSource>(this IQueryable<TSource> source)
{
if (source == null)
throw Error.ArgumentNull(nameof(source));
CachedReflectionInfo.FirstOrDefault_TSource_1(typeof(TSource)), source.Expression));
}
- [return: MaybeNull]
- public static TSource FirstOrDefault<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
+ public static TSource? FirstOrDefault<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
{
if (source == null)
throw Error.ArgumentNull(nameof(source));
));
}
- [return: MaybeNull]
- public static TSource LastOrDefault<TSource>(this IQueryable<TSource> source)
+ public static TSource? LastOrDefault<TSource>(this IQueryable<TSource> source)
{
if (source == null)
throw Error.ArgumentNull(nameof(source));
CachedReflectionInfo.LastOrDefault_TSource_1(typeof(TSource)), source.Expression));
}
- [return: MaybeNull]
- public static TSource LastOrDefault<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
+ public static TSource? LastOrDefault<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
{
if (source == null)
throw Error.ArgumentNull(nameof(source));
));
}
- [return: MaybeNull]
- public static TSource SingleOrDefault<TSource>(this IQueryable<TSource> source)
+ public static TSource? SingleOrDefault<TSource>(this IQueryable<TSource> source)
{
if (source == null)
throw Error.ArgumentNull(nameof(source));
CachedReflectionInfo.SingleOrDefault_TSource_1(typeof(TSource)), source.Expression));
}
- [return: MaybeNull]
- public static TSource SingleOrDefault<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
+ public static TSource? SingleOrDefault<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>> predicate)
{
if (source == null)
throw Error.ArgumentNull(nameof(source));
));
}
- [return: MaybeNull]
- public static TSource ElementAtOrDefault<TSource>(this IQueryable<TSource> source, int index)
+ public static TSource? ElementAtOrDefault<TSource>(this IQueryable<TSource> source, int index)
{
if (source == null)
throw Error.ArgumentNull(nameof(source));
));
}
- [return: MaybeNull]
- public static TSource Min<TSource>(this IQueryable<TSource> source)
+ public static TSource? Min<TSource>(this IQueryable<TSource> source)
{
if (source == null)
throw Error.ArgumentNull(nameof(source));
CachedReflectionInfo.Min_TSource_1(typeof(TSource)), source.Expression));
}
- [return: MaybeNull]
- public static TResult Min<TSource, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, TResult>> selector)
+ public static TResult? Min<TSource, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, TResult>> selector)
{
if (source == null)
throw Error.ArgumentNull(nameof(source));
));
}
- [return: MaybeNull]
- public static TSource Max<TSource>(this IQueryable<TSource> source)
+ public static TSource? Max<TSource>(this IQueryable<TSource> source)
{
if (source == null)
throw Error.ArgumentNull(nameof(source));
CachedReflectionInfo.Max_TSource_1(typeof(TSource)), source.Expression));
}
- [return: MaybeNull]
- public static TResult Max<TSource, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, TResult>> selector)
+ public static TResult? Max<TSource, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, TResult>> selector)
{
if (source == null)
throw Error.ArgumentNull(nameof(source));
public static bool Contains<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, TSource value, System.Collections.Generic.IEqualityComparer<TSource>? comparer) { throw null; }
public static int Count<TSource>(this System.Collections.Generic.IEnumerable<TSource> source) { throw null; }
public static int Count<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
- public static System.Collections.Generic.IEnumerable<TSource> DefaultIfEmpty<TSource>(this System.Collections.Generic.IEnumerable<TSource> source) { throw null; }
+ public static System.Collections.Generic.IEnumerable<TSource?> DefaultIfEmpty<TSource>(this System.Collections.Generic.IEnumerable<TSource> source) { throw null; }
public static System.Collections.Generic.IEnumerable<TSource> DefaultIfEmpty<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, TSource defaultValue) { throw null; }
public static System.Collections.Generic.IEnumerable<TSource> Distinct<TSource>(this System.Collections.Generic.IEnumerable<TSource> source) { throw null; }
public static System.Collections.Generic.IEnumerable<TSource> Distinct<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Collections.Generic.IEqualityComparer<TSource>? comparer) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute] public static TSource ElementAtOrDefault<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, int index) { throw null; }
+ public static TSource? ElementAtOrDefault<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, int index) { throw null; }
public static TSource ElementAt<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, int index) { throw null; }
public static System.Collections.Generic.IEnumerable<TResult> Empty<TResult>() { throw null; }
public static System.Collections.Generic.IEnumerable<TSource> Except<TSource>(this System.Collections.Generic.IEnumerable<TSource> first, System.Collections.Generic.IEnumerable<TSource> second) { throw null; }
public static System.Collections.Generic.IEnumerable<TSource> Except<TSource>(this System.Collections.Generic.IEnumerable<TSource> first, System.Collections.Generic.IEnumerable<TSource> second, System.Collections.Generic.IEqualityComparer<TSource>? comparer) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute] public static TSource FirstOrDefault<TSource>(this System.Collections.Generic.IEnumerable<TSource> source) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute] public static TSource FirstOrDefault<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
+ public static TSource? FirstOrDefault<TSource>(this System.Collections.Generic.IEnumerable<TSource> source) { throw null; }
+ public static TSource? FirstOrDefault<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
public static TSource First<TSource>(this System.Collections.Generic.IEnumerable<TSource> source) { throw null; }
public static TSource First<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
public static System.Collections.Generic.IEnumerable<System.Linq.IGrouping<TKey, TSource>> GroupBy<TSource, TKey>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, TKey> keySelector) { throw null; }
public static System.Collections.Generic.IEnumerable<TSource> Intersect<TSource>(this System.Collections.Generic.IEnumerable<TSource> first, System.Collections.Generic.IEnumerable<TSource> second, System.Collections.Generic.IEqualityComparer<TSource>? comparer) { throw null; }
public static System.Collections.Generic.IEnumerable<TResult> Join<TOuter, TInner, TKey, TResult>(this System.Collections.Generic.IEnumerable<TOuter> outer, System.Collections.Generic.IEnumerable<TInner> inner, System.Func<TOuter, TKey> outerKeySelector, System.Func<TInner, TKey> innerKeySelector, System.Func<TOuter, TInner, TResult> resultSelector) { throw null; }
public static System.Collections.Generic.IEnumerable<TResult> Join<TOuter, TInner, TKey, TResult>(this System.Collections.Generic.IEnumerable<TOuter> outer, System.Collections.Generic.IEnumerable<TInner> inner, System.Func<TOuter, TKey> outerKeySelector, System.Func<TInner, TKey> innerKeySelector, System.Func<TOuter, TInner, TResult> resultSelector, System.Collections.Generic.IEqualityComparer<TKey>? comparer) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute] public static TSource LastOrDefault<TSource>(this System.Collections.Generic.IEnumerable<TSource> source) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute] public static TSource LastOrDefault<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
+ public static TSource? LastOrDefault<TSource>(this System.Collections.Generic.IEnumerable<TSource> source) { throw null; }
+ public static TSource? LastOrDefault<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
public static TSource Last<TSource>(this System.Collections.Generic.IEnumerable<TSource> source) { throw null; }
public static TSource Last<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
public static long LongCount<TSource>(this System.Collections.Generic.IEnumerable<TSource> source) { throw null; }
public static long? Max(this System.Collections.Generic.IEnumerable<long?> source) { throw null; }
public static float? Max(this System.Collections.Generic.IEnumerable<float?> source) { throw null; }
public static float Max(this System.Collections.Generic.IEnumerable<float> source) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute] public static TSource Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source) { throw null; }
+ public static TSource? Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source) { throw null; }
public static decimal Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, decimal> selector) { throw null; }
public static double Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, double> selector) { throw null; }
public static int Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, int> selector) { throw null; }
public static long? Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, long?> selector) { throw null; }
public static float? Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, float?> selector) { throw null; }
public static float Max<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, float> selector) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute] public static TResult Max<TSource, TResult>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, TResult> selector) { throw null; }
+ public static TResult? Max<TSource, TResult>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, TResult> selector) { throw null; }
public static decimal Min(this System.Collections.Generic.IEnumerable<decimal> source) { throw null; }
public static double Min(this System.Collections.Generic.IEnumerable<double> source) { throw null; }
public static int Min(this System.Collections.Generic.IEnumerable<int> source) { throw null; }
public static long? Min(this System.Collections.Generic.IEnumerable<long?> source) { throw null; }
public static float? Min(this System.Collections.Generic.IEnumerable<float?> source) { throw null; }
public static float Min(this System.Collections.Generic.IEnumerable<float> source) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute] public static TSource Min<TSource>(this System.Collections.Generic.IEnumerable<TSource> source) { throw null; }
+ public static TSource? Min<TSource>(this System.Collections.Generic.IEnumerable<TSource> source) { throw null; }
public static decimal Min<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, decimal> selector) { throw null; }
public static double Min<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, double> selector) { throw null; }
public static int Min<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, int> selector) { throw null; }
public static long? Min<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, long?> selector) { throw null; }
public static float? Min<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, float?> selector) { throw null; }
public static float Min<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, float> selector) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute] public static TResult Min<TSource, TResult>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, TResult> selector) { throw null; }
+ public static TResult? Min<TSource, TResult>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, TResult> selector) { throw null; }
public static System.Collections.Generic.IEnumerable<TResult> OfType<TResult>(this System.Collections.IEnumerable source) { throw null; }
public static System.Linq.IOrderedEnumerable<TSource> OrderByDescending<TSource, TKey>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, TKey> keySelector) { throw null; }
public static System.Linq.IOrderedEnumerable<TSource> OrderByDescending<TSource, TKey>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, TKey> keySelector, System.Collections.Generic.IComparer<TKey>? comparer) { throw null; }
public static System.Collections.Generic.IEnumerable<TResult> Select<TSource, TResult>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, TResult> selector) { throw null; }
public static bool SequenceEqual<TSource>(this System.Collections.Generic.IEnumerable<TSource> first, System.Collections.Generic.IEnumerable<TSource> second) { throw null; }
public static bool SequenceEqual<TSource>(this System.Collections.Generic.IEnumerable<TSource> first, System.Collections.Generic.IEnumerable<TSource> second, System.Collections.Generic.IEqualityComparer<TSource>? comparer) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute] public static TSource SingleOrDefault<TSource>(this System.Collections.Generic.IEnumerable<TSource> source) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute] public static TSource SingleOrDefault<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
+ public static TSource? SingleOrDefault<TSource>(this System.Collections.Generic.IEnumerable<TSource> source) { throw null; }
+ public static TSource? SingleOrDefault<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
public static TSource Single<TSource>(this System.Collections.Generic.IEnumerable<TSource> source) { throw null; }
public static TSource Single<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, System.Func<TSource, bool> predicate) { throw null; }
public static System.Collections.Generic.IEnumerable<TSource> SkipLast<TSource>(this System.Collections.Generic.IEnumerable<TSource> source, int count) { throw null; }
{
public static partial class Enumerable
{
- public static IEnumerable<TSource> DefaultIfEmpty<TSource>(this IEnumerable<TSource> source) =>
+ public static IEnumerable<TSource?> DefaultIfEmpty<TSource>(this IEnumerable<TSource> source) =>
DefaultIfEmpty(source, default!);
public static IEnumerable<TSource> DefaultIfEmpty<TSource>(this IEnumerable<TSource> source, TSource defaultValue)
return default;
}
- [return: MaybeNull]
- public static TSource ElementAtOrDefault<TSource>(this IEnumerable<TSource> source, int index)
+ public static TSource? ElementAtOrDefault<TSource>(this IEnumerable<TSource> source, int index)
{
if (source == null)
{
}
}
- return default!;
+ return default;
}
}
}
return first!;
}
- [return: MaybeNull]
- public static TSource FirstOrDefault<TSource>(this IEnumerable<TSource> source) =>
+ public static TSource? FirstOrDefault<TSource>(this IEnumerable<TSource> source) =>
source.TryGetFirst(out bool _);
- [return: MaybeNull]
- public static TSource FirstOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) =>
+ public static TSource? FirstOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) =>
source.TryGetFirst(predicate, out bool _);
- [return: MaybeNull]
- private static TSource TryGetFirst<TSource>(this IEnumerable<TSource> source, out bool found)
+ private static TSource? TryGetFirst<TSource>(this IEnumerable<TSource> source, out bool found)
{
if (source == null)
{
}
found = false;
- return default!;
+ return default;
}
- [return: MaybeNull]
- private static TSource TryGetFirst<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate, out bool found)
+ private static TSource? TryGetFirst<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate, out bool found)
{
if (source == null)
{
}
found = false;
- return default!;
+ return default;
}
}
}
/// <param name="index">The 0-based index to access.</param>
/// <param name="found"><c>true</c> if the sequence contains an element at that index, <c>false</c> otherwise.</param>
/// <returns>The element if <paramref name="found"/> is <c>true</c>, otherwise, the default value of <typeparamref name="TElement"/>.</returns>
- [return: MaybeNull]
- TElement TryGetElementAt(int index, out bool found);
+ TElement? TryGetElementAt(int index, out bool found);
/// <summary>
/// Gets the first item in this sequence.
/// </summary>
/// <param name="found"><c>true</c> if the sequence contains an element, <c>false</c> otherwise.</param>
/// <returns>The element if <paramref name="found"/> is <c>true</c>, otherwise, the default value of <typeparamref name="TElement"/>.</returns>
- [return: MaybeNull]
- TElement TryGetFirst(out bool found);
+ TElement? TryGetFirst(out bool found);
/// <summary>
/// Gets the last item in this sequence.
/// </summary>
/// <param name="found"><c>true</c> if the sequence contains an element, <c>false</c> otherwise.</param>
/// <returns>The element if <paramref name="found"/> is <c>true</c>, otherwise, the default value of <typeparamref name="TElement"/>.</returns>
- [return: MaybeNull]
- TElement TryGetLast(out bool found);
+ TElement? TryGetLast(out bool found);
}
}
return last!;
}
- [return: MaybeNull]
- public static TSource LastOrDefault<TSource>(this IEnumerable<TSource> source) =>
+ public static TSource? LastOrDefault<TSource>(this IEnumerable<TSource> source) =>
source.TryGetLast(out bool _);
- [return: MaybeNull]
- public static TSource LastOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) =>
+ public static TSource? LastOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate) =>
source.TryGetLast(predicate, out bool _);
- [return: MaybeNull]
- private static TSource TryGetLast<TSource>(this IEnumerable<TSource> source, out bool found)
+ private static TSource? TryGetLast<TSource>(this IEnumerable<TSource> source, out bool found)
{
if (source == null)
{
}
found = false;
- return default!;
+ return default;
}
- [return: MaybeNull]
- private static TSource TryGetLast<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate, out bool found)
+ private static TSource? TryGetLast<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate, out bool found)
{
if (source == null)
{
}
found = false;
- return default!;
+ return default;
}
}
}
return value;
}
- [return: MaybeNull]
- public static TSource Max<TSource>(this IEnumerable<TSource> source)
+ public static TSource? Max<TSource>(this IEnumerable<TSource> source)
{
if (source == null)
{
}
Comparer<TSource> comparer = Comparer<TSource>.Default;
- TSource value = default!;
+ TSource? value = default;
if (value == null)
{
using (IEnumerator<TSource> e = source.GetEnumerator())
return value;
}
- [return: MaybeNull]
- public static TResult Max<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
+ public static TResult? Max<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
{
if (source == null)
{
}
Comparer<TResult> comparer = Comparer<TResult>.Default;
- TResult value = default!;
+ TResult? value = default;
if (value == null)
{
using (IEnumerator<TSource> e = source.GetEnumerator())
return value;
}
- [return: MaybeNull]
- public static TSource Min<TSource>(this IEnumerable<TSource> source)
+ public static TSource? Min<TSource>(this IEnumerable<TSource> source)
{
if (source == null)
{
}
Comparer<TSource> comparer = Comparer<TSource>.Default;
- TSource value = default!;
+ TSource? value = default;
if (value == null)
{
using (IEnumerator<TSource> e = source.GetEnumerator())
return value;
}
- [return: MaybeNull]
- public static TResult Min<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
+ public static TResult? Min<TSource, TResult>(this IEnumerable<TSource> source, Func<TSource, TResult> selector)
{
if (source == null)
{
}
Comparer<TResult> comparer = Comparer<TResult>.Default;
- TResult value = default!;
+ TResult? value = default;
if (value == null)
{
using (IEnumerator<TSource> e = source.GetEnumerator())
public IPartition<TElement> Take(int count) => new OrderedPartition<TElement>(this, 0, count - 1);
- [return: MaybeNull]
- public TElement TryGetElementAt(int index, out bool found)
+ public TElement? TryGetElementAt(int index, out bool found)
{
if (index == 0)
{
}
found = false;
- return default!;
+ return default;
}
- [return: MaybeNull]
- public TElement TryGetFirst(out bool found)
+ public TElement? TryGetFirst(out bool found)
{
CachingComparer<TElement> comparer = GetComparer();
using (IEnumerator<TElement> e = _source.GetEnumerator())
if (!e.MoveNext())
{
found = false;
- return default!;
+ return default;
}
TElement value = e.Current;
}
}
- [return: MaybeNull]
- public TElement TryGetLast(out bool found)
+ public TElement? TryGetLast(out bool found)
{
using (IEnumerator<TElement> e = _source.GetEnumerator())
{
if (!e.MoveNext())
{
found = false;
- return default!;
+ return default;
}
CachingComparer<TElement> comparer = GetComparer();
}
}
- [return: MaybeNull]
- public TElement TryGetLast(int minIdx, int maxIdx, out bool found)
+ public TElement? TryGetLast(int minIdx, int maxIdx, out bool found)
{
Buffer<TElement> buffer = new Buffer<TElement>(_source);
int count = buffer._count;
if (minIdx >= count)
{
found = false;
- return default!;
+ return default;
}
found = true;
IOrderedEnumerable<TElement> IOrderedEnumerable<TElement>.CreateOrderedEnumerable<TKey>(Func<TElement, TKey> keySelector, IComparer<TKey>? comparer, bool descending) =>
new OrderedEnumerable<TElement, TKey>(_source, keySelector, comparer, @descending, this);
- [return: MaybeNull]
- public TElement TryGetLast(Func<TElement, bool> predicate, out bool found)
+ public TElement? TryGetLast(Func<TElement, bool> predicate, out bool found)
{
CachingComparer<TElement> comparer = GetComparer();
using (IEnumerator<TElement> e = _source.GetEnumerator())
if (!e.MoveNext())
{
found = false;
- return default!;
+ return default;
}
value = e.Current;
protected readonly Func<TElement, TKey> _keySelector;
protected readonly IComparer<TKey> _comparer;
protected readonly bool _descending;
- [MaybeNull] protected TKey _lastKey = default!;
+ protected TKey? _lastKey;
public CachingComparer(Func<TElement, TKey> keySelector, IComparer<TKey> comparer, bool descending)
{
public TElement Current => default!;
[ExcludeFromCodeCoverage(Justification = "Shouldn't be called, and as undefined can return or throw anything anyway")]
- [MaybeNull]
object IEnumerator.Current => default!;
void IEnumerator.Reset()
public IPartition<TElement> Take(int count) => this;
- [return: MaybeNull]
- public TElement TryGetElementAt(int index, out bool found)
+ public TElement? TryGetElementAt(int index, out bool found)
{
found = false;
- return default!;
+ return default;
}
- [return: MaybeNull]
- public TElement TryGetFirst(out bool found)
+ public TElement? TryGetFirst(out bool found)
{
found = false;
- return default!;
+ return default;
}
- [return: MaybeNull]
- public TElement TryGetLast(out bool found)
+ public TElement? TryGetLast(out bool found)
{
found = false;
- return default!;
+ return default;
}
public TElement[] ToArray() => Array.Empty<TElement>();
return new OrderedPartition<TElement>(_source, _minIndexInclusive, maxIndex);
}
- [return: MaybeNull]
- public TElement TryGetElementAt(int index, out bool found)
+ public TElement? TryGetElementAt(int index, out bool found)
{
if (unchecked((uint)index <= (uint)(_maxIndexInclusive - _minIndexInclusive)))
{
}
found = false;
- return default!;
+ return default;
}
- [return: MaybeNull]
- public TElement TryGetFirst(out bool found) => _source.TryGetElementAt(_minIndexInclusive, out found);
+ public TElement? TryGetFirst(out bool found) => _source.TryGetElementAt(_minIndexInclusive, out found);
- [return: MaybeNull]
- public TElement TryGetLast(out bool found) =>
+ public TElement? TryGetLast(out bool found) =>
_source.TryGetLast(_minIndexInclusive, _maxIndexInclusive, out found);
public TElement[] ToArray() => _source.ToArray(_minIndexInclusive, _maxIndexInclusive);
return unchecked((uint)maxIndex >= (uint)_maxIndexInclusive) ? this : new ListPartition<TSource>(_source, _minIndexInclusive, maxIndex);
}
- [return: MaybeNull]
- public TSource TryGetElementAt(int index, out bool found)
+ public TSource? TryGetElementAt(int index, out bool found)
{
if (unchecked((uint)index <= (uint)(_maxIndexInclusive - _minIndexInclusive) && index < _source.Count - _minIndexInclusive))
{
}
found = false;
- return default!;
+ return default;
}
- [return: MaybeNull]
- public TSource TryGetFirst(out bool found)
+ public TSource? TryGetFirst(out bool found)
{
if (_source.Count > _minIndexInclusive)
{
}
found = false;
- return default!;
+ return default;
}
- [return: MaybeNull]
- public TSource TryGetLast(out bool found)
+ public TSource? TryGetLast(out bool found)
{
int lastIndex = _source.Count - 1;
if (lastIndex >= _minIndexInclusive)
}
found = false;
- return default!;
+ return default;
}
private int Count
return new EnumerablePartition<TSource>(_source, _minIndexInclusive, maxIndex);
}
- [return: MaybeNull]
- public TSource TryGetElementAt(int index, out bool found)
+ public TSource? TryGetElementAt(int index, out bool found)
{
// If the index is negative or >= our max count, return early.
if (index >= 0 && (!HasLimit || index < Limit))
}
found = false;
- return default!;
+ return default;
}
- [return: MaybeNull]
- public TSource TryGetFirst(out bool found)
+ public TSource? TryGetFirst(out bool found)
{
using (IEnumerator<TSource> en = _source.GetEnumerator())
{
}
found = false;
- return default!;
+ return default;
}
- [return: MaybeNull]
- public TSource TryGetLast(out bool found)
+ public TSource? TryGetLast(out bool found)
{
using (IEnumerator<TSource> en = _source.GetEnumerator())
{
}
found = false;
- return default!;
+ return default;
}
public TSource[] ToArray()
return new RepeatIterator<TResult>(_current, count);
}
- [return: MaybeNull]
- public TResult TryGetElementAt(int index, out bool found)
+ public TResult? TryGetElementAt(int index, out bool found)
{
if ((uint)index < (uint)_count)
{
}
found = false;
- return default!;
+ return default;
}
public TResult TryGetFirst(out bool found)
new SelectListPartitionIterator<TSource, TResult>(_source, _selector, 0, count - 1);
}
- [return: MaybeNull]
- public TResult TryGetElementAt(int index, out bool found)
+ public TResult? TryGetElementAt(int index, out bool found)
{
if (unchecked((uint)index < (uint)_source.Length))
{
}
found = false;
- return default!;
+ return default;
}
public TResult TryGetFirst(out bool found)
return new SelectRangeIterator<TResult>(_start, _start + count, _selector);
}
- [return: MaybeNull]
- public TResult TryGetElementAt(int index, out bool found)
+ public TResult? TryGetElementAt(int index, out bool found)
{
if ((uint)index < (uint)(_end - _start))
{
}
found = false;
- return default!;
+ return default;
}
public TResult TryGetFirst(out bool found)
return new SelectListPartitionIterator<TSource, TResult>(_source, _selector, 0, count - 1);
}
- [return: MaybeNull]
- public TResult TryGetElementAt(int index, out bool found)
+ public TResult? TryGetElementAt(int index, out bool found)
{
if (unchecked((uint)index < (uint)_source.Count))
{
}
found = false;
- return default!;
+ return default;
}
- [return: MaybeNull]
- public TResult TryGetFirst(out bool found)
+ public TResult? TryGetFirst(out bool found)
{
if (_source.Count != 0)
{
}
found = false;
- return default!;
+ return default;
}
- [return: MaybeNull]
- public TResult TryGetLast(out bool found)
+ public TResult? TryGetLast(out bool found)
{
int len = _source.Count;
if (len != 0)
}
found = false;
- return default!;
+ return default;
}
}
return new SelectListPartitionIterator<TSource, TResult>(_source, _selector, 0, count - 1);
}
- [return: MaybeNull]
- public TResult TryGetElementAt(int index, out bool found)
+ public TResult? TryGetElementAt(int index, out bool found)
{
if (unchecked((uint)index < (uint)_source.Count))
{
}
found = false;
- return default!;
+ return default;
}
- [return: MaybeNull]
- public TResult TryGetFirst(out bool found)
+ public TResult? TryGetFirst(out bool found)
{
if (_source.Count != 0)
{
}
found = false;
- return default!;
+ return default;
}
- [return: MaybeNull]
- public TResult TryGetLast(out bool found)
+ public TResult? TryGetLast(out bool found)
{
int len = _source.Count;
if (len != 0)
}
found = false;
- return default!;
+ return default;
}
}
return new SelectIPartitionIterator<TSource, TResult>(_source.Take(count), _selector);
}
- [return: MaybeNull]
- public TResult TryGetElementAt(int index, out bool found)
+ public TResult? TryGetElementAt(int index, out bool found)
{
bool sourceFound;
TSource input = _source.TryGetElementAt(index, out sourceFound);
return sourceFound ? _selector(input!) : default!;
}
- [return: MaybeNull]
- public TResult TryGetFirst(out bool found)
+ public TResult? TryGetFirst(out bool found)
{
bool sourceFound;
TSource input = _source.TryGetFirst(out sourceFound);
return sourceFound ? _selector(input!) : default!;
}
- [return: MaybeNull]
- public TResult TryGetLast(out bool found)
+ public TResult? TryGetLast(out bool found)
{
bool sourceFound;
TSource input = _source.TryGetLast(out sourceFound);
return (uint)maxIndex >= (uint)_maxIndexInclusive ? this : new SelectListPartitionIterator<TSource, TResult>(_source, _selector, _minIndexInclusive, maxIndex);
}
- [return: MaybeNull]
- public TResult TryGetElementAt(int index, out bool found)
+ public TResult? TryGetElementAt(int index, out bool found)
{
if ((uint)index <= (uint)(_maxIndexInclusive - _minIndexInclusive) && index < _source.Count - _minIndexInclusive)
{
}
found = false;
- return default!;
+ return default;
}
- [return: MaybeNull]
- public TResult TryGetFirst(out bool found)
+ public TResult? TryGetFirst(out bool found)
{
if (_source.Count > _minIndexInclusive)
{
}
found = false;
- return default!;
+ return default;
}
- [return: MaybeNull]
- public TResult TryGetLast(out bool found)
+ public TResult? TryGetLast(out bool found)
{
int lastIndex = _source.Count - 1;
if (lastIndex >= _minIndexInclusive)
}
found = false;
- return default!;
+ return default;
}
private int Count
return default;
}
- [return: MaybeNull]
- public static TSource SingleOrDefault<TSource>(this IEnumerable<TSource> source)
+ public static TSource? SingleOrDefault<TSource>(this IEnumerable<TSource> source)
{
if (source == null)
{
switch (list.Count)
{
case 0:
- return default!;
+ return default;
case 1:
return list[0];
}
{
if (!e.MoveNext())
{
- return default!;
+ return default;
}
TSource result = e.Current;
return default;
}
- [return: MaybeNull]
- public static TSource SingleOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
+ public static TSource? SingleOrDefault<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate)
{
if (source == null)
{
}
}
- return default!;
+ return default;
}
}
}
public readonly partial struct ReadOnlySequence<T>
{
// The data is essentially two SequencePositions, however the Start and End SequencePositions are deconstructed to improve packing.
- [AllowNull] private readonly object? _startObject;
- [AllowNull] private readonly object? _endObject;
+ private readonly object? _startObject;
+ private readonly object? _endObject;
private readonly int _startInteger;
private readonly int _endInteger;
public static System.Threading.Tasks.Task<object?> GetFromJsonAsync(this System.Net.Http.HttpClient client, string? requestUri, System.Type type, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public static System.Threading.Tasks.Task<object?> GetFromJsonAsync(this System.Net.Http.HttpClient client, System.Uri? requestUri, System.Type type, System.Text.Json.JsonSerializerOptions? options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public static System.Threading.Tasks.Task<object?> GetFromJsonAsync(this System.Net.Http.HttpClient client, System.Uri? requestUri, System.Type type, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
- public static System.Threading.Tasks.Task<TValue> GetFromJsonAsync<TValue>(this System.Net.Http.HttpClient client, string? requestUri, System.Text.Json.JsonSerializerOptions? options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
- public static System.Threading.Tasks.Task<TValue> GetFromJsonAsync<TValue>(this System.Net.Http.HttpClient client, string? requestUri, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
- public static System.Threading.Tasks.Task<TValue> GetFromJsonAsync<TValue>(this System.Net.Http.HttpClient client, System.Uri? requestUri, System.Text.Json.JsonSerializerOptions? options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
- public static System.Threading.Tasks.Task<TValue> GetFromJsonAsync<TValue>(this System.Net.Http.HttpClient client, System.Uri? requestUri, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
+ public static System.Threading.Tasks.Task<TValue?> GetFromJsonAsync<TValue>(this System.Net.Http.HttpClient client, string? requestUri, System.Text.Json.JsonSerializerOptions? options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
+ public static System.Threading.Tasks.Task<TValue?> GetFromJsonAsync<TValue>(this System.Net.Http.HttpClient client, string? requestUri, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
+ public static System.Threading.Tasks.Task<TValue?> GetFromJsonAsync<TValue>(this System.Net.Http.HttpClient client, System.Uri? requestUri, System.Text.Json.JsonSerializerOptions? options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
+ public static System.Threading.Tasks.Task<TValue?> GetFromJsonAsync<TValue>(this System.Net.Http.HttpClient client, System.Uri? requestUri, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public static System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PostAsJsonAsync<TValue>(this System.Net.Http.HttpClient client, string? requestUri, TValue value, System.Text.Json.JsonSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public static System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PostAsJsonAsync<TValue>(this System.Net.Http.HttpClient client, string? requestUri, TValue value, System.Threading.CancellationToken cancellationToken) { throw null; }
public static System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PostAsJsonAsync<TValue>(this System.Net.Http.HttpClient client, System.Uri? requestUri, TValue value, System.Text.Json.JsonSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public static partial class HttpContentJsonExtensions
{
public static System.Threading.Tasks.Task<object?> ReadFromJsonAsync(this System.Net.Http.HttpContent content, System.Type type, System.Text.Json.JsonSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
- public static System.Threading.Tasks.Task<T> ReadFromJsonAsync<T>(this System.Net.Http.HttpContent content, System.Text.Json.JsonSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
+ public static System.Threading.Tasks.Task<T?> ReadFromJsonAsync<T>(this System.Net.Http.HttpContent content, System.Text.Json.JsonSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
public sealed partial class JsonContent : System.Net.Http.HttpContent
{
return GetFromJsonAsyncCore(taskResponse, type, options, cancellationToken);
}
- public static Task<TValue> GetFromJsonAsync<TValue>(this HttpClient client, string? requestUri, JsonSerializerOptions? options, CancellationToken cancellationToken = default)
+ public static Task<TValue?> GetFromJsonAsync<TValue>(this HttpClient client, string? requestUri, JsonSerializerOptions? options, CancellationToken cancellationToken = default)
{
if (client == null)
{
return GetFromJsonAsyncCore<TValue>(taskResponse, options, cancellationToken);
}
- public static Task<TValue> GetFromJsonAsync<TValue>(this HttpClient client, Uri? requestUri, JsonSerializerOptions? options, CancellationToken cancellationToken = default)
+ public static Task<TValue?> GetFromJsonAsync<TValue>(this HttpClient client, Uri? requestUri, JsonSerializerOptions? options, CancellationToken cancellationToken = default)
{
if (client == null)
{
public static Task<object?> GetFromJsonAsync(this HttpClient client, Uri? requestUri, Type type, CancellationToken cancellationToken = default)
=> client.GetFromJsonAsync(requestUri, type, options: null, cancellationToken);
- public static Task<TValue> GetFromJsonAsync<TValue>(this HttpClient client, string? requestUri, CancellationToken cancellationToken = default)
+ public static Task<TValue?> GetFromJsonAsync<TValue>(this HttpClient client, string? requestUri, CancellationToken cancellationToken = default)
=> client.GetFromJsonAsync<TValue>(requestUri, options: null, cancellationToken);
- public static Task<TValue> GetFromJsonAsync<TValue>(this HttpClient client, Uri? requestUri, CancellationToken cancellationToken = default)
+ public static Task<TValue?> GetFromJsonAsync<TValue>(this HttpClient client, Uri? requestUri, CancellationToken cancellationToken = default)
=> client.GetFromJsonAsync<TValue>(requestUri, options: null, cancellationToken);
private static async Task<object?> GetFromJsonAsyncCore(Task<HttpResponseMessage> taskResponse, Type type, JsonSerializerOptions? options, CancellationToken cancellationToken)
}
}
- private static async Task<T> GetFromJsonAsyncCore<T>(Task<HttpResponseMessage> taskResponse, JsonSerializerOptions? options, CancellationToken cancellationToken)
+ private static async Task<T?> GetFromJsonAsyncCore<T>(Task<HttpResponseMessage> taskResponse, JsonSerializerOptions? options, CancellationToken cancellationToken)
{
using (HttpResponseMessage response = await taskResponse.ConfigureAwait(false))
{
return ReadFromJsonAsyncCore(content, type, sourceEncoding, options, cancellationToken);
}
- public static Task<T> ReadFromJsonAsync<T>(this HttpContent content, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default)
+ public static Task<T?> ReadFromJsonAsync<T>(this HttpContent content, JsonSerializerOptions? options = null, CancellationToken cancellationToken = default)
{
ValidateContent(content);
Debug.Assert(content.Headers.ContentType != null);
}
}
- private static async Task<T> ReadFromJsonAsyncCore<T>(HttpContent content, Encoding? sourceEncoding, JsonSerializerOptions? options, CancellationToken cancellationToken)
+ private static async Task<T?> ReadFromJsonAsyncCore<T>(HttpContent content, Encoding? sourceEncoding, JsonSerializerOptions? options, CancellationToken cancellationToken)
{
Stream contentStream = await ReadHttpContentStreamAsync(content, cancellationToken).ConfigureAwait(false);
private class StructuralEqualityComparer<T> : IEqualityComparer<T> where T : IStructuralEquatable
{
- public bool Equals([AllowNull] T left, [AllowNull] T right) => left != null && left.Equals(right, StructuralComparisons.StructuralEqualityComparer);
+ public bool Equals(T? left, T? right) => left != null && left.Equals(right, StructuralComparisons.StructuralEqualityComparer);
public int GetHashCode(T value) => value.GetHashCode(StructuralComparisons.StructuralEqualityComparer);
}
}
/// <summary>
/// Normalize, check for duplicates, and add if the value is unique.
/// </summary>
- private void AddIfNew([MaybeNull]string serviceName)
+ private void AddIfNew(string serviceName)
{
if (string.IsNullOrEmpty(serviceName))
{
// prefix/host:port
// prefix/host/DistinguishedName
// prefix/host:port/DistinguishedName
+ [return: NotNullIfNotNull("inputServiceName")]
private static string? NormalizeServiceName(string? inputServiceName)
{
if (string.IsNullOrWhiteSpace(inputServiceName))
}
}
- item = default(TItem)!;
+ item = default;
return false;
}
public delegate void Action<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14, in T15>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15);
public delegate void Action<in T1, in T2, in T3, in T4, in T5, in T6, in T7, in T8, in T9, in T10, in T11, in T12, in T13, in T14, in T15, in T16>(T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10, T11 arg11, T12 arg12, T13 arg13, T14 arg14, T15 arg15, T16 arg16);
- public delegate int Comparison<in T>([AllowNull] T x, [AllowNull] T y);
+ // This should probably technically be T? rather than T to match `IComparer<T>`. However, the use cases are generally different,
+ // with Comparison<T> typically being used via a lambda, with the T inferred from the type of the collection being sorted,
+ // and forcing nullable warnings onto all such usage leads to many spurious warnings.
+ public delegate int Comparison<in T>(T x, T y);
public delegate TOutput Converter<in TInput, out TOutput>(TInput input);
}
}
- [return: MaybeNull]
- public static T Find<T>(T[] array, Predicate<T> match)
+ public static T? Find<T>(T[] array, Predicate<T> match)
{
if (array == null)
{
return array[i];
}
}
- return default!;
+ return default;
}
public static T[] FindAll<T>(T[] array, Predicate<T> match)
return -1;
}
- [return: MaybeNull]
- public static T FindLast<T>(T[] array, Predicate<T> match)
+ public static T? FindLast<T>(T[] array, Predicate<T> match)
{
if (array == null)
{
return array[i];
}
}
- return default!;
+ return default;
}
public static int FindLastIndex<T>(T[] array, Predicate<T> match)
// check and this check, another item could have arrived).
if (head._nextSegment == null)
{
- item = default!;
+ item = default;
return false;
}
// and we'll traverse to that segment.
}
- result = default!;
+ result = default;
return false;
}
int currentTail = Volatile.Read(ref _headAndTail.Tail);
if (currentTail - currentHead <= 0 || (frozen && (currentTail - FreezeOffset - currentHead <= 0)))
{
- item = default!;
+ item = default;
return false;
}
int currentTail = Volatile.Read(ref _headAndTail.Tail);
if (currentTail - currentHead <= 0 || (frozen && (currentTail - FreezeOffset - currentHead <= 0)))
{
- result = default!;
+ result = default;
return false;
}
internal struct Slot
{
/// <summary>The item.</summary>
- [AllowNull, MaybeNull] public T Item; // SOS's ThreadPool command depends on this being at the beginning of the struct when T is a reference type
+ public T? Item; // SOS's ThreadPool command depends on this being at the beginning of the struct when T is a reference type
/// <summary>The sequence number for this slot, used to synchronize between enqueuers and dequeuers.</summary>
public int SequenceNumber;
}
return new ComparisonComparer<T>(comparison);
}
- public abstract int Compare([AllowNull] T x, [AllowNull] T y);
+ public abstract int Compare(T? x, T? y);
int IComparer.Compare(object? x, object? y)
{
_comparison = comparison;
}
- public override int Compare([AllowNull] T x, [AllowNull] T y)
- {
- return _comparison(x, y);
- }
+ public override int Compare(T? x, T? y) => _comparison(x!, y!);
}
// Note: although there is a lot of shared code in the following
// Needs to be public to support binary serialization compatibility
public sealed partial class GenericComparer<T> : Comparer<T> where T : IComparable<T>
{
- public override int Compare([AllowNull] T x, [AllowNull] T y)
+ public override int Compare(T? x, T? y)
{
if (x != null)
{
// Needs to be public to support binary serialization compatibility
public sealed partial class ObjectComparer<T> : Comparer<T>
{
- public override int Compare([AllowNull] T x, [AllowNull] T y)
+ public override int Compare(T? x, T? y)
{
return System.Collections.Comparer.Default.Compare(x, y);
}
private readonly Dictionary<TKey, TValue> _dictionary;
private int _index;
private readonly int _version;
- [AllowNull, MaybeNull] private TKey _currentKey;
+ private TKey? _currentKey;
internal Enumerator(Dictionary<TKey, TValue> dictionary)
{
private readonly Dictionary<TKey, TValue> _dictionary;
private int _index;
private readonly int _version;
- [AllowNull, MaybeNull] private TValue _currentValue;
+ private TValue? _currentValue;
internal Enumerator(Dictionary<TKey, TValue> dictionary)
{
{
// public static EqualityComparer<T> Default is runtime-specific
- public abstract bool Equals([AllowNull] T x, [AllowNull] T y);
+ public abstract bool Equals(T? x, T? y);
public abstract int GetHashCode([DisallowNull] T obj);
int IEqualityComparer.GetHashCode(object? obj)
public sealed partial class GenericEqualityComparer<T> : EqualityComparer<T> where T : IEquatable<T>
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public override bool Equals([AllowNull] T x, [AllowNull] T y)
+ public override bool Equals(T? x, T? y)
{
if (x != null)
{
public sealed partial class ObjectEqualityComparer<T> : EqualityComparer<T>
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public override bool Equals([AllowNull] T x, [AllowNull] T y)
+ public override bool Equals(T? x, T? y)
{
if (x != null)
{
// value less than zero if x is less than y, zero if x is equal to y, or a
// value greater than zero if x is greater than y.
//
- int Compare([AllowNull] T x, [AllowNull] T y);
+ int Compare(T? x, T? y);
}
}
// It is used in Dictionary class.
public interface IEqualityComparer<in T>
{
- bool Equals([AllowNull] T x, [AllowNull] T y);
+ bool Equals(T? x, T? y);
int GetHashCode([DisallowNull] T obj);
}
}
public bool Exists(Predicate<T> match)
=> FindIndex(match) != -1;
- [return: MaybeNull]
- public T Find(Predicate<T> match)
+ public T? Find(Predicate<T> match)
{
if (match == null)
{
return _items[i];
}
}
- return default!;
+ return default;
}
public List<T> FindAll(Predicate<T> match)
return -1;
}
- [return: MaybeNull]
- public T FindLast(Predicate<T> match)
+ public T? FindLast(Predicate<T> match)
{
if (match == null)
{
return _items[i];
}
}
- return default!;
+ return default;
}
public int FindLastIndex(Predicate<T> match)
private readonly List<T> _list;
private int _index;
private readonly int _version;
- [AllowNull, MaybeNull] private T _current;
+ private T? _current;
internal Enumerator(List<T> list)
{
{
ThrowHelper.IfNullAndNullsAreIllegalThenThrow<T>(value, ExceptionArgument.value);
- T item = default!;
+ T? item = default;
try
{
}
ThrowHelper.IfNullAndNullsAreIllegalThenThrow<T>(value, ExceptionArgument.value);
- T item = default!;
+ T? item = default;
try
{
}
ThrowHelper.IfNullAndNullsAreIllegalThenThrow<T>(value, ExceptionArgument.value);
- T item = default!;
+ T? item = default;
try
{
if (m_etwProvider != null)
{
m_etwProvider.Dispose();
- m_etwProvider = null!; // TODO-NULLABLE: Avoid nulling out in Dispose
+ m_etwProvider = null!;
}
#endif
#if FEATURE_PERFTRACING
if (m_eventPipeProvider != null)
{
m_eventPipeProvider.Dispose();
- m_eventPipeProvider = null!; // TODO-NULLABLE: Avoid nulling out in Dispose
+ m_eventPipeProvider = null!;
}
#endif
}
// if this is equal to object, or a value greater than zero
// if this is greater than object.
//
- int CompareTo([AllowNull] T other);
+ int CompareTo(T? other);
}
}
{
public interface IEquatable<T> // invariant due to questionable semantics around equality and inheritance
{
- bool Equals([AllowNull] T other);
+ bool Equals(T? other);
}
}
private Func<T>? _factory;
// _value eventually stores the lazily created value. It is valid when _state = null.
- private T _value = default!;
+ private T? _value;
/// <summary>
/// Initializes a new instance of the <see cref="System.Lazy{T}"/> class that
}
/// <summary>Gets the value of the Lazy<T> for debugging display purposes.</summary>
- [MaybeNull]
- internal T ValueForDebugDisplay
+ internal T? ValueForDebugDisplay
{
get
{
if (!IsValueCreated)
{
- return default!;
+ return default;
}
return _value;
}
/// from initialization delegate.
/// </remarks>
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
- public T Value => _state == null ? _value : CreateValue();
+ public T Value => _state == null ? _value! : CreateValue();
}
/// <summary>A debugger view of the Lazy<T> to surface additional debugging properties and
public bool IsValueCreated => _lazy.IsValueCreated;
/// <summary>Returns the value of the Lazy object.</summary>
- [MaybeNull]
- public T Value => _lazy.ValueForDebugDisplay;
+ public T? Value => _lazy.ValueForDebugDisplay;
/// <summary>Returns the execution mode of the Lazy object</summary>
public LazyThreadSafetyMode? Mode => _lazy.Mode;
// Close the stream in a thread-safe way. This fix means
// that we may call Close n times, but that's safe.
BinaryReader copyOfStore = _store;
- _store = null!; // TODO-NULLABLE: Avoid nulling out in Dispose
+ _store = null!;
if (copyOfStore != null)
copyOfStore.Close();
}
- _store = null!; // TODO-NULLABLE: Avoid nulling out in Dispose
+ _store = null!;
_namePositions = null;
_nameHashes = null;
_ums = null;
public class ResourceSet : IDisposable, IEnumerable
{
protected IResourceReader Reader = null!;
- internal Hashtable? Table; // TODO-NULLABLE: Avoid nulling out in Dispose
+ internal Hashtable? Table;
private Hashtable? _caseInsensitiveTable; // For case-insensitive lookups.
{
// Close the Reader in a thread-safe way.
IResourceReader? copyOfReader = Reader;
- Reader = null!; // TODO-NULLABLE: Avoid nulling out in Dispose
+ Reader = null!;
if (copyOfReader != null)
copyOfReader.Close();
}
- Reader = null!; // TODO-NULLABLE: Avoid nulling out in Dispose
+ Reader = null!;
_caseInsensitiveTable = null;
Table = null;
}
// for arbitrarily long times, since the object is usually a string
// literal that will live for the lifetime of the appdomain. The
// value is a ResourceLocator instance, which might cache the object.
- private Dictionary<string, ResourceLocator>? _resCache; // TODO-NULLABLE: Avoid nulling out in Dispose
+ private Dictionary<string, ResourceLocator>? _resCache;
// For our special load-on-demand reader, cache the cast. The
// RuntimeResourceSet's implementation knows how to treat this reader specially.
- private ResourceReader? _defaultReader; // TODO-NULLABLE: Avoid nulling out in Dispose
+ private ResourceReader? _defaultReader;
// This is a lookup table for case-insensitive lookups, and may be null.
// Consider always using a case-insensitive resource cache, as we don't
/// <typeparam name="TResult">Specifies the result type.</typeparam>
/// <param name="result">The result for the task.</param>
/// <returns>The cacheable task.</returns>
- internal static Task<TResult> CreateCacheableTask<TResult>([AllowNull] TResult result) =>
+ internal static Task<TResult> CreateCacheableTask<TResult>(TResult? result) =>
new Task<TResult>(false, result, (TaskCreationOptions)InternalTaskOptions.DoNotDispose, default);
/// <summary>Creates an array of cached tasks for the values in the range [INCLUSIVE_MIN,EXCLUSIVE_MAX).</summary>
/// <summary>A delegate to the <see cref="MoveNext()"/> method.</summary>
private Action? _moveNextAction;
/// <summary>The state machine itself.</summary>
- [AllowNull, MaybeNull]
- public TStateMachine StateMachine = default; // mutable struct; do not make this readonly. SOS DumpAsync command depends on this name.
+ public TStateMachine? StateMachine; // mutable struct; do not make this readonly. SOS DumpAsync command depends on this name.
/// <summary>Captured ExecutionContext with which to invoke <see cref="MoveNextAction"/>; may be null.</summary>
public ExecutionContext? Context;
/// <summary>Completes the already initialized task with the specified result.</summary>
/// <param name="result">The result to use to complete the task.</param>
/// <param name="task">The task to complete.</param>
- internal static void SetExistingTaskResult(Task<TResult> task, [AllowNull] TResult result)
+ internal static void SetExistingTaskResult(Task<TResult> task, TResult? result)
{
Debug.Assert(task != null, "Expected non-null task");
/// <summary>If this box is stored in the cache, the next box in the cache.</summary>
private StateMachineBox<TStateMachine>? _next;
/// <summary>The state machine itself.</summary>
- [AllowNull, MaybeNull]
- public TStateMachine StateMachine = default;
+ public TStateMachine? StateMachine;
/// <summary>Gets a box object to use for an operation. This may be a reused, pooled object, or it may be new.</summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)] // only one caller
}
key = default;
- value = default!;
+ value = default;
return false;
}
}
[SupportedOSPlatform("windows")]
- public static TWrapper CreateWrapperOfType<T, TWrapper>([AllowNull] T o)
+ public static TWrapper CreateWrapperOfType<T, TWrapper>(T? o)
{
throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
}
}
[SupportedOSPlatform("windows")]
- public static void GetNativeVariantForObject<T>([AllowNull] T obj, IntPtr pDstNativeVariant)
+ public static void GetNativeVariantForObject<T>(T? obj, IntPtr pDstNativeVariant)
{
throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
}
}
[SupportedOSPlatform("windows")]
- [return: MaybeNull]
- public static T GetObjectForNativeVariant<T>(IntPtr pSrcNativeVariant)
+ public static T? GetObjectForNativeVariant<T>(IntPtr pSrcNativeVariant)
{
throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop);
}
PtrToStructure(ptr, (object)structure!);
}
- [return: MaybeNull]
- public static T PtrToStructure<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]T>(IntPtr ptr) => (T)PtrToStructure(ptr, typeof(T))!;
+ public static T? PtrToStructure<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)]T>(IntPtr ptr) => (T)PtrToStructure(ptr, typeof(T))!;
public static void DestroyStructure<T>(IntPtr ptr) => DestroyStructure(ptr, typeof(T));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public int CompareTo([AllowNull] T other) => _comparer.Compare(_value, other);
+ public int CompareTo(T? other) => _comparer.Compare(_value, other);
}
}
}
public readonly struct AsyncLocalValueChangedArgs<T>
{
- [MaybeNull] public T PreviousValue { get; }
- [MaybeNull] public T CurrentValue { get; }
+ public T? PreviousValue { get; }
+ public T? CurrentValue { get; }
//
// If the value changed because we changed to a different ExecutionContext, this is true. If it changed
//
public bool ThreadContextChanged { get; }
- internal AsyncLocalValueChangedArgs([AllowNull] T previousValue, [AllowNull] T currentValue, bool contextChanged)
+ internal AsyncLocalValueChangedArgs(T? previousValue, T? currentValue, bool contextChanged)
{
PreviousValue = previousValue!;
CurrentValue = currentValue!;
public class Task<TResult> : Task
{
// The value itself, if set.
- [MaybeNull, AllowNull] internal TResult m_result = default!;
+ internal TResult? m_result;
private static readonly TaskFactory<TResult> s_Factory = new TaskFactory<TResult>();
m_result = result;
}
- internal Task(bool canceled, [AllowNull] TResult result, TaskCreationOptions creationOptions, CancellationToken ct)
+ internal Task(bool canceled, TResult? result, TaskCreationOptions creationOptions, CancellationToken ct)
: base(canceled, creationOptions, ct)
{
if (!canceled)
// internal helper function breaks out logic used by TaskCompletionSource
- internal bool TrySetResult([AllowNull] TResult result)
+ internal bool TrySetResult(TResult? result)
{
Debug.Assert(m_action == null, "Task<T>.TrySetResult(): non-null m_action");
m_task = task;
}
- [MaybeNull] public TResult Result => m_task.Status == TaskStatus.RanToCompletion ? m_task.Result : default!;
+ public TResult? Result => m_task.Status == TaskStatus.RanToCompletion ? m_task.Result : default;
public object? AsyncState => m_task.AsyncState;
public TaskCreationOptions CreationOptions => m_task.CreationOptions;
public Exception? Exception => m_task.Exception;
if (first == segment.m_state.m_last)
{
- result = default!;
+ result = default;
return false;
}
/// <summary>Whether the current operation has completed.</summary>
private bool _completed;
/// <summary>The result with which the operation succeeded, or the default value if it hasn't yet completed or failed.</summary>
- [AllowNull, MaybeNull] private TResult _result;
+ private TResult? _result;
/// <summary>The exception with which the operation failed, or null if it hasn't yet completed or completed successfully.</summary>
private ExceptionDispatchInfo? _error;
/// <summary>The current version of this value, used to help prevent misuse.</summary>
}
_error?.Throw();
- return _result;
+ return _result!;
}
/// <summary>Schedules the continuation action for this operation.</summary>
/// <summary>null if <see cref="_result"/> has the result, otherwise a <see cref="Task{TResult}"/> or a <see cref="IValueTaskSource{TResult}"/>.</summary>
internal readonly object? _obj;
/// <summary>The result to be used if the operation completed successfully synchronously.</summary>
- [AllowNull] internal readonly TResult _result;
+ internal readonly TResult? _result;
/// <summary>Opaque value passed through to the <see cref="IValueTaskSource{TResult}"/>.</summary>
internal readonly short _token;
/// <summary>true to continue on the captured context; otherwise, false.</summary>
/// <param name="token">The token.</param>
/// <param name="continueOnCapturedContext">true to continue on captured context; otherwise, false.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private ValueTask(object? obj, TResult result, short token, bool continueOnCapturedContext)
+ private ValueTask(object? obj, TResult? result, short token, bool continueOnCapturedContext)
{
_obj = obj;
_result = result;
if (obj == null)
{
- return AsyncTaskMethodBuilder<TResult>.GetTaskForResult(_result);
+ return AsyncTaskMethodBuilder<TResult>.GetTaskForResult(_result!);
}
if (obj is Task<TResult> t)
if (obj == null)
{
- return _result;
+ return _result!;
}
if (obj is Task<TResult> t)
}
}
- [return: MaybeNull]
- private T GetValueSlow()
+ private T? GetValueSlow()
{
// If the object has been disposed, the id will be -1.
int id = ~_idComplement;
/// <summary>Gets the value of the ThreadLocal<T> for debugging display purposes. It takes care of getting
/// the value for the current thread in the ThreadLocal mode.</summary>
- [MaybeNull]
- internal T ValueForDebugDisplay
+ internal T? ValueForDebugDisplay
{
get
{
LinkedSlot? slot;
if (slotArray == null || id >= slotArray.Length || (slot = slotArray[id].Value) == null || !_initialized)
- return default!;
+ return default;
return slot._value;
}
}
internal volatile LinkedSlotVolatile[]? _slotArray;
// The value for this slot.
- [AllowNull, MaybeNull] internal T _value = default;
+ internal T? _value;
}
/// <summary>
public bool IsValueCreated => _tlocal.IsValueCreated;
/// <summary>Returns the value of the ThreadLocal object.</summary>
- [MaybeNull]
- public T Value => _tlocal.ValueForDebugDisplay;
+ public T? Value => _tlocal.ValueForDebugDisplay;
/// <summary>Return all values for all threads that have accessed this instance.</summary>
public List<T>? Values => _tlocal.ValuesForDebugDisplay;
{
for (i = 0; i < e.Length; i++)
if (e[i] != null)
- ret[cnt++] = e[i]!; // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644)
+ ret[cnt++] = e[i]!; // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644)
}
// Copy the Types
{
for (i = 0; i < t.Length; i++)
if (t[i] != null)
- ret[cnt++] = t[i]!; // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644)
+ ret[cnt++] = t[i]!; // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644)
}
return ret;
/// </summary>
internal static class EnumerableExtensions
{
- [return: MaybeNull]
- public static T FirstOrDefault<T>(this ImmutableArray<T> collection, Func<T, bool> predicate)
+ public static T? FirstOrDefault<T>(this ImmutableArray<T> collection, Func<T, bool> predicate)
{
foreach (var item in collection)
{
}
}
- return default!;
+ return default;
}
// used only in debugger display so we needn't get fancy with optimizations.
public unsafe static ref T AsRef<T>(void* source) { throw null; }
public static ref T AsRef<T>(in T source) { throw null; }
#if NETSTANDARD2_1
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
[return: System.Diagnostics.CodeAnalysis.NotNullIfNotNull("o")]
#endif
- public static T As<T>(object? o) where T : class? { throw null; }
+ public static T? As<T>(object? o) where T : class? { throw null; }
public static ref TTo As<TFrom, TTo>(ref TFrom source) { throw null; }
public static System.IntPtr ByteOffset<T>(ref T origin, ref T target) { throw null; }
public static void CopyBlock(ref byte destination, ref byte source, uint byteCount) { }
[return: System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute("o")]
public static object? CreateWrapperOfType(object? o, System.Type t) { throw null; }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
- public static TWrapper CreateWrapperOfType<T, TWrapper>([System.Diagnostics.CodeAnalysis.AllowNullAttribute] T o) { throw null; }
+ public static TWrapper CreateWrapperOfType<T, TWrapper>(T? o) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static void DestroyStructure(System.IntPtr ptr, System.Type structuretype) { }
public static void DestroyStructure<T>(System.IntPtr ptr) { }
public static void GetNativeVariantForObject(object? obj, System.IntPtr pDstNativeVariant) { }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
- public static void GetNativeVariantForObject<T>([System.Diagnostics.CodeAnalysis.AllowNullAttribute] T obj, System.IntPtr pDstNativeVariant) { }
+ public static void GetNativeVariantForObject<T>(T? obj, System.IntPtr pDstNativeVariant) { }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
public static object GetObjectForIUnknown(System.IntPtr pUnk) { throw null; }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
public static object? GetObjectForNativeVariant(System.IntPtr pSrcNativeVariant) { throw null; }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T GetObjectForNativeVariant<T>(System.IntPtr pSrcNativeVariant) { throw null; }
+ public static T? GetObjectForNativeVariant<T>(System.IntPtr pSrcNativeVariant) { throw null; }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static object?[] GetObjectsForNativeVariants(System.IntPtr aSrcNativeVariant, int cVars) { throw null; }
public static void PtrToStructure(System.IntPtr ptr, object structure) { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static object? PtrToStructure(System.IntPtr ptr, System.Type structureType) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T PtrToStructure<T>(System.IntPtr ptr) { throw null; }
+ public static T? PtrToStructure<T>(System.IntPtr ptr) { throw null; }
public static void PtrToStructure<T>(System.IntPtr ptr, [System.Diagnostics.CodeAnalysis.DisallowNullAttribute] T structure) { }
[System.Runtime.Versioning.SupportedOSPlatformAttribute("windows")]
public static int QueryInterface(System.IntPtr pUnk, ref System.Guid iid, out System.IntPtr ppv) { throw null; }
{
Type type =
memberTypes[i] != null ? memberTypes[i] :
- memberData[i] != null ? GetType(memberData[i]!) : // TODO-NULLABLE https://github.com/dotnet/roslyn/issues/34644
+ memberData[i] != null ? GetType(memberData[i]!) : // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644)
Converter.s_typeofObject;
InternalPrimitiveTypeE code = ToCode(type);
if (memberData[i] != null)
{
memberObjectInfos[i] = WriteObjectInfo.Serialize(
- memberData[i]!, // TODO-NULLABLE https://github.com/dotnet/roslyn/issues/34644
+ memberData[i]!, // TODO-NULLABLE: Indexer nullability tracked (https://github.com/dotnet/roslyn/issues/34644)
_surrogates,
_context,
_serObjectInfoInit,
public static int FindLastIndex<T>(T[] array, int startIndex, int count, System.Predicate<T> match) { throw null; }
public static int FindLastIndex<T>(T[] array, int startIndex, System.Predicate<T> match) { throw null; }
public static int FindLastIndex<T>(T[] array, System.Predicate<T> match) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T FindLast<T>(T[] array, System.Predicate<T> match) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static T Find<T>(T[] array, System.Predicate<T> match) { throw null; }
+ public static T? FindLast<T>(T[] array, System.Predicate<T> match) { throw null; }
+ public static T? Find<T>(T[] array, System.Predicate<T> match) { throw null; }
public static void ForEach<T>(T[] array, System.Action<T> action) { }
public System.Collections.IEnumerator GetEnumerator() { throw null; }
public int GetLength(int dimension) { throw null; }
public CLSCompliantAttribute(bool isCompliant) { }
public bool IsCompliant { get { throw null; } }
}
- public delegate int Comparison<in T>([System.Diagnostics.CodeAnalysis.AllowNullAttribute] T x, [System.Diagnostics.CodeAnalysis.AllowNullAttribute] T y);
+ public delegate int Comparison<in T>(T x, T y);
public abstract partial class ContextBoundObject : System.MarshalByRefObject
{
protected ContextBoundObject() { }
}
public partial interface IComparable<in T>
{
- int CompareTo([System.Diagnostics.CodeAnalysis.AllowNullAttribute] T other);
+ int CompareTo(T? other);
}
[System.CLSCompliantAttribute(false)]
public partial interface IConvertible
}
public partial interface IEquatable<T>
{
- bool Equals([System.Diagnostics.CodeAnalysis.AllowNullAttribute] T other);
+ bool Equals(T? other);
}
public partial interface IFormatProvider
{
}
public partial interface IComparer<in T>
{
- int Compare([System.Diagnostics.CodeAnalysis.AllowNullAttribute] T x, [System.Diagnostics.CodeAnalysis.AllowNullAttribute] T y);
+ int Compare(T? x, T? y);
}
public partial interface IDictionary<TKey, TValue> : System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey, TValue>>, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<TKey, TValue>>, System.Collections.IEnumerable
{
}
public partial interface IEqualityComparer<in T>
{
- bool Equals([System.Diagnostics.CodeAnalysis.AllowNullAttribute] T x, [System.Diagnostics.CodeAnalysis.AllowNullAttribute] T y);
+ bool Equals(T? x, T? y);
int GetHashCode([System.Diagnostics.CodeAnalysis.DisallowNullAttribute] T obj);
}
public partial interface IList<T> : System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.IEnumerable
public System.Security.Cryptography.CngKeyUsages? KeyUsage { get { throw null; } set { } }
public System.Security.Cryptography.CngPropertyCollection Parameters { get { throw null; } }
public System.IntPtr ParentWindowHandle { get { throw null; } set { } }
- [System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
public System.Security.Cryptography.CngProvider Provider { get { throw null; } set { } }
public System.Security.Cryptography.CngUIPolicy? UIPolicy { get { throw null; } set { } }
}
/// <summary>
/// Wrapper for the _holder field which ensures that we're in a consistent state
/// </summary>
- [MaybeNull]
- private SafeNCryptHandle Holder
+ [DisallowNull]
+ private SafeNCryptHandle? Holder
{
get
{
}
}
- [return: MaybeNull]
- public override T GetPrivateKeyForSigning<T>(X509Certificate2 certificate, bool silent)
+ public override T? GetPrivateKeyForSigning<T>(X509Certificate2 certificate, bool silent) where T : class
{
return GetPrivateKey<T>(certificate);
}
- [return: MaybeNull]
- public override T GetPrivateKeyForDecryption<T>(X509Certificate2 certificate, bool silent)
+ public override T? GetPrivateKeyForDecryption<T>(X509Certificate2 certificate, bool silent) where T : class
{
return GetPrivateKey<T>(certificate);
}
}
}
- [return: MaybeNull]
- public override T GetPrivateKeyForSigning<T>(X509Certificate2 certificate, bool silent)
+ public override T? GetPrivateKeyForSigning<T>(X509Certificate2 certificate, bool silent) where T : class
{
return GetPrivateKey<T>(certificate, silent, preferNCrypt: true);
}
- [return: MaybeNull]
- public override T GetPrivateKeyForDecryption<T>(X509Certificate2 certificate, bool silent)
+ public override T? GetPrivateKeyForDecryption<T>(X509Certificate2 certificate, bool silent) where T : class
{
return GetPrivateKey<T>(certificate, silent, preferNCrypt: false);
}
public static object? Deserialize(string json, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(MembersAccessedOnRead)] System.Type returnType, System.Text.Json.JsonSerializerOptions? options = null) { throw null; }
public static object? Deserialize(ref System.Text.Json.Utf8JsonReader reader, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(MembersAccessedOnRead)] System.Type returnType, System.Text.Json.JsonSerializerOptions? options = null) { throw null; }
public static System.Threading.Tasks.ValueTask<object?> DeserializeAsync(System.IO.Stream utf8Json, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(MembersAccessedOnRead)] System.Type returnType, System.Text.Json.JsonSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
- public static System.Threading.Tasks.ValueTask<TValue> DeserializeAsync<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(MembersAccessedOnRead)] TValue>(System.IO.Stream utf8Json, System.Text.Json.JsonSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TValue Deserialize<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(MembersAccessedOnRead)] TValue>(System.ReadOnlySpan<byte> utf8Json, System.Text.Json.JsonSerializerOptions? options = null) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TValue Deserialize<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(MembersAccessedOnRead)] TValue>(string json, System.Text.Json.JsonSerializerOptions? options = null) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TValue Deserialize<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(MembersAccessedOnRead)] TValue>(ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions? options = null) { throw null; }
+ public static System.Threading.Tasks.ValueTask<TValue?> DeserializeAsync<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(MembersAccessedOnRead)] TValue>(System.IO.Stream utf8Json, System.Text.Json.JsonSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
+ public static TValue? Deserialize<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(MembersAccessedOnRead)] TValue>(System.ReadOnlySpan<byte> utf8Json, System.Text.Json.JsonSerializerOptions? options = null) { throw null; }
+ public static TValue? Deserialize<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(MembersAccessedOnRead)] TValue>(string json, System.Text.Json.JsonSerializerOptions? options = null) { throw null; }
+ public static TValue? Deserialize<[System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(MembersAccessedOnRead)] TValue>(ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions? options = null) { throw null; }
public static string Serialize(object? value, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(MembersAccessedOnWrite)] System.Type inputType, System.Text.Json.JsonSerializerOptions? options = null) { throw null; }
public static void Serialize(System.Text.Json.Utf8JsonWriter writer, object? value, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(MembersAccessedOnWrite)] System.Type inputType, System.Text.Json.JsonSerializerOptions? options = null) { }
public static System.Threading.Tasks.Task SerializeAsync(System.IO.Stream utf8Json, object? value, [System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute(MembersAccessedOnWrite)] System.Type inputType, System.Text.Json.JsonSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public static object? Deserialize(string json, System.Type returnType, System.Text.Json.JsonSerializerOptions? options = null) { throw null; }
public static object? Deserialize(ref System.Text.Json.Utf8JsonReader reader, System.Type returnType, System.Text.Json.JsonSerializerOptions? options = null) { throw null; }
public static System.Threading.Tasks.ValueTask<object?> DeserializeAsync(System.IO.Stream utf8Json, System.Type returnType, System.Text.Json.JsonSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
- public static System.Threading.Tasks.ValueTask<TValue> DeserializeAsync<TValue>(System.IO.Stream utf8Json, System.Text.Json.JsonSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TValue Deserialize<TValue>(System.ReadOnlySpan<byte> utf8Json, System.Text.Json.JsonSerializerOptions? options = null) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TValue Deserialize<TValue>(string json, System.Text.Json.JsonSerializerOptions? options = null) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public static TValue Deserialize<TValue>(ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions? options = null) { throw null; }
+ public static System.Threading.Tasks.ValueTask<TValue?> DeserializeAsync<TValue>(System.IO.Stream utf8Json, System.Text.Json.JsonSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
+ public static TValue? Deserialize<TValue>(System.ReadOnlySpan<byte> utf8Json, System.Text.Json.JsonSerializerOptions? options = null) { throw null; }
+ public static TValue? Deserialize<TValue>(string json, System.Text.Json.JsonSerializerOptions? options = null) { throw null; }
+ public static TValue? Deserialize<TValue>(ref System.Text.Json.Utf8JsonReader reader, System.Text.Json.JsonSerializerOptions? options = null) { throw null; }
public static string Serialize(object? value, System.Type inputType, System.Text.Json.JsonSerializerOptions? options = null) { throw null; }
public static void Serialize(System.Text.Json.Utf8JsonWriter writer, object? value, System.Type inputType, System.Text.Json.JsonSerializerOptions? options = null) { }
public static System.Threading.Tasks.Task SerializeAsync(System.IO.Stream utf8Json, object? value, System.Type inputType, System.Text.Json.JsonSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
protected internal JsonConverter() { }
public override bool CanConvert(System.Type typeToConvert) { throw null; }
public virtual bool HandleNull { get { throw null; } }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public abstract T Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options);
+ public abstract T? Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options);
public abstract void Write(System.Text.Json.Utf8JsonWriter writer, T value, System.Text.Json.JsonSerializerOptions options);
}
[System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.Struct | System.AttributeTargets.Property | System.AttributeTargets.Field, AllowMultiple = false)]
return ReadCore(ref reader, options, ref state);
}
- [return: MaybeNull]
- internal T ReadCore(
+ internal T? ReadCore(
ref Utf8JsonReader reader,
JsonSerializerOptions options,
ref ReadStack state)
if (state.Current.ReturnValue == null)
{
// Avoid returning null for value types.
- return default!;
+ return default;
}
return (T)state.Current.ReturnValue!;
{
// Read more data until we have the full element.
state.BytesConsumed += reader.BytesConsumed;
- return default!;
+ return default;
}
}
}
if (!SingleValueReadWithReadAhead(ClassType.Value, ref reader, ref state))
{
state.BytesConsumed += reader.BytesConsumed;
- return default!;
+ return default;
}
}
}
// Provide a default implementation for value converters.
- internal virtual bool OnTryRead(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, ref ReadStack state, [MaybeNull] out T value)
+ internal virtual bool OnTryRead(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, ref ReadStack state, out T? value)
{
value = Read(ref reader, typeToConvert, options);
return true;
/// <param name="typeToConvert">The <see cref="Type"/> being converted.</param>
/// <param name="options">The <see cref="JsonSerializerOptions"/> being used.</param>
/// <returns>The value that was converted.</returns>
- [return: MaybeNull]
- public abstract T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options);
+ public abstract T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options);
- internal bool TryRead(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, ref ReadStack state, [MaybeNull] out T value)
+ internal bool TryRead(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options, ref ReadStack state, out T? value)
{
if (ClassType == ClassType.Value)
{
ThrowHelper.ThrowJsonException_DeserializeUnableToConvertValue(Converter.TypeToConvert);
}
- value = default(T)!;
+ value = default(T);
success = true;
}
else
/// <typeparam name="T"></typeparam>
internal abstract class JsonResumableConverter<T> : JsonConverter<T>
{
- [return: MaybeNull]
- public sealed override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ public sealed override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
// Bridge from resumable to value converters.
if (options == null)
// Members accessed by the serializer when deserializing.
private const DynamicallyAccessedMemberTypes MembersAccessedOnRead = DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.PublicProperties;
- [return: MaybeNull]
- private static TValue ReadCore<TValue>(ref Utf8JsonReader reader, Type returnType, JsonSerializerOptions options)
+ private static TValue? ReadCore<TValue>(ref Utf8JsonReader reader, Type returnType, JsonSerializerOptions options)
{
ReadStack state = default;
state.Initialize(returnType, options, supportContinuation: false);
return ReadCore<TValue>(jsonConverter, ref reader, options, ref state);
}
- [return: MaybeNull]
- private static TValue ReadCore<TValue>(JsonConverter jsonConverter, ref Utf8JsonReader reader, JsonSerializerOptions options, ref ReadStack state)
+ private static TValue? ReadCore<TValue>(JsonConverter jsonConverter, ref Utf8JsonReader reader, JsonSerializerOptions options, ref ReadStack state)
{
if (jsonConverter is JsonConverter<TValue> converter)
{
/// There is no compatible <see cref="System.Text.Json.Serialization.JsonConverter"/>
/// for <typeparamref name="TValue"/> or its serializable members.
/// </exception>
- [return: MaybeNull]
- public static TValue Deserialize<[DynamicallyAccessedMembers(MembersAccessedOnRead)] TValue>(ReadOnlySpan<byte> utf8Json, JsonSerializerOptions? options = null)
+ public static TValue? Deserialize<[DynamicallyAccessedMembers(MembersAccessedOnRead)] TValue>(ReadOnlySpan<byte> utf8Json, JsonSerializerOptions? options = null)
{
if (options == null)
{
/// There is no compatible <see cref="System.Text.Json.Serialization.JsonConverter"/>
/// for <typeparamref name="TValue"/> or its serializable members.
/// </exception>
- public static ValueTask<TValue> DeserializeAsync<[DynamicallyAccessedMembers(MembersAccessedOnRead)] TValue>(
+ public static ValueTask<TValue?> DeserializeAsync<[DynamicallyAccessedMembers(MembersAccessedOnRead)] TValue>(
Stream utf8Json,
JsonSerializerOptions? options = null,
CancellationToken cancellationToken = default)
return ReadAsync<object?>(utf8Json, returnType, options, cancellationToken);
}
- private static async ValueTask<TValue> ReadAsync<TValue>(
+ private static async ValueTask<TValue?> ReadAsync<TValue>(
Stream utf8Json,
Type returnType,
JsonSerializerOptions? options,
/// <remarks>Using a <see cref="string"/> is not as efficient as using the
/// UTF-8 methods since the implementation natively uses UTF-8.
/// </remarks>
- [return: MaybeNull]
- public static TValue Deserialize<[DynamicallyAccessedMembers(MembersAccessedOnRead)] TValue>(string json, JsonSerializerOptions? options = null)
+ public static TValue? Deserialize<[DynamicallyAccessedMembers(MembersAccessedOnRead)] TValue>(string json, JsonSerializerOptions? options = null)
{
if (json == null)
{
return value;
}
- [return: MaybeNull]
- private static TValue Deserialize<TValue>(string json, Type returnType, JsonSerializerOptions? options)
+ private static TValue? Deserialize<TValue>(string json, Type returnType, JsonSerializerOptions? options)
{
const long ArrayPoolMaxSizeBeforeUsingNormalAlloc = 1024 * 1024;
/// Hence, <see cref="JsonReaderOptions.AllowTrailingCommas"/>, <see cref="JsonReaderOptions.MaxDepth"/>, <see cref="JsonReaderOptions.CommentHandling"/> are used while reading.
/// </para>
/// </remarks>
- [return: MaybeNull]
- public static TValue Deserialize<[DynamicallyAccessedMembers(MembersAccessedOnRead)] TValue>(ref Utf8JsonReader reader, JsonSerializerOptions? options = null)
+ public static TValue? Deserialize<[DynamicallyAccessedMembers(MembersAccessedOnRead)] TValue>(ref Utf8JsonReader reader, JsonSerializerOptions? options = null)
{
if (options == null)
{
}
}
- [return: MaybeNull]
- private static TValue ReadValueCore<TValue>(JsonSerializerOptions options, ref Utf8JsonReader reader, ref ReadStack state)
+ private static TValue? ReadValueCore<TValue>(JsonSerializerOptions options, ref Utf8JsonReader reader, ref ReadStack state)
{
JsonReaderState readerState = reader.CurrentState;
CheckSupportedOptions(readerState.Options, nameof(reader));
{
internal static class HashtableExtensions
{
- public static bool TryGetValue<T>(this Hashtable table, object key, [MaybeNull] out T value)
+ public static bool TryGetValue<T>(this Hashtable table, object key, out T? value)
{
if (table.ContainsKey(key))
{
value = (T)table[key]!;
return true;
}
- value = default!;
+
+ value = default;
return false;
}
}
/// <summary>Only relevant to cancelable operations; 0 if the operation hasn't had completion reserved, 1 if it has.</summary>
private volatile int _completionReserved;
/// <summary>The result of the operation.</summary>
- [MaybeNull, AllowNull]
- private TResult _result = default;
+ private TResult? _result;
/// <summary>Any error that occurred during the operation.</summary>
private ExceptionDispatchInfo? _error;
/// <summary>The continuation callback.</summary>
}
/// <summary>The item being written.</summary>
- [MaybeNull, AllowNull]
- public TData Item { get; set; } = default!;
+ public TData? Item { get; set; }
}
}
}
}
- item = default!;
+ item = default;
return false;
}
return true;
}
- item = default!;
+ item = default;
return false;
}
public void Complete() { }
public System.IDisposable LinkTo(System.Threading.Tasks.Dataflow.ITargetBlock<T[]> target, System.Threading.Tasks.Dataflow.DataflowLinkOptions linkOptions) { throw null; }
void System.Threading.Tasks.Dataflow.IDataflowBlock.Fault(System.Exception exception) { }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- T[] System.Threading.Tasks.Dataflow.ISourceBlock<T[]>.ConsumeMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<T[]> target, out bool messageConsumed) { throw null; }
+ T[]? System.Threading.Tasks.Dataflow.ISourceBlock<T[]>.ConsumeMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<T[]> target, out bool messageConsumed) { throw null; }
void System.Threading.Tasks.Dataflow.ISourceBlock<T[]>.ReleaseReservation(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<T[]> target) { }
bool System.Threading.Tasks.Dataflow.ISourceBlock<T[]>.ReserveMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<T[]> target) { throw null; }
System.Threading.Tasks.Dataflow.DataflowMessageStatus System.Threading.Tasks.Dataflow.ITargetBlock<T>.OfferMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, T messageValue, System.Threading.Tasks.Dataflow.ISourceBlock<T>? source, bool consumeToAccept) { throw null; }
public System.IDisposable LinkTo(System.Threading.Tasks.Dataflow.ITargetBlock<T> target, System.Threading.Tasks.Dataflow.DataflowLinkOptions linkOptions) { throw null; }
void System.Threading.Tasks.Dataflow.IDataflowBlock.Fault(System.Exception exception) { }
bool System.Threading.Tasks.Dataflow.IReceivableSourceBlock<T>.TryReceiveAll([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Collections.Generic.IList<T>? items) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- T System.Threading.Tasks.Dataflow.ISourceBlock<T>.ConsumeMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<T> target, out bool messageConsumed) { throw null; }
+ T? System.Threading.Tasks.Dataflow.ISourceBlock<T>.ConsumeMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<T> target, out bool messageConsumed) { throw null; }
void System.Threading.Tasks.Dataflow.ISourceBlock<T>.ReleaseReservation(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<T> target) { }
bool System.Threading.Tasks.Dataflow.ISourceBlock<T>.ReserveMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<T> target) { throw null; }
System.Threading.Tasks.Dataflow.DataflowMessageStatus System.Threading.Tasks.Dataflow.ITargetBlock<T>.OfferMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, T messageValue, System.Threading.Tasks.Dataflow.ISourceBlock<T>? source, bool consumeToAccept) { throw null; }
public void Complete() { }
public System.IDisposable LinkTo(System.Threading.Tasks.Dataflow.ITargetBlock<T> target, System.Threading.Tasks.Dataflow.DataflowLinkOptions linkOptions) { throw null; }
void System.Threading.Tasks.Dataflow.IDataflowBlock.Fault(System.Exception exception) { }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- T System.Threading.Tasks.Dataflow.ISourceBlock<T>.ConsumeMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<T> target, out bool messageConsumed) { throw null; }
+ T? System.Threading.Tasks.Dataflow.ISourceBlock<T>.ConsumeMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<T> target, out bool messageConsumed) { throw null; }
void System.Threading.Tasks.Dataflow.ISourceBlock<T>.ReleaseReservation(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<T> target) { }
bool System.Threading.Tasks.Dataflow.ISourceBlock<T>.ReserveMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<T> target) { throw null; }
System.Threading.Tasks.Dataflow.DataflowMessageStatus System.Threading.Tasks.Dataflow.ITargetBlock<T>.OfferMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, T messageValue, System.Threading.Tasks.Dataflow.ISourceBlock<T>? source, bool consumeToAccept) { throw null; }
}
public partial interface ISourceBlock<out TOutput> : System.Threading.Tasks.Dataflow.IDataflowBlock
{
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- TOutput ConsumeMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<TOutput> target, out bool messageConsumed);
+ TOutput? ConsumeMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<TOutput> target, out bool messageConsumed);
System.IDisposable LinkTo(System.Threading.Tasks.Dataflow.ITargetBlock<TOutput> target, System.Threading.Tasks.Dataflow.DataflowLinkOptions linkOptions);
void ReleaseReservation(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<TOutput> target);
bool ReserveMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<TOutput> target);
public void Complete() { }
public System.IDisposable LinkTo(System.Threading.Tasks.Dataflow.ITargetBlock<TOutput> target, System.Threading.Tasks.Dataflow.DataflowLinkOptions linkOptions) { throw null; }
void System.Threading.Tasks.Dataflow.IDataflowBlock.Fault(System.Exception exception) { }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- TOutput System.Threading.Tasks.Dataflow.ISourceBlock<TOutput>.ConsumeMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<TOutput> target, out bool messageConsumed) { throw null; }
+ TOutput? System.Threading.Tasks.Dataflow.ISourceBlock<TOutput>.ConsumeMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<TOutput> target, out bool messageConsumed) { throw null; }
void System.Threading.Tasks.Dataflow.ISourceBlock<TOutput>.ReleaseReservation(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<TOutput> target) { }
bool System.Threading.Tasks.Dataflow.ISourceBlock<TOutput>.ReserveMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<TOutput> target) { throw null; }
System.Threading.Tasks.Dataflow.DataflowMessageStatus System.Threading.Tasks.Dataflow.ITargetBlock<TInput>.OfferMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, TInput messageValue, System.Threading.Tasks.Dataflow.ISourceBlock<TInput>? source, bool consumeToAccept) { throw null; }
public void Complete() { }
public System.IDisposable LinkTo(System.Threading.Tasks.Dataflow.ITargetBlock<TOutput> target, System.Threading.Tasks.Dataflow.DataflowLinkOptions linkOptions) { throw null; }
void System.Threading.Tasks.Dataflow.IDataflowBlock.Fault(System.Exception exception) { }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- TOutput System.Threading.Tasks.Dataflow.ISourceBlock<TOutput>.ConsumeMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<TOutput> target, out bool messageConsumed) { throw null; }
+ TOutput? System.Threading.Tasks.Dataflow.ISourceBlock<TOutput>.ConsumeMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<TOutput> target, out bool messageConsumed) { throw null; }
void System.Threading.Tasks.Dataflow.ISourceBlock<TOutput>.ReleaseReservation(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<TOutput> target) { }
bool System.Threading.Tasks.Dataflow.ISourceBlock<TOutput>.ReserveMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<TOutput> target) { throw null; }
System.Threading.Tasks.Dataflow.DataflowMessageStatus System.Threading.Tasks.Dataflow.ITargetBlock<TInput>.OfferMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, TInput messageValue, System.Threading.Tasks.Dataflow.ISourceBlock<TInput>? source, bool consumeToAccept) { throw null; }
public System.IDisposable LinkTo(System.Threading.Tasks.Dataflow.ITargetBlock<T> target, System.Threading.Tasks.Dataflow.DataflowLinkOptions linkOptions) { throw null; }
void System.Threading.Tasks.Dataflow.IDataflowBlock.Fault(System.Exception exception) { }
bool System.Threading.Tasks.Dataflow.IReceivableSourceBlock<T>.TryReceiveAll([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Collections.Generic.IList<T>? items) { throw null; }
- [return: System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- T System.Threading.Tasks.Dataflow.ISourceBlock<T>.ConsumeMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<T> target, out bool messageConsumed) { throw null; }
+ T? System.Threading.Tasks.Dataflow.ISourceBlock<T>.ConsumeMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<T> target, out bool messageConsumed) { throw null; }
void System.Threading.Tasks.Dataflow.ISourceBlock<T>.ReleaseReservation(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<T> target) { }
bool System.Threading.Tasks.Dataflow.ISourceBlock<T>.ReserveMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, System.Threading.Tasks.Dataflow.ITargetBlock<T> target) { throw null; }
System.Threading.Tasks.Dataflow.DataflowMessageStatus System.Threading.Tasks.Dataflow.ITargetBlock<T>.OfferMessage(System.Threading.Tasks.Dataflow.DataflowMessageHeader messageHeader, T messageValue, System.Threading.Tasks.Dataflow.ISourceBlock<T>? source, bool consumeToAccept) { throw null; }
}
/// <include file='XmlDocs/CommonXmlDocComments.xml' path='CommonXmlDocComments/Sources/Member[@name="ConsumeMessage"]/*' />
- [return: MaybeNull]
- T ISourceBlock<T>.ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<T> target, out bool messageConsumed)
+ T? ISourceBlock<T>.ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<T> target, out bool messageConsumed)
{
// This message should have only made it to the target if it passes the filter, so we shouldn't need to check again.
// The real source will also be doing verifications, so we don't need to validate args here.
}
/// <summary>Called by the target to consume the buffered message.</summary>
- [return: MaybeNull]
- TOutput ISourceBlock<TOutput>.ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target, out bool messageConsumed)
+ TOutput? ISourceBlock<TOutput>.ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target, out bool messageConsumed)
{
// Validate arguments
if (!messageHeader.IsValid) throw new ArgumentException(SR.Argument_InvalidMessageHeader, nameof(messageHeader));
};
/// <summary>The received value if we accepted a value from the source.</summary>
- [AllowNull, MaybeNull]
- private T _receivedValue = default!;
+ private T? _receivedValue;
/// <summary>The cancellation token source representing both external and internal cancellation.</summary>
internal readonly CancellationTokenSource _cts = new CancellationTokenSource();
}
/// <include file='XmlDocs/CommonXmlDocComments.xml' path='CommonXmlDocComments/Sources/Member[@name="ConsumeMessage"]/*' />
- [return: MaybeNull]
- public TOutput ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target, out bool messageConsumed)
+ public TOutput? ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target, out bool messageConsumed)
{
return _source.ConsumeMessage(messageHeader, target, out messageConsumed);
}
// IMPLEMENT EXPLICITLY
/// <include file='XmlDocs/CommonXmlDocComments.xml' path='CommonXmlDocComments/Sources/Member[@name="ConsumeMessage"]/*' />
- [return: MaybeNull]
- TOutput ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target, out bool messageConsumed);
+ TOutput? ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target, out bool messageConsumed);
/// <include file='XmlDocs/CommonXmlDocComments.xml' path='CommonXmlDocComments/Sources/Member[@name="ReserveMessage"]/*' />
bool ReserveMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target);
}
/// <include file='XmlDocs/CommonXmlDocComments.xml' path='CommonXmlDocComments/Sources/Member[@name="ConsumeMessage"]/*' />
- [return: MaybeNull]
- T[] ISourceBlock<T[]>.ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<T[]> target, out bool messageConsumed)
+ T[]? ISourceBlock<T[]>.ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<T[]> target, out bool messageConsumed)
{
return _source.ConsumeMessage(messageHeader, target, out messageConsumed);
}
}
/// <include file='XmlDocs/CommonXmlDocComments.xml' path='CommonXmlDocComments/Sources/Member[@name="ConsumeMessage"]/*' />
- [return: MaybeNull]
- Tuple<IList<T1>, IList<T2>> ISourceBlock<Tuple<IList<T1>, IList<T2>>>.ConsumeMessage(
+ Tuple<IList<T1>, IList<T2>>? ISourceBlock<Tuple<IList<T1>, IList<T2>>>.ConsumeMessage(
DataflowMessageHeader messageHeader, ITargetBlock<Tuple<IList<T1>, IList<T2>>> target, out bool messageConsumed)
{
return _source.ConsumeMessage(messageHeader, target, out messageConsumed);
}
/// <include file='XmlDocs/CommonXmlDocComments.xml' path='CommonXmlDocComments/Sources/Member[@name="ConsumeMessage"]/*' />
- [return: MaybeNull]
- Tuple<IList<T1>, IList<T2>, IList<T3>> ISourceBlock<Tuple<IList<T1>, IList<T2>, IList<T3>>>.ConsumeMessage(
+ Tuple<IList<T1>, IList<T2>, IList<T3>>? ISourceBlock<Tuple<IList<T1>, IList<T2>, IList<T3>>>.ConsumeMessage(
DataflowMessageHeader messageHeader, ITargetBlock<Tuple<IList<T1>, IList<T2>, IList<T3>>> target, out bool messageConsumed)
{
return _source.ConsumeMessage(messageHeader, target, out messageConsumed);
}
/// <include file='XmlDocs/CommonXmlDocComments.xml' path='CommonXmlDocComments/Sources/Member[@name="ConsumeMessage"]/*' />
- [return: MaybeNull]
- T ISourceBlock<T>.ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<T> target, out bool messageConsumed)
+ T? ISourceBlock<T>.ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<T> target, out bool messageConsumed)
{
return _source.ConsumeMessage(messageHeader, target, out messageConsumed);
}
/// <summary>An indicator whether _currentMessage has a value.</summary>
private bool _currentMessageIsValid;
/// <summary>The message currently being broadcast.</summary>
- [AllowNull, MaybeNull]
- private TOutput _currentMessage = default;
+ private TOutput? _currentMessage;
/// <summary>The target that the next message is reserved for, or null if nothing is reserved.</summary>
private ITargetBlock<TOutput>? _nextMessageReservedFor;
/// <summary>Whether this block should again attempt to offer messages to targets.</summary>
}
/// <include file='XmlDocs/CommonXmlDocComments.xml' path='CommonXmlDocComments/Sources/Member[@name="ConsumeMessage"]/*' />
- [return: MaybeNull]
- internal TOutput ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target, out bool messageConsumed)
+ internal TOutput? ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target, out bool messageConsumed)
{
// Validate arguments
if (!messageHeader.IsValid) throw new ArgumentException(SR.Argument_InvalidMessageHeader, nameof(messageHeader));
public Task Completion { get { return _source.Completion; } }
/// <include file='XmlDocs/CommonXmlDocComments.xml' path='CommonXmlDocComments/Sources/Member[@name="ConsumeMessage"]/*' />
- [return: MaybeNull]
- T ISourceBlock<T>.ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<T> target, out bool messageConsumed)
+ T? ISourceBlock<T>.ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<T> target, out bool messageConsumed)
{
return _source.ConsumeMessage(messageHeader, target, out messageConsumed);
}
}
/// <include file='XmlDocs/CommonXmlDocComments.xml' path='CommonXmlDocComments/Sources/Member[@name="ConsumeMessage"]/*' />
- [return: MaybeNull]
- TOutput ISourceBlock<TOutput>.ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target, out bool messageConsumed)
+ TOutput? ISourceBlock<TOutput>.ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target, out bool messageConsumed)
{
return _source.ConsumeMessage(messageHeader, target, out messageConsumed);
}
}
/// <include file='XmlDocs/CommonXmlDocComments.xml' path='CommonXmlDocComments/Sources/Member[@name="ConsumeMessage"]/*' />
- [return: MaybeNull]
- TOutput ISourceBlock<TOutput>.ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target, out bool messageConsumed)
+ TOutput? ISourceBlock<TOutput>.ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target, out bool messageConsumed)
{
return _source.ConsumeMessage(messageHeader, target, out messageConsumed);
}
/// <summary>The header of the singly-assigned value.</summary>
private DataflowMessageHeader _header;
/// <summary>The singly-assigned value.</summary>
- [AllowNull, MaybeNull]
- private T _value = default;
+ private T? _value;
/// <summary>Gets the object used as the value lock.</summary>
private object ValueLock { get { return _targetRegistry; } }
}
/// <include file='XmlDocs/CommonXmlDocComments.xml' path='CommonXmlDocComments/Sources/Member[@name="ConsumeMessage"]/*' />
- T ISourceBlock<T>.ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<T> target, out bool messageConsumed)
+ T? ISourceBlock<T>.ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<T> target, out bool messageConsumed)
{
// Validate arguments
if (!messageHeader.IsValid) throw new ArgumentException(SR.Argument_InvalidMessageHeader, nameof(messageHeader));
else
{
messageConsumed = false;
- return default(T)!;
+ return default;
}
}
/// <summary>Gets whether the block is storing a value.</summary>
private bool HasValue { get { return _header.IsValid; } }
/// <summary>Gets the value being stored by the block.</summary>
- [MaybeNull]
- private T Value { get { return _header.IsValid ? _value : default(T); } }
+ private T? Value { get { return _header.IsValid ? _value : default(T); } }
/// <include file='XmlDocs/CommonXmlDocComments.xml' path='CommonXmlDocComments/Blocks/Member[@name="ToString"]/*' />
public override string ToString() { return Common.GetNameForDebugger(this, _dataflowBlockOptions); }
/// <summary>Gets whether the WriteOnceBlock has a value.</summary>
public bool HasValue { get { return _writeOnceBlock.HasValue; } }
/// <summary>Gets the WriteOnceBlock's value if it has one, or default(T) if it doesn't.</summary>
- [MaybeNull]
- public T Value { get { return _writeOnceBlock.Value; } }
+ public T? Value { get { return _writeOnceBlock.Value; } }
/// <summary>Gets the DataflowBlockOptions used to configure this block.</summary>
public DataflowBlockOptions DataflowBlockOptions { get { return _writeOnceBlock._dataflowBlockOptions; } }
/// <typeparam name="T">The type of the data to be unwrapped.</typeparam>
/// <param name="state">The weak reference.</param>
/// <returns>The T instance.</returns>
- [return: MaybeNull]
- internal static T UnwrapWeakReference<T>(object state) where T : class
+ internal static T? UnwrapWeakReference<T>(object state) where T : class
{
var wr = state as WeakReference<T>;
Debug.Assert(wr != null, "Expected a WeakReference<T> as the state argument");
/// <param name="id">The ID of the item.</param>
/// <param name="item">The completed item.</param>
/// <param name="itemIsValid">Specifies whether the item is valid (true) or just a placeholder (false).</param>
- internal void AddItem(long id, [AllowNull] TOutput item, bool itemIsValid)
+ internal void AddItem(long id, TOutput? item, bool itemIsValid)
{
Debug.Assert(id != Common.INVALID_REORDERING_ID, "This ID should never have been handed out.");
Common.ContractAssertMonitorStatus(ValueLock, held: false);
/// true if the item was not added but is next in line.
/// false if the item was not added and is not next in line.
/// </returns>
- internal bool? AddItemIfNextAndTrusted(long id, [AllowNull] TOutput item, bool isTrusted)
+ internal bool? AddItemIfNextAndTrusted(long id, TOutput? item, bool isTrusted)
{
Debug.Assert(id != Common.INVALID_REORDERING_ID, "This ID should never have been handed out.");
Common.ContractAssertMonitorStatus(ValueLock, held: false);
/// <summary>Outputs the item. The item must have already been confirmed to have the next ID.</summary>
/// <param name="theNextItem">The item to output.</param>
/// <param name="itemIsValid">Whether the item is valid.</param>
- private void OutputNextItem([AllowNull] TOutput theNextItem, bool itemIsValid)
+ private void OutputNextItem(TOutput? theNextItem, bool itemIsValid)
{
Common.ContractAssertMonitorStatus(ValueLock, held: true);
}
/// <include file='XmlDocs/CommonXmlDocComments.xml' path='CommonXmlDocComments/Sources/Member[@name="ConsumeMessage"]/*' />
- [return: MaybeNull]
- internal TOutput ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target, out bool messageConsumed)
+ internal TOutput? ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<TOutput> target, out bool messageConsumed)
{
// Validate arguments
if (!messageHeader.IsValid) throw new ArgumentException(SR.Argument_InvalidMessageHeader, nameof(messageHeader));
}
/// <include file='XmlDocs/CommonXmlDocComments.xml' path='CommonXmlDocComments/Sources/Member[@name="ConsumeMessage"]/*' />
- [return: MaybeNull]
- T ISourceBlock<T>.ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<T> target, out bool messageConsumed)
+ T? ISourceBlock<T>.ConsumeMessage(DataflowMessageHeader messageHeader, ITargetBlock<T> target, out bool messageConsumed)
{
return _owningSource.ConsumeMessage(messageHeader, this, out messageConsumed);
}
private readonly T _PreviousValue_k__BackingField;
private readonly T _CurrentValue_k__BackingField;
private readonly int _dummyPrimitive;
- [System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public T CurrentValue { get { throw null; } }
- [System.Diagnostics.CodeAnalysis.MaybeNullAttribute]
- public T PreviousValue { get { throw null; } }
+ public T? CurrentValue { get { throw null; } }
+ public T? PreviousValue { get { throw null; } }
public bool ThreadContextChanged { get { throw null; } }
}
public sealed partial class AsyncLocal<T>
public abstract ITypeName NestedName(ITypeIdentifier innerName);
- public bool Equals([AllowNull] ITypeName other)
+ public bool Equals(ITypeName? other)
{
return other != null && DisplayName == other.DisplayName;
}
private GCHandle handle;
private bool trackResurrection;
- [MaybeNull]
- private T Target
+ private T? Target
{
get
{