Repository: CommunityToolkit/Maui

Issue #501: [Bug] MCT001 doesn't recognize initialization in a library
Created: 2022-07-20T14:54:16Z
Description
Update to the latest CommunityToolkit.Maui Version="1.1.0" and my project now fails build due to error:

MCT001: .UseMauiCommunityToolkit() must be chained to .UseMauiApp<T>()

While I like the fact that the library is looking over my shoulder to ensure I'm calling this, it really should be written to understand the dependency chain when looking for the call to the initialization routine.  My software architecture is loosely coupled allowing libraries of functionality to be added individually to the main/exe project.  Anytime a individual library is added, a corresponding fluent init method is called (just as you're doing with the toolkit). So in my situation, one of my UI libraries takes advantage of the Toolkit, and thus its MauiApp Fluent Initialization method calls .UseMauiCommunityToolkit() directly. My main/exe project therefore calls the .UseMauiCommunityToolkit() method indirectly.  However, because your initialization test is transient, it is failing the top level project when in fact it should be stopping at the library level.
This also brings up the question - can the  .UseMauiCommunityToolkit() method be called multiple times (multiple decoupled libraries in a project use the toolkit) without undesired side effects such as service registrations, etc.
Steps to Reproduce

Create a MAUI app that references a MAUI Library.
Inside that library, add a reference to CommunityToolkit.Maui Version="1.1.0"
Call .UseMauiCommunityToolkit() from inside the Library
Build and see error

Expected Behavior
No build failure
Actual Behavior
build failure
Basic Information

Version with issue: 1.1.0
Last known good version: 1.0.0

Workaround
Add MCT001 to Suppress specific warnings in project Build>Errors and Warnings section
Demo project
I created this project with Microsoft Visual Studio Professional 2022 (64-bit) - Preview
Version 17.3.0 Preview 4.0
MauiAppInitBug.zip

Duplicate issue #867: [BUG] UseMauiCommunityToolkitMediaElement()` must be chained to `.UseMauiApp<T>()`
Created: 2023-01-04T08:46:29Z
Is there an existing issue for this?

 I have searched the existing issues

Current Behavior
Hi
I have done a MAUI library(nuget) that implements a videoPlayer(fullscreen Droid and other stuff that is specific for my customers) that use the MAUI MediaElement.
I do the registration of the
UseMauiCommunityToolkitMediaElement() inside the library so I don't want the be forced to add this to the consuming app of the lib.
//Regards Joacim
Expected Behavior
Not e forced to do this twice.
Steps To Reproduce
Create a MAUI lib
create a function in the lib that you use from the apps MauiProgram.cs
public static MauiAppBuilder UseFmShared(this MauiAppBuilder builder)
{
builder.UseMauiCommunityToolkitMediaElement();
return builder;
}
Link to public reproduction project repository
Not needed
Environment
- .NET MAUI CommunityToolkit:
- OS: MAC Ventura 13.1 
- .NET MAUI:
Visual Studio Professional 2022 for Mac Preview
Version 17.5 Preview (17.5 build 1095)

Xamarin.Mac
Version: 9.0.0.27 Visual Studio Professional
Hash: 933c6c2c9
Branch: xcode14.1
Build date: 2022-11-22 02:00:36-0500

Xamarin.iOS
Version: 16.1.1.27 Visual Studio Professional
Hash: 933c6c2c9
Branch: xcode14.1
Build date: 2022-11-22 02:00:37-0500

Xamarin Designer
Version: 17.5.2.64
Hash: 627f860876
Branch: remotes/origin/d17-5
Build date: 2022-12-13 00:19:58 UTC

Xamarin.Android
Version: 13.1.0.1 (Visual Studio Professional)
Commit: xamarin-android/d17-4/13ba222
Android SDK: /Users/joacimwall/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		12.0 (API level 31)
		8.1  (API level 27)
		11.0 (API level 30)
		10.0 (API level 29)
		9.0  (API level 28)
		13.0 (API level 33)
Anything else?
I can move this line UseMauiCommunityToolkitMediaElement() to the consuming app but it would be nice if I was not force to do this. The previous preview versions of MediaElement did not force me to do this.
//Thanks Joacim

Closing comment (2023-01-04T16:34:19Z): Duplicate #501