interoptopus_csharp 0.16.0-alpha.9

The C# backend for Interoptopus.
Documentation
// Auto-generated plugin interop
// <auto-generated/>

using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
using My.Company.Common;
using Interoptopus.API;

namespace My.Company;

public class Plugin : IPlugin
{
    public static void Gc()
    {
        GC.Collect();
        GC.WaitForPendingFinalizers();
        GC.Collect();
    }
}

partial class Heavy : IHeavy<Heavy>
{
    private readonly uint[] _data;

    public Heavy() { _data = []; }
    private Heavy(uint[] data) { _data = data; }

    public static Heavy NewSelf(nuint size, uint value)
    {
        var data = new uint[(int)size];
        Array.Fill(data, value);
        return new Heavy(data);
    }

    public static Task<Heavy> NewSelfAsync(nuint size)
    {
        return Task.FromResult(new Heavy(new uint[(int)size]));
    }

    public uint Get(nuint i) => _data[(int)i];
}

partial class Fliparoo : IFliparoo<Fliparoo>
{
    private Heavy _left;
    private Heavy _right;

    public Fliparoo() { _left = new Heavy(); _right = new Heavy(); }
    private Fliparoo(Heavy left, Heavy right) { _left = left; _right = right; }

    public static Fliparoo Create1(Heavy heavy_1, Heavy heavy_2) => new Fliparoo(heavy_1, heavy_2);

    public static Task<Fliparoo> Create2(Heavy heavy1, Heavy heavy2)
        => Task.FromResult(new Fliparoo(heavy1, heavy2));

    public static Task<Fliparoo> Create3(Heavy heavy1, Heavy heavy3)
        => Task.FromResult(new Fliparoo(heavy1, heavy3));

    public Heavy ReplaceLeft1(Heavy heavy) { var old = _left; _left = heavy; return old; }

    public Heavy ReplaceLeft2(Heavy heavy) { var old = _left; _left = heavy; return old; }

    public Heavy ReplaceRight1(Heavy heavy) { var old = _right; _right = heavy; return old; }

    public Heavy ReplaceRight2(Heavy heavy) { var old = _right; _right = heavy; return old; }

    public async Task<Heavy> ReplaceLeftAsync(Heavy heavy)
    {
        await Task.Yield();
        var old = _left;
        _left = heavy;
        return old;
    }

    public async Task<Heavy> ReplaceRightAsync(Heavy heavy)
    {
        await Task.Yield();
        var old = _right;
        _right = heavy;
        return old;
    }

    public Heavy GetLeft() => _left;

    public Heavy GetRight() => _right;
}