simpleinjector / Documentation

Documentation for Simple Injector in reStructureText
20 stars 55 forks source link

Add example for the new ASP.NET Core 6.0 "startup-less" configuration to ASP.NET Core MVC Integration NuGet package integration docs #132

Open greyseal96 opened 1 year ago

greyseal96 commented 1 year ago

I am just starting to work with a new project that is using ASP.NET Core 6.0 and I noticed that the startup class is now not the "standard" way of setting up the application. I went to the Simple Injector documentation to try to find how to integrate Simple Injector with the application and I had trouble figuring out:

After searching online for a while I eventually found this issue comment on the Simple Injector repo which lists an example of how to do the Simple Injector integration in the "startup-less" way. It would be really helpful to have an example of this way on the ASP.NET Core MVC Integration page as well. I found this commit in the Documentation repo where it looks like a change was made to update the documentation to be compatible with .NET 6 but it was just a small addition to the existing example which shows how to do the bootstrapping in a Startup class. It would be really helpful to have a separate example that shows how to do the integration in the "new way". I would be happy to submit a PR with the change, if that helps. I'll just take the example that Steven posted and add it as an example.

One other request... This is sort of related to this issue, as I mentioned above, but it might be its own separate issue. If it is, let me know and I'll open another issue. I know that ASP.NET and ASP.NET Core have changed their names of things a lot which has made things difficult to keep track of in the documentation. But I had some trouble figuring out which integration package to use. With the dotnet SDK, there are several templates which can be used. It's really hard to know which one of those templates maps to which Simple Injector integration package. For example, in this particular instance, I used the "webapi" template (ASP.NET Core Web API). In the documentation there is a page in the Integration Guide for ASP.NET Web API but it looks like it pertains to the "old" ASP.NET. It would be really helpful if there were some additional guidance or verbiage to help indicate which integration package to use. For example, I just took my best guess that the page for ASP.NET Core and ASP.NET Core MVC was the page I should use but it's really hard to know for sure based on the page names and the integration package names. For example, it's not super clear that the SimpleInjector.Integration.AspNetCore.Mvc.Core package is the correct package to use for integrating with something started from the "webapi" template, especially when there's a separate template in the dotnet SDK named "mvc". Adding to my confusion was that the page in the documentation guide is named something like "ASP.NET Core and ASP.NET Core MVC". There is no mention in the page that this includes ASP.NET Core Web API as well. I realize that a lot of this is due to Microsoft's changing product naming but perhaps there's something that the documentation can do to help out in this regard?

greyseal96 commented 1 year ago

I just remembered that on the ASP.NET Core and ASP.NET Core MVC page the Available integration packages table has a mention of Web API in the description of the SimpleInjector.Integration .AspNetCore.Mvc.Core package. That was helpful for me in deciding that this was the integration package that I wanted but it would be really helpful to have some sort of mention up towards the top that if you're using , , or ASP.NET Core technology (MVC, Web API, etc.) this is the documentation page you should be reading.

greyseal96 commented 1 year ago

I also came across this StackOverflow answer from Steven which indicates that the reason why the SimpleInjector.Integration.AspNetCore.MVC.Core and SimpleInjector.Integration.AspNetCore.MVC packages are named what they are. That would be super helpful to add somewhere towards the top of the ASP.NET Core and ASP.NET Core MVC page so that users know that they have landed in the right place.

dotnetjunkie commented 1 year ago

Thank you for your detailed feedback. That's very much appreciated. I made some updates to the ASP.NET Core integration guide that, hopefully, reflect your feedback. Please take a look and if you find any shortcomings, please let me know.