Skip to content

Comments

Remove InternalsVisibleTo attributes for .NET MAUI Community Toolkit#34070

Draft
jfversluis wants to merge 1 commit intonet11.0from
remove-toolkit-ivt-net11
Draft

Remove InternalsVisibleTo attributes for .NET MAUI Community Toolkit#34070
jfversluis wants to merge 1 commit intonet11.0from
remove-toolkit-ivt-net11

Conversation

@jfversluis
Copy link
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 + 1 duplicate Controls.TestCases.HostApp
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.

Internal APIs Still Used by the Toolkit

Can be fixed on the toolkit side (public alternatives exist):

API Toolkit Usage Public Alternative
InvalidateMeasureInternal(InvalidationTrigger) AvatarView Use public InvalidateMeasure()
XamlParseException(string, IServiceProvider) AppThemeResourceExtension Use public ctor with IXmlLineInfo
GetDefaultFontSize() AvatarView Resolve IFontManager.DefaultFontSize from services
RequireFontManager() Snackbar, UIFontExtensions Resolve IFontManager from MauiContext.Services
AppThemeBinding AppThemeObject Already public on net11.0
GetTargetOrDefault() Snackbar Toolkit already has its own copy

Requires MAUI to provide public alternatives:

API Toolkit Usage Suggested Action
FontElement (static class) AvatarView — 4 BindableProperty defs Make public
TextElement (static class) AvatarView — 3 BindableProperty defs Make public
ImageElement (static class) AvatarView, TouchBehavior, ImageTouchBehavior Make public
IResourcesProvider (interface) AppThemeResourceExtension Make public
ImageSource.CancellationTokenSource GravatarImageSource Change to protected
StreamWrapper HttpClientExtensions Make public or provide alternative

Issues Fixed

Context: #29444, #34048

cc @TheCodeTraveler

Remove all InternalsVisibleTo attributes that grant the .NET MAUI Community
Toolkit access to internal APIs across 4 assembly files:

- src/Controls/src/Core/Properties/AssemblyInfo.cs (6 entries)
- src/Controls/src/Xaml/Properties/AssemblyInfo.cs (6 entries)
- src/Essentials/src/AssemblyInfo/AssemblyInfo.shared.cs (5 entries)
- src/Core/src/Properties/AssemblyInfo.cs (5 entries)

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

Also removed a pre-existing duplicate Controls.TestCases.HostApp entry.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

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

[assembly: InternalsVisibleTo("CommunityToolkit.Maui.Markup.UnitTests")]
[assembly: InternalsVisibleTo("Controls.TestCases.HostApp")]

[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to issue #29444, the file src/Controls/src/Core/ILineHeightElementInternal.cs should be deleted as part of removing InternalsVisibleTo attributes. This file was only kept to provide a transition path for the toolkit and is now obsolete. The interface has been replaced by Microsoft.Maui.Controls.ILineHeightElement and is no longer used within the MAUI codebase.

Copilot uses AI. Check for mistakes.
@jfversluis
Copy link
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant