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

C#: Consider changing List parameters to e.g. IEnumerable #1013

Open
dicej opened this issue Aug 1, 2024 · 2 comments
Open

C#: Consider changing List parameters to e.g. IEnumerable #1013

dicej opened this issue Aug 1, 2024 · 2 comments
Labels
gen-c# Related to the C# code generator

Comments

@dicej
Copy link
Collaborator

dicej commented Aug 1, 2024

Per dotnet/runtimelab#2614 (comment), List parameters are often unnecessarily restrictive -- callers might want to pass collections of other types without converting them to Lists first.

@pavelsavara
Copy link

note that IEnumerable doesn't have Count/Length but you will likely need to know it upfront to allocate for marshaling. So maybe other interfaces I mentioned would be better fit. Or you could even generate multiple signatures.

@pavelsavara
Copy link

pavelsavara commented Aug 1, 2024

I don't know if we also marshal arrays of structs and primitive types (not resources), but in such case Span<T> and ReadOnlySpan<T> are better choices. Because those could live on stack. It would also help with stream APIs

@jsturtevant jsturtevant added the gen-c# Related to the C# code generator label Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gen-c# Related to the C# code generator
Projects
Status: No status
Development

No branches or pull requests

3 participants