Skip to content
This repository was archived by the owner on Nov 2, 2018. It is now read-only.

Conversation

@davidfowl
Copy link
Member

  • Make ServiceProvider public so that it can be returned
    from BuildServiceProvider().
  • Make it sealed since it can't really be extended.
  • Changed tests to stop down casting.

#338

- Make ServiceProvider public so that it can be returned from BuildServiceProvider(). - Make it sealed since it can't really be extended. - Changed tests to stop down casting.
/// The default IServiceProvider.
/// </summary>
internal class ServiceProvider : IServiceProvider, IDisposable
public sealed class ServiceProvider : IServiceProvider, IDisposable
Copy link
Member Author

Choose a reason for hiding this comment

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

I know it's evil but @benaadams will be happy

Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't any virtual calls; might as well make it non-sealed? (Then people can extend/enhance in a non-interfering way)

Copy link
Member Author

Choose a reason for hiding this comment

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

The other reason I made it sealed is to avoid things like #476

Copy link
Contributor

Choose a reason for hiding this comment

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

And people can always wrap.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can't add extra data to the type and then use an as cast to surface it with a wrap...

"OldMemberId": "public static System.IServiceProvider BuildServiceProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection services)",
"NewTypeId": "public static class Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions",
"NewMemberId": "public static Microsoft.Extensions.DependencyInjection.ServiceProvider BuildServiceProvider(this Microsoft.Extensions.DependencyInjection.IServiceCollection services)",
"Kind": "Modification"
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI API Check doesn't actually care much about additions to regular classes and it has a bug when handling Modification exceptions in interfaces (aspnet/BuildTools#154). Might as well make this a Removal and leave out the New* properties.

Copy link
Member Author

Choose a reason for hiding this comment

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

When the tool spits out what it wants me to write I'll do that. It took me way too long to figure this out.

@davidfowl davidfowl merged commit 45bbdb5 into dev Mar 28, 2017
@khellang
Copy link
Contributor

👍

@halter73
Copy link
Member

@davidfowl Will hosting continue to call (_applicationServices as IDisposable)?.Dispose();, or will it only dispose ServiceProviders?

@davidfowl
Copy link
Member Author

davidfowl commented Mar 28, 2017

It needs to keep doing that to support other service providers.

@davidfowl davidfowl deleted the davidfowl/make-service-provider-public branch August 22, 2018 07:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

8 participants