Skip to content

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

Closed
mergify[bot] wants to merge 1 commit into
release/stable/7.0from
mergify/bp/release/stable/7.0/pr-25905
Closed

mergify[bot] wants to merge 1 commit into
release/stable/7.0from
mergify/bp/release/stable/7.0/pr-25905

Conversation

@mergify

@mergify mergify Bot commented Nov 6, 2026

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


This is an automatic backport of pull request #25905 done by [Mergify](https://mergify.com).

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 #25010

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
(cherry picked from commit 09516f2)
@github-actions github-actions Bot added area/code-generation Categorizes an issue or PR as relevant to code generation kind/documentation labels Nov 6, 2026
@MartinZikmund
MartinZikmund deleted the mergify/bp/release/stable/7.0/pr-25905 branch November 12, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

2 participants