Skip to content

Mono WASM PInvoke Table generation does not handle file scoped types #93999

@jkoritzinsky

Description

@jkoritzinsky

Description

File scoped types are named like <File_Name_Without_Periods>Hash__ClassName. For UnmanagedCallersOnly methods in file-scoped types, Mono tries to generate a method in C, but it doesn't escape the name. As a result, you get errors like the following:

/root/helix/work/correlation/build/wasm/WasmApp.Native.targets(367,5): error : In file included from /root/helix/work/correlation/build/microsoft.netcore.app.runtime.browser-wasm/runtimes/browser-wasm/native/src/pinvoke.c:15: [/root/helix/work/workitem/e/publish/ProxyProjectForAOTOnHelix.proj]
/root/helix/work/correlation/build/wasm/WasmApp.Native.targets(367,5): error : /root/helix/work/workitem/e/wasm_build/obj/wasm/for-build/pinvoke-table.h:212:64: error: expected ';' after top level declarator [/root/helix/work/workitem/e/publish/ProxyProjectForAOTOnHelix.proj]
/root/helix/work/correlation/build/wasm/WasmApp.Native.targets(367,5): error : int wasm_native_to_interp_System_Runtime_InteropServices_Tests_<System_Runtime_InteropServices_Tests_ComVariantMarshallerTests_IGeneratedComInterface>F3F2786D8F8679299059CA9E93026F23079CBD4B40DBBE7EBFBCA0FE1F6116567__InterfaceImplementation_ABI_Method (int arg0) {  [/root/helix/work/workitem/e/publish/ProxyProjectForAOTOnHelix.proj]
/root/helix/work/correlation/build/wasm/WasmApp.Native.targets(367,5): error :                                                                ^ [/root/helix/work/workitem/e/publish/ProxyProjectForAOTOnHelix.proj]
/root/helix/work/correlation/build/wasm/WasmApp.Native.targets(367,5): error :                                                                ; [/root/helix/work/workitem/e/publish/ProxyProjectForAOTOnHelix.proj]
/root/helix/work/correlation/build/wasm/WasmApp.Native.targets(367,5): error : /root/helix/work/workitem/e/wasm_build/obj/wasm/for-build/pinvoke-table.h:220:3: error: use of undeclared identifier 'WasmInterpEntrySig_5' [/root/helix/work/workitem/e/publish/ProxyProjectForAOTOnHelix.proj]
/root/helix/work/correlation/build/wasm/WasmApp.Native.targets(367,5): error : ((WasmInterpEntrySig_5)wasm_native_to_interp_ftndescs [5].func) ((int*)&res, (int*)&arg0, (int*)&arg1, wasm_native_to_interp_ftndescs [5].arg); [/root/helix/work/workitem/e/publish/ProxyProjectForAOTOnHelix.proj]
/root/helix/work/correlation/build/wasm/WasmApp.Native.targets(367,5): error :   ^ [/root/helix/work/workitem/e/publish/ProxyProjectForAOTOnHelix.proj]
/root/helix/work/correlation/build/wasm/WasmApp.Native.targets(367,5): error : /root/helix/work/workitem/e/wasm_build/obj/wasm/for-build/pinvoke-table.h:269:420: error: use of undeclared identifier 'System_Runtime_InteropServices_Tests_ComVariantMarshallerTests_IGeneratedComInterface' 

Reproduction Steps

Build #93635 in the LibraryTests_EAT configuration.

Expected behavior

Build succeeds

Actual behavior

Build fails with above mentioned error.

Regression?

Unknown

Known Workarounds

No response

Configuration

Running in a PR into this repo: #93635

Other information

Helix log for the failing test:

https://helixre107v0xdcypoyl9e7f.blob.core.windows.net/dotnet-runtime-refs-pull-93635-merge-9667f32037a34a4fa0/normal-System.Runtime.InteropServices.Tests/1/console.147620a6.log?helixlogtype=result

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions