Skip to content

MarshalingPInvokeScanner detects structs as non-blittable #112982

Closed as not planned

Description

@rolfbjarne

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.

Activity

  1. added
    untriaged
    on Feb 27, 2025
  2. dotnet-policy-service commented on Feb 27, 2025

    @dotnet-policy-service
    Contributor

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

  3. agocke commented on May 19, 2025

    @agocke
    Member

    Closing as unplanned.

  4. removed
    untriaged
    on May 19, 2025
  5. locked and limited conversation to collaborators on Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions