Skip to content

Fix schemafields that are supposed to return fix sized arrays #134

@KillStr3aK

Description

@KillStr3aK

The current workaround is this:

public unsafe T[] GetFixedArray<T>(nint pointer, string @class, string member, int length) where T: NativeObject
{
    nint ptr = pointer + Schema.GetSchemaOffset(@class, member);
    Span<nint> references = MemoryMarshal.CreateSpan<nint>(ref ptr, length);
    T[] values = new T[length];

    for (int i = 0; i < length; i++)
    {
        values[i] = (T)Activator.CreateInstance(typeof(T), references[i])!;
    }

    return values;
}

this works in general and can access the whole schemaclass but when I messed with viewmodels I've experienced a segfault when tried to access the animation? string and it was corrupted memory but haven't investigated further yet but this needs attention for sure.

I might take on this just to dont forget about the issue in general I've opened this

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions