}
/// <summary>
- /// Returns a reference to the 0th element of the Span. If the Span is empty, returns a reference to the location where the 0th element
- /// would have been stored. Such a reference can be used for pinning but must never be dereferenced.
- /// </summary>
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal ref readonly T DangerousGetPinnableReference()
- {
- return ref _pointer.Value;
- }
-
- /// <summary>
/// The number of items in the read-only span.
/// </summary>
public int Length
if ((uint)_length <= (uint)destination.Length)
{
- Buffer.Memmove(ref destination.DangerousGetPinnableReference(), ref _pointer.Value, (nuint)_length);
+ Buffer.Memmove(ref destination._pointer.Value, ref _pointer.Value, (nuint)_length);
}
else
{
bool retVal = false;
if ((uint)_length <= (uint)destination.Length)
{
- Buffer.Memmove(ref destination.DangerousGetPinnableReference(), ref _pointer.Value, (nuint)_length);
+ Buffer.Memmove(ref destination._pointer.Value, ref _pointer.Value, (nuint)_length);
retVal = true;
}
return retVal;
ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(TTo));
return new Span<TTo>(
- ref Unsafe.As<TFrom, TTo>(ref source.DangerousGetPinnableReference()),
+ ref Unsafe.As<TFrom, TTo>(ref source._pointer.Value),
checked((int)((long)source.Length * Unsafe.SizeOf<TFrom>() / Unsafe.SizeOf<TTo>())));
}
}
/// <summary>
- /// Returns a reference to the 0th element of the Span. If the Span is empty, returns a reference to the location where the 0th element
- /// would have been stored. Such a reference can be used for pinning but must never be dereferenced.
- /// </summary>
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal ref T DangerousGetPinnableReference()
- {
- return ref _pointer.Value;
- }
-
- /// <summary>
/// The number of items in the span.
/// </summary>
public int Length
if (length == 0)
return;
- ref T r = ref DangerousGetPinnableReference();
+ ref T r = ref _pointer.Value;
// TODO: Create block fill for value types of power of two sizes e.g. 2,4,8,16
if ((uint)_length <= (uint)destination.Length)
{
- Buffer.Memmove(ref destination.DangerousGetPinnableReference(), ref _pointer.Value, (nuint)_length);
+ Buffer.Memmove(ref destination._pointer.Value, ref _pointer.Value, (nuint)_length);
}
else
{
bool retVal = false;
if ((uint)_length <= (uint)destination.Length)
{
- Buffer.Memmove(ref destination.DangerousGetPinnableReference(), ref _pointer.Value, (nuint)_length);
+ Buffer.Memmove(ref destination._pointer.Value, ref _pointer.Value, (nuint)_length);
retVal = true;
}
return retVal;