Skip to content

[browser] JSExport missing global:: #116960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2025

Conversation

pavelsavara
Copy link
Member

Fixes #116254

@pavelsavara pavelsavara added this to the 10.0.0 milestone Jun 24, 2025
@pavelsavara pavelsavara self-assigned this Jun 24, 2025
@pavelsavara pavelsavara added arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm labels Jun 24, 2025
@pavelsavara pavelsavara marked this pull request as ready for review June 24, 2025 13:51
@Copilot Copilot AI review requested due to automatic review settings June 24, 2025 13:51
@pavelsavara pavelsavara requested a review from lewing as a code owner June 24, 2025 13:51
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that generated JS export stubs and tests use the global:: alias to avoid ambiguities when calling methods on the Basic class.

  • Unit tests now explicitly invoke Basic.AnnotatedExport and Basic.Export1 with global:: qualification.
  • The JS export generator prefixes method invocations with the global alias in the generated stub.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/libraries/System.Runtime.InteropServices.JavaScript/tests/JSImportGenerator.UnitTest/Compiles.cs Prefixed calls to Basic.AnnotatedExport and Basic.Export1 with global::
src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportGenerator.cs Updated stub generator to insert global:: before method name in GenerateInnerLocalFunction
Comments suppressed due to low confidence (1)

src/libraries/System.Runtime.InteropServices.JavaScript/gen/JSImportGenerator/JSExportGenerator.cs:433

  • Using IdentifierName to represent a global alias–qualified name will produce invalid syntax. Consider using ParseName(TypeNames.GlobalAlias + context.SignatureContext.MethodName) or constructing an AliasQualifiedNameSyntax to correctly model global::Basic.MethodName.
                .WithBody(stubGenerator.GenerateStubBody(IdentifierName(TypeNames.GlobalAlias + context.SignatureContext.MethodName)))

@pavelsavara
Copy link
Member Author

It seems CI failures are infra issue. The relevant test passed.

Log

[15:40:18] info: Finished:    System.Runtime.InteropServices.JavaScript.Tests.dll
[15:40:18] info: Stored /root/helix/work/workitem/uploads/xharness-output/testResults.xml results 110773 bytes
[15:40:18] info: Finished uploading 110773 bytes of RESULTXML
[15:40:18] info: Xml file was written to the provided writer.
[15:40:18] info: 
[15:40:18] info: === TEST EXECUTION SUMMARY ===
[15:40:18] info: Tests run: 424 Passed: 422 Inconclusive: 0 Failed: 0 Ignored: 0 Skipped:

@pavelsavara pavelsavara merged commit cdb1b8f into dotnet:main Jun 25, 2025
89 of 97 checks passed
@pavelsavara pavelsavara deleted the jsexport_global branch June 25, 2025 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generated code of JSExport missing global
2 participants