Remove InternalsVisibleTo attributes for .NET MAUI Community Toolkit - #34070
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes all InternalsVisibleTo attributes that grant the .NET MAUI Community Toolkit access to internal APIs. This is the third attempt to make this change, now targeting the net11.0 branch to provide the toolkit team sufficient time to migrate away from internal API dependencies.
Changes:
- Removed 22
InternalsVisibleTodeclarations across 4 AssemblyInfo files for CommunityToolkit assemblies - Removed duplicate
Controls.TestCases.HostAppentry from Controls/Core AssemblyInfo - Preserved all other InternalsVisibleTo entries for MAUI's own test and compatibility assemblies
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Essentials/src/AssemblyInfo/AssemblyInfo.shared.cs | Removed 5 CommunityToolkit InternalsVisibleTo entries |
| src/Core/src/Properties/AssemblyInfo.cs | Removed 5 CommunityToolkit InternalsVisibleTo entries |
| src/Controls/src/Xaml/Properties/AssemblyInfo.cs | Removed 6 CommunityToolkit InternalsVisibleTo entries |
| src/Controls/src/Core/Properties/AssemblyInfo.cs | Removed 6 CommunityToolkit entries + 1 duplicate Controls.TestCases.HostApp entry |
|
Moving this to draft, the Toolkit team can get the resulting artifacts from this for testing to make sure that all APIs are replaced. |
|
/review -b feature/refactor-copilot-yml |
|
|
AI code review for net11.0 targetVerdict: Needs discussion (draft; intentional decoupling with cross-repo coordination cost and red CI) Independent review (diff-first, then reconciled with the PR narrative). This is not an approval — a human still needs to sign off. PR is a draft. What the PR doesRemoves the Findings
CI
Confidence: medium. The mechanical change is sound; the open questions are the CTK-side coordination and confirming the red CI is the expected downstream fallout rather than an unrelated break. |
|
Verdict: NEEDS_DISCUSSION (draft; intentional, purely-subtractive change with a cross-repo coordination cost — not an approval) All four review models agree this change is mechanically correct and low-risk within this repo: it only removes the CI: Multi-model review (gpt-5.5 · opus-4.8 · opus-4.6 · gemini-3.1-pro). Comments only — not a formal approval. |
a353da8 to
f9d8af6
Compare
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34070Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34070" |
f9d8af6 to
5c02c9d
Compare
04c29d1 to
00b0bb5
Compare
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [CommunityToolkit.Maui](https://github.com/CommunityToolkit/Maui) | `14.2.2` → `15.0.0` |  |  | --- ### Release Notes <details> <summary>CommunityToolkit/Maui (CommunityToolkit.Maui)</summary> ### [`v15.0.0`](https://github.com/CommunityToolkit/Maui/releases/tag/15.0.0): Prevent Breaking Changes in .NET 11 [Compare Source](CommunityToolkit/Maui@14.2.2...15.0.0) #### .NET 11 Compatibility This release provides compatibility with the upcoming release of .NET 11. In .NET 11, [`CommunityToolkit.Maui` will no longer have access to internal .NET MAUI APIs](dotnet/maui#34070). This release removes our use of internal .NET MAUI APIs to ensure compatibility with .NET 11. > \[!IMPORTANT] > We recommend every .NET MAUI app preparing for .NET 11 install this release, v15.0.0 (or later), before .NET 11 is released in November. Apps running `CommunityToolkit.Maui` v14.2.2 and earlier will not be compatible with .NET 11. #### What's Changed - Remove MAUI internal API usage by [@​jfversluis](https://github.com/jfversluis) in [#​3251](CommunityToolkit/Maui#3251) - Hardcode NuGet trusted publishing user by [@​jfversluis](https://github.com/jfversluis) in [#​3266](CommunityToolkit/Maui#3266) #### Housekeeping - Bump actions/setup-dotnet from 5.4.0 to 6.0.0 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​3268](CommunityToolkit/Maui#3268) - Bump actions/setup-java from 5.5.0 to 5.6.0 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​3267](CommunityToolkit/Maui#3267) **Full Changelog**: <CommunityToolkit/Maui@14.2.2...14.2.3> </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or PR is renamed to start with "rebase!". 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
> ℹ️ **Note** > > This PR body was truncated due to platform limits. This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [CommunityToolkit.Maui](https://github.com/CommunityToolkit/Maui) | `15.0.0` → `15.0.1` |  |  | --- ### Release Notes <details> <summary>CommunityToolkit/Maui (CommunityToolkit.Maui)</summary> ### [`v15.0.1`](https://github.com/CommunityToolkit/Maui/releases/tag/15.0.1): Fix WindowsAppSDK Compatibility, Remove Remaining .NET MAUI Internal API Usage [Compare Source](CommunityToolkit/Maui@15.0.0...15.0.1) #### v15.0.1 Fix Crashes on Windows This release removes the `WindowsAppSDK v2.2.0` dependency that was causing apps to crash on Windows. Long story short, [.NET 10 MAUI currently expects Windows App SDK 1.8.x, while .NET 11 expects 2.3.1](CommunityToolkit/Maui#3271 (comment)). We also found a few more internal .NET MAUI APIs that we missed in the [`CommunityToolkti.Maui v15.0.0` Release](https://github.com/CommunityToolkit/Maui/releases/tag/15.0.0) used by `FileSaver`, `FolderPicker`, `Snackbar`, `Toast`, `Expander` and `TouchBehavior` that we have now removed. In .NET 11. [`CommunityToolkit.Maui` will no longer have access to internal .NET MAUI APIs](dotnet/maui#34070). We have updated our .NET 11 Migration guidance to use `CommunityToolkit.Maui v15.0.1` or later to ensure compatibility with .NET 11. Specifically, > \[!IMPORTANT] > We recommend every .NET MAUI app preparing for .NET 11 install this release, v15.0.1 (or later), before .NET 11 is released in November. Apps running `CommunityToolkit.Maui` v14.2.2 and earlier will not be compatible with .NET 11. #### What's Changed - Align Windows App SDK version with .NET MAUI by [@​jfversluis](https://github.com/jfversluis) in [#​3282](CommunityToolkit/Maui#3282) - Remove all usage of .NET MAUI internal APIs by [@​jfversluis](https://github.com/jfversluis) in [#​3273](CommunityToolkit/Maui#3273) #### Housekeeping - \[housekeeping] Automated PR to fix formatting errors by [@​github-actions](https://github.com/github-actions)\[bot] in [#​3286](CommunityToolkit/Maui#3286) - Bump Microsoft.Testing.Extensions.CodeCoverage from 18.9.0 to 18.10.0 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​3285](CommunityToolkit/Maui#3285) - Bump actions/checkout from 7.0.0 to 7.0.1 by [@​dependabot](https://github.com/dependabot)\[bot] in [#​3275](https://github.com/Commun...
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
Removes all
InternalsVisibleToattributes that grant the .NET MAUI Community Toolkit access to internal APIs. This is the same change as #33442 (which was reverted in #34047 for .NET 10 SR4), now targeting net11.0 to give the toolkit team time to migrate.Previous attempts:
ITextElement,ICornerElement, etc.)Files Modified
src/Controls/src/Core/Properties/AssemblyInfo.cssrc/Controls/src/Xaml/Properties/AssemblyInfo.cssrc/Essentials/src/AssemblyInfo/AssemblyInfo.shared.cssrc/Core/src/Properties/AssemblyInfo.csTotal: 22
InternalsVisibleTodeclarations removed forCommunityToolkit.Maui,.Core,.Embedding,.UnitTests,.Markup,.Markup.UnitTests.Impact on CommunityToolkit.Maui 15.0.0 (verified — see verification comment below)
The toolkit has made great progress: everything the older tables in this PR used to describe (
AvatarView/FontElement/TextElement/ImageElement,GravatarImageSource/ImageSource.CancellationTokenSource,AppThemeResourceExtension/IResourcesProvider,StreamWrapper,RequireFontManager,InvalidateMeasureInternal, …) is already resolved in 15.0.0. Mac Catalyst builds completely clean.What remains is Android-only. Building pristine
CommunityToolkit.Maui15.0.0 sources against this PR's packages produces 5 errors:Microsoft.Maui.ApplicationModel.IntermediateActivity(internal type, Essentials)FileSaverImplementation.android.cs:40,FolderPickerImplementation.android.cs:37CS0122×2Microsoft.Maui.Platform.ElementExtensions.ToPlatform(this IElement)— the 1-arg internal overloadSnackbar.android.cs:43CS1929Microsoft.Maui.JavaObjectExtensions.IsDisposed(internal static class)Snackbar.android.cs:91CS1061Microsoft.Maui.JavaObjectExtensions.IsAlive(internal static class)TouchBehavior.android.cs:109CS1061Microsoft.Maui.Platform.ViewExtensions.GetParentOfType<T>(internal method)TouchBehavior.android.cs:44CS1061Plus one binary-only break that the compiler hides:
Microsoft.Maui.Controls.DispatcherExtensions.DispatchIfRequiredAsyncUserStoppedTypingBehavior.shared.cs:108,113DispatchIfRequiredAsync(IDispatcher, Action, CancellationToken = default). With IVT the 2-arg call sites bind to MAUI's internal one; without IVT a source rebuild silently rebinds to the toolkit's own. Prebuilt 15.0.0 assemblies therefore carry an IL memberref to MAUI's internal method and would throwMethodAccessException. A toolkit rebuild fixes it.Suggested resolution — items 2–5 are all trivially re-implementable inside the toolkit (a handful of lines each), and item 1 can be replaced with the toolkit's own activity-result plumbing over
Platform.CurrentActivity. None of these require MAUI to make anything public.Consumer note:
CommunityToolkit.Maui.Markupmust be ≥ 8.0.0CommunityToolkit.Maui.Markup7.0.1 contains 45 IL references to MAUI internals (FontElement,TextElement,ImageElement,PaddingElement,PlaceholderElement,SetterSpecificity,BindingExpression,TypedBindingBase..ctor,BindableObject.SetValueCore,BindingBase.Apply/Unapply/GetSourceValue, …) and hard-crashes without IVT. 8.0.0 already has zero — it's clean. Anyone still on 7.0.1 must upgrade.Issues Fixed
Context: #29444, #34048
cc @TheCodeTraveler