Skip to content

RVA fields can be set in Mono; should throw FieldAccessException instead #97829

@steveharter

Description

@steveharter

In the Core runtime, a FieldAccessException is thrown.

Found by newly added tests in #97784

Repro

FieldInfo fieldInfo = typeof(MyStruct).GetField(nameof(MyStruct.s_rvaIntField));
fieldInfo.SetValue(null, MyStruct.s_rvaIntField);
// Result: no exception

public struct MyStruct
{
    public static readonly int[] s_rvaIntField = [1, 2];

    public MyStruct() { }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions