Skip to content

JSexport regression in .NET 9 SDK preview 4 #103205

@Youssef1313

Description

@Youssef1313

Description

I believe the regression started from this PR #99924.

The PR introduces a usage of typeof(__GeneratedInitializer), but when you have two assemblies that are using JSExport, then both will generate __GeneratedInitializer class, then typeof(__GeneratedInitializer) is ambiguous.

I guess the __GeneratedInitializer class could be file instead? This should still work with ModuleInitializer. Or maybe generated code could have #pragma warning disable CS0436

Reproduction Steps

It's happening currently in Uno Platform, I haven't tried to make a minimal repro, but I think the description makes it clear on why it happens.

Expected behavior

Things should work as they were in Preview 3

Actual behavior

Build fails with:

/agent/_work/1/s/src/Uno.UI.Dispatching/obj/Uno.UI.Dispatching.Wasm/Release/net9.0/Microsoft.Interop.JavaScript.JSImportGenerator/Microsoft.Interop.JavaScript.JSExportGenerator/JSExports.g.cs(9,328): error CS0436: The type '__GeneratedInitializer' in '/agent/_work/1/s/src/Uno.UI.Dispatching/obj/Uno.UI.Dispatching.Wasm/Release/net9.0/Microsoft.Interop.JavaScript.JSImportGenerator/Microsoft.Interop.JavaScript.JSExportGenerator/JSExports.g.cs' conflicts with the imported type '__GeneratedInitializer' in 'Uno.Foundation.Runtime.WebAssembly, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null'. Using the type defined in '/agent/_work/1/s/src/Uno.UI.Dispatching/obj/Uno.UI.Dispatching.Wasm/Release/net9.0/Microsoft.Interop.JavaScript.JSImportGenerator/Microsoft.Interop.JavaScript.JSExportGenerator/JSExports.g.cs'. [/agent/_work/1/s/src/Uno.UI.Dispatching/Uno.UI.Dispatching.Wasm.csproj::TargetFramework=net9.0]

Regression?

Yes. It works in Preview 3 but not Preview 4

Known Workarounds

<PropertyGroup>
  <!-- Workaround for https://github.com/dotnet/runtime/issues/103205 -->
  <NoWarn>$(NoWarn);CS0436</NoWarn>
</PropertyGroup>

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions