From 1cc548a031004031e8c285ad85f11875e94f671e Mon Sep 17 00:00:00 2001 From: Shannon Date: Fri, 8 May 2020 17:47:21 +1000 Subject: [PATCH] Adds notes --- .../CompositionExtensions_Essentials.cs | 4 ++++ .../Extensions/UmbracoCoreServiceCollectionExtensions.cs | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Infrastructure/CompositionExtensions_Essentials.cs b/src/Umbraco.Infrastructure/CompositionExtensions_Essentials.cs index 02e5a6f5ee..88ae80bf8b 100644 --- a/src/Umbraco.Infrastructure/CompositionExtensions_Essentials.cs +++ b/src/Umbraco.Infrastructure/CompositionExtensions_Essentials.cs @@ -20,6 +20,10 @@ namespace Umbraco.Core /// These services are all either created by the runtime or used to construct the runtime /// public static void RegisterEssentials(this Composition composition, + // TODO: Configs should be here too, the reason is that we only register them before the Core Runtime in aspnetcore + // then we pre-resolve them which means that the instance re-resolved later is different... BUT if we register that + // pre-resolved instance here again, then it will be the same instance re-resolved later, just like we are doing with + // IDbProviderFactoryCreator. ILogger logger, IProfiler profiler, IProfilingLogger profilingLogger, IMainDom mainDom, AppCaches appCaches, diff --git a/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs b/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs index 03b54f350b..256bc1a78c 100644 --- a/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs @@ -183,11 +183,17 @@ namespace Umbraco.Extensions x.GetServices() )); + // TODO: We want to avoid pre-resolving a container as much as possible we should not + // be doing this any more than we are now. The ugly part about this is that the service + // instances resolved here won't be the same instances resolved from the container + // later once the true container is built. However! ... in the case of IDbProviderFactoryCreator + // it will be the same instance resolved later because we are re-registering this instance back + // into the container. This is not true for `Configs` but we should do that too, see comments in + // `RegisterEssentials`. var serviceProvider = services.BuildServiceProvider(); var configs = serviceProvider.GetService(); var dbProviderFactoryCreator = serviceProvider.GetRequiredService(); - CreateCompositionRoot(services, configs, webHostEnvironment,