interoptopus_csharp 0.16.0-alpha.20

The C# backend for Interoptopus.
Documentation
using System;
using My.Company;
using My.Company.Common;
using Xunit;

public class TestPatternServicesCallbacksTable
{
    private CallbackTable _table = null!;

    private void CreatePatternDelegateTable(ServiceCallbacks service)
    {
        _table = new CallbackTable
        {
            my_callback = new MyCallback(value => 1),
            my_callback_namespaced = new MyCallbackNamespaced(_ => 0),
            my_callback_void = new MyCallbackVoid(ptr => { }),
            my_callback_contextual = new MyCallbackContextual((context, value) => { }),
            sum_delegate_1 = new SumDelegate1(() => { }),
            sum_delegate_2 = new SumDelegate2((x, y) => x + y),
            sum_delegate_return = new SumDelegateReturn((i, i1) => ResultVoidError.Ok),
            sum_delegate_return_2 = new SumDelegateReturn2((i, i1) => { })
        };
        service.SetDelegateTable(_table);
    }

    [Fact]
    public void InvokeDelegates()
    {
        using var service = ServiceCallbacks.Create();

        CreatePatternDelegateTable(service);
        // ^-- this might run at risk of our delegates getting GC'ed if we don't add
        // special handling. For example, if we don't do GC.Collect() it might just pass
        // because the delegates didn't get cleaned up, but once you comment the line
        // below out it'll crash.
        //
        GC.Collect();

        service.InvokeDelegates();
    }
}