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

MarshalingPInvokeScanner detects structs as non-blittable #112982

Open
Tracked by #15684
rolfbjarne opened this issue Feb 27, 2025 · 1 comment
Open
Tracked by #15684

MarshalingPInvokeScanner detects structs as non-blittable #112982

rolfbjarne opened this issue Feb 27, 2025 · 1 comment
Labels
area-Interop-mono untriaged New issue has not been triaged by the area owner

Comments

@rolfbjarne
Copy link
Member

Description

MarshalingPInvokeScanner says all structs as non-blittable.

Reproduction Steps

Expected behavior

Test case should succeed.

Actual behavior

Fails with:

[...]
Assembly /Users/rolf/test/dotnet/marshalling-scanner/customstruct/bin/Debug/net9.0/customstruct.dll requires marshal-ilgen for method .Class1:DoSomething (first pass).
❌ Failed, because some assemblies are incompatible
make: *** [customstruct] Error 1

Regression?

No

Known Workarounds

No response

Configuration

No response

Other information

This happens because there's no code here handling structs:

if (baseTypeHandle.Kind == HandleKind.TypeReference)
{
TypeReference baseType = reader.GetTypeReference((TypeReferenceHandle)baseTypeHandle);
if (reader.GetString(typeDef.Namespace) == "System" &&
reader.GetString(baseType.Name) == "Enum")
return Compatibility.Compatible;
}

The code should look at all instance fields of a struct, and if they're all blittable, then the struct is blittable too.

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Feb 27, 2025
Copy link
Contributor

Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Interop-mono untriaged New issue has not been triaged by the area owner
Projects
Status: No status
Development

No branches or pull requests

2 participants