Core/FrameList.cs

A small internal collection for Frame structs. It stores frames in an array, exposes Count and an indexer by ref, can Reserve a new slot (growing the array) and Reset to clear contents.

Native Interop
using System;

namespace Goo;

internal sealed class FrameList
{
    Frame[] _items = new Frame[4];
    int _count;
    public int Count => _count;
    public ref Frame this[int i] => ref _items[i];

    public ref Frame Reserve()
    {
        if (_count == _items.Length) Array.Resize(ref _items, _items.Length * 2);
        return ref _items[_count++];
    }

    internal void Reset()
    {
        Array.Clear(_items, 0, _count);
        _count = 0;
    }
}