Skip to content

Remove InternalsVisibleTo attributes for .NET MAUI Community Toolkit - #34070

Merged
kubaflo merged 1 commit into
net11.0from
remove-toolkit-ivt-net11
Jul 30, 2026
Merged

kubaflo merged 1 commit into
net11.0from
remove-toolkit-ivt-net11

Conversation

@jfversluis

@jfversluis jfversluis commented Feb 16, 2026

Copy link
Copy Markdown
Member

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 InternalsVisibleTo attributes 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:

Files Modified

File Entries Removed
src/Controls/src/Core/Properties/AssemblyInfo.cs 6
src/Controls/src/Xaml/Properties/AssemblyInfo.cs 6
src/Essentials/src/AssemblyInfo/AssemblyInfo.shared.cs 5
src/Core/src/Properties/AssemblyInfo.cs 5

Total: 22 InternalsVisibleTo declarations removed for CommunityToolkit.Maui, .Core, .Embedding, .UnitTests, .Markup, .Markup.UnitTests.

CommunityToolkit.Maui.Embedding has never been published to NuGet, so that grant was already dead.

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.Maui 15.0.0 sources against this PR's packages produces 5 errors:

# MAUI internal API Toolkit call site Error
1 Microsoft.Maui.ApplicationModel.IntermediateActivity (internal type, Essentials) FileSaverImplementation.android.cs:40, FolderPickerImplementation.android.cs:37 CS0122 ×2
2 Microsoft.Maui.Platform.ElementExtensions.ToPlatform(this IElement) — the 1-arg internal overload Snackbar.android.cs:43 CS1929
3 Microsoft.Maui.JavaObjectExtensions.IsDisposed (internal static class) Snackbar.android.cs:91 CS1061
4 Microsoft.Maui.JavaObjectExtensions.IsAlive (internal static class) TouchBehavior.android.cs:109 CS1061
5 Microsoft.Maui.Platform.ViewExtensions.GetParentOfType<T> (internal method) TouchBehavior.android.cs:44 CS1061

Plus one binary-only break that the compiler hides:

