[WASM] MarshalingPInvokeScanner fails when using a nested value type contained in a different assembly.
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 42/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- csharp, wasm
- Domain
- build-system
Research direction
Build the attached dotnet_wasm_issue.zip reproduction using the wasmconsole template, then inspect MarshalingPInvokeScanner and MinimalMarshalingTypeCompatibilityProvider.cs around line 142. Compare the nested value type case with the documented top-level-type workaround; done means the Wasm project builds and runs successfully without the MSB4018 or NotImplementedException error.
Written by the indexing model from the issue text.
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
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/runtime
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
area-System.Reflection blocking-clean-ci-optional Known Build Error os-mac-os-x untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
area-CodeGen-coreclr untriaged
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
agentic-workflows untriaged
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
area-VM-meta-mono untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
Create parent directories only after the containment check in InstallHelper.TryExtractToDirectory Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
PowerShell/PSResourceGet#2056 ·