Skip to content

fix(xamlgen): Skip ApiExtension registrations of inaccessible types - #25905

Merged
MartinZikmund merged 1 commit into
unoplatform:masterfrom
ramezgerges:dev/rara/apiextension-accessibility
Nov 6, 2026
Merged

MartinZikmund merged 1 commit into
unoplatform:masterfrom
ramezgerges:dev/rara/apiextension-accessibility

Conversation

@ramezgerges

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #25010

PR Type:

🐞 Bugfix

What changed? 🚀

The application's generated App code registers the [assembly: ApiExtension] declarations of every referenced assembly (XamlFileGenerator.GenerateApiExtensionRegistrations). It wrote the types straight into typeof(global::…) / new global::…(o) without checking that the app can see them. A library declaring the attribute on internal types compiled fine, and then every app referencing it failed with CS0122.

The generator now checks each type an ApiExtension names (extended, extension and owner) with Compilation.IsSymbolAccessibleWithin(…, Compilation.Assembly). When one isn't accessible, it skips that registration and reports a warning naming the registration, the declaring assembly and the type:

warning UXAML0008: The [assembly: ApiExtension] registration of 'Lib.IMyExtension' in 'Lib' was skipped because 'Lib.IMyExtension' is not accessible from this project

Skipping (rather than a reflection-based registration) keeps the existing contract: every ApiExtension Uno ships names public types (Foldable, GooglePlay, Graphics3DGL, SpellChecking, WebView.X11, Lottie). A reflection path would also leave the extension's constructor exposed to trimming. uno-build-error-codes.md documents UXAML0008 and its fix, which is to make the types public in the declaring library.

Validation

  • New generator tests, Given_ApiExtension, with an app that references a second compiled project Lib carrying the attribute:
    • internal types: the app compiles and reports exactly one UXAML0008. With the previous generator this test fails with the issue's errors (CS0122: 'IMyExtension' is inaccessible due to its protection level, same for MyExtension).
    • public types: the app compiles with no diagnostics.
  • Full Uno.UI.SourceGenerators.Tests run locally: same failure set as master (environment-related), plus the two new tests passing.
  • Not run: a build of a real app against a packed Uno.Sdk.

PR Checklist ✅

🤖 Generated with Claude Code

@github-actions github-actions Bot added area/code-generation Categorizes an issue or PR as relevant to code generation kind/documentation labels Nov 2, 2026
@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 242679 has failed on Uno.UI - CI.

@ramezgerges

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines will not run the associated pipelines, because the pull request was updated after the run command was issued. Review the pull request again and issue a new run command.

@ramezgerges
ramezgerges force-pushed the dev/rara/apiextension-accessibility branch from 1cf0df9 to e67aa80 Compare November 2, 2026 15:09
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 242860 has failed on Uno.UI - CI.

@MartinZikmund MartinZikmund added the 7.0 PRs only. For issues, use the Release field. label Nov 4, 2026
@MartinZikmund

Copy link
Copy Markdown
Member

@Mergifyio backport release/stable/7.0

@mergify

mergify Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

backport release/stable/7.0

✅ Backports have been created

Details

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@ramezgerges
ramezgerges force-pushed the dev/rara/apiextension-accessibility branch from 0f335fe to 2e9cde5 Compare November 5, 2026 17:55
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@unodevops

Copy link
Copy Markdown
Contributor

The app's generated code registers every [assembly: ApiExtension] of its
references. A registration naming an internal type failed the app's build
with CS0122. It is now skipped with a UXAML0008 warning that points at the
declaring assembly.

Fixes unoplatform#25010

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@ramezgerges
ramezgerges force-pushed the dev/rara/apiextension-accessibility branch from 2e9cde5 to 09516f2 Compare November 6, 2026 16:37
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@unodevops

Copy link
Copy Markdown
Contributor

@mergify

mergify Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@MartinZikmund
MartinZikmund merged commit e8217ac into unoplatform:master Nov 6, 2026
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

7.0 PRs only. For issues, use the Release field. area/code-generation Categorizes an issue or PR as relevant to code generation kind/documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XAML generator emits ApiExtension registrations for non-public types, breaking the consuming app with CS0122

4 participants