Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

TestHost.Create() has incompatible overloads #497

Closed
joaroyen opened this issue Nov 22, 2015 · 2 comments
Closed

TestHost.Create() has incompatible overloads #497

joaroyen opened this issue Nov 22, 2015 · 2 comments

Comments

@joaroyen
Copy link

rc1 added a set of "Func<IServiceCollection, IServiceProvider> configureServices" overloads to TestHost.Create() that is not compatible with the existing "Action configureServices" overloads:

public static TestServer Create(Action<IApplicationBuilder> configureApp, Action<IServiceCollection> configureServices)
public static TestServer Create(Action<IApplicationBuilder> configureApp, Func<IServiceCollection, IServiceProvider> configureServices)

After upgrading to rc1 I get this error from the compiler:
Error CS0407 'void Startup.ConfigureServices(IServiceCollection)' has the wrong return type MediaStreams.Test.

I've currently implemented a workaround by changing signature from void to System.IServiceProvider and returning services.BuildServiceProvider() at the end of the method.

@muratg
Copy link

muratg commented Nov 23, 2015

Ugh. Perhaps we should rename the second overload?

@davidfowl

@Radek44
Copy link

Radek44 commented Dec 3, 2015

Quick workaround for now is to cast explicitely:

var startup = new Startup(hostingEnvironment, applicationEnvironment);
var server = TestServer.Create(startup.Configure, (Action<IServiceCollection>)startup.ConfigureServices);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants