From 04dd4993ae020bafd633c9f5b1a49fcf1cf882a7 Mon Sep 17 00:00:00 2001 From: dotnet-maestro-bot Date: Thu, 21 Sep 2017 10:17:58 -0700 Subject: [PATCH 1/2] Update CoreClr, CoreSetup, ProjectNTfs, ProjectNTfsTestILC, Standard to preview1-25720-03, preview1-25719-04, beta-25721-01, beta-25721-01, preview1-25721-01, respectively --- dependencies.props | 22 +++++++++++----------- external/test-runtime/optional.json | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/dependencies.props b/dependencies.props index 50b4200c8b95..5ce9accfd127 100644 --- a/dependencies.props +++ b/dependencies.props @@ -10,13 +10,13 @@ --> ed8cf4ba3c0e143c142542aaf53a8cdaa6cb0023 - ed8cf4ba3c0e143c142542aaf53a8cdaa6cb0023 - ed8cf4ba3c0e143c142542aaf53a8cdaa6cb0023 + 790f084a4cfcc9f4559edc92988809906ebb6b6b + 790f084a4cfcc9f4559edc92988809906ebb6b6b 96dc7805f5df4a70a55783964ce69dcd91bfca80 - 568fb017cade704dcf611a1c991e7b8e2e27972b - 568fb017cade704dcf611a1c991e7b8e2e27972b + 790f084a4cfcc9f4559edc92988809906ebb6b6b + 790f084a4cfcc9f4559edc92988809906ebb6b6b 8bd1ec5fac9f0eec34ff6b34b1d878b4359e02dd - ed8cf4ba3c0e143c142542aaf53a8cdaa6cb0023 + 790f084a4cfcc9f4559edc92988809906ebb6b6b 8cd983ea0756ec0b094cce18c820b9d1b9d2b107 @@ -24,14 +24,14 @@ 2.1.0-preview1-25718-03 preview1-25718-03 - 2.1.0-preview1-25718-02 + 2.1.0-preview1-25720-03 beta-25627-00 - beta-25715-00 - beta-25715-00 - 1.0.0-beta-25715-00 - 2.1.0-preview1-25718-01 + beta-25721-01 + beta-25721-01 + 1.0.0-beta-25721-01 + 2.1.0-preview1-25721-01 NETStandard.Library - 2.1.0-preview1-25717-02 + 2.1.0-preview1-25719-04 4.4.0 diff --git a/external/test-runtime/optional.json b/external/test-runtime/optional.json index 25a480967be9..d0f9c76a8e77 100644 --- a/external/test-runtime/optional.json +++ b/external/test-runtime/optional.json @@ -3,9 +3,9 @@ "net45": { "dependencies": { "Microsoft.DotNet.IBCMerge": "4.6.0-alpha-00001", - "TestILC.amd64ret": "1.0.0-beta-25715-00", - "TestILC.armret": "1.0.0-beta-25715-00", - "TestILC.x86ret": "1.0.0-beta-25715-00" + "TestILC.amd64ret": "1.0.0-beta-25721-01", + "TestILC.armret": "1.0.0-beta-25721-01", + "TestILC.x86ret": "1.0.0-beta-25721-01" } } } From 786195a51ca0b751f5aec127faf655fe358c6993 Mon Sep 17 00:00:00 2001 From: ahsonkhan Date: Mon, 18 Sep 2017 19:54:45 -0700 Subject: [PATCH 2/2] Change AsSpan to property Span and rename AsMemory to Memory --- src/Common/tests/System/Buffers/NativeOwnedMemory.cs | 2 +- .../tests/Stream/Stream.ReadWriteSpan.netcoreapp.cs | 4 ++-- src/System.Memory/ref/System.Memory.cs | 4 ++-- src/System.Memory/src/System/Buffers/OwnedMemory.cs | 4 ++-- src/System.Memory/src/System/Memory.cs | 2 +- src/System.Memory/src/System/ReadOnlyMemory.cs | 2 +- .../tests/Memory/CustomMemoryForTest.cs | 11 +++++++---- src/System.Memory/tests/Memory/OwnedMemory.cs | 10 +++++----- src/System.Memory/tests/Memory/Retain.cs | 4 ++-- src/System.Memory/tests/Memory/Slice.cs | 12 ++++++------ src/System.Memory/tests/Memory/Span.cs | 10 +++++----- src/System.Memory/tests/Memory/TryGetArray.cs | 2 +- .../tests/ReadOnlyMemory/DangerousTryGetArray.cs | 2 +- src/System.Memory/tests/ReadOnlyMemory/Retain.cs | 4 ++-- src/System.Memory/tests/ReadOnlyMemory/Slice.cs | 12 ++++++------ src/System.Memory/tests/ReadOnlyMemory/Span.cs | 10 +++++----- .../FunctionalTests/ReadOnlyMemoryContentTest.cs | 2 +- src/System.Runtime/ref/System.Runtime.cs | 4 ++-- 18 files changed, 52 insertions(+), 49 deletions(-) diff --git a/src/Common/tests/System/Buffers/NativeOwnedMemory.cs b/src/Common/tests/System/Buffers/NativeOwnedMemory.cs index 3058add17c19..31d90b35bfe4 100644 --- a/src/Common/tests/System/Buffers/NativeOwnedMemory.cs +++ b/src/Common/tests/System/Buffers/NativeOwnedMemory.cs @@ -51,7 +51,7 @@ protected override bool IsRetained } } - public override unsafe Span AsSpan() => new Span((void*)_ptr, _length); + public override unsafe Span Span => new Span((void*)_ptr, _length); public override unsafe MemoryHandle Pin() => new MemoryHandle(this, (void*)_ptr); diff --git a/src/System.IO/tests/Stream/Stream.ReadWriteSpan.netcoreapp.cs b/src/System.IO/tests/Stream/Stream.ReadWriteSpan.netcoreapp.cs index 8825704cc13c..6bdea544b0f0 100644 --- a/src/System.IO/tests/Stream/Stream.ReadWriteSpan.netcoreapp.cs +++ b/src/System.IO/tests/Stream/Stream.ReadWriteSpan.netcoreapp.cs @@ -117,7 +117,7 @@ public async Task ReadAsyncMemory_WrapsNative_DelegatesToReadAsyncArrayWithPool_ using (var totalNativeMemory = new NativeOwnedMemory(30)) { - Memory totalMemory = totalNativeMemory.AsMemory; + Memory totalMemory = totalNativeMemory.Memory; Memory targetMemory = totalMemory.Slice(5, 20); Assert.Equal(10, await s.ReadAsync(targetMemory)); @@ -176,7 +176,7 @@ public async Task WriteAsyncMemory_WrapsNative_DelegatesToWrite_Success() using (var nativeMemory = new NativeOwnedMemory(10)) { - Memory memory = nativeMemory.AsMemory; + Memory memory = nativeMemory.Memory; memory.Span[2] = 0; memory.Span[3] = 1; memory.Span[4] = 2; diff --git a/src/System.Memory/ref/System.Memory.cs b/src/System.Memory/ref/System.Memory.cs index 802a0610d25d..ee6ecea323e4 100644 --- a/src/System.Memory/ref/System.Memory.cs +++ b/src/System.Memory/ref/System.Memory.cs @@ -189,11 +189,11 @@ public interface IRetainable public abstract class OwnedMemory : IDisposable, IRetainable { - public Memory AsMemory { get { throw null; } } + public Memory Memory { get { throw null; } } public abstract bool IsDisposed { get; } protected abstract bool IsRetained { get; } public abstract int Length { get; } - public abstract Span AsSpan(); + public abstract Span Span { get; } public void Dispose() { throw null; } protected abstract void Dispose(bool disposing); public abstract MemoryHandle Pin(); diff --git a/src/System.Memory/src/System/Buffers/OwnedMemory.cs b/src/System.Memory/src/System/Buffers/OwnedMemory.cs index 446f3a8c6bb4..3daae843daec 100644 --- a/src/System.Memory/src/System/Buffers/OwnedMemory.cs +++ b/src/System.Memory/src/System/Buffers/OwnedMemory.cs @@ -22,7 +22,7 @@ public abstract class OwnedMemory : IDisposable, IRetainable /// /// Returns a span wrapping the underlying memory. /// - public abstract Span AsSpan(); + public abstract Span Span { get; } /// /// Returns a Memory if the underlying memory has not been freed. @@ -30,7 +30,7 @@ public abstract class OwnedMemory : IDisposable, IRetainable /// /// Thrown when the underlying memory has already been disposed. /// - public Memory AsMemory + public Memory Memory { get { diff --git a/src/System.Memory/src/System/Memory.cs b/src/System.Memory/src/System/Memory.cs index 29af166f5b4d..a71fc76fb2ed 100644 --- a/src/System.Memory/src/System/Memory.cs +++ b/src/System.Memory/src/System/Memory.cs @@ -176,7 +176,7 @@ public Span Span get { if (_index < 0) - return ((OwnedMemory)_arrayOrOwnedMemory).AsSpan().Slice(_index & RemoveOwnedFlagBitMask, _length); + return ((OwnedMemory)_arrayOrOwnedMemory).Span.Slice(_index & RemoveOwnedFlagBitMask, _length); return new Span((T[])_arrayOrOwnedMemory, _index, _length); } } diff --git a/src/System.Memory/src/System/ReadOnlyMemory.cs b/src/System.Memory/src/System/ReadOnlyMemory.cs index 94d3c224a03b..5d5e3bd78efc 100644 --- a/src/System.Memory/src/System/ReadOnlyMemory.cs +++ b/src/System.Memory/src/System/ReadOnlyMemory.cs @@ -161,7 +161,7 @@ public ReadOnlySpan Span get { if (_index < 0) - return ((OwnedMemory)_arrayOrOwnedMemory).AsSpan().Slice(_index & RemoveOwnedFlagBitMask, _length); + return ((OwnedMemory)_arrayOrOwnedMemory).Span.Slice(_index & RemoveOwnedFlagBitMask, _length); return new ReadOnlySpan((T[])_arrayOrOwnedMemory, _index, _length); } } diff --git a/src/System.Memory/tests/Memory/CustomMemoryForTest.cs b/src/System.Memory/tests/Memory/CustomMemoryForTest.cs index 1250731f3c60..ae23459eac65 100644 --- a/src/System.Memory/tests/Memory/CustomMemoryForTest.cs +++ b/src/System.Memory/tests/Memory/CustomMemoryForTest.cs @@ -29,11 +29,14 @@ public CustomMemoryForTest(T[] array) protected override bool IsRetained => _referenceCount > 0; - public override Span AsSpan() + public override Span Span { - if (IsDisposed) - throw new ObjectDisposedException(nameof(CustomMemoryForTest)); - return new Span(_array, 0, _array.Length); + get + { + if (IsDisposed) + throw new ObjectDisposedException(nameof(CustomMemoryForTest)); + return new Span(_array, 0, _array.Length); + } } public override MemoryHandle Pin() diff --git a/src/System.Memory/tests/Memory/OwnedMemory.cs b/src/System.Memory/tests/Memory/OwnedMemory.cs index c15c7f340d2e..cef1264f9151 100644 --- a/src/System.Memory/tests/Memory/OwnedMemory.cs +++ b/src/System.Memory/tests/Memory/OwnedMemory.cs @@ -18,7 +18,7 @@ public static void MemoryFromOwnedMemoryInt() { int[] a = { 91, 92, -93, 94 }; OwnedMemory owner = new CustomMemoryForTest(a); - Memory memory = owner.AsMemory; + Memory memory = owner.Memory; memory.Validate(91, 92, -93, 94); } @@ -27,7 +27,7 @@ public static void MemoryFromOwnedMemoryLong() { long[] a = { 91, -92, 93, 94, -95 }; OwnedMemory owner = new CustomMemoryForTest(a); - Memory memory = owner.AsMemory; + Memory memory = owner.Memory; memory.Validate(91, -92, 93, 94, -95); } @@ -38,7 +38,7 @@ public static void MemoryFromOwnedMemoryObject() object o2 = new object(); object[] a = { o1, o2 }; OwnedMemory owner = new CustomMemoryForTest(a); - Memory memory = owner.AsMemory; + Memory memory = owner.Memory; memory.ValidateReferenceType(o1, o2); } @@ -47,7 +47,7 @@ public static void ImplicitReadOnlyMemoryFromOwnedMemory() { long[] a = { 91, -92, 93, 94, -95 }; OwnedMemory owner = new CustomMemoryForTest(a); - Memory memory = owner.AsMemory; + Memory memory = owner.Memory; CastReadOnly(memory, 91, -92, 93, 94, -95); } @@ -67,7 +67,7 @@ public static void MemoryFromOwnedMemoryAfterDispose() int[] a = { 91, 92, -93, 94 }; OwnedMemory owner = new CustomMemoryForTest(a); owner.Dispose(); - Assert.Throws(() => owner.AsMemory); + Assert.Throws(() => owner.Memory); } [Fact] diff --git a/src/System.Memory/tests/Memory/Retain.cs b/src/System.Memory/tests/Memory/Retain.cs index 8032933bfddb..d64a9d0a7273 100644 --- a/src/System.Memory/tests/Memory/Retain.cs +++ b/src/System.Memory/tests/Memory/Retain.cs @@ -50,7 +50,7 @@ public static void OwnedMemoryRetainWithoutPinning() { int[] array = { 1, 2, 3, 4, 5 }; OwnedMemory owner = new CustomMemoryForTest(array); - Memory memory = owner.AsMemory; + Memory memory = owner.Memory; MemoryHandle handle = memory.Retain(); unsafe { @@ -65,7 +65,7 @@ public static void OwnedMemoryRetainWithPinning() { int[] array = { 1, 2, 3, 4, 5 }; OwnedMemory owner = new CustomMemoryForTest(array); - Memory memory = owner.AsMemory; + Memory memory = owner.Memory; MemoryHandle handle = memory.Retain(pin: true); unsafe { diff --git a/src/System.Memory/tests/Memory/Slice.cs b/src/System.Memory/tests/Memory/Slice.cs index 6cba89de4dea..70dcdb26e778 100644 --- a/src/System.Memory/tests/Memory/Slice.cs +++ b/src/System.Memory/tests/Memory/Slice.cs @@ -19,7 +19,7 @@ public static void SliceWithStart() Assert.True(Unsafe.AreSame(ref a[6], ref memory.Span.DangerousGetPinnableReference())); OwnedMemory owner = new CustomMemoryForTest(a); - Memory memoryFromOwner = owner.AsMemory.Slice(6); + Memory memoryFromOwner = owner.Memory.Slice(6); Assert.Equal(4, memoryFromOwner.Length); Assert.True(Unsafe.AreSame(ref a[6], ref memoryFromOwner.Span.DangerousGetPinnableReference())); @@ -34,7 +34,7 @@ public static void SliceWithStartPastEnd() Assert.True(Unsafe.AreSame(ref a[a.Length - 1], ref Unsafe.Subtract(ref memory.Span.DangerousGetPinnableReference(), 1))); OwnedMemory owner = new CustomMemoryForTest(a); - Memory memoryFromOwner = owner.AsMemory.Slice(a.Length); + Memory memoryFromOwner = owner.Memory.Slice(a.Length); Assert.Equal(0, memoryFromOwner.Length); Assert.True(Unsafe.AreSame(ref a[a.Length - 1], ref Unsafe.Subtract(ref memoryFromOwner.Span.DangerousGetPinnableReference(), 1))); @@ -49,7 +49,7 @@ public static void SliceWithStartAndLength() Assert.True(Unsafe.AreSame(ref a[3], ref memory.Span.DangerousGetPinnableReference())); OwnedMemory owner = new CustomMemoryForTest(a); - Memory memoryFromOwner = owner.AsMemory.Slice(3, 5); + Memory memoryFromOwner = owner.Memory.Slice(3, 5); Assert.Equal(5, memoryFromOwner.Length); Assert.True(Unsafe.AreSame(ref a[3], ref memoryFromOwner.Span.DangerousGetPinnableReference())); @@ -64,7 +64,7 @@ public static void SliceWithStartAndLengthUpToEnd() Assert.True(Unsafe.AreSame(ref a[4], ref memory.Span.DangerousGetPinnableReference())); OwnedMemory owner = new CustomMemoryForTest(a); - Memory memoryFromOwner = owner.AsMemory.Slice(4, 6); + Memory memoryFromOwner = owner.Memory.Slice(4, 6); Assert.Equal(6, memoryFromOwner.Length); Assert.True(Unsafe.AreSame(ref a[4], ref memoryFromOwner.Span.DangerousGetPinnableReference())); @@ -79,7 +79,7 @@ public static void SliceWithStartAndLengthPastEnd() Assert.True(Unsafe.AreSame(ref a[a.Length - 1], ref Unsafe.Subtract(ref memory.Span.DangerousGetPinnableReference(), 1))); OwnedMemory owner = new CustomMemoryForTest(a); - Memory memoryFromOwner = owner.AsMemory.Slice(a.Length, 0); + Memory memoryFromOwner = owner.Memory.Slice(a.Length, 0); Assert.Equal(0, memoryFromOwner.Length); Assert.True(Unsafe.AreSame(ref a[a.Length - 1], ref Unsafe.Subtract(ref memoryFromOwner.Span.DangerousGetPinnableReference(), 1))); @@ -98,7 +98,7 @@ public static void SliceRangeChecks() Assert.Throws(() => new Memory(a).Slice(a.Length, 1)); OwnedMemory owner = new CustomMemoryForTest(a); - Memory memory = owner.AsMemory; + Memory memory = owner.Memory; Assert.Throws(() => memory.Slice(-1)); Assert.Throws(() => memory.Slice(a.Length + 1)); diff --git a/src/System.Memory/tests/Memory/Span.cs b/src/System.Memory/tests/Memory/Span.cs index bb95fedfedf7..ec10646cc5da 100644 --- a/src/System.Memory/tests/Memory/Span.cs +++ b/src/System.Memory/tests/Memory/Span.cs @@ -22,7 +22,7 @@ public static void SpanFromCtorArrayInt() memory.Span.Validate(91, 92, -93, 94); OwnedMemory owner = new CustomMemoryForTest(a); - owner.AsMemory.Span.Validate(91, 92, -93, 94); + owner.Memory.Span.Validate(91, 92, -93, 94); } [Fact] @@ -38,7 +38,7 @@ public static void SpanFromCtorArrayLong() memory.Span.Validate(91, -92, 93, 94, -95); OwnedMemory owner = new CustomMemoryForTest(a); - owner.AsMemory.Span.Validate(91, -92, 93, 94, -95); + owner.Memory.Span.Validate(91, -92, 93, 94, -95); } [ActiveIssue(23952, TargetFrameworkMonikers.UapAot)] @@ -57,7 +57,7 @@ public static void SpanFromCtorArrayObject() memory.Span.ValidateReferenceType(o1, o2); OwnedMemory owner = new CustomMemoryForTest(a); - owner.AsMemory.Span.ValidateReferenceType(o1, o2); + owner.Memory.Span.ValidateReferenceType(o1, o2); } [Fact] @@ -73,7 +73,7 @@ public static void SpanFromCtorArrayZeroLength() memory.Span.Validate(); OwnedMemory owner = new CustomMemoryForTest(empty); - owner.AsMemory.Span.Validate(); + owner.Memory.Span.Validate(); } [Fact] @@ -92,7 +92,7 @@ public static void SpanFromCtorArrayWrongValueType() memory.Span.Validate(42, -1); OwnedMemory owner = new CustomMemoryForTest(aAsIntArray); - owner.AsMemory.Span.Validate(42, -1); + owner.Memory.Span.Validate(42, -1); } } diff --git a/src/System.Memory/tests/Memory/TryGetArray.cs b/src/System.Memory/tests/Memory/TryGetArray.cs index 2592218084ba..b2cbc098b762 100644 --- a/src/System.Memory/tests/Memory/TryGetArray.cs +++ b/src/System.Memory/tests/Memory/TryGetArray.cs @@ -28,7 +28,7 @@ public static void OwnedMemoryTryGetArray() { int[] array = new int[10]; OwnedMemory owner = new CustomMemoryForTest(array); - Memory memory = owner.AsMemory; + Memory memory = owner.Memory; Assert.True(memory.TryGetArray(out ArraySegment segment)); Assert.Equal(array.Length, segment.Count); diff --git a/src/System.Memory/tests/ReadOnlyMemory/DangerousTryGetArray.cs b/src/System.Memory/tests/ReadOnlyMemory/DangerousTryGetArray.cs index 01364cca7509..f6a9c7baf593 100644 --- a/src/System.Memory/tests/ReadOnlyMemory/DangerousTryGetArray.cs +++ b/src/System.Memory/tests/ReadOnlyMemory/DangerousTryGetArray.cs @@ -28,7 +28,7 @@ public static void OwnedMemoryTryGetArray() { int[] array = new int[10]; OwnedMemory owner = new CustomMemoryForTest(array); - ReadOnlyMemory memory = owner.AsMemory; + ReadOnlyMemory memory = owner.Memory; Assert.True(memory.DangerousTryGetArray(out ArraySegment segment)); Assert.Equal(array.Length, segment.Count); diff --git a/src/System.Memory/tests/ReadOnlyMemory/Retain.cs b/src/System.Memory/tests/ReadOnlyMemory/Retain.cs index 57ba8ec1ee6e..437b6f39b46d 100644 --- a/src/System.Memory/tests/ReadOnlyMemory/Retain.cs +++ b/src/System.Memory/tests/ReadOnlyMemory/Retain.cs @@ -50,7 +50,7 @@ public static void OwnedMemoryRetainWithoutPinning() { int[] array = { 1, 2, 3, 4, 5 }; OwnedMemory owner = new CustomMemoryForTest(array); - ReadOnlyMemory memory = owner.AsMemory; + ReadOnlyMemory memory = owner.Memory; MemoryHandle handle = memory.Retain(); unsafe { @@ -65,7 +65,7 @@ public static void OwnedMemoryRetainWithPinning() { int[] array = { 1, 2, 3, 4, 5 }; OwnedMemory owner = new CustomMemoryForTest(array); - ReadOnlyMemory memory = owner.AsMemory; + ReadOnlyMemory memory = owner.Memory; MemoryHandle handle = memory.Retain(pin: true); unsafe { diff --git a/src/System.Memory/tests/ReadOnlyMemory/Slice.cs b/src/System.Memory/tests/ReadOnlyMemory/Slice.cs index 48f032a96195..edeeb9d53f3c 100644 --- a/src/System.Memory/tests/ReadOnlyMemory/Slice.cs +++ b/src/System.Memory/tests/ReadOnlyMemory/Slice.cs @@ -19,7 +19,7 @@ public static void SliceWithStart() Assert.True(Unsafe.AreSame(ref a[6], ref memory.Span.DangerousGetPinnableReference())); OwnedMemory owner = new CustomMemoryForTest(a); - ReadOnlyMemory memoryFromOwner = ((ReadOnlyMemory)owner.AsMemory).Slice(6); + ReadOnlyMemory memoryFromOwner = ((ReadOnlyMemory)owner.Memory).Slice(6); Assert.Equal(4, memoryFromOwner.Length); Assert.True(Unsafe.AreSame(ref a[6], ref memoryFromOwner.Span.DangerousGetPinnableReference())); @@ -34,7 +34,7 @@ public static void SliceWithStartPastEnd() Assert.True(Unsafe.AreSame(ref a[a.Length - 1], ref Unsafe.Subtract(ref memory.Span.DangerousGetPinnableReference(), 1))); OwnedMemory owner = new CustomMemoryForTest(a); - ReadOnlyMemory memoryFromOwner = ((ReadOnlyMemory)owner.AsMemory).Slice(a.Length); + ReadOnlyMemory memoryFromOwner = ((ReadOnlyMemory)owner.Memory).Slice(a.Length); Assert.Equal(0, memoryFromOwner.Length); Assert.True(Unsafe.AreSame(ref a[a.Length - 1], ref Unsafe.Subtract(ref memoryFromOwner.Span.DangerousGetPinnableReference(), 1))); @@ -49,7 +49,7 @@ public static void SliceWithStartAndLength() Assert.True(Unsafe.AreSame(ref a[3], ref memory.Span.DangerousGetPinnableReference())); OwnedMemory owner = new CustomMemoryForTest(a); - ReadOnlyMemory memoryFromOwner = ((ReadOnlyMemory)owner.AsMemory).Slice(3, 5); + ReadOnlyMemory memoryFromOwner = ((ReadOnlyMemory)owner.Memory).Slice(3, 5); Assert.Equal(5, memoryFromOwner.Length); Assert.True(Unsafe.AreSame(ref a[3], ref memoryFromOwner.Span.DangerousGetPinnableReference())); @@ -64,7 +64,7 @@ public static void SliceWithStartAndLengthUpToEnd() Assert.True(Unsafe.AreSame(ref a[4], ref memory.Span.DangerousGetPinnableReference())); OwnedMemory owner = new CustomMemoryForTest(a); - ReadOnlyMemory memoryFromOwner = ((ReadOnlyMemory)owner.AsMemory).Slice(4, 6); + ReadOnlyMemory memoryFromOwner = ((ReadOnlyMemory)owner.Memory).Slice(4, 6); Assert.Equal(6, memoryFromOwner.Length); Assert.True(Unsafe.AreSame(ref a[4], ref memoryFromOwner.Span.DangerousGetPinnableReference())); @@ -79,7 +79,7 @@ public static void SliceWithStartAndLengthPastEnd() Assert.True(Unsafe.AreSame(ref a[a.Length - 1], ref Unsafe.Subtract(ref memory.Span.DangerousGetPinnableReference(), 1))); OwnedMemory owner = new CustomMemoryForTest(a); - ReadOnlyMemory memoryFromOwner = ((ReadOnlyMemory)owner.AsMemory).Slice(a.Length, 0); + ReadOnlyMemory memoryFromOwner = ((ReadOnlyMemory)owner.Memory).Slice(a.Length, 0); Assert.Equal(0, memoryFromOwner.Length); Assert.True(Unsafe.AreSame(ref a[a.Length - 1], ref Unsafe.Subtract(ref memoryFromOwner.Span.DangerousGetPinnableReference(), 1))); @@ -98,7 +98,7 @@ public static void SliceRangeChecks() Assert.Throws(() => new ReadOnlyMemory(a).Slice(a.Length, 1)); OwnedMemory owner = new CustomMemoryForTest(a); - ReadOnlyMemory memory = owner.AsMemory; + ReadOnlyMemory memory = owner.Memory; Assert.Throws(() => memory.Slice(-1)); Assert.Throws(() => memory.Slice(a.Length + 1)); diff --git a/src/System.Memory/tests/ReadOnlyMemory/Span.cs b/src/System.Memory/tests/ReadOnlyMemory/Span.cs index 5598788bd327..dd0a3b93748e 100644 --- a/src/System.Memory/tests/ReadOnlyMemory/Span.cs +++ b/src/System.Memory/tests/ReadOnlyMemory/Span.cs @@ -22,7 +22,7 @@ public static void SpanFromCtorArrayInt() memory.Span.Validate(91, 92, -93, 94); OwnedMemory owner = new CustomMemoryForTest(a); - ((ReadOnlyMemory)owner.AsMemory).Span.Validate(91, 92, -93, 94); + ((ReadOnlyMemory)owner.Memory).Span.Validate(91, 92, -93, 94); } [Fact] @@ -38,7 +38,7 @@ public static void SpanFromCtorArrayLong() memory.Span.Validate(91, -92, 93, 94, -95); OwnedMemory owner = new CustomMemoryForTest(a); - ((ReadOnlyMemory)owner.AsMemory).Span.Validate(91, -92, 93, 94, -95); + ((ReadOnlyMemory)owner.Memory).Span.Validate(91, -92, 93, 94, -95); } [ActiveIssue(23952, TargetFrameworkMonikers.UapAot)] @@ -57,7 +57,7 @@ public static void SpanFromCtorArrayObject() memory.Span.ValidateReferenceType(o1, o2); OwnedMemory owner = new CustomMemoryForTest(a); - ((ReadOnlyMemory)owner.AsMemory).Span.ValidateReferenceType(o1, o2); + ((ReadOnlyMemory)owner.Memory).Span.ValidateReferenceType(o1, o2); } [Fact] @@ -73,7 +73,7 @@ public static void SpanFromCtorArrayZeroLength() memory.Span.Validate(); OwnedMemory owner = new CustomMemoryForTest(empty); - ((ReadOnlyMemory)owner.AsMemory).Span.Validate(); + ((ReadOnlyMemory)owner.Memory).Span.Validate(); } [Fact] @@ -92,7 +92,7 @@ public static void SpanFromCtorArrayWrongValueType() memory.Span.Validate(42, -1); OwnedMemory owner = new CustomMemoryForTest(aAsIntArray); - ((ReadOnlyMemory)owner.AsMemory).Span.Validate(42, -1); + ((ReadOnlyMemory)owner.Memory).Span.Validate(42, -1); } } diff --git a/src/System.Net.Http/tests/FunctionalTests/ReadOnlyMemoryContentTest.cs b/src/System.Net.Http/tests/FunctionalTests/ReadOnlyMemoryContentTest.cs index 94fa7eebebc8..01334a8c3fbe 100644 --- a/src/System.Net.Http/tests/FunctionalTests/ReadOnlyMemoryContentTest.cs +++ b/src/System.Net.Http/tests/FunctionalTests/ReadOnlyMemoryContentTest.cs @@ -393,7 +393,7 @@ private static ReadOnlyMemoryContent CreateContent(int contentLength, bool useAr else { ownedMemory = new NativeOwnedMemory(contentLength); - memory = ownedMemory.AsMemory; + memory = ownedMemory.Memory; } new Random(contentLength).NextBytes(memory.Span); diff --git a/src/System.Runtime/ref/System.Runtime.cs b/src/System.Runtime/ref/System.Runtime.cs index d122a4f2185f..b5821e9339b2 100644 --- a/src/System.Runtime/ref/System.Runtime.cs +++ b/src/System.Runtime/ref/System.Runtime.cs @@ -3847,11 +3847,11 @@ public interface IRetainable public abstract class OwnedMemory : IDisposable, IRetainable { - public Memory AsMemory { get { throw null; } } + public Memory Memory { get { throw null; } } public abstract bool IsDisposed { get; } protected abstract bool IsRetained { get; } public abstract int Length { get; } - public abstract Span AsSpan(); + public abstract Span Span { get; } public void Dispose() { throw null; } protected abstract void Dispose(bool disposing); public abstract MemoryHandle Pin();