Nihlus/AdvancedDLSupport

Use of 'in' keyword in mapping interface throws

TheBuzzSaw opened this issue · 0 comments

Describe the bug
The ref and out keywords seem to map just fine between the C# interface and the C API, but the in keyword triggers a System.TypeLoadException.

To Reproduce
Steps to reproduce the behavior:

  1. Create an interface that maps an in parameter to a const T* C parameter.
  2. Attempt to activate that interface.
  3. System.TypeLoadException is thrown.

Please provide a minimal compilable example of

[NativeSymbols(Prefix = "gl")]
public interface IOpenGl : IDisposable
{
    [NativeSymbol("DeleteBuffers")]
    void DeleteBuffersByRef(int n, ref uint buffers);

    [NativeSymbol("DeleteBuffers")]
    void DeleteBuffersByOut(int n, out uint buffers);

    // This one throws. If I comment it out, no throw.
    [NativeSymbol("DeleteBuffers")]
    void DeleteBuffersByIn(int n, in uint buffers);
}

class Program
{
    static void Main(string[] args)
    {
        using (var gl = NativeLibraryBuilder.Default.ActivateInterface<IOpenGl>("GL"))
        {

        }
    }
}

Expected behavior
It would be wonderful to be able to map in parameters to const T* parameters.

Desktop (please complete the following information):

  • OS: Arch Linux (Antergos)
  • Runtime: .NET Core
  • Version: 2.2

Additional context
N/A