Closed Sieluna closed 5 months ago
Host.UnsafeGetByteRef will return a managed type reference, it should be safe.
using System.Runtime.CompilerServices;
var s = new E(new H<char>(new B<char>(['B', 'e', 's', 't', ',', 'S', 'i', 'a'])));
ref var b = ref s.G<char>();
Console.WriteLine($"{b}");
struct B<T>(T[] b)
{
public readonly ref T GetRef(int i)
=> ref b[i];
}
struct H<TEntity>(B<TEntity> b)
{
public ref byte UnsafeGetByteRef()
=> ref Unsafe.As<TEntity, byte>(ref b.GetRef(0));
}
struct E(H<char> h)
{
public ref TComponent G<TComponent>()
{
ref var byteRef = ref h.UnsafeGetByteRef();
nint offset = 2;
return ref Unsafe.As<byte, TComponent>(ref Unsafe.AddByteOffset(ref byteRef, offset));
}
}
Expect e, result e
Describe the bug
In Entity.cs, compiler will confuse at Get and GetOrNull function
Steps to reproduce
Will throw compile error, which can be fixed by
Logs
No response