Repository navigation
fix(xamlgen): Skip ApiExtension registrations of inaccessible types (backport #25905) - #26190
Closed
mergify[bot] wants to merge 1 commit into
Closed
mergify[bot] wants to merge 1 commit into
mergify[bot] wants to merge 1 commit into
Conversation
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)
3 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitHub Issue: closes #25010
PR Type:
🐞 Bugfix
What changed? 🚀
The application's generated
Appcode registers the[assembly: ApiExtension]declarations of every referenced assembly (XamlFileGenerator.GenerateApiExtensionRegistrations). It wrote the types straight intotypeof(global::…)/new global::…(o)without checking that the app can see them. A library declaring the attribute oninternaltypes compiled fine, and then every app referencing it failed withCS0122.The generator now checks each type an
ApiExtensionnames (extended, extension and owner) withCompilation.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:Skipping (rather than a reflection-based registration) keeps the existing contract: every
ApiExtensionUno 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.mddocuments UXAML0008 and its fix, which is to make the types public in the declaring library.Validation
Given_ApiExtension, with an app that references a second compiled projectLibcarrying the attribute:internaltypes: 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 forMyExtension).publictypes: the app compiles with no diagnostics.Uno.UI.SourceGenerators.Testsrun locally: same failure set asmaster(environment-related), plus the two new tests passing.Uno.Sdk.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code
This is an automatic backport of pull request #25905 done by [Mergify](https://mergify.com).