From 9e99b02b798ac51db6837b0d364cef59a5f24d70 Mon Sep 17 00:00:00 2001 From: Santiago Fernandez Madero Date: Tue, 18 Jun 2019 16:16:18 -0700 Subject: [PATCH] Add nullable annotations to System.Memory ref assembly (dotnet/corefx#38299) * Add nullable annotations to System.Memory ref assembly * Nullable feedback * Include where T inside pragma to be consistent with sources * Make CultureInfo nullable in ToLower/Upper to match updates we did on String * Revert comparer nullable change in BinarySearch per pr feedback in implementation Commit migrated from https://github.com/dotnet/corefx/commit/ad961d0dc9d9054942c6a7e3a8c96c8684dd16cc --- src/libraries/System.Memory/ref/System.Memory.cs | 332 +++++++++++++++------ .../System.Memory/ref/System.Memory.csproj | 1 + .../Runtime/InteropServices/SequenceMarshal.cs | 2 +- 3 files changed, 247 insertions(+), 88 deletions(-) diff --git a/src/libraries/System.Memory/ref/System.Memory.cs b/src/libraries/System.Memory/ref/System.Memory.cs index db944f1..51745be 100644 --- a/src/libraries/System.Memory/ref/System.Memory.cs +++ b/src/libraries/System.Memory/ref/System.Memory.cs @@ -9,32 +9,32 @@ namespace System { public static partial class MemoryExtensions { - public static System.ReadOnlyMemory AsMemory(this string text) { throw null; } - public static System.ReadOnlyMemory AsMemory(this string text, System.Index startIndex) { throw null; } - public static System.ReadOnlyMemory AsMemory(this string text, int start) { throw null; } - public static System.ReadOnlyMemory AsMemory(this string text, int start, int length) { throw null; } - public static System.ReadOnlyMemory AsMemory(this string text, System.Range range) { throw null; } + public static System.ReadOnlyMemory AsMemory(this string? text) { throw null; } + public static System.ReadOnlyMemory AsMemory(this string? text, System.Index startIndex) { throw null; } + public static System.ReadOnlyMemory AsMemory(this string? text, int start) { throw null; } + public static System.ReadOnlyMemory AsMemory(this string? text, int start, int length) { throw null; } + public static System.ReadOnlyMemory AsMemory(this string? text, System.Range range) { throw null; } public static System.Memory AsMemory(this System.ArraySegment segment) { throw null; } public static System.Memory AsMemory(this System.ArraySegment segment, int start) { throw null; } public static System.Memory AsMemory(this System.ArraySegment segment, int start, int length) { throw null; } - public static System.Memory AsMemory(this T[] array) { throw null; } - public static System.Memory AsMemory(this T[] array, System.Index startIndex) { throw null; } - public static System.Memory AsMemory(this T[] array, int start) { throw null; } - public static System.Memory AsMemory(this T[] array, int start, int length) { throw null; } - public static System.Memory AsMemory(this T[] array, System.Range range) { throw null; } - public static System.ReadOnlySpan AsSpan(this string text) { throw null; } - public static System.ReadOnlySpan AsSpan(this string text, int start) { throw null; } - public static System.ReadOnlySpan AsSpan(this string text, int start, int length) { throw null; } + public static System.Memory AsMemory(this T[]? array) { throw null; } + public static System.Memory AsMemory(this T[]? array, System.Index startIndex) { throw null; } + public static System.Memory AsMemory(this T[]? array, int start) { throw null; } + public static System.Memory AsMemory(this T[]? array, int start, int length) { throw null; } + public static System.Memory AsMemory(this T[]? array, System.Range range) { throw null; } + public static System.ReadOnlySpan AsSpan(this string? text) { throw null; } + public static System.ReadOnlySpan AsSpan(this string? text, int start) { throw null; } + public static System.ReadOnlySpan AsSpan(this string? text, int start, int length) { throw null; } public static System.Span AsSpan(this System.ArraySegment segment) { throw null; } public static System.Span AsSpan(this System.ArraySegment segment, System.Index startIndex) { throw null; } public static System.Span AsSpan(this System.ArraySegment segment, int start) { throw null; } public static System.Span AsSpan(this System.ArraySegment segment, int start, int length) { throw null; } public static System.Span AsSpan(this System.ArraySegment segment, System.Range range) { throw null; } - public static System.Span AsSpan(this T[] array) { throw null; } - public static System.Span AsSpan(this T[] array, System.Index startIndex) { throw null; } - public static System.Span AsSpan(this T[] array, int start) { throw null; } - public static System.Span AsSpan(this T[] array, int start, int length) { throw null; } - public static System.Span AsSpan(this T[] array, System.Range range) { throw null; } + public static System.Span AsSpan(this T[]? array) { throw null; } + public static System.Span AsSpan(this T[]? array, System.Index startIndex) { throw null; } + public static System.Span AsSpan(this T[]? array, int start) { throw null; } + public static System.Span AsSpan(this T[]? array, int start, int length) { throw null; } + public static System.Span AsSpan(this T[]? array, System.Range range) { throw null; } public static int BinarySearch(this System.ReadOnlySpan span, System.IComparable comparable) { throw null; } public static int BinarySearch(this System.Span span, System.IComparable comparable) { throw null; } public static int BinarySearch(this System.ReadOnlySpan span, T value, TComparer comparer) where TComparer : System.Collections.Generic.IComparer { throw null; } @@ -43,39 +43,111 @@ namespace System public static int BinarySearch(this System.Span span, TComparable comparable) where TComparable : System.IComparable { throw null; } public static int CompareTo(this System.ReadOnlySpan span, System.ReadOnlySpan other, System.StringComparison comparisonType) { throw null; } public static bool Contains(this System.ReadOnlySpan span, System.ReadOnlySpan value, System.StringComparison comparisonType) { throw null; } - public static bool Contains(this System.ReadOnlySpan span, T value) where T : System.IEquatable { throw null; } - public static bool Contains(this System.Span span, T value) where T : System.IEquatable { throw null; } - public static void CopyTo(this T[] source, System.Memory destination) { } - public static void CopyTo(this T[] source, System.Span destination) { } + public static bool Contains(this System.ReadOnlySpan span, T value) +#nullable disable // to enable use with both T and T? for reference types due to IEquatable being invariant + where T : System.IEquatable { throw null; } +#nullable restore + public static bool Contains(this System.Span span, T value) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static void CopyTo(this T[]? source, System.Memory destination) { } + public static void CopyTo(this T[]? source, System.Span destination) { } public static bool EndsWith(this System.ReadOnlySpan span, System.ReadOnlySpan value, System.StringComparison comparisonType) { throw null; } - public static bool EndsWith(this System.ReadOnlySpan span, System.ReadOnlySpan value) where T : System.IEquatable { throw null; } - public static bool EndsWith(this System.Span span, System.ReadOnlySpan value) where T : System.IEquatable { throw null; } + public static bool EndsWith(this System.ReadOnlySpan span, System.ReadOnlySpan value) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static bool EndsWith(this System.Span span, System.ReadOnlySpan value) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore public static System.Text.SpanRuneEnumerator EnumerateRunes(this System.ReadOnlySpan span) { throw null; } public static System.Text.SpanRuneEnumerator EnumerateRunes(this System.Span span) { throw null; } public static bool Equals(this System.ReadOnlySpan span, System.ReadOnlySpan other, System.StringComparison comparisonType) { throw null; } public static int IndexOf(this System.ReadOnlySpan span, System.ReadOnlySpan value, System.StringComparison comparisonType) { throw null; } - public static int IndexOfAny(this System.ReadOnlySpan span, System.ReadOnlySpan values) where T : System.IEquatable { throw null; } - public static int IndexOfAny(this System.ReadOnlySpan span, T value0, T value1) where T : System.IEquatable { throw null; } - public static int IndexOfAny(this System.ReadOnlySpan span, T value0, T value1, T value2) where T : System.IEquatable { throw null; } - public static int IndexOfAny(this System.Span span, System.ReadOnlySpan values) where T : System.IEquatable { throw null; } - public static int IndexOfAny(this System.Span span, T value0, T value1) where T : System.IEquatable { throw null; } - public static int IndexOfAny(this System.Span span, T value0, T value1, T value2) where T : System.IEquatable { throw null; } - public static int IndexOf(this System.ReadOnlySpan span, System.ReadOnlySpan value) where T : System.IEquatable { throw null; } - public static int IndexOf(this System.ReadOnlySpan span, T value) where T : System.IEquatable { throw null; } - public static int IndexOf(this System.Span span, System.ReadOnlySpan value) where T : System.IEquatable { throw null; } - public static int IndexOf(this System.Span span, T value) where T : System.IEquatable { throw null; } + public static int IndexOfAny(this System.ReadOnlySpan span, System.ReadOnlySpan values) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int IndexOfAny(this System.ReadOnlySpan span, T value0, T value1) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int IndexOfAny(this System.ReadOnlySpan span, T value0, T value1, T value2) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int IndexOfAny(this System.Span span, System.ReadOnlySpan values) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int IndexOfAny(this System.Span span, T value0, T value1) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int IndexOfAny(this System.Span span, T value0, T value1, T value2) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int IndexOf(this System.ReadOnlySpan span, System.ReadOnlySpan value) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int IndexOf(this System.ReadOnlySpan span, T value) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int IndexOf(this System.Span span, System.ReadOnlySpan value) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int IndexOf(this System.Span span, T value) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore public static bool IsWhiteSpace(this System.ReadOnlySpan span) { throw null; } public static int LastIndexOf(this System.ReadOnlySpan span, System.ReadOnlySpan value, System.StringComparison comparisonType) { throw null; } - public static int LastIndexOfAny(this System.ReadOnlySpan span, System.ReadOnlySpan values) where T : System.IEquatable { throw null; } - public static int LastIndexOfAny(this System.ReadOnlySpan span, T value0, T value1) where T : System.IEquatable { throw null; } - public static int LastIndexOfAny(this System.ReadOnlySpan span, T value0, T value1, T value2) where T : System.IEquatable { throw null; } - public static int LastIndexOfAny(this System.Span span, System.ReadOnlySpan values) where T : System.IEquatable { throw null; } - public static int LastIndexOfAny(this System.Span span, T value0, T value1) where T : System.IEquatable { throw null; } - public static int LastIndexOfAny(this System.Span span, T value0, T value1, T value2) where T : System.IEquatable { throw null; } - public static int LastIndexOf(this System.ReadOnlySpan span, System.ReadOnlySpan value) where T : System.IEquatable { throw null; } - public static int LastIndexOf(this System.ReadOnlySpan span, T value) where T : System.IEquatable { throw null; } - public static int LastIndexOf(this System.Span span, System.ReadOnlySpan value) where T : System.IEquatable { throw null; } - public static int LastIndexOf(this System.Span span, T value) where T : System.IEquatable { throw null; } + public static int LastIndexOfAny(this System.ReadOnlySpan span, System.ReadOnlySpan values) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int LastIndexOfAny(this System.ReadOnlySpan span, T value0, T value1) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int LastIndexOfAny(this System.ReadOnlySpan span, T value0, T value1, T value2) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int LastIndexOfAny(this System.Span span, System.ReadOnlySpan values) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int LastIndexOfAny(this System.Span span, T value0, T value1) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int LastIndexOfAny(this System.Span span, T value0, T value1, T value2) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int LastIndexOf(this System.ReadOnlySpan span, System.ReadOnlySpan value) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int LastIndexOf(this System.ReadOnlySpan span, T value) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int LastIndexOf(this System.Span span, System.ReadOnlySpan value) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int LastIndexOf(this System.Span span, T value) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore public static bool Overlaps(this System.ReadOnlySpan span, System.ReadOnlySpan other) { throw null; } public static bool Overlaps(this System.ReadOnlySpan span, System.ReadOnlySpan other, out int elementOffset) { throw null; } public static bool Overlaps(this System.Span span, System.ReadOnlySpan other) { throw null; } @@ -83,14 +155,26 @@ namespace System public static void Reverse(this System.Span span) { } public static int SequenceCompareTo(this System.ReadOnlySpan span, System.ReadOnlySpan other) where T : System.IComparable { throw null; } public static int SequenceCompareTo(this System.Span span, System.ReadOnlySpan other) where T : System.IComparable { throw null; } - public static bool SequenceEqual(this System.ReadOnlySpan span, System.ReadOnlySpan other) where T : System.IEquatable { throw null; } - public static bool SequenceEqual(this System.Span span, System.ReadOnlySpan other) where T : System.IEquatable { throw null; } + public static bool SequenceEqual(this System.ReadOnlySpan span, System.ReadOnlySpan other) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static bool SequenceEqual(this System.Span span, System.ReadOnlySpan other) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore public static bool StartsWith(this System.ReadOnlySpan span, System.ReadOnlySpan value, System.StringComparison comparisonType) { throw null; } - public static bool StartsWith(this System.ReadOnlySpan span, System.ReadOnlySpan value) where T : System.IEquatable { throw null; } - public static bool StartsWith(this System.Span span, System.ReadOnlySpan value) where T : System.IEquatable { throw null; } - public static int ToLower(this System.ReadOnlySpan source, System.Span destination, System.Globalization.CultureInfo culture) { throw null; } + public static bool StartsWith(this System.ReadOnlySpan span, System.ReadOnlySpan value) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static bool StartsWith(this System.Span span, System.ReadOnlySpan value) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static int ToLower(this System.ReadOnlySpan source, System.Span destination, System.Globalization.CultureInfo? culture) { throw null; } public static int ToLowerInvariant(this System.ReadOnlySpan source, System.Span destination) { throw null; } - public static int ToUpper(this System.ReadOnlySpan source, System.Span destination, System.Globalization.CultureInfo culture) { throw null; } + public static int ToUpper(this System.ReadOnlySpan source, System.Span destination, System.Globalization.CultureInfo? culture) { throw null; } public static int ToUpperInvariant(this System.ReadOnlySpan source, System.Span destination) { throw null; } public static System.Memory Trim(this System.Memory memory) { throw null; } public static System.ReadOnlyMemory Trim(this System.ReadOnlyMemory memory) { throw null; } @@ -104,51 +188,123 @@ namespace System public static System.ReadOnlySpan TrimEnd(this System.ReadOnlySpan span, char trimChar) { throw null; } public static System.ReadOnlySpan TrimEnd(this System.ReadOnlySpan span, System.ReadOnlySpan trimChars) { throw null; } public static System.Span TrimEnd(this System.Span span) { throw null; } - public static System.Memory TrimEnd(this System.Memory memory, System.ReadOnlySpan trimElements) where T : System.IEquatable { throw null; } - public static System.Memory TrimEnd(this System.Memory memory, T trimElement) where T : System.IEquatable { throw null; } - public static System.ReadOnlyMemory TrimEnd(this System.ReadOnlyMemory memory, System.ReadOnlySpan trimElements) where T : System.IEquatable { throw null; } - public static System.ReadOnlyMemory TrimEnd(this System.ReadOnlyMemory memory, T trimElement) where T : System.IEquatable { throw null; } - public static System.ReadOnlySpan TrimEnd(this System.ReadOnlySpan span, System.ReadOnlySpan trimElements) where T : System.IEquatable { throw null; } - public static System.ReadOnlySpan TrimEnd(this System.ReadOnlySpan span, T trimElement) where T : System.IEquatable { throw null; } - public static System.Span TrimEnd(this System.Span span, System.ReadOnlySpan trimElements) where T : System.IEquatable { throw null; } - public static System.Span TrimEnd(this System.Span span, T trimElement) where T : System.IEquatable { throw null; } + public static System.Memory TrimEnd(this System.Memory memory, System.ReadOnlySpan trimElements) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.Memory TrimEnd(this System.Memory memory, T trimElement) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.ReadOnlyMemory TrimEnd(this System.ReadOnlyMemory memory, System.ReadOnlySpan trimElements) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.ReadOnlyMemory TrimEnd(this System.ReadOnlyMemory memory, T trimElement) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.ReadOnlySpan TrimEnd(this System.ReadOnlySpan span, System.ReadOnlySpan trimElements) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.ReadOnlySpan TrimEnd(this System.ReadOnlySpan span, T trimElement) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.Span TrimEnd(this System.Span span, System.ReadOnlySpan trimElements) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.Span TrimEnd(this System.Span span, T trimElement) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore public static System.Memory TrimStart(this System.Memory memory) { throw null; } public static System.ReadOnlyMemory TrimStart(this System.ReadOnlyMemory memory) { throw null; } public static System.ReadOnlySpan TrimStart(this System.ReadOnlySpan span) { throw null; } public static System.ReadOnlySpan TrimStart(this System.ReadOnlySpan span, char trimChar) { throw null; } public static System.ReadOnlySpan TrimStart(this System.ReadOnlySpan span, System.ReadOnlySpan trimChars) { throw null; } public static System.Span TrimStart(this System.Span span) { throw null; } - public static System.Memory TrimStart(this System.Memory memory, System.ReadOnlySpan trimElements) where T : System.IEquatable { throw null; } - public static System.Memory TrimStart(this System.Memory memory, T trimElement) where T : System.IEquatable { throw null; } - public static System.ReadOnlyMemory TrimStart(this System.ReadOnlyMemory memory, System.ReadOnlySpan trimElements) where T : System.IEquatable { throw null; } - public static System.ReadOnlyMemory TrimStart(this System.ReadOnlyMemory memory, T trimElement) where T : System.IEquatable { throw null; } - public static System.ReadOnlySpan TrimStart(this System.ReadOnlySpan span, System.ReadOnlySpan trimElements) where T : System.IEquatable { throw null; } - public static System.ReadOnlySpan TrimStart(this System.ReadOnlySpan span, T trimElement) where T : System.IEquatable { throw null; } - public static System.Span TrimStart(this System.Span span, System.ReadOnlySpan trimElements) where T : System.IEquatable { throw null; } - public static System.Span TrimStart(this System.Span span, T trimElement) where T : System.IEquatable { throw null; } - public static System.Memory Trim(this System.Memory memory, System.ReadOnlySpan trimElements) where T : System.IEquatable { throw null; } - public static System.Memory Trim(this System.Memory memory, T trimElement) where T : System.IEquatable { throw null; } - public static System.ReadOnlyMemory Trim(this System.ReadOnlyMemory memory, System.ReadOnlySpan trimElements) where T : System.IEquatable { throw null; } - public static System.ReadOnlyMemory Trim(this System.ReadOnlyMemory memory, T trimElement) where T : System.IEquatable { throw null; } - public static System.ReadOnlySpan Trim(this System.ReadOnlySpan span, System.ReadOnlySpan trimElements) where T : System.IEquatable { throw null; } - public static System.ReadOnlySpan Trim(this System.ReadOnlySpan span, T trimElement) where T : System.IEquatable { throw null; } - public static System.Span Trim(this System.Span span, System.ReadOnlySpan trimElements) where T : System.IEquatable { throw null; } - public static System.Span Trim(this System.Span span, T trimElement) where T : System.IEquatable { throw null; } + public static System.Memory TrimStart(this System.Memory memory, System.ReadOnlySpan trimElements) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.Memory TrimStart(this System.Memory memory, T trimElement) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.ReadOnlyMemory TrimStart(this System.ReadOnlyMemory memory, System.ReadOnlySpan trimElements) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.ReadOnlyMemory TrimStart(this System.ReadOnlyMemory memory, T trimElement) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.ReadOnlySpan TrimStart(this System.ReadOnlySpan span, System.ReadOnlySpan trimElements) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.ReadOnlySpan TrimStart(this System.ReadOnlySpan span, T trimElement) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.Span TrimStart(this System.Span span, System.ReadOnlySpan trimElements) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.Span TrimStart(this System.Span span, T trimElement) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.Memory Trim(this System.Memory memory, System.ReadOnlySpan trimElements) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.Memory Trim(this System.Memory memory, T trimElement) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.ReadOnlyMemory Trim(this System.ReadOnlyMemory memory, System.ReadOnlySpan trimElements) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.ReadOnlyMemory Trim(this System.ReadOnlyMemory memory, T trimElement) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.ReadOnlySpan Trim(this System.ReadOnlySpan span, System.ReadOnlySpan trimElements) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.ReadOnlySpan Trim(this System.ReadOnlySpan span, T trimElement) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.Span Trim(this System.Span span, System.ReadOnlySpan trimElements) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore + public static System.Span Trim(this System.Span span, T trimElement) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore } public readonly partial struct SequencePosition : System.IEquatable { private readonly object _dummy; private readonly int _dummyPrimitive; - public SequencePosition(object @object, int integer) { throw null; } + public SequencePosition(object? @object, int integer) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override bool Equals(object obj) { throw null; } + public override bool Equals(object? obj) { throw null; } public bool Equals(System.SequencePosition other) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override int GetHashCode() { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public int GetInteger() { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public object GetObject() { throw null; } + public object? GetObject() { throw null; } } } namespace System.Buffers @@ -170,7 +326,10 @@ namespace System.Buffers public static partial class BuffersExtensions { public static void CopyTo(this in System.Buffers.ReadOnlySequence source, System.Span destination) { } - public static System.SequencePosition? PositionOf(this in System.Buffers.ReadOnlySequence source, T value) where T : System.IEquatable { throw null; } + public static System.SequencePosition? PositionOf(this in System.Buffers.ReadOnlySequence source, T value) +#nullable disable + where T : System.IEquatable { throw null; } +#nullable restore public static T[] ToArray(this in System.Buffers.ReadOnlySequence sequence) { throw null; } public static void Write(this System.Buffers.IBufferWriter writer, System.ReadOnlySpan value) { } } @@ -193,7 +352,7 @@ namespace System.Buffers { protected ReadOnlySequenceSegment() { } public System.ReadOnlyMemory Memory { get { throw null; } protected set { } } - public System.Buffers.ReadOnlySequenceSegment Next { get { throw null; } protected set { } } + public System.Buffers.ReadOnlySequenceSegment? Next { get { throw null; } protected set { } } public long RunningIndex { get { throw null; } protected set { } } } public readonly partial struct ReadOnlySequence @@ -229,7 +388,6 @@ namespace System.Buffers public partial struct Enumerator { private object _dummy; - private int _dummyPrimitive; public Enumerator(in System.Buffers.ReadOnlySequence sequence) { throw null; } public System.ReadOnlyMemory Current { get { throw null; } } public bool MoveNext() { throw null; } @@ -291,13 +449,13 @@ namespace System.Buffers public byte Precision { get { throw null; } } public char Symbol { get { throw null; } } public bool Equals(System.Buffers.StandardFormat other) { throw null; } - public override bool Equals(object obj) { throw null; } + public override bool Equals(object? obj) { throw null; } public override int GetHashCode() { throw null; } public static bool operator ==(System.Buffers.StandardFormat left, System.Buffers.StandardFormat right) { throw null; } public static implicit operator System.Buffers.StandardFormat (char symbol) { throw null; } public static bool operator !=(System.Buffers.StandardFormat left, System.Buffers.StandardFormat right) { throw null; } public static System.Buffers.StandardFormat Parse(System.ReadOnlySpan format) { throw null; } - public static System.Buffers.StandardFormat Parse(string format) { throw null; } + public static System.Buffers.StandardFormat Parse(string? format) { throw null; } public override string ToString() { throw null; } public static bool TryParse(System.ReadOnlySpan format, out System.Buffers.StandardFormat result) { throw null; } } @@ -461,7 +619,7 @@ namespace System.Runtime.InteropServices public static ref T AsRef(System.Span span) where T : struct { throw null; } public static System.ReadOnlySpan Cast(System.ReadOnlySpan span) where TFrom : struct where TTo : struct { throw null; } public static System.Span Cast(System.Span span) where TFrom : struct where TTo : struct { throw null; } - public static System.Memory CreateFromPinnedArray(T[] array, int start, int length) { throw null; } + public static System.Memory CreateFromPinnedArray(T[]? array, int start, int length) { throw null; } public static System.ReadOnlySpan CreateReadOnlySpan(ref T reference, int length) { throw null; } public static System.Span CreateSpan(ref T reference, int length) { throw null; } public static ref T GetReference(System.ReadOnlySpan span) { throw null; } @@ -469,9 +627,9 @@ namespace System.Runtime.InteropServices public static T Read(System.ReadOnlySpan source) where T : struct { throw null; } public static System.Collections.Generic.IEnumerable ToEnumerable(System.ReadOnlyMemory memory) { throw null; } public static bool TryGetArray(System.ReadOnlyMemory memory, out System.ArraySegment segment) { throw null; } - public static bool TryGetMemoryManager(System.ReadOnlyMemory memory, out TManager manager) where TManager : System.Buffers.MemoryManager { throw null; } - public static bool TryGetMemoryManager(System.ReadOnlyMemory memory, out TManager manager, out int start, out int length) where TManager : System.Buffers.MemoryManager { throw null; } - public static bool TryGetString(System.ReadOnlyMemory memory, out string text, out int start, out int length) { throw null; } + public static bool TryGetMemoryManager(System.ReadOnlyMemory memory, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TManager? manager) where TManager : System.Buffers.MemoryManager { throw null; } + public static bool TryGetMemoryManager(System.ReadOnlyMemory memory, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out TManager? manager, out int start, out int length) where TManager : System.Buffers.MemoryManager { throw null; } + public static bool TryGetString(System.ReadOnlyMemory memory, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out string? text, out int start, out int length) { throw null; } public static bool TryRead(System.ReadOnlySpan source, out T value) where T : struct { throw null; } public static bool TryWrite(System.Span destination, ref T value) where T : struct { throw null; } public static void Write(System.Span destination, ref T value) where T : struct { } @@ -480,7 +638,7 @@ namespace System.Runtime.InteropServices { public static bool TryGetArray(System.Buffers.ReadOnlySequence sequence, out System.ArraySegment segment) { throw null; } public static bool TryGetReadOnlyMemory(System.Buffers.ReadOnlySequence sequence, out System.ReadOnlyMemory memory) { throw null; } - public static bool TryGetReadOnlySequenceSegment(System.Buffers.ReadOnlySequence sequence, out System.Buffers.ReadOnlySequenceSegment startSegment, out int startIndex, out System.Buffers.ReadOnlySequenceSegment endSegment, out int endIndex) { throw null; } + public static bool TryGetReadOnlySequenceSegment(System.Buffers.ReadOnlySequence sequence, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Buffers.ReadOnlySequenceSegment? startSegment, out int startIndex, [System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] out System.Buffers.ReadOnlySequenceSegment? endSegment, out int endIndex) { throw null; } public static bool TryRead(ref System.Buffers.SequenceReader reader, out T value) where T : unmanaged { throw null; } } } diff --git a/src/libraries/System.Memory/ref/System.Memory.csproj b/src/libraries/System.Memory/ref/System.Memory.csproj index 3431d8f..e49442a 100644 --- a/src/libraries/System.Memory/ref/System.Memory.csproj +++ b/src/libraries/System.Memory/ref/System.Memory.csproj @@ -3,6 +3,7 @@ true {E883935B-D8FD-4FC9-A189-9D9E7F7EF550} netcoreapp-Debug;netcoreapp-Release;uap-Debug;uap-Release + enable diff --git a/src/libraries/System.Memory/src/System/Runtime/InteropServices/SequenceMarshal.cs b/src/libraries/System.Memory/src/System/Runtime/InteropServices/SequenceMarshal.cs index fd1f9f6..aeb3ac7 100644 --- a/src/libraries/System.Memory/src/System/Runtime/InteropServices/SequenceMarshal.cs +++ b/src/libraries/System.Memory/src/System/Runtime/InteropServices/SequenceMarshal.cs @@ -17,7 +17,7 @@ namespace System.Runtime.InteropServices /// If unable to get the , return false. /// public static bool TryGetReadOnlySequenceSegment(ReadOnlySequence sequence, - out ReadOnlySequenceSegment? startSegment, + [NotNullWhen(true)] out ReadOnlySequenceSegment? startSegment, out int startIndex, [NotNullWhen(true)] out ReadOnlySequenceSegment? endSegment, out int endIndex) -- 2.7.4