Skip to content

MarshalingPInvokeScanner detects structs as non-blittable #112982

Closed as not planned
@rolfbjarne

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.

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