diff --git a/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs index 0deac29761..54e5982a58 100644 --- a/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs +++ b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs @@ -114,7 +114,6 @@ namespace Umbraco.Core.DependencyInjection // Adds no-op registrations as many core services require these dependencies but these // dependencies cannot be fulfilled in the Core project Services.AddUnique(); - //Services.AddUnique(); Services.AddUnique(); Services.AddUnique(); diff --git a/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs b/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs index cef471b2d4..63b3b13e13 100644 --- a/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs +++ b/src/Umbraco.Tests/Scoping/ScopedNuCacheTests.cs @@ -105,8 +105,6 @@ namespace Umbraco.Tests.Scoping hostingEnvironment, Microsoft.Extensions.Options.Options.Create(nuCacheSettings)); - //lifetime.Raise(e => e.ApplicationInit += null, EventArgs.Empty); - return snapshotService; } diff --git a/src/Umbraco.Web.Common/Profiler/InitializeWebProfiling.cs b/src/Umbraco.Web.Common/Profiler/InitializeWebProfiling.cs index ff4b2293ed..fede88e14f 100644 --- a/src/Umbraco.Web.Common/Profiler/InitializeWebProfiling.cs +++ b/src/Umbraco.Web.Common/Profiler/InitializeWebProfiling.cs @@ -1,8 +1,8 @@ -using System; -using System.Collections.Generic; +// Copyright (c) Umbraco. +// See LICENSE for more details. + using System.Threading; using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using Umbraco.Core.Events; using Umbraco.Core.Logging; @@ -10,26 +10,38 @@ using Umbraco.Web.Common.Lifetime; namespace Umbraco.Web.Common.Profiler { + /// + /// Initialized the web profiling. Ensures the boot process profiling is stopped. + /// public class InitializeWebProfiling : INotificationHandler { private readonly bool _profile; private readonly WebProfiler _profiler; private readonly IUmbracoRequestLifetime _umbracoRequestLifetime; - private readonly List _terminate = new List(); + + /// + /// Initializes a new instance of the class. + /// public InitializeWebProfiling(IProfiler profiler, IUmbracoRequestLifetime umbracoRequestLifetime, ILogger logger) { _umbracoRequestLifetime = umbracoRequestLifetime; _profile = true; - // although registered in WebRuntime.Compose, ensure that we have not + // although registered in UmbracoBuilderExtensions.AddUmbraco, ensure that we have not // been replaced by another component, and we are still "the" profiler _profiler = profiler as WebProfiler; - if (_profiler != null) return; + if (_profiler != null) + { + return; + } // if VoidProfiler was registered, let it be known if (profiler is NoopProfiler) + { logger.LogInformation( "Profiler is VoidProfiler, not profiling (must run debug mode to profile)."); + } + _profile = false; } @@ -38,13 +50,9 @@ namespace Umbraco.Web.Common.Profiler { if (_profile) { - void requestStart(object sender, HttpContext context) => _profiler.UmbracoApplicationBeginRequest(context); - _umbracoRequestLifetime.RequestStart += requestStart; - _terminate.Add(() => _umbracoRequestLifetime.RequestStart -= requestStart); + _umbracoRequestLifetime.RequestStart += (sender, context) => _profiler.UmbracoApplicationBeginRequest(context); - void requestEnd(object sender, HttpContext context) => _profiler.UmbracoApplicationEndRequest(context); - _umbracoRequestLifetime.RequestEnd += requestEnd; - _terminate.Add(() => _umbracoRequestLifetime.RequestEnd -= requestEnd); + _umbracoRequestLifetime.RequestEnd += (sender, context) => _profiler.UmbracoApplicationEndRequest(context); // Stop the profiling of the booting process _profiler.StopBoot();