Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix c# generated string marshalling #138

Merged

Conversation

arsher
Copy link
Contributor

@arsher arsher commented Feb 1, 2025

I hope this is the last one, same as previous fix just for the string bits that I missed.

@ralfbiedert ralfbiedert merged commit 1f68902 into ralfbiedert:master Feb 1, 2025
2 checks passed
@arsher arsher deleted the csharp_marshaller_more_fixes branch February 1, 2025 17:36
@ralfbiedert
Copy link
Owner

Thanks!

@ralfbiedert
Copy link
Owner

Quick update, I changed array handling in that it now really only allows for the exact number of elements and throws otherwise. I'd argue that's the only correct thing to do:

Like, this works:

    [Theory]
    [InlineData(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 })]
    public void array_1(byte[] array)
    {
        Assert.Equal((array?.Length ?? 0) > 0 ? 1 : 0, Interop.array_1(new Array
        {
            data = array
        }));
    }

And these won't work:

    [Theory]
    [InlineData(new byte[] { })]
    [InlineData(new byte[] { 1, 2, 3 })]
    [InlineData(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 })]
    [InlineData(null)]
    public void array_1_throws(byte[] array)
    {
        Assert.Throws<System.InvalidOperationException>(() =>  Interop.array_1(new Array
        {
            data = array
        }));
    }

Does that make sense?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants