From 37806d0f7bbfb8a59555033c05429b4a2cf23c52 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Thu, 13 Jun 2019 16:55:11 -0400 Subject: [PATCH] Update corefx for compiler nullable attribute updates Commit migrated from https://github.com/dotnet/corefx/commit/3c129ac0340a3843ab5b00a9c730730e7b60729b --- .../System/Collections/Concurrent/BlockingCollection.cs | 16 ++++++++-------- .../src/System/Collections/Concurrent/ConcurrentStack.cs | 4 ++-- .../src/System/Collections/BitArray.cs | 2 +- .../src/System/Collections/Generic/Stack.cs | 4 ++-- .../System.Memory/src/System/Buffers/ReadOnlySequence.cs | 6 +++--- src/libraries/System.Private.Uri/src/System/Uri.cs | 2 +- src/libraries/System.Private.Uri/src/System/UriExt.cs | 4 ++-- .../src/System/Net/WebUtility.cs | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs index b6442f3..9da52a7 100644 --- a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs +++ b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs @@ -1167,7 +1167,7 @@ nameof(boundedCapacity), boundedCapacity, /// The count of is greater than the maximum size of /// 62 for STA and 63 for MTA. /// A call to TakeFromAny may block until an item is available to be removed. - public static int TakeFromAny(BlockingCollection[] collections, [MaybeNullWhen(false)] out T item) + public static int TakeFromAny(BlockingCollection[] collections, [MaybeNull] out T item) { return TakeFromAny(collections, out item, CancellationToken.None); } @@ -1196,7 +1196,7 @@ nameof(boundedCapacity), boundedCapacity, /// The count of is greater than the maximum size of /// 62 for STA and 63 for MTA. /// A call to TakeFromAny may block until an item is available to be removed. - public static int TakeFromAny(BlockingCollection[] collections, [MaybeNullWhen(false)] out T item, CancellationToken cancellationToken) + public static int TakeFromAny(BlockingCollection[] collections, [MaybeNull] out T item, CancellationToken cancellationToken) { int returnValue = TryTakeFromAnyCore(collections, out item, Timeout.Infinite, true, cancellationToken); Debug.Assert((returnValue >= 0 && returnValue < collections.Length) @@ -1224,7 +1224,7 @@ nameof(boundedCapacity), boundedCapacity, /// The count of is greater than the maximum size of /// 62 for STA and 63 for MTA. /// A call to TryTakeFromAny may block until an item is available to be removed. - public static int TryTakeFromAny(BlockingCollection[] collections, [MaybeNullWhen(false)] out T item) + public static int TryTakeFromAny(BlockingCollection[] collections, [MaybeNull] out T item) { return TryTakeFromAny(collections, out item, 0); } @@ -1255,7 +1255,7 @@ nameof(boundedCapacity), boundedCapacity, /// The count of is greater than the maximum size of /// 62 for STA and 63 for MTA. /// A call to TryTakeFromAny may block until an item is available to be removed. - public static int TryTakeFromAny(BlockingCollection[] collections, [MaybeNullWhen(false)] out T item, TimeSpan timeout) + public static int TryTakeFromAny(BlockingCollection[] collections, [MaybeNull] out T item, TimeSpan timeout) { ValidateTimeout(timeout); return TryTakeFromAnyCore(collections, out item, (int)timeout.TotalMilliseconds, false, CancellationToken.None); @@ -1285,7 +1285,7 @@ nameof(boundedCapacity), boundedCapacity, /// The count of is greater than the maximum size of /// 62 for STA and 63 for MTA. /// A call to TryTakeFromAny may block until an item is available to be removed. - public static int TryTakeFromAny(BlockingCollection[] collections, [MaybeNullWhen(false)] out T item, int millisecondsTimeout) + public static int TryTakeFromAny(BlockingCollection[] collections, [MaybeNull] out T item, int millisecondsTimeout) { ValidateMillisecondsTimeout(millisecondsTimeout); return TryTakeFromAnyCore(collections, out item, millisecondsTimeout, false, CancellationToken.None); @@ -1319,7 +1319,7 @@ nameof(boundedCapacity), boundedCapacity, /// The count of is greater than the maximum size of /// 62 for STA and 63 for MTA. /// A call to TryTakeFromAny may block until an item is available to be removed. - public static int TryTakeFromAny(BlockingCollection[] collections, [MaybeNullWhen(false)] out T item, int millisecondsTimeout, CancellationToken cancellationToken) + public static int TryTakeFromAny(BlockingCollection[] collections, [MaybeNull] out T item, int millisecondsTimeout, CancellationToken cancellationToken) { ValidateMillisecondsTimeout(millisecondsTimeout); return TryTakeFromAnyCore(collections, out item, millisecondsTimeout, false, cancellationToken); @@ -1342,7 +1342,7 @@ nameof(boundedCapacity), boundedCapacity, /// 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. /// If at least one of the collections has been disposed. - private static int TryTakeFromAnyCore(BlockingCollection[] collections, [MaybeNullWhen(false)] out T item, int millisecondsTimeout, bool isTakeOperation, CancellationToken externalCancellationToken) + private static int TryTakeFromAnyCore(BlockingCollection[] collections, [MaybeNull] out T item, int millisecondsTimeout, bool isTakeOperation, CancellationToken externalCancellationToken) { ValidateCollectionsArray(collections, false); @@ -1376,7 +1376,7 @@ nameof(boundedCapacity), boundedCapacity, /// 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. /// If at least one of the collections has been disposed. - private static int TryTakeFromAnyCoreSlow(BlockingCollection[] collections, [MaybeNullWhen(false)] out T item, int millisecondsTimeout, bool isTakeOperation, CancellationToken externalCancellationToken) + private static int TryTakeFromAnyCoreSlow(BlockingCollection[] collections, [MaybeNull] out T item, int millisecondsTimeout, bool isTakeOperation, CancellationToken externalCancellationToken) { const int OPERATION_FAILED = -1; diff --git a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentStack.cs b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentStack.cs index 44a0f11..48f10d5 100644 --- a/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentStack.cs +++ b/src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentStack.cs @@ -579,7 +579,7 @@ namespace System.Collections.Concurrent if (TryPopCore(1, out poppedNode) == 1) { - result = poppedNode!._value; // TODO-NULLABLE: Remove ! when nullable attributes are respected + result = poppedNode!._value; return true; } @@ -598,7 +598,7 @@ namespace System.Collections.Concurrent /// /// The number of objects successfully popped from the top of /// the . - private int TryPopCore(int count, [NotNullWhen(true)] out Node? poppedHead) + private int TryPopCore(int count, out Node? poppedHead) { SpinWait spin = new SpinWait(); diff --git a/src/libraries/System.Collections/src/System/Collections/BitArray.cs b/src/libraries/System.Collections/src/System/Collections/BitArray.cs index 4591929..81bc0e5 100644 --- a/src/libraries/System.Collections/src/System/Collections/BitArray.cs +++ b/src/libraries/System.Collections/src/System/Collections/BitArray.cs @@ -548,7 +548,7 @@ namespace System.Collections if (newints > m_array.Length || newints + _ShrinkThreshold < m_array.Length) { // grow or shrink (if wasting more than _ShrinkThreshold ints) - Array.Resize(ref m_array!, newints); // TODO-NULLABLE: Remove ! when nullable attributes are respected + Array.Resize(ref m_array, newints); } if (value > m_length) diff --git a/src/libraries/System.Collections/src/System/Collections/Generic/Stack.cs b/src/libraries/System.Collections/src/System/Collections/Generic/Stack.cs index 321d180..2ffc185 100644 --- a/src/libraries/System.Collections/src/System/Collections/Generic/Stack.cs +++ b/src/libraries/System.Collections/src/System/Collections/Generic/Stack.cs @@ -181,7 +181,7 @@ namespace System.Collections.Generic int threshold = (int)(((double)_array.Length) * 0.9); if (_size < threshold) { - Array.Resize(ref _array!, _size); // TODO-NULLABLE: Remove ! when nullable attributes are respected + Array.Resize(ref _array, _size); _version++; } } @@ -283,7 +283,7 @@ namespace System.Collections.Generic [MethodImpl(MethodImplOptions.NoInlining)] private void PushWithResize(T item) { - Array.Resize(ref _array!, (_array.Length == 0) ? DefaultCapacity : 2 * _array.Length); // TODO-NULLABLE: Remove ! when nullable attributes are respected + Array.Resize(ref _array, (_array.Length == 0) ? DefaultCapacity : 2 * _array.Length); _array[_size] = item; _version++; _size++; diff --git a/src/libraries/System.Memory/src/System/Buffers/ReadOnlySequence.cs b/src/libraries/System.Memory/src/System/Buffers/ReadOnlySequence.cs index b88121a..51c69df 100644 --- a/src/libraries/System.Memory/src/System/Buffers/ReadOnlySequence.cs +++ b/src/libraries/System.Memory/src/System/Buffers/ReadOnlySequence.cs @@ -118,8 +118,8 @@ namespace System.Buffers if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); - _startObject = array!; // TODO-NULLABLE: Remove ! when nullable attributes are respected - _endObject = array!; // TODO-NULLABLE: Remove ! when nullable attributes are respected + _startObject = array!; // TODO-NULLABLE: Remove ! when [DoesNotReturn] respected + _endObject = array!; // TODO-NULLABLE: Remove ! when [DoesNotReturn] respected _startInteger = ReadOnlySequence.ArrayToSequenceStart(0); _endInteger = ReadOnlySequence.ArrayToSequenceEnd(array!.Length); // TODO-NULLABLE: Remove ! when [DoesNotReturn] respected } @@ -485,7 +485,7 @@ namespace System.Buffers if (SequenceMarshal.TryGetString(charSequence, out string? text, out int start, out int length)) { - return text!.Substring(start, length); // TODO-NULLABLE: Remove ! when nullable attributes are respected + return text.Substring(start, length); } if (Length < int.MaxValue) diff --git a/src/libraries/System.Private.Uri/src/System/Uri.cs b/src/libraries/System.Private.Uri/src/System/Uri.cs index fabc104..ff53cd4 100644 --- a/src/libraries/System.Private.Uri/src/System/Uri.cs +++ b/src/libraries/System.Private.Uri/src/System/Uri.cs @@ -1694,7 +1694,7 @@ namespace System // Since v1.0 two Uris are equal if everything but fragment and UserInfo does match // This check is for a case where we already fixed up the equal references - if ((object)_string == (object)obj!._string) // TODO-NULLABLE: Remove ! when nullable attributes are respected + if ((object)_string == (object)obj._string) { return true; } diff --git a/src/libraries/System.Private.Uri/src/System/UriExt.cs b/src/libraries/System.Private.Uri/src/System/UriExt.cs index b9fd95f..1d371f7 100644 --- a/src/libraries/System.Private.Uri/src/System/UriExt.cs +++ b/src/libraries/System.Private.Uri/src/System/UriExt.cs @@ -281,7 +281,7 @@ namespace System Uri? relativeLink; if (TryCreate(relativeUri, UriKind.RelativeOrAbsolute, out relativeLink)) { - if (!relativeLink!.IsAbsoluteUri) // TODO-NULLABLE: Remove ! when nullable attributes are respected + if (!relativeLink.IsAbsoluteUri) return TryCreate(baseUri, relativeLink, out result); result = relativeLink; @@ -391,7 +391,7 @@ namespace System if (!Uri.TryCreate(uriString, uriKind, out result)) return false; - return result!.IsWellFormedOriginalString(); // TODO-NULLABLE: Remove ! when nullable attributes are respected + return result.IsWellFormedOriginalString(); } // diff --git a/src/libraries/System.Runtime.Extensions/src/System/Net/WebUtility.cs b/src/libraries/System.Runtime.Extensions/src/System/Net/WebUtility.cs index cac319a..8ee73af 100644 --- a/src/libraries/System.Runtime.Extensions/src/System/Net/WebUtility.cs +++ b/src/libraries/System.Runtime.Extensions/src/System/Net/WebUtility.cs @@ -597,7 +597,7 @@ namespace System.Net if (decodedBytesCount < decodedBytes.Length) { - Array.Resize(ref decodedBytes!, decodedBytesCount); // TODO-NULLABLE: Remove ! when nullable attributes are respected + Array.Resize(ref decodedBytes, decodedBytesCount); } return decodedBytes; -- 2.7.4