Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Diagnostics;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

namespace System
Expand Down Expand Up @@ -36,7 +37,7 @@ public EnumInfo(bool hasFlagsAttribute, TStorage[] values, string[] names)
public unsafe TResult[] CloneValues<TResult>() where TResult : struct
{
Debug.Assert(sizeof(TStorage) == sizeof(TResult));
return MemoryMarshal.Cast<TStorage, TResult>(Values).ToArray();
return Unsafe.BitCast<ReadOnlySpan<TStorage>, ReadOnlySpan<TResult>>(Values).ToArray();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ internal static void AppendChar<TChar>(ref ValueListBuilder<TChar> result, char
{
Debug.Assert(typeof(TChar) == typeof(byte));
var r = new Rune(ch);
r.EncodeToUtf8(MemoryMarshal.AsBytes(result.AppendSpan(r.Utf8SequenceLength)));
r.EncodeToUtf8(Unsafe.BitCast<Span<TChar>, Span<byte>>(result.AppendSpan(r.Utf8SequenceLength)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;

Expand Down Expand Up @@ -211,7 +212,7 @@ internal static void Append<TChar>(ref ValueListBuilder<TChar> outputBuffer, int
else
{
Debug.Assert(typeof(TChar) == typeof(byte));
Rune.DecodeLastFromUtf8(MemoryMarshal.AsBytes(outputBuffer.AsSpan()), out Rune value, out int bytesConsumed);
Rune.DecodeLastFromUtf8(Unsafe.BitCast<ReadOnlySpan<TChar>, ReadOnlySpan<byte>>(outputBuffer.AsSpan()), out Rune value, out int bytesConsumed);
outputBuffer.Length -= bytesConsumed;
outputBuffer.Append(TChar.CastFrom('"'));
DateTimeFormat.AppendChar(ref outputBuffer, (char)value.Value);
Expand Down
Loading