You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to get a compile time error when one fails to perform the above call?
An alternative to detecting a misconfigured Startup only at runtime would be to create a unit test recreating the service collection and manually checking if all expected services are present. However this is still vulnerable to forgetting to update the unit test. It also adds the pain of creating a viable environment (appsettings, etc.) for unit tests, which isn't needed when using mocks. eg:
var s = new WebHostBuilder().UseStartup<Startup>().Build();
s.Services.GetRequiredService(...)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
Within the context of a webapi, there may be a number of injectable dependencies added to various scopes using calls such as
Is it possible to get a compile time error when one fails to perform the above call?
An alternative to detecting a misconfigured Startup only at runtime would be to create a unit test recreating the service collection and manually checking if all expected services are present. However this is still vulnerable to forgetting to update the unit test. It also adds the pain of creating a viable environment (appsettings, etc.) for unit tests, which isn't needed when using mocks. eg:
Beta Was this translation helpful? Give feedback.
All reactions