Skip to content

UnsafeAccessor throws MissingFieldException on generic field (T) #92633

@AoshiW

Description

@AoshiW

Description

UnsafeAccessor throws MissingFieldException on generic field (T) in generic type, where genetic T is:

  • class (e.g. string)
  • struct that has class as a generic parameter (e.g. ArraySegment<string>)

Reproduction Steps

[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "_items")]
static extern ref string[] GetItems(List<string> list);

GetItems(new());

Expected behavior

getting field

Actual behavior

throws exception

System.MissingFieldException: Field not found: 'System.Collections.Generic.List`1._items'.

Regression?

No response

Known Workarounds

No response

Configuration

.NET SDK: 8.0.100-rc.1.23455.8

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions