Closed
Description
Issue #109665 was fixed with #109694 and assumed to also address issues with readonly
and so tests were added with in #109944 - these tests do pass.
The issue is best showcased with the following:
static class Accessors
{
[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<obj>P")]
public static extern ref readonly object MEMBER(ref readonly Foo value);
public static void A()
{
[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "<obj>P")]
static extern ref readonly object LOCAL(ref readonly Foo value);
}
}
The MEMBER
and LOCAL
are the same definition, but MEMBER
uses an modreq
when LOCAL
doesn't. For testing the LOCAL
scenario was used for validation and this created a false sense of correctness in the tests. The result is the modopt/modreq issues can still occur for fields depending on how the UnsafeAccessor
is defined. This means we need to service .NET 9 again, see #109709, and make the correct fix in .NET 10 along with updating the testing so we validate both types of definition.