-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Returning a ReadOnlySpan<byte> from a LibraryImport fails #96525
Comments
Tagging subscribers to this area: @dotnet/interop-contrib Issue DetailsDescriptionReturning a ReadOnlySpan from a call generated by LibraryImport fails to compile, even though it should. It correctly works with a byte[] as the return type instead of ReadOnlySpan Reproduction StepsCompile the following code definition
Expected behaviorThe code should compile Actual behaviorThe code fails with the following error
Regression?No response Known WorkaroundsNo response Configuration.NET 8 Other informationNo response
|
@jtschuster Can you take a look at this? |
Talking with @jkoritzinsky this is expected behavior, since the ReadOnlySpan can't be written to later in the source generator. So not a bug. |
Agreed on it being by-design for now. I'm going to recommend we look at how to make this more natural in this release. The model should have a way to express both a read-only and read-write concept with respect to types. This is a low-priority issue, but definitely will a win for expressing intent for interop scenarios. |
Description
Returning a ReadOnlySpan from a call generated by LibraryImport fails to compile, even though it should. It correctly works with a byte[] as the return type instead of ReadOnlySpan
Reproduction Steps
Compile the following code definition
Expected behavior
The code should compile
Actual behavior
The code fails with the following error
Regression?
No response
Known Workarounds
No response
Configuration
.NET 8
Other information
No response
The text was updated successfully, but these errors were encountered: