Skip to content

UnmanagedCallersOnlyAttribute does not properly export mangled names to aot DLL when using stdcall on x86 windows #116585

Closed as not planned
@tyrel-alastair-hunter-bosch

Description

Describe the bug

When using UnmanagedCallersOnlyAttribute to export a function into a native library on x86 platforms if the function uses stdcall then the name is not properly mangled.

To Reproduce

internal static class NameMangling
{
    [UnmanagedCallersOnly(EntryPoint = "TestNameMangling", CallConvs = new Type[] { typeof(CallConvStdcall) })]
    public static unsafe int TestNameMangling(void* name, int* id)
    {
        return 0;
    }
 <PropertyGroup>
   <TargetFramework>net10.0</TargetFramework>
   <OutputType>Library</OutputType>
   <PublishAot>true</PublishAot>
   <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
   <StripSymbols>true</StripSymbols>
 </PropertyGroup>

Further technical details

Its expected that when publishing with dotnet publish -r win-x86 --self-contained
then using dependencies gui to inspect the published dll that you should see both

TestNameMangling exported
as well
as _TestNameMangling@8 exported.
Without this export any native assembly that load this assembly at runtime will have issues with loading this function pointer.

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