Skip to content

RuntimeHelpers::InitializeArray isn't handled (used for arrays of >=3 constants) #8

@zeromus

Description

@zeromus

This c# will crash AlterNative: class foo { float[] bar = { 1,2,3 }; };
It's easier to see why that might be when you try this:

class foo {
    void baz() {
        float[] bar = { 1, 2, 3 };
    }
};

which results in

void foo::baz(){
    RuntimeHelpers::InitializeArray(new Array<float>(3), fieldof(<PrivateImplementationDetails>{169D9E6B-C4D0-4476-851A-DD23AA0A2F9B}::$$method0x6000001-1)->FieldHandle);
}

For 1 or 2 elements, the c# compiler will emit array stores. For the 3rd element it begins emitting that ugly hacky approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions