Skip to content

[WASM] MarshalingPInvokeScanner fails when using a nested value type contained in a different assembly. #110938

Open
@FriendSea

Description

Description

In a WASM project, when using NativeFileReference for linking, it seems that the types used in DllImport are being scanned.
However, this process does not appear to support nested types contained in other assemblies.

It seems like the issue stems from the assumption that the parent of the type is always an AssemblyReference.
https://github.com/dotnet/runtime/blob/main/src/tasks/MonoTargetsTasks/MarshalingPInvokeScanner/MinimalMarshalingTypeCompatibilityProvider.cs#L142

Reproduction Steps

Download the zip file and try building the WasmProject.
dotnet_wasm_issue.zip

This project uses the wasmconsole template as the minimal setup to reproduce the issue, but the same problem occurs in Blazor WebAssembly as well.

Expected behavior

The project should build and run successfully.

Actual behavior

Error occurs.

C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.WebAssembly.Sdk\8.0.11\Sdk\WasmAp
p.Native.targets(737,5): error MSB4018: "MarshalingPInvokeScanner" タスクが予期せずに 失敗しました。

C:\Program Files\dotnet\packs\Microsoft.NET.Runtime.WebAssembly.Sdk\8.0.11\Sdk\WasmAp
p.Native.targets(737,5): error MSB4018: System.NotImplementedException: Unsupported R
esolutionScope kind 'TypeReference' used in type :InnerValueType.

Regression?

No response

Known Workarounds

There is no issue when using top-level types, even if they are contained in a different assembly.

Configuration

No response

Other information

No response

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions