Skip to content

Commit f737ea6

Browse files
committed
Align member name with AsSpan overloads
1 parent 6a10ac9 commit f737ea6

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

src/DotNext.Tests/Runtime/InteropServices/PointerTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,4 +294,17 @@ public static unsafe void ClearValue()
294294

295295
Equal(0, i);
296296
}
297+
298+
[Fact]
299+
public static unsafe void SpanOverElements()
300+
{
301+
const int count = 2;
302+
Pointer<int> ptr = stackalloc int[count];
303+
var elements = ptr.AsSpan(count);
304+
elements[0] = 42;
305+
elements[1] = 43;
306+
307+
Equal(42, ptr[0]);
308+
Equal(43, ptr[1]);
309+
}
297310
}

src/DotNext.Tests/Runtime/InteropServices/UnmanagedMemoryTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public sealed class UnmanagedMemoryTests : Test
77
[Fact]
88
public static void DefaultValue()
99
{
10-
var memory = default(UnmanagedMemory<Int128>);
10+
using var memory = default(UnmanagedMemory<Int128>);
1111
True(memory.Pointer.IsNull);
1212
True(Unsafe.IsNullRef(in memory.Pointer.Value));
1313

src/DotNext.Unsafe/IO/MemoryMappedFiles/MappedMemory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ internal MappedMemory(MemoryMappedViewAccessor accessor)
3636

3737
public void Flush() => accessor.Flush();
3838

39-
public override Span<byte> GetSpan() => Pointer.ToSpan((int)accessor.Capacity);
39+
public override Span<byte> GetSpan() => Pointer.AsSpan((int)accessor.Capacity);
4040

4141
public override Memory<byte> Memory => CreateMemory((int)accessor.Capacity);
4242

src/DotNext.Unsafe/IO/MemoryMappedFiles/MemoryMappedDirectAccessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ internal MemoryMappedDirectAccessor(MemoryMappedViewAccessor accessor)
5959
/// Represents memory-mapped file segment in the form of <see cref="Span{T}"/>.
6060
/// </summary>
6161
/// <value><see cref="Span{T}"/> representing virtual memory of the mapped file segment.</value>
62-
public readonly Span<byte> Bytes => Pointer.ToSpan(int.CreateSaturating(accessor.Capacity));
62+
public readonly Span<byte> Bytes => Pointer.AsSpan(int.CreateSaturating(accessor.Capacity));
6363

6464
/// <summary>
6565
/// Sets all bits of allocated memory to zero.

src/DotNext.Unsafe/Runtime/InteropServices/Pointer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public unsafe void Fill(T value, nuint count)
109109
/// </summary>
110110
/// <param name="length">The number of elements located in the unmanaged memory identified by this pointer.</param>
111111
/// <returns><see cref="Span{T}"/> representing elements in the unmanaged memory.</returns>
112-
public unsafe Span<T> ToSpan(int length) => IsNull ? [] : new(value, length);
112+
public unsafe Span<T> AsSpan(int length) => IsNull ? [] : new(value, length);
113113

114114
/// <summary>
115115
/// Converts this pointer into span of bytes.

0 commit comments

Comments
 (0)