diff --git a/src/Umbraco.Web.BackOffice/Extensions/BackOfficeServiceCollectionExtensions.cs b/src/Umbraco.Web.BackOffice/Extensions/BackOfficeServiceCollectionExtensions.cs index d30db016e7..c340b87ea6 100644 --- a/src/Umbraco.Web.BackOffice/Extensions/BackOfficeServiceCollectionExtensions.cs +++ b/src/Umbraco.Web.BackOffice/Extensions/BackOfficeServiceCollectionExtensions.cs @@ -52,6 +52,9 @@ namespace Umbraco.Extensions services.TryAddScoped(); + // TODO: MSDI - This needs some work, e.g. additional registrations / not registering as UserManager + // if we want container validation back on. + services.BuildUmbracoBackOfficeIdentity() .AddDefaultTokenProviders() .AddUserStore() diff --git a/src/Umbraco.Web.BackOffice/Extensions/CompositionExtensions.cs b/src/Umbraco.Web.BackOffice/Extensions/CompositionExtensions.cs index 198f98e3c0..2a8a2e900d 100644 --- a/src/Umbraco.Web.BackOffice/Extensions/CompositionExtensions.cs +++ b/src/Umbraco.Web.BackOffice/Extensions/CompositionExtensions.cs @@ -1,7 +1,4 @@ using Umbraco.Core.Composing; -using Umbraco.Web.BackOffice.Controllers; -using Umbraco.Web.Common.Controllers; -using Umbraco.Web.Common.Install; using Umbraco.Web.BackOffice.Trees; // the namespace here is intentional - although defined in Umbraco.Web assembly, @@ -27,26 +24,5 @@ namespace Umbraco.Extensions => composition.WithCollectionBuilder(); #endregion - - - /// - /// Registers Umbraco backoffice controllers. - /// - public static Composition ComposeUmbracoBackOfficeControllers(this Composition composition) - { - composition.RegisterControllers(new [] - { - typeof(BackOfficeController), - typeof(PreviewController), - typeof(AuthenticationController), - typeof(InstallController), - typeof(InstallApiController), - }); - - var umbracoAuthorizedApiControllers = composition.TypeLoader.GetTypes(); - composition.RegisterControllers(umbracoAuthorizedApiControllers); - - return composition; - } } } diff --git a/src/Umbraco.Web.BackOffice/Runtime/BackOfficeComposer.cs b/src/Umbraco.Web.BackOffice/Runtime/BackOfficeComposer.cs index 78b7317362..59a1182cb5 100644 --- a/src/Umbraco.Web.BackOffice/Runtime/BackOfficeComposer.cs +++ b/src/Umbraco.Web.BackOffice/Runtime/BackOfficeComposer.cs @@ -51,8 +51,6 @@ namespace Umbraco.Web.BackOffice.Runtime composition.Services.AddUnique(); composition.Services.AddUnique(); - - composition.ComposeUmbracoBackOfficeControllers(); } } } diff --git a/src/Umbraco.Web.Common/Extensions/CompositionExtensions.cs b/src/Umbraco.Web.Common/Extensions/CompositionExtensions.cs deleted file mode 100644 index ae648f9c8a..0000000000 --- a/src/Umbraco.Web.Common/Extensions/CompositionExtensions.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.DependencyInjection; -using Umbraco.Core.Composing; -using Umbraco.Web.Common.Controllers; -using Umbraco.Web.Mvc; - -namespace Umbraco.Extensions -{ - public static class CompositionExtensions - { - public static void RegisterControllers(this Composition composition, IEnumerable controllerTypes) - { - foreach (var controllerType in controllerTypes) - composition.Services.AddScoped(controllerType); - } - } -} diff --git a/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs b/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs index 2ba38b6e02..9fac304d6b 100644 --- a/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs +++ b/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs @@ -80,6 +80,7 @@ namespace Umbraco.Web.Common.Runtime //register the install components //NOTE: i tried to not have these registered if we weren't installing or upgrading but post install when the site restarts //it still needs to use the install controller so we can't do that + // TODO: MSDI we can fix that composition.ComposeInstaller(); var umbracoApiControllerTypes = composition.TypeLoader.GetUmbracoApiControllers().ToList(); diff --git a/src/Umbraco.Web.UI.NetCore/Program.cs b/src/Umbraco.Web.UI.NetCore/Program.cs index 4f87e74075..4fe23356f0 100644 --- a/src/Umbraco.Web.UI.NetCore/Program.cs +++ b/src/Umbraco.Web.UI.NetCore/Program.cs @@ -21,9 +21,8 @@ namespace Umbraco.Web.UI.NetCore x.ClearProviders(); }) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup(); }) - // TODO: MSDI - this should probably be on one day, more so when we can reduce the number - // of times we build a ServiceProvider from services collection - // right now it's just painful. + // TODO: MSDI - this should probably be on one day + // First we need to resolve the composition conditional registration issues see #8563 .UseDefaultServiceProvider(options => options.ValidateOnBuild = false) .UseUmbraco(); } diff --git a/src/Umbraco.Web.Website/Extensions/CompositionExtensions.cs b/src/Umbraco.Web.Website/Extensions/CompositionExtensions.cs deleted file mode 100644 index 19917a8d1c..0000000000 --- a/src/Umbraco.Web.Website/Extensions/CompositionExtensions.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Linq; -using Umbraco.Core.Composing; -using Umbraco.Web.Common.Controllers; -using Umbraco.Web.Mvc; -using Umbraco.Web.Website.Controllers; - -namespace Umbraco.Extensions -{ - public static class CompositionExtensions - { - /// - /// Registers Umbraco website controllers. - /// - public static Composition ComposeWebsiteUmbracoControllers(this Composition composition) - { - composition.RegisterControllers(new [] - { - // typeof(UmbProfileController), //TODO introduce when migrated - // typeof(UmbLoginStatusController),//TODO introduce when migrated - // typeof(UmbRegisterController),//TODO introduce when migrated - // typeof(UmbLoginController),//TODO introduce when migrated - typeof(RenderMvcController), - typeof(RenderNoContentController), - - }); - - var umbracoWebAssembly = typeof(SurfaceController).Assembly; - - // scan and register every PluginController in everything (PluginController is IDiscoverable and IController) - var nonUmbracoWebPluginController = composition.TypeLoader.GetTypes().Where(x => x.Assembly != umbracoWebAssembly); - composition.RegisterControllers(nonUmbracoWebPluginController); - - // can and register every IRenderMvcController in everything (IRenderMvcController is IDiscoverable) - var renderMvcControllers = composition.TypeLoader.GetTypes().Where(x => x.Assembly != umbracoWebAssembly); - composition.RegisterControllers(renderMvcControllers); - - return composition; - } - } -} diff --git a/src/Umbraco.Web.Website/Extensions/UmbracoWebstiteServiceCollectionExtensions.cs b/src/Umbraco.Web.Website/Extensions/UmbracoWebstiteServiceCollectionExtensions.cs index b47679a1bf..5e9a9db642 100644 --- a/src/Umbraco.Web.Website/Extensions/UmbracoWebstiteServiceCollectionExtensions.cs +++ b/src/Umbraco.Web.Website/Extensions/UmbracoWebstiteServiceCollectionExtensions.cs @@ -1,8 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Controllers; -using Microsoft.AspNetCore.Mvc.ViewEngines; +using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Umbraco.Web.Website.ViewEngines; @@ -13,8 +9,6 @@ namespace Umbraco.Extensions { public static void AddUmbracoWebsite(this IServiceCollection services) { - services.AddSingleton(); - // Set the render & plugin view engines (Super complicated, but this allows us to use the IServiceCollection // to inject dependencies into the viewEngines) services.AddTransient, RenderMvcViewOptionsSetup>(); @@ -24,8 +18,6 @@ namespace Umbraco.Extensions // Wraps all existing view engines in a ProfilerViewEngine services.AddTransient, ProfilingViewEngineWrapperMvcViewOptionsSetup>(); - } - } } diff --git a/src/Umbraco.Web.Website/Runtime/WebsiteComposer.cs b/src/Umbraco.Web.Website/Runtime/WebsiteComposer.cs index 11204483bd..b3f336871e 100644 --- a/src/Umbraco.Web.Website/Runtime/WebsiteComposer.cs +++ b/src/Umbraco.Web.Website/Runtime/WebsiteComposer.cs @@ -14,11 +14,6 @@ namespace Umbraco.Web.Website.Runtime public void Compose(Composition composition) { composition.Services.AddUnique(); - - composition - .ComposeWebsiteUmbracoControllers() - //.SetDefaultRenderMvcController()// default controller for template views - ; } } }