Description
Spotted while porting my ComputeSharp samples to .NET 9 (see here). It seems that [UnsafeAccessor] is broken in .NET 9 when used to access unspeakable fields (captured primary constructor parameters being a common example).
Reproduction Steps
using System.Runtime.CompilerServices;
Blah blah = new("Bob");
string name = Blah.GetName(in blah);
Console.WriteLine(name);
public readonly struct Blah(string name)
{
public string EnsureCaptured => name;
[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<name>P")]
public static extern ref readonly string GetName(ref readonly Blah value);
}
Expected behavior
Should work as expected.
Actual behavior
Sergio0694/ComputeSharp#871
Regression?
Yes. Works fine on .NET 8.
Known Workarounds
None that I can think of.
Configuration
Description
Spotted while porting my ComputeSharp samples to .NET 9 (see here). It seems that
[UnsafeAccessor]is broken in .NET 9 when used to access unspeakable fields (captured primary constructor parameters being a common example).Reproduction Steps
Expected behavior
Should work as expected.
Actual behavior
Sergio0694/ComputeSharp#871
Regression?
Yes. Works fine on .NET 8.
Known Workarounds
None that I can think of.
Configuration