Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use unified container between Uno & Maui #1933

Merged
merged 2 commits into from
Oct 5, 2023
Merged

Conversation

dansiegel
Copy link
Contributor

GitHub Issue (If applicable): #

PR Type

What kind of change does this PR introduce?

  • Feature

What is the current behavior?

Uno's Host Builder and the MauiAppBuilder provide 2 separate instances of the IServiceProvider each with their own registered services. This means that services registered in one cannot be properly resolved by the other.

What is the new behavior?

Both builders have an IServiceProviderFactory. When using the IHostBuilder the initialization of the MauiAppBuilder is deferred so that all Services can be registered with both the HostBuilder's IServiceCollection and the MauiAppBuilder.Services. The two are combined and an IServiceProvider is created. This IServiceProvider is then shared with .NET MAUI so that both Uno and .NET MAUI can make use of the same container with all of the same services available to each.

NOTE In testing the only "Duplicated" Service out of the box is IConfiguration. To prevent this from being an issue when we combine the two IServiceCollection's we use TryAdd. This prevents the addition of a ServiceDescriptor from the .NET MAUI side with a ServiceType that has already been provided on the Uno side.

@dansiegel dansiegel merged commit e71cf47 into main Oct 5, 2023
12 of 13 checks passed
@dansiegel dansiegel deleted the dev/ds/unify-container branch October 5, 2023 13:18
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.

None yet

2 participants