Update corefx for compiler nullable attribute updates
authorStephen Toub <stoub@microsoft.com>
Thu, 13 Jun 2019 20:55:11 +0000 (16:55 -0400)
committerStephen Toub <stoub@microsoft.com>
Thu, 13 Jun 2019 22:26:36 +0000 (18:26 -0400)
Commit migrated from https://github.com/dotnet/corefx/commit/3c129ac0340a3843ab5b00a9c730730e7b60729b

src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/BlockingCollection.cs
src/libraries/System.Collections.Concurrent/src/System/Collections/Concurrent/ConcurrentStack.cs
src/libraries/System.Collections/src/System/Collections/BitArray.cs
src/libraries/System.Collections/src/System/Collections/Generic/Stack.cs
src/libraries/System.Memory/src/System/Buffers/ReadOnlySequence.cs
src/libraries/System.Private.Uri/src/System/Uri.cs
src/libraries/System.Private.Uri/src/System/UriExt.cs
src/libraries/System.Runtime.Extensions/src/System/Net/WebUtility.cs

index b6442f3..9da52a7 100644 (file)
@@ -1167,7 +1167,7 @@ nameof(boundedCapacity), boundedCapacity,
         /// <exception cref="T: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, [MaybeNullWhen(false)] out T item)
+        public static int TakeFromAny(BlockingCollection<T>[] collections, [MaybeNull] out T item)
         {
             return TakeFromAny(collections, out item, CancellationToken.None);
         }
@@ -1196,7 +1196,7 @@ nameof(boundedCapacity), boundedCapacity,
         /// <exception cref="T: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, [MaybeNullWhen(false)] out T item, CancellationToken cancellationToken)
+        public static int TakeFromAny(BlockingCollection<T>[] 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,
         /// <exception cref="T: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, [MaybeNullWhen(false)] out T item)
+        public static int TryTakeFromAny(BlockingCollection<T>[] collections, [MaybeNull] out T item)
         {
             return TryTakeFromAny(collections, out item, 0);
         }
@@ -1255,7 +1255,7 @@ nameof(boundedCapacity), boundedCapacity,
         /// <exception cref="T: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, [MaybeNullWhen(false)] out T item, TimeSpan timeout)
+        public static int TryTakeFromAny(BlockingCollection<T>[] 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,
         /// <exception cref="T: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, [MaybeNullWhen(false)] out T item, int millisecondsTimeout)
+        public static int TryTakeFromAny(BlockingCollection<T>[] 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,
         /// <exception cref="T: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, [MaybeNullWhen(false)] out T item, int millisecondsTimeout, CancellationToken cancellationToken)
+        public static int TryTakeFromAny(BlockingCollection<T>[] 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,
         /// <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, [MaybeNullWhen(false)] out T item, int millisecondsTimeout, bool isTakeOperation, CancellationToken externalCancellationToken)
+        private static int TryTakeFromAnyCore(BlockingCollection<T>[] collections, [MaybeNull] out T item, int millisecondsTimeout, bool isTakeOperation, CancellationToken externalCancellationToken)
         {
             ValidateCollectionsArray(collections, false);
 
@@ -1376,7 +1376,7 @@ nameof(boundedCapacity), boundedCapacity,
         /// <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, [MaybeNullWhen(false)] out T item, int millisecondsTimeout, bool isTakeOperation, CancellationToken externalCancellationToken)
+        private static int TryTakeFromAnyCoreSlow(BlockingCollection<T>[] collections, [MaybeNull] out T item, int millisecondsTimeout, bool isTakeOperation, CancellationToken externalCancellationToken)
         {
             const int OPERATION_FAILED = -1;
 
index 44a0f11..48f10d5 100644 (file)
@@ -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
         /// </param>
         /// <returns>The number of objects successfully popped from the top of
         /// the <see cref="ConcurrentStack{T}"/>.</returns>
-        private int TryPopCore(int count, [NotNullWhen(true)] out Node? poppedHead)
+        private int TryPopCore(int count, out Node? poppedHead)
         {
             SpinWait spin = new SpinWait();
 
index 4591929..81bc0e5 100644 (file)
@@ -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)
index 321d180..2ffc185 100644 (file)
@@ -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++;
index b88121a..51c69df 100644 (file)
@@ -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)
index fabc104..ff53cd4 100644 (file)
@@ -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;
             }
index b9fd95f..1d371f7 100644 (file)
@@ -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();
         }
 
         //
index cac319a..8ee73af 100644 (file)
@@ -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;