# MAUI internal API Toolkit call site Notes
6 Microsoft.Maui.Controls.DispatcherExtensions.DispatchIfRequiredAsync UserStoppedTypingBehavior.shared.cs:108,113 The toolkit has its own 3-arg DispatchIfRequiredAsync(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 throw MethodAccessException. 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.Markup must be ≥ 8.0.0

CommunityToolkit.Maui.Markup 7.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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 InternalsVisibleTo declarations across 4 AssemblyInfo files for CommunityToolkit assemblies
  • Removed duplicate Controls.TestCases.HostApp entry 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

Comment thread src/Controls/src/Core/Properties/AssemblyInfo.cs
@jfversluis

Copy link
Copy Markdown
Member Author

Moving this to draft, the Toolkit team can get the resulting artifacts from this for testing to make sure that all APIs are replaced.

@kubaflo

kubaflo commented May 24, 2026

Copy link
Copy Markdown
Contributor

/review -b feature/refactor-copilot-yml

@MauiBot

MauiBot commented May 24, 2026

Copy link
Copy Markdown
Collaborator

⚠️ Merge Conflict Detected — This PR has merge conflicts with its target branch. Please rebase onto the target branch and resolve the conflicts.

@kubaflo

kubaflo commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

AI code review for net11.0 target

Verdict: 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 does

Removes the [assembly: InternalsVisibleTo("CommunityToolkit.Maui*")] entries from Core, Controls.Core, Controls.Xaml, and Essentials AssemblyInfo files — i.e., the .NET MAUI Community Toolkit will no longer be able to reach MAUI internal members.

Findings

  • This is a deliberate API-coupling cleanup, but it is a breaking change for CommunityToolkit.Maui. It only works if CTK no longer depends on any of these internals. That coordination must land on the CTK side first (or simultaneously); otherwise CTK builds break against net11 MAUI. The PR description should link the corresponding CTK change/issue and the migration plan (which internals CTK used and their public replacements).
  • The change is purely subtractive and low-risk in this repo — no product code is touched, only friend-assembly grants. Mechanically correct (each block removed cleanly; unrelated InternalsVisibleTo entries preserved). The duplicate InternalsVisibleTo("Controls.TestCases.HostApp") removed from Controls.Core is a no-op since the canonical entry remains above. ✔️
  • Confirm no MAUI test/sample assembly transitively relied on these grants via CTK references.

CI

maui-pr and Build Analysis are red, including Build macOS (Release), Run Integration Tests Build (macOS/windows), RunOnAndroid, and a Helix unit-test leg. These failures are consistent with downstream consumers (samples/tests that reference CommunityToolkit.Maui) failing to compile once the internals are withdrawn — i.e., likely PR-caused and exactly what this change is meant to surface. Needs investigation before this can leave draft.

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.

@kubaflo

kubaflo commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

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 CommunityToolkit.Maui* friend-assembly grants from the Core, Controls.Core, Controls.Xaml, and Essentials AssemblyInfo files — no product code is touched (verified: zero CommunityToolkit InternalsVisibleTo entries remain, and the duplicate Controls.TestCases.HostApp removal is a no-op since the canonical entry survives). Because there is no anchorable code defect, there are no inline findings; the only open question is one of coordination/timing for an intentional breaking change to the Toolkit. For the author (while this stays a draft): can you confirm the CTK-side migration off these internals has landed or will land in lockstep — ideally linking the corresponding toolkit change/issue and migration plan — and confirm the red CI is exactly this expected downstream fallout rather than an unrelated break?

CI: maui-pr and Build Analysis are red. The failing legs — Build macOS (Release), Run Integration Tests Build (macOS/windows), RunOnAndroid (macOS), and Helix Unit Tests Windows (Release) — are consistent with MAUI's own templates/tests/samples (which reference CommunityToolkit.Maui, still dependent on these internals) failing to compile once the grants are withdrawn; the remaining legs (Windows builds, Blazor, Samples, iOS runs, MultiProject, Unit Tests) pass. This needs confirmation before the PR leaves draft.

Multi-model review (gpt-5.5 · opus-4.8 · opus-4.6 · gemini-3.1-pro). Comments only — not a formal approval.

@jfversluis
jfversluis force-pushed the remove-toolkit-ivt-net11 branch from a353da8 to f9d8af6 Compare June 24, 2026 08:17
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 34070

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 34070"

@jfversluis
jfversluis force-pushed the remove-toolkit-ivt-net11 branch from f9d8af6 to 5c02c9d Compare June 30, 2026 07:38
@jfversluis
jfversluis force-pushed the remove-toolkit-ivt-net11 branch from 04c29d1 to 00b0bb5 Compare July 16, 2026 21:10
evgenygunko pushed a commit to evgenygunko/CopyWordsDA that referenced this pull request Jul 25, 2026
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` | ![age](https://developer.mend.io/api/mc/badges/age/nuget/CommunityToolkit.Maui/15.0.0?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/CommunityToolkit.Maui/14.2.2/15.0.0?slim=true) |

---

### 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 [@&#8203;jfversluis](https://github.com/jfversluis) in [#&#8203;3251](CommunityToolkit/Maui#3251)
- Hardcode NuGet trusted publishing user by [@&#8203;jfversluis](https://github.com/jfversluis) in [#&#8203;3266](CommunityToolkit/Maui#3266)

#### Housekeeping

- Bump actions/setup-dotnet from 5.4.0 to 6.0.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;3268](CommunityToolkit/Maui#3268)
- Bump actions/setup-java from 5.5.0 to 5.6.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;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).
evgenygunko pushed a commit to evgenygunko/CopyWordsDA that referenced this pull request Aug 22, 2026
> ℹ️ **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` | ![age](https://developer.mend.io/api/mc/badges/age/nuget/CommunityToolkit.Maui/15.0.1?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/CommunityToolkit.Maui/15.0.0/15.0.1?slim=true) |

---

### 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 [@&#8203;jfversluis](https://github.com/jfversluis) in [#&#8203;3282](CommunityToolkit/Maui#3282)
- Remove all usage of .NET MAUI internal APIs by [@&#8203;jfversluis](https://github.com/jfversluis) in [#&#8203;3273](CommunityToolkit/Maui#3273)

#### Housekeeping

- \[housekeeping] Automated PR to fix formatting errors by [@&#8203;github-actions](https://github.com/github-actions)\[bot] in [#&#8203;3286](CommunityToolkit/Maui#3286)
- Bump Microsoft.Testing.Extensions.CodeCoverage from 18.9.0 to 18.10.0 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;3285](CommunityToolkit/Maui#3285)
- Bump actions/checkout from 7.0.0 to 7.0.1 by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;3275](https://github.com/Commun...
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants