Skip to content

Revoking InternalsVisibleTo for the .NET MAUI Toolkits in Microsoft.Maui.Controls v10.0.40 Has Broken CommunityToolkit.Maui and CommunityToolkit.Maui.Markup #34048

@TheCodeTraveler

Description

@TheCodeTraveler

Description

Lead Maintainer for the .NET MAUI Community Toolkits here!

In Microsoft.Maui.Controls v10.0.40, InternalsVisibleTo was revoked for the .NET MAUI Community Toolkits in this PR: #33442

I agree with removing InternalsVisibleTo for the .NET MAUI Community Toolkits because it has caused many headaches and bugs for both us maintainers and developers using the CommunityToolkit.Maui.* libraries.

I was told this was going to be implemented in the .NET 10 release of Microsoft.Maui.Controls, v10.0.0, and that the .NET MAUI team would ensure that the internal APIs used by the .NET MAUI Community Toolkits would be promoted to public. I was unaware of the PR that made this change and I wish someone from the .NET MAUI team had reached out to me directly to help test it.

This has broken the following features in the .NET MAUI Community Toolkits:

  • CommunityToolkit.Maui.Markup
  • CommunityToolkit.Maui.Expander
  • CommunityToolkit.Maui.AvatarView
  • CommunityToolkit.Maui.AppThemeObject
  • CommunityToolkit.Maui.Snackbar
  • CommunityToolkit.Maui.GravatarImageSource
  • CommunityToolkit.Maui.AppThemeResourceExtension
  • CommunityToolkit.Maui.ImageTouchBehavior
  • CommunityToolkit.Maui.TouchBehavior
  • CommunityToolkit.Maui.StateContainer

Below are the public APIs the .NET MAUI Community Toolkits use that should be promoted to public:

Classes

  • class StreamWrapper
  • class FontElement
  • class TextElement
  • class ImageElement
  • class AppThemeBinding
  • sealed class BindingExpression
  • sealed class WeakPropertyChangedProxy
  • static class DispatcherExtensions
  • internal readonly struct SetterSpecificity

Interfaces

  • interface IResourcesProvider

Constructors

  • internal XamlParseException(string, IServiceProvider serviceProvider, Exception)
  • internal TypedBindingBase()

Methods

  • VisualElement.InvaldateMeasureInternal(InvalidationTrigger);

Properties

  • private protected CancellationTokenSource CancellationTokenSource { get; private set; }

Extension Methods

  • internal static double GetDefaultFontSize(this Element);
  • internal static void BindableLayout.Remove(this IBindableLayout, object);
  • internal static void BindableLayout.Add(this IBindableLayout, object);
  • internal static IFontManager RequireFontManager(this Element, bool);
  • internal static T? GetTargetOrDefault<T>(this WeakReference<T>)

My ask is that these APIs be promoted to public. I'm also happy to chat about work-arounds for these APIs if the team finds that they cannot (or should not) be promoted to public.

In the future, please work with me directly when there may be impacts to the .NET MAUI Community Toolkits.

Steps to Reproduce

  1. Download/clone the reproduction sample: https://github.com/TheCodeTraveler/Community-Toolkit-Reproduction-for-Microsoft.Maui.Controls-v10.0.40-/tree/main
  2. Build/run the reproduction sample on an Android emulator or device
  3. In the reproduction sample, navigate to Layouts -> Expander Page
  4. Confirm sample crashes
  5. In the reproduction sample, navigate to Views -> AvatarView Bindable Properties Page
  6. Confirm sample crashes
  7. In the reproduction sample, navigate to Extensions -> AvatarView Keyboard Page
  8. Confirm sample crashes
  9. In the reproduction sample, navigate to Essentials -> AppTheme Page
  10. Confirm sample crashes
  11. In the reproduction sample, navigate to Alerts -> Snackbar Page
  12. Confirm sample crashes
  13. In the reproduction sample, navigate to ImageSources -> GravatarImageSource Page
  14. Confirm sample crashes
  15. In the reproduction sample, navigate to ImageSources -> GravatarImageSource Page
  16. Confirm sample crashes
  17. In the reproduction sample, navigate to Behaviors -> Touch Behavior Page
  18. Confirm sample crashes
  19. In the reproduction sample, navigate to Layouts -> State Container Page
  20. Confirm sample crashes

Link to public reproduction project repository

https://github.com/TheCodeTraveler/Community-Toolkit-Reproduction-for-Microsoft.Maui.Controls-v10.0.40-/

Version with bug

10.0.40

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

10.0.30

Affected platforms

Android, iOS, Windows, macOS

Affected platform versions

All

Did you find any workaround?

Downgrading to Microsoft.Maui.Controls v10.0.31 allows developers to continue using CommunityToolkit.Maui

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    t/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions