From e41122eb8c344abb4b429c459fab3f013fc61f65 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Mon, 30 Nov 2020 23:39:56 +0000 Subject: [PATCH 1/9] Add EventAggregator --- .../Builder/UmbracoBuilder.Events.cs | 27 +++++++ src/Umbraco.Core/Builder/UmbracoBuilder.cs | 15 ++++ .../Events/EventAggregator.Notifications.cs | 66 ++++++++++++++++ src/Umbraco.Core/Events/EventAggregator.cs | 65 ++++++++++++++++ src/Umbraco.Core/Events/IEventAggregator.cs | 42 +++++++++++ .../Events/EventAggregatorTests.cs | 75 +++++++++++++++++++ 6 files changed, 290 insertions(+) create mode 100644 src/Umbraco.Core/Builder/UmbracoBuilder.Events.cs create mode 100644 src/Umbraco.Core/Events/EventAggregator.Notifications.cs create mode 100644 src/Umbraco.Core/Events/EventAggregator.cs create mode 100644 src/Umbraco.Core/Events/IEventAggregator.cs create mode 100644 src/Umbraco.Tests.UnitTests/Umbraco.Core/Events/EventAggregatorTests.cs diff --git a/src/Umbraco.Core/Builder/UmbracoBuilder.Events.cs b/src/Umbraco.Core/Builder/UmbracoBuilder.Events.cs new file mode 100644 index 0000000000..84902481ff --- /dev/null +++ b/src/Umbraco.Core/Builder/UmbracoBuilder.Events.cs @@ -0,0 +1,27 @@ +using Microsoft.Extensions.DependencyInjection; +using Umbraco.Core.Events; + +namespace Umbraco.Core.Builder +{ + /// + /// Contains extensions methods for . + /// + public static partial class UmbracoBuilderExtensions + { + /// + /// Registers a notification handler against the Umbraco service collection. + /// + /// The type of notification. + /// The type of notificiation handler. + /// The Umbraco builder. + /// The . + public static IUmbracoBuilder AddNotificationHandler(this IUmbracoBuilder builder) + where TNotificationHandler : INotificationHandler + where TNotification : INotification + { + // Register the handler as transient. This ensures that anything can be injected into it. + builder.Services.AddTransient(typeof(INotificationHandler), typeof(TNotificationHandler)); + return builder; + } + } +} diff --git a/src/Umbraco.Core/Builder/UmbracoBuilder.cs b/src/Umbraco.Core/Builder/UmbracoBuilder.cs index 9514b0de59..b167f1694f 100644 --- a/src/Umbraco.Core/Builder/UmbracoBuilder.cs +++ b/src/Umbraco.Core/Builder/UmbracoBuilder.cs @@ -6,6 +6,8 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Umbraco.Core.Builder; using Umbraco.Core.Composing; +using Umbraco.Core.Events; +using Microsoft.Extensions.DependencyInjection.Extensions; namespace Umbraco.Web.Common.Builder { @@ -28,6 +30,8 @@ namespace Umbraco.Web.Common.Builder Config = config; BuilderLoggerFactory = loggerFactory; TypeLoader = typeLoader; + + AddCoreServices(); } /// @@ -55,5 +59,16 @@ namespace Umbraco.Web.Common.Builder _builders.Clear(); } + + private void AddCoreServices() + { + // TODO: Should this be an explicit public method accepting a service lifetime? + // Register the aggregator and factory as transient. + // Use TryAdd to allow simple refactoring to allow additional registrations. + // Transiant registration matches the default registration of Mediatr and + // should encourage the avoidance of singletons throughout the codebase. + Services.TryAddTransient(p => p.GetService); + Services.TryAdd(new ServiceDescriptor(typeof(IEventAggregator), typeof(EventAggregator), ServiceLifetime.Transient)); + } } } diff --git a/src/Umbraco.Core/Events/EventAggregator.Notifications.cs b/src/Umbraco.Core/Events/EventAggregator.Notifications.cs new file mode 100644 index 0000000000..1e6bf9901f --- /dev/null +++ b/src/Umbraco.Core/Events/EventAggregator.Notifications.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; + +namespace Umbraco.Core.Events +{ + /// + /// Contains types and methods that allow publishing general notifications. + /// + public partial class EventAggregator : IEventAggregator + { + private static readonly ConcurrentDictionary NotificationHandlers + = new ConcurrentDictionary(); + + private Task PublishNotificationAsync(INotification notification, CancellationToken cancellationToken = default) + { + var notificationType = notification.GetType(); + var handler = NotificationHandlers.GetOrAdd( + notificationType, + t => (NotificationHandlerWrapper)Activator.CreateInstance(typeof(NotificationHandlerWrapperImpl<>).MakeGenericType(notificationType))); + + return handler.HandleAsync(notification, cancellationToken, _serviceFactory, PublishCoreAsync); + } + + private async Task PublishCoreAsync( + IEnumerable> allHandlers, + INotification notification, CancellationToken cancellationToken) + { + foreach (var handler in allHandlers) + { + await handler(notification, cancellationToken).ConfigureAwait(false); + } + } + } + + internal abstract class NotificationHandlerWrapper + { + public abstract Task HandleAsync( + INotification notification, + CancellationToken cancellationToken, + ServiceFactory serviceFactory, + Func>, INotification, CancellationToken, Task> publish); + } + + internal class NotificationHandlerWrapperImpl : NotificationHandlerWrapper + where TNotification : INotification + { + public override Task HandleAsync( + INotification notification, + CancellationToken cancellationToken, + ServiceFactory serviceFactory, + Func>, INotification, CancellationToken, Task> publish) + { + IEnumerable> handlers = serviceFactory + .GetInstances>() + .Select(x => new Func( + (theNotification, theToken) => + x.HandleAsync((TNotification)theNotification, theToken))); + + return publish(handlers, notification, cancellationToken); + } + } +} diff --git a/src/Umbraco.Core/Events/EventAggregator.cs b/src/Umbraco.Core/Events/EventAggregator.cs new file mode 100644 index 0000000000..384cb1f9ff --- /dev/null +++ b/src/Umbraco.Core/Events/EventAggregator.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace Umbraco.Core.Events +{ + /// + public partial class EventAggregator : IEventAggregator + { + private readonly ServiceFactory _serviceFactory; + + /// + /// Initializes a new instance of the class. + /// + /// The service instance factory. + public EventAggregator(ServiceFactory serviceFactory) + => _serviceFactory = serviceFactory; + + /// + public Task PublishAsync(TNotification notification, CancellationToken cancellationToken = default) + where TNotification : INotification + { + // TODO: Introduce codegen efficient Guard classes to reduce noise. + if (notification == null) + { + throw new ArgumentNullException(nameof(notification)); + } + + return PublishNotificationAsync(notification, cancellationToken); + } + } + + /// + /// A factory method used to resolve all services. + /// For multiple instances, it will resolve against . + /// + /// Type of service to resolve. + /// An instance of type . + public delegate object ServiceFactory(Type serviceType); + + /// + /// Extensions for . + /// + public static class ServiceFactoryExtensions + { + /// + /// Gets an instance of . + /// + /// The type to return. + /// The service factory. + /// The new instance. + public static T GetInstance(this ServiceFactory factory) + => (T)factory(typeof(T)); + + /// + /// Gets a collection of instances of . + /// + /// The collection item type to return. + /// The service factory. + /// The new instance collection. + public static IEnumerable GetInstances(this ServiceFactory factory) + => (IEnumerable)factory(typeof(IEnumerable)); + } +} diff --git a/src/Umbraco.Core/Events/IEventAggregator.cs b/src/Umbraco.Core/Events/IEventAggregator.cs new file mode 100644 index 0000000000..fd8005aef8 --- /dev/null +++ b/src/Umbraco.Core/Events/IEventAggregator.cs @@ -0,0 +1,42 @@ +using System.Threading; +using System.Threading.Tasks; + +namespace Umbraco.Core.Events +{ + /// + /// Defines an object that channels events from multiple objects into a single object + /// to simplify registration for clients. + /// + public interface IEventAggregator + { + /// + /// Asynchronously send a notification to multiple handlers + /// + /// The type of notification being handled. + /// The notification object. + /// An optional cancellation token + /// A task that represents the publish operation. + Task PublishAsync(TNotification notification, CancellationToken cancellationToken = default) + where TNotification : INotification; + } + + /// + /// A marker interface to represent a notification. + /// + public interface INotification { } + + /// + /// Defines a handler for a notification + /// + /// The type of notification being handled. + public interface INotificationHandler + where TNotification : INotification + { + /// + /// Handles a notification + /// + /// The notification + /// Cancellation token + Task HandleAsync(TNotification notification, CancellationToken cancellationToken); + } +} diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Events/EventAggregatorTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Events/EventAggregatorTests.cs new file mode 100644 index 0000000000..c89fa2f9fd --- /dev/null +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Events/EventAggregatorTests.cs @@ -0,0 +1,75 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Moq; +using NUnit.Framework; +using System.Threading; +using System.Threading.Tasks; +using Umbraco.Core.Builder; +using Umbraco.Core.Events; +using Umbraco.Tests.TestHelpers; +using Umbraco.Web.Common.Builder; + +namespace Umbraco.Tests.UnitTests.Umbraco.Core.Events +{ + public class EventAggregatorTests + { + private const int A = 3; + private const int B = 5; + private const int C = 7; + private IUmbracoBuilder _builder; + + [SetUp] + public void Setup() + { + var register = TestHelper.GetServiceCollection(); + _builder = new UmbracoBuilder(register, Mock.Of(), TestHelper.GetMockedTypeLoader()); + } + + [Test] + public async Task CanPublishEvents() + { + _builder.AddNotificationHandler(); + _builder.AddNotificationHandler(); + _builder.AddNotificationHandler(); + var provider = _builder.Services.BuildServiceProvider(); + + var notification = new Notification(); + var aggregator = provider.GetService(); + await aggregator.PublishAsync(notification); + + Assert.AreEqual(A + B + C, notification.SubscriberCount); + } + + public class Notification : INotification + { + public int SubscriberCount { get; set; } + } + + public class NotificationHandlerA : INotificationHandler + { + public Task HandleAsync(Notification notification, CancellationToken cancellationToken) + { + notification.SubscriberCount += A; + return Task.CompletedTask; + } + } + + public class NotificationHandlerB : INotificationHandler + { + public Task HandleAsync(Notification notification, CancellationToken cancellationToken) + { + notification.SubscriberCount += B; + return Task.CompletedTask; + } + } + + public class NotificationHandlerC : INotificationHandler + { + public Task HandleAsync(Notification notification, CancellationToken cancellationToken) + { + notification.SubscriberCount += C; + return Task.CompletedTask; + } + } + } +} From a3cc3769c06cd42db5c12dd3d95fae286c0c2191 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 1 Dec 2020 01:13:08 +0000 Subject: [PATCH 2/9] Mocking should be an act of desperation! --- .../Umbraco.Core/Components/ComponentTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs index 4cc2a54327..4352035a9c 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs @@ -62,7 +62,8 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Components private static IServiceCollection MockRegister() { - return Mock.Of(); + // Why mock something you can spin up an instance of? + return new ServiceCollection(); // Mock.Of(); } private static TypeLoader MockTypeLoader() From ea790511040e6cc9d1fc2ed0a7c9428d611577f8 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 1 Dec 2020 12:09:50 +0000 Subject: [PATCH 3/9] Register as singleton, test DI into handlers. --- src/Umbraco.Core/Builder/UmbracoBuilder.cs | 15 +++++---------- .../Umbraco.Core/Events/EventAggregatorTests.cs | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/Umbraco.Core/Builder/UmbracoBuilder.cs b/src/Umbraco.Core/Builder/UmbracoBuilder.cs index b167f1694f..2a5c93b0d7 100644 --- a/src/Umbraco.Core/Builder/UmbracoBuilder.cs +++ b/src/Umbraco.Core/Builder/UmbracoBuilder.cs @@ -1,13 +1,12 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; +using System; +using System.Collections.Generic; using Umbraco.Core.Builder; using Umbraco.Core.Composing; using Umbraco.Core.Events; -using Microsoft.Extensions.DependencyInjection.Extensions; namespace Umbraco.Web.Common.Builder { @@ -62,13 +61,9 @@ namespace Umbraco.Web.Common.Builder private void AddCoreServices() { - // TODO: Should this be an explicit public method accepting a service lifetime? - // Register the aggregator and factory as transient. - // Use TryAdd to allow simple refactoring to allow additional registrations. - // Transiant registration matches the default registration of Mediatr and - // should encourage the avoidance of singletons throughout the codebase. - Services.TryAddTransient(p => p.GetService); - Services.TryAdd(new ServiceDescriptor(typeof(IEventAggregator), typeof(EventAggregator), ServiceLifetime.Transient)); + // Register as singleton to allow injection everywhere. + Services.AddSingleton(p => p.GetService); + Services.AddSingleton(); } } } diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Events/EventAggregatorTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Events/EventAggregatorTests.cs index c89fa2f9fd..9c1fd87974 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Events/EventAggregatorTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Events/EventAggregatorTests.cs @@ -28,6 +28,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Events [Test] public async Task CanPublishEvents() { + _builder.Services.AddScoped(); _builder.AddNotificationHandler(); _builder.AddNotificationHandler(); _builder.AddNotificationHandler(); @@ -65,11 +66,23 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Events public class NotificationHandlerC : INotificationHandler { + private readonly Adder _adder; + + public NotificationHandlerC(Adder adder) => _adder = adder; + public Task HandleAsync(Notification notification, CancellationToken cancellationToken) { - notification.SubscriberCount += C; + notification.SubscriberCount = _adder.Add(notification.SubscriberCount, C); return Task.CompletedTask; } } + + public class Adder + { + public int Add(int a, int b) + { + return a + b; + } + } } } From 748cbb1f7b0cb8c399059abc54269df873637470 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 1 Dec 2020 12:42:14 +0000 Subject: [PATCH 4/9] Normalize builder namespace --- src/Umbraco.Core/Builder/IUmbracoBuilder.cs | 2 +- src/Umbraco.Core/Builder/UmbracoBuilder.Events.cs | 2 +- src/Umbraco.Core/Builder/UmbracoBuilder.cs | 3 +-- src/Umbraco.Core/Composing/ComponentComposer.cs | 2 +- src/Umbraco.Core/Composing/Composers.cs | 2 +- src/Umbraco.Core/Composing/CompositionExtensions.cs | 2 +- src/Umbraco.Core/Composing/IComposer.cs | 2 +- src/Umbraco.Core/CompositionExtensions.cs | 2 +- src/Umbraco.Examine.Lucene/ExamineLuceneComposer.cs | 2 +- .../Cache/DistributedCacheBinderComposer.cs | 2 +- .../Compose/DatabaseServerRegistrarAndMessengerComponent.cs | 2 +- src/Umbraco.Infrastructure/Compose/NotificationsComposer.cs | 2 +- .../Composing/CompositionExtensions/CoreMappingProfiles.cs | 2 +- .../Composing/CompositionExtensions/FileSystems.cs | 2 +- .../Composing/CompositionExtensions/Installer.cs | 2 +- .../Composing/CompositionExtensions/Repositories.cs | 2 +- .../Composing/CompositionExtensions/Services.cs | 2 +- src/Umbraco.Infrastructure/CompositionExtensions.cs | 2 +- src/Umbraco.Infrastructure/Logging/Serilog/SerilogComposer.cs | 2 +- .../Logging/Viewer/LogViewerComposer.cs | 2 +- .../Upgrade/V_8_0_0/DataTypes/PreValueMigratorComposer.cs | 2 +- src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs | 2 +- src/Umbraco.Infrastructure/Search/ExamineComposer.cs | 2 +- src/Umbraco.Infrastructure/WebAssets/WebAssetsComposer.cs | 2 +- .../Compose/ModelsBuilderComposer.cs | 2 +- src/Umbraco.PublishedCache.NuCache/NuCacheComposer.cs | 2 +- src/Umbraco.Tests.Integration/RuntimeTests.cs | 4 ++-- .../TestServerTest/UmbracoBuilderExtensions.cs | 4 ++-- .../TestServerTest/UmbracoTestServerTestBase.cs | 2 +- .../Testing/IntegrationTestComposer.cs | 2 +- .../Testing/UmbracoIntegrationTest.cs | 4 ++-- src/Umbraco.Tests.UnitTests/TestHelpers/BaseUsingSqlSyntax.cs | 2 +- .../TestHelpers/CompositionExtensions.cs | 2 +- .../Umbraco.Core/Components/ComponentTests.cs | 4 ++-- .../Umbraco.Core/Composing/CollectionBuildersTests.cs | 4 ++-- .../Umbraco.Core/Composing/LazyCollectionBuilderTests.cs | 2 +- .../Umbraco.Core/Composing/PackageActionCollectionTests.cs | 2 +- .../Umbraco.Core/Events/EventAggregatorTests.cs | 3 +-- .../Extensions/CompositionExtensions.cs | 2 +- .../Extensions/UmbracoBuilderExtensions.cs | 4 ++-- src/Umbraco.Web.BackOffice/Extensions/WebMappingProfiles.cs | 2 +- src/Umbraco.Web.BackOffice/Runtime/BackOfficeComposer.cs | 2 +- src/Umbraco.Web.BackOffice/SignalR/PreviewHubComposer.cs | 2 +- src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs | 4 ++-- .../Extensions/UmbracoWebServiceCollectionExtensions.cs | 2 +- src/Umbraco.Web.Common/Profiler/WebProfilerComposer.cs | 2 +- .../Runtime/AspNetCoreBootFailedComposer.cs | 2 +- src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs | 2 +- src/Umbraco.Web.Common/RuntimeMinification/SmidgeComposer.cs | 2 +- src/Umbraco.Web.UI.NetCore/Startup.cs | 2 +- .../Extensions/UmbracoBuilderExtensions.cs | 4 ++-- src/Umbraco.Web.Website/Runtime/WebsiteComposer.cs | 2 +- 52 files changed, 60 insertions(+), 62 deletions(-) diff --git a/src/Umbraco.Core/Builder/IUmbracoBuilder.cs b/src/Umbraco.Core/Builder/IUmbracoBuilder.cs index 4659be55f1..d1bd991ef5 100644 --- a/src/Umbraco.Core/Builder/IUmbracoBuilder.cs +++ b/src/Umbraco.Core/Builder/IUmbracoBuilder.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Umbraco.Core.Composing; -namespace Umbraco.Core.Builder +namespace Umbraco.Core.DependencyInjection { public interface IUmbracoBuilder { diff --git a/src/Umbraco.Core/Builder/UmbracoBuilder.Events.cs b/src/Umbraco.Core/Builder/UmbracoBuilder.Events.cs index 84902481ff..8a555d58dd 100644 --- a/src/Umbraco.Core/Builder/UmbracoBuilder.Events.cs +++ b/src/Umbraco.Core/Builder/UmbracoBuilder.Events.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.DependencyInjection; using Umbraco.Core.Events; -namespace Umbraco.Core.Builder +namespace Umbraco.Core.DependencyInjection { /// /// Contains extensions methods for . diff --git a/src/Umbraco.Core/Builder/UmbracoBuilder.cs b/src/Umbraco.Core/Builder/UmbracoBuilder.cs index 2a5c93b0d7..9579d22a76 100644 --- a/src/Umbraco.Core/Builder/UmbracoBuilder.cs +++ b/src/Umbraco.Core/Builder/UmbracoBuilder.cs @@ -4,11 +4,10 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using System; using System.Collections.Generic; -using Umbraco.Core.Builder; using Umbraco.Core.Composing; using Umbraco.Core.Events; -namespace Umbraco.Web.Common.Builder +namespace Umbraco.Core.DependencyInjection { public class UmbracoBuilder : IUmbracoBuilder { diff --git a/src/Umbraco.Core/Composing/ComponentComposer.cs b/src/Umbraco.Core/Composing/ComponentComposer.cs index 8092b58c79..853d4f4502 100644 --- a/src/Umbraco.Core/Composing/ComponentComposer.cs +++ b/src/Umbraco.Core/Composing/ComponentComposer.cs @@ -1,5 +1,5 @@  -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; namespace Umbraco.Core.Composing { diff --git a/src/Umbraco.Core/Composing/Composers.cs b/src/Umbraco.Core/Composing/Composers.cs index caef92f90a..47f272cbf4 100644 --- a/src/Umbraco.Core/Composing/Composers.cs +++ b/src/Umbraco.Core/Composing/Composers.cs @@ -6,7 +6,7 @@ using System.Text; using Umbraco.Core.Collections; using Umbraco.Core.Logging; using Microsoft.Extensions.Logging; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; namespace Umbraco.Core.Composing { diff --git a/src/Umbraco.Core/Composing/CompositionExtensions.cs b/src/Umbraco.Core/Composing/CompositionExtensions.cs index ff99142c2c..e4e02443eb 100644 --- a/src/Umbraco.Core/Composing/CompositionExtensions.cs +++ b/src/Umbraco.Core/Composing/CompositionExtensions.cs @@ -1,6 +1,6 @@ using System; using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; using Umbraco.Web.PublishedCache; diff --git a/src/Umbraco.Core/Composing/IComposer.cs b/src/Umbraco.Core/Composing/IComposer.cs index 6ba21eff4e..d67bb71461 100644 --- a/src/Umbraco.Core/Composing/IComposer.cs +++ b/src/Umbraco.Core/Composing/IComposer.cs @@ -1,4 +1,4 @@ -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; namespace Umbraco.Core.Composing { diff --git a/src/Umbraco.Core/CompositionExtensions.cs b/src/Umbraco.Core/CompositionExtensions.cs index d6c73478bf..c99b0a6ad5 100644 --- a/src/Umbraco.Core/CompositionExtensions.cs +++ b/src/Umbraco.Core/CompositionExtensions.cs @@ -1,4 +1,4 @@ -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; using Umbraco.Core.HealthCheck; using Umbraco.Core.Manifest; diff --git a/src/Umbraco.Examine.Lucene/ExamineLuceneComposer.cs b/src/Umbraco.Examine.Lucene/ExamineLuceneComposer.cs index a9bf887c16..e2f2460d58 100644 --- a/src/Umbraco.Examine.Lucene/ExamineLuceneComposer.cs +++ b/src/Umbraco.Examine.Lucene/ExamineLuceneComposer.cs @@ -1,6 +1,6 @@ using System.Runtime.InteropServices; using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; namespace Umbraco.Examine diff --git a/src/Umbraco.Infrastructure/Cache/DistributedCacheBinderComposer.cs b/src/Umbraco.Infrastructure/Cache/DistributedCacheBinderComposer.cs index bb9140634c..7279eaf10c 100644 --- a/src/Umbraco.Infrastructure/Cache/DistributedCacheBinderComposer.cs +++ b/src/Umbraco.Infrastructure/Cache/DistributedCacheBinderComposer.cs @@ -1,5 +1,5 @@ using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; namespace Umbraco.Web.Cache diff --git a/src/Umbraco.Infrastructure/Compose/DatabaseServerRegistrarAndMessengerComponent.cs b/src/Umbraco.Infrastructure/Compose/DatabaseServerRegistrarAndMessengerComponent.cs index 6f0a52d033..8d2a2e19cc 100644 --- a/src/Umbraco.Infrastructure/Compose/DatabaseServerRegistrarAndMessengerComponent.cs +++ b/src/Umbraco.Infrastructure/Compose/DatabaseServerRegistrarAndMessengerComponent.cs @@ -1,7 +1,7 @@ using System; using Microsoft.Extensions.DependencyInjection; using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; using Umbraco.Core.Services.Changes; using Umbraco.Core.Sync; diff --git a/src/Umbraco.Infrastructure/Compose/NotificationsComposer.cs b/src/Umbraco.Infrastructure/Compose/NotificationsComposer.cs index e68d6dabf8..0fee815560 100644 --- a/src/Umbraco.Infrastructure/Compose/NotificationsComposer.cs +++ b/src/Umbraco.Infrastructure/Compose/NotificationsComposer.cs @@ -1,5 +1,5 @@ using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; namespace Umbraco.Web.Compose diff --git a/src/Umbraco.Infrastructure/Composing/CompositionExtensions/CoreMappingProfiles.cs b/src/Umbraco.Infrastructure/Composing/CompositionExtensions/CoreMappingProfiles.cs index 04f715c7c0..09a8523cb9 100644 --- a/src/Umbraco.Infrastructure/Composing/CompositionExtensions/CoreMappingProfiles.cs +++ b/src/Umbraco.Infrastructure/Composing/CompositionExtensions/CoreMappingProfiles.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.DependencyInjection; using Umbraco.Core.BackOffice; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Mapping; using Umbraco.Web.Models.Mapping; diff --git a/src/Umbraco.Infrastructure/Composing/CompositionExtensions/FileSystems.cs b/src/Umbraco.Infrastructure/Composing/CompositionExtensions/FileSystems.cs index 1f539782c7..f098cfaf57 100644 --- a/src/Umbraco.Infrastructure/Composing/CompositionExtensions/FileSystems.cs +++ b/src/Umbraco.Infrastructure/Composing/CompositionExtensions/FileSystems.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Configuration.Models; using Umbraco.Core.Hosting; using Umbraco.Core.IO; diff --git a/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Installer.cs b/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Installer.cs index e4272a44f3..31b3133e4d 100644 --- a/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Installer.cs +++ b/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Installer.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.DependencyInjection; using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; using Umbraco.Web.Install; using Umbraco.Web.Install.InstallSteps; diff --git a/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Repositories.cs b/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Repositories.cs index ba4195faf0..05b7371d15 100644 --- a/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Repositories.cs +++ b/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Repositories.cs @@ -1,4 +1,4 @@ -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Persistence.Repositories; using Umbraco.Core.Persistence.Repositories.Implement; diff --git a/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Services.cs b/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Services.cs index f657236cad..696f846d13 100644 --- a/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Services.cs +++ b/src/Umbraco.Infrastructure/Composing/CompositionExtensions/Services.cs @@ -4,7 +4,7 @@ using System.Linq; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Microsoft.Extensions.Logging; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Cache; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.Models; diff --git a/src/Umbraco.Infrastructure/CompositionExtensions.cs b/src/Umbraco.Infrastructure/CompositionExtensions.cs index d7a1c1125b..703c35e06b 100644 --- a/src/Umbraco.Infrastructure/CompositionExtensions.cs +++ b/src/Umbraco.Infrastructure/CompositionExtensions.cs @@ -1,6 +1,6 @@ using System; using Microsoft.Extensions.DependencyInjection; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Dictionary; diff --git a/src/Umbraco.Infrastructure/Logging/Serilog/SerilogComposer.cs b/src/Umbraco.Infrastructure/Logging/Serilog/SerilogComposer.cs index c7f222f0ca..fc26f922eb 100644 --- a/src/Umbraco.Infrastructure/Logging/Serilog/SerilogComposer.cs +++ b/src/Umbraco.Infrastructure/Logging/Serilog/SerilogComposer.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; using Umbraco.Core.Logging.Serilog.Enrichers; using Umbraco.Infrastructure.Logging.Serilog.Enrichers; diff --git a/src/Umbraco.Infrastructure/Logging/Viewer/LogViewerComposer.cs b/src/Umbraco.Infrastructure/Logging/Viewer/LogViewerComposer.cs index 856b6e892d..aa57383541 100644 --- a/src/Umbraco.Infrastructure/Logging/Viewer/LogViewerComposer.cs +++ b/src/Umbraco.Infrastructure/Logging/Viewer/LogViewerComposer.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Serilog; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; namespace Umbraco.Core.Logging.Viewer diff --git a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_8_0_0/DataTypes/PreValueMigratorComposer.cs b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_8_0_0/DataTypes/PreValueMigratorComposer.cs index 08c890e5b0..2cca4a839f 100644 --- a/src/Umbraco.Infrastructure/Migrations/Upgrade/V_8_0_0/DataTypes/PreValueMigratorComposer.cs +++ b/src/Umbraco.Infrastructure/Migrations/Upgrade/V_8_0_0/DataTypes/PreValueMigratorComposer.cs @@ -1,4 +1,4 @@ -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0.DataTypes diff --git a/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs b/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs index b710594689..e76043a4fe 100644 --- a/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs +++ b/src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs @@ -59,7 +59,7 @@ using Umbraco.Web.Trees; using IntegerValidator = Umbraco.Core.PropertyEditors.Validators.IntegerValidator; using TextStringValueConverter = Umbraco.Core.PropertyEditors.ValueConverters.TextStringValueConverter; using Microsoft.Extensions.Logging; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Configuration.HealthChecks; using Umbraco.Core.HealthCheck; using Umbraco.Core.HealthCheck.Checks; diff --git a/src/Umbraco.Infrastructure/Search/ExamineComposer.cs b/src/Umbraco.Infrastructure/Search/ExamineComposer.cs index 87deb21bde..683ed48ecd 100644 --- a/src/Umbraco.Infrastructure/Search/ExamineComposer.cs +++ b/src/Umbraco.Infrastructure/Search/ExamineComposer.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.DependencyInjection; using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; diff --git a/src/Umbraco.Infrastructure/WebAssets/WebAssetsComposer.cs b/src/Umbraco.Infrastructure/WebAssets/WebAssetsComposer.cs index 6a048daca4..af59c27ef2 100644 --- a/src/Umbraco.Infrastructure/WebAssets/WebAssetsComposer.cs +++ b/src/Umbraco.Infrastructure/WebAssets/WebAssetsComposer.cs @@ -1,5 +1,5 @@ using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; namespace Umbraco.Web.WebAssets diff --git a/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs b/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs index 324b5f0df7..81869a9261 100644 --- a/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs +++ b/src/Umbraco.ModelsBuilder.Embedded/Compose/ModelsBuilderComposer.cs @@ -7,7 +7,7 @@ using Umbraco.Core.Models.PublishedContent; using Umbraco.ModelsBuilder.Embedded.Building; using Umbraco.Core.Configuration.Models; using Microsoft.Extensions.Options; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; namespace Umbraco.ModelsBuilder.Embedded.Compose { diff --git a/src/Umbraco.PublishedCache.NuCache/NuCacheComposer.cs b/src/Umbraco.PublishedCache.NuCache/NuCacheComposer.cs index eb1b4b3d5f..17e707effd 100644 --- a/src/Umbraco.PublishedCache.NuCache/NuCacheComposer.cs +++ b/src/Umbraco.PublishedCache.NuCache/NuCacheComposer.cs @@ -1,6 +1,6 @@ using Microsoft.Extensions.DependencyInjection; using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; using Umbraco.Core.Models; using Umbraco.Core.Scoping; diff --git a/src/Umbraco.Tests.Integration/RuntimeTests.cs b/src/Umbraco.Tests.Integration/RuntimeTests.cs index 89006ef245..e930e12b9c 100644 --- a/src/Umbraco.Tests.Integration/RuntimeTests.cs +++ b/src/Umbraco.Tests.Integration/RuntimeTests.cs @@ -10,7 +10,7 @@ using Moq; using NUnit.Framework; using Microsoft.Extensions.Logging; using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Configuration.Models; @@ -23,7 +23,7 @@ using Umbraco.Tests.Common; using Umbraco.Tests.Integration.Extensions; using Umbraco.Tests.Integration.Implementations; using Umbraco.Tests.Integration.Testing; -using Umbraco.Web.Common.Builder; +using Umbraco.Core.DependencyInjection; namespace Umbraco.Tests.Integration { diff --git a/src/Umbraco.Tests.Integration/TestServerTest/UmbracoBuilderExtensions.cs b/src/Umbraco.Tests.Integration/TestServerTest/UmbracoBuilderExtensions.cs index 897bc38c2f..16cf6a35f4 100644 --- a/src/Umbraco.Tests.Integration/TestServerTest/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Tests.Integration/TestServerTest/UmbracoBuilderExtensions.cs @@ -1,11 +1,11 @@ using Moq; using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Cache; using Umbraco.Core.Logging; using Umbraco.Core.Runtime; using Umbraco.Tests.Integration.Implementations; -using Umbraco.Web.Common.Builder; +using Umbraco.Core.DependencyInjection; namespace Umbraco.Tests.Integration.TestServerTest { diff --git a/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs b/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs index f6ece372ea..6348a91280 100644 --- a/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs +++ b/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs @@ -18,7 +18,7 @@ using Umbraco.Extensions; using Umbraco.Tests.Integration.Testing; using Umbraco.Tests.Testing; using Umbraco.Web; -using Umbraco.Web.Common.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Web.Common.Controllers; using Microsoft.Extensions.Hosting; using Umbraco.Core.Cache; diff --git a/src/Umbraco.Tests.Integration/Testing/IntegrationTestComposer.cs b/src/Umbraco.Tests.Integration/Testing/IntegrationTestComposer.cs index c556d4d29d..dacfd950e0 100644 --- a/src/Umbraco.Tests.Integration/Testing/IntegrationTestComposer.cs +++ b/src/Umbraco.Tests.Integration/Testing/IntegrationTestComposer.cs @@ -8,7 +8,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Configuration; diff --git a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs index db71603089..50f3bf47ee 100644 --- a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs +++ b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs @@ -33,8 +33,8 @@ using Microsoft.Extensions.Options; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Serilog; -using Umbraco.Core.Builder; -using Umbraco.Web.Common.Builder; +using Umbraco.Core.DependencyInjection; +using Umbraco.Core.DependencyInjection; using ConnectionStrings = Umbraco.Core.Configuration.Models.ConnectionStrings; namespace Umbraco.Tests.Integration.Testing diff --git a/src/Umbraco.Tests.UnitTests/TestHelpers/BaseUsingSqlSyntax.cs b/src/Umbraco.Tests.UnitTests/TestHelpers/BaseUsingSqlSyntax.cs index 4093dfb892..52bc1880a3 100644 --- a/src/Umbraco.Tests.UnitTests/TestHelpers/BaseUsingSqlSyntax.cs +++ b/src/Umbraco.Tests.UnitTests/TestHelpers/BaseUsingSqlSyntax.cs @@ -12,7 +12,7 @@ using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Mappers; using Umbraco.Core.Persistence.SqlSyntax; using Umbraco.Tests.UnitTests.TestHelpers; -using Umbraco.Web.Common.Builder; +using Umbraco.Core.DependencyInjection; namespace Umbraco.Tests.TestHelpers { diff --git a/src/Umbraco.Tests.UnitTests/TestHelpers/CompositionExtensions.cs b/src/Umbraco.Tests.UnitTests/TestHelpers/CompositionExtensions.cs index 7bbfed4e85..5481bfcd76 100644 --- a/src/Umbraco.Tests.UnitTests/TestHelpers/CompositionExtensions.cs +++ b/src/Umbraco.Tests.UnitTests/TestHelpers/CompositionExtensions.cs @@ -1,6 +1,6 @@ using System; using Microsoft.Extensions.DependencyInjection; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; namespace Umbraco.Tests.UnitTests.TestHelpers diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs index 4352035a9c..11bf3bf49d 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs @@ -10,7 +10,7 @@ using Microsoft.Extensions.Logging.Abstractions; using Moq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Configuration.Models; @@ -21,7 +21,7 @@ using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Mappers; using Umbraco.Core.Scoping; using Umbraco.Tests.TestHelpers; -using Umbraco.Web.Common.Builder; +using Umbraco.Core.DependencyInjection; namespace Umbraco.Tests.UnitTests.Umbraco.Core.Components { diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/CollectionBuildersTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/CollectionBuildersTests.cs index 6bc33605ac..5de3928486 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/CollectionBuildersTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/CollectionBuildersTests.cs @@ -6,13 +6,13 @@ using Microsoft.Extensions.DependencyInjection; using Moq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Logging; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.UnitTests.TestHelpers; -using Umbraco.Web.Common.Builder; +using Umbraco.Core.DependencyInjection; namespace Umbraco.Tests.UnitTests.Umbraco.Core.Composing { diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/LazyCollectionBuilderTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/LazyCollectionBuilderTests.cs index c756023151..c87b267c1a 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/LazyCollectionBuilderTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/LazyCollectionBuilderTests.cs @@ -11,7 +11,7 @@ using Umbraco.Core.Composing; using Umbraco.Core.Logging; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.UnitTests.TestHelpers; -using Umbraco.Web.Common.Builder; +using Umbraco.Core.DependencyInjection; namespace Umbraco.Tests.UnitTests.Umbraco.Core.Composing { diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/PackageActionCollectionTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/PackageActionCollectionTests.cs index 6ebd0c677a..17e406e02f 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/PackageActionCollectionTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/PackageActionCollectionTests.cs @@ -13,7 +13,7 @@ using Umbraco.Core.Logging; using Umbraco.Core.PackageActions; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.UnitTests.TestHelpers; -using Umbraco.Web.Common.Builder; +using Umbraco.Core.DependencyInjection; namespace Umbraco.Tests.UnitTests.Umbraco.Core.Composing { diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Events/EventAggregatorTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Events/EventAggregatorTests.cs index 9c1fd87974..84626612d9 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Events/EventAggregatorTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Events/EventAggregatorTests.cs @@ -4,10 +4,9 @@ using Moq; using NUnit.Framework; using System.Threading; using System.Threading.Tasks; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Events; using Umbraco.Tests.TestHelpers; -using Umbraco.Web.Common.Builder; namespace Umbraco.Tests.UnitTests.Umbraco.Core.Events { diff --git a/src/Umbraco.Web.BackOffice/Extensions/CompositionExtensions.cs b/src/Umbraco.Web.BackOffice/Extensions/CompositionExtensions.cs index 4e8fe01b7f..2c14e33e2b 100644 --- a/src/Umbraco.Web.BackOffice/Extensions/CompositionExtensions.cs +++ b/src/Umbraco.Web.BackOffice/Extensions/CompositionExtensions.cs @@ -1,4 +1,4 @@ -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; using Umbraco.Web.BackOffice.Trees; diff --git a/src/Umbraco.Web.BackOffice/Extensions/UmbracoBuilderExtensions.cs b/src/Umbraco.Web.BackOffice/Extensions/UmbracoBuilderExtensions.cs index 76fd4a46f7..ac20853f37 100644 --- a/src/Umbraco.Web.BackOffice/Extensions/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Web.BackOffice/Extensions/UmbracoBuilderExtensions.cs @@ -1,10 +1,10 @@ using System; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.Extensions.DependencyInjection; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Web.BackOffice.Filters; using Umbraco.Web.BackOffice.Security; -using Umbraco.Web.Common.Builder; +using Umbraco.Core.DependencyInjection; namespace Umbraco.Extensions { diff --git a/src/Umbraco.Web.BackOffice/Extensions/WebMappingProfiles.cs b/src/Umbraco.Web.BackOffice/Extensions/WebMappingProfiles.cs index 600ff101fe..4cd9cf5823 100644 --- a/src/Umbraco.Web.BackOffice/Extensions/WebMappingProfiles.cs +++ b/src/Umbraco.Web.BackOffice/Extensions/WebMappingProfiles.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.DependencyInjection; using Umbraco.Core; using Umbraco.Core.BackOffice; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; using Umbraco.Core.Mapping; using Umbraco.Web.BackOffice.Mapping; diff --git a/src/Umbraco.Web.BackOffice/Runtime/BackOfficeComposer.cs b/src/Umbraco.Web.BackOffice/Runtime/BackOfficeComposer.cs index 2f1b42aed5..44896016cd 100644 --- a/src/Umbraco.Web.BackOffice/Runtime/BackOfficeComposer.cs +++ b/src/Umbraco.Web.BackOffice/Runtime/BackOfficeComposer.cs @@ -2,7 +2,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; using Umbraco.Core.Hosting; using Umbraco.Core.IO; diff --git a/src/Umbraco.Web.BackOffice/SignalR/PreviewHubComposer.cs b/src/Umbraco.Web.BackOffice/SignalR/PreviewHubComposer.cs index e994571c90..9b06e07f7c 100644 --- a/src/Umbraco.Web.BackOffice/SignalR/PreviewHubComposer.cs +++ b/src/Umbraco.Web.BackOffice/SignalR/PreviewHubComposer.cs @@ -1,5 +1,5 @@ using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; namespace Umbraco.Web.BackOffice.SignalR diff --git a/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs b/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs index 1fae03ba75..d69d886785 100644 --- a/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs @@ -20,7 +20,7 @@ using Serilog; using Smidge; using Smidge.Nuglify; using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Configuration; @@ -42,7 +42,7 @@ using Umbraco.Web.Common.ModelBinders; using Umbraco.Web.Common.Profiler; using IHostingEnvironment = Umbraco.Core.Hosting.IHostingEnvironment; -namespace Umbraco.Web.Common.Builder +namespace Umbraco.Core.DependencyInjection { // TODO: We could add parameters to configure each of these for flexibility public static class UmbracoBuilderExtensions diff --git a/src/Umbraco.Web.Common/Extensions/UmbracoWebServiceCollectionExtensions.cs b/src/Umbraco.Web.Common/Extensions/UmbracoWebServiceCollectionExtensions.cs index c1f9849621..2b077fe840 100644 --- a/src/Umbraco.Web.Common/Extensions/UmbracoWebServiceCollectionExtensions.cs +++ b/src/Umbraco.Web.Common/Extensions/UmbracoWebServiceCollectionExtensions.cs @@ -14,7 +14,7 @@ using SixLabors.ImageSharp.Web.Processors; using SixLabors.ImageSharp.Web.Providers; using Smidge; using Smidge.Nuglify; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Configuration.Models; using Umbraco.Core.Configuration.Models.Validation; using Umbraco.Web.Common.ApplicationModels; diff --git a/src/Umbraco.Web.Common/Profiler/WebProfilerComposer.cs b/src/Umbraco.Web.Common/Profiler/WebProfilerComposer.cs index 702c30f692..3c00b0d3bc 100644 --- a/src/Umbraco.Web.Common/Profiler/WebProfilerComposer.cs +++ b/src/Umbraco.Web.Common/Profiler/WebProfilerComposer.cs @@ -1,5 +1,5 @@ using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; namespace Umbraco.Web.Common.Profiler diff --git a/src/Umbraco.Web.Common/Runtime/AspNetCoreBootFailedComposer.cs b/src/Umbraco.Web.Common/Runtime/AspNetCoreBootFailedComposer.cs index 58fa5ea317..a23f880e7e 100644 --- a/src/Umbraco.Web.Common/Runtime/AspNetCoreBootFailedComposer.cs +++ b/src/Umbraco.Web.Common/Runtime/AspNetCoreBootFailedComposer.cs @@ -1,5 +1,5 @@ using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; using Umbraco.Web.Common.Middleware; diff --git a/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs b/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs index d5980c10b5..101e6f0f69 100644 --- a/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs +++ b/src/Umbraco.Web.Common/Runtime/AspNetCoreComposer.cs @@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; using Umbraco.Core.Configuration.Models; using Umbraco.Core.Diagnostics; diff --git a/src/Umbraco.Web.Common/RuntimeMinification/SmidgeComposer.cs b/src/Umbraco.Web.Common/RuntimeMinification/SmidgeComposer.cs index 5b3d776679..1058192034 100644 --- a/src/Umbraco.Web.Common/RuntimeMinification/SmidgeComposer.cs +++ b/src/Umbraco.Web.Common/RuntimeMinification/SmidgeComposer.cs @@ -1,7 +1,7 @@ using Microsoft.Extensions.DependencyInjection; using Smidge.FileProcessors; using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; using Umbraco.Core.Runtime; using Umbraco.Core.WebAssets; diff --git a/src/Umbraco.Web.UI.NetCore/Startup.cs b/src/Umbraco.Web.UI.NetCore/Startup.cs index ca62523c4d..d86e6a8776 100644 --- a/src/Umbraco.Web.UI.NetCore/Startup.cs +++ b/src/Umbraco.Web.UI.NetCore/Startup.cs @@ -5,7 +5,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Umbraco.Extensions; -using Umbraco.Web.Common.Builder; +using Umbraco.Core.DependencyInjection; namespace Umbraco.Web.UI.NetCore { diff --git a/src/Umbraco.Web.Website/Extensions/UmbracoBuilderExtensions.cs b/src/Umbraco.Web.Website/Extensions/UmbracoBuilderExtensions.cs index 3715f5e37b..72d12809e2 100644 --- a/src/Umbraco.Web.Website/Extensions/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Web.Website/Extensions/UmbracoBuilderExtensions.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -using Umbraco.Core.Builder; -using Umbraco.Web.Common.Builder; +using Umbraco.Core.DependencyInjection; +using Umbraco.Core.DependencyInjection; using Umbraco.Web.Website.ViewEngines; namespace Umbraco.Extensions diff --git a/src/Umbraco.Web.Website/Runtime/WebsiteComposer.cs b/src/Umbraco.Web.Website/Runtime/WebsiteComposer.cs index ce3ff7271e..a40b29aea2 100644 --- a/src/Umbraco.Web.Website/Runtime/WebsiteComposer.cs +++ b/src/Umbraco.Web.Website/Runtime/WebsiteComposer.cs @@ -1,5 +1,5 @@ using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; using Umbraco.Extensions; using Umbraco.Web.Website.Routing; From c9b7655f1d608209db7ca858d5984acb54f5e273 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 1 Dec 2020 14:59:08 +0000 Subject: [PATCH 5/9] Fix missing namespace replacements. --- src/Umbraco.Web/Runtime/WebInitialComposer.cs | 2 +- src/Umbraco.Web/UmbracoBuilderExtensions.cs | 2 +- src/Umbraco.Web/WebAssets/CDF/ClientDependencyComposer.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web/Runtime/WebInitialComposer.cs b/src/Umbraco.Web/Runtime/WebInitialComposer.cs index 80fa50f294..49cff7196e 100644 --- a/src/Umbraco.Web/Runtime/WebInitialComposer.cs +++ b/src/Umbraco.Web/Runtime/WebInitialComposer.cs @@ -3,7 +3,7 @@ using System.Web.Security; using Microsoft.AspNet.SignalR; using Microsoft.Extensions.DependencyInjection; using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; using Umbraco.Core.Dictionary; using Umbraco.Core.Templates; diff --git a/src/Umbraco.Web/UmbracoBuilderExtensions.cs b/src/Umbraco.Web/UmbracoBuilderExtensions.cs index 422d0a8b23..bb6fe29c93 100644 --- a/src/Umbraco.Web/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Web/UmbracoBuilderExtensions.cs @@ -1,7 +1,7 @@ using System; using Microsoft.Extensions.DependencyInjection; using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Web.Routing; namespace Umbraco.Web diff --git a/src/Umbraco.Web/WebAssets/CDF/ClientDependencyComposer.cs b/src/Umbraco.Web/WebAssets/CDF/ClientDependencyComposer.cs index c591191524..75e0d6123f 100644 --- a/src/Umbraco.Web/WebAssets/CDF/ClientDependencyComposer.cs +++ b/src/Umbraco.Web/WebAssets/CDF/ClientDependencyComposer.cs @@ -1,5 +1,5 @@ using Umbraco.Core; -using Umbraco.Core.Builder; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Composing; using Umbraco.Core.WebAssets; From 6d1cd89f4ecfbcfaac6d9e41cd735bb88fb2a2b6 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Tue, 1 Dec 2020 20:41:18 +0000 Subject: [PATCH 6/9] Fix tests build --- src/Umbraco.TestData/LoadTestController.cs | 2 +- .../Cache/DistributedCacheBinderTests.cs | 12 ++--- .../Published/ConvertersTests.cs | 7 +-- .../Scoping/ScopeEventDispatcherTests.cs | 5 +-- .../TestHelpers/BaseUsingSqlCeSyntax.cs | 2 +- src/Umbraco.Tests/Testing/UmbracoTestBase.cs | 45 +++++++++---------- 6 files changed, 29 insertions(+), 44 deletions(-) diff --git a/src/Umbraco.TestData/LoadTestController.cs b/src/Umbraco.TestData/LoadTestController.cs index ed9e0b456e..1d03c8bb2a 100644 --- a/src/Umbraco.TestData/LoadTestController.cs +++ b/src/Umbraco.TestData/LoadTestController.cs @@ -11,8 +11,8 @@ using System.Diagnostics; using Umbraco.Core.Composing; using System.Configuration; using Microsoft.Extensions.DependencyInjection; -using Umbraco.Core.Builder; using Umbraco.Core.Strings; +using Umbraco.Core.DependencyInjection; // see https://github.com/Shazwazza/UmbracoScripts/tree/master/src/LoadTesting diff --git a/src/Umbraco.Tests/Cache/DistributedCacheBinderTests.cs b/src/Umbraco.Tests/Cache/DistributedCacheBinderTests.cs index 8d2a6eb217..1800abc8a8 100644 --- a/src/Umbraco.Tests/Cache/DistributedCacheBinderTests.cs +++ b/src/Umbraco.Tests/Cache/DistributedCacheBinderTests.cs @@ -1,16 +1,13 @@ -using System; +using Moq; +using NUnit.Framework; +using System; using System.Linq; using System.Threading; -using Moq; -using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.Builder; -using Umbraco.Core.Cache; -using Umbraco.Core.Composing; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Events; using Umbraco.Core.Models; using Umbraco.Core.Models.Membership; -using Umbraco.Core.Serialization; using Umbraco.Core.Services; using Umbraco.Tests.Common; using Umbraco.Tests.TestHelpers; @@ -19,7 +16,6 @@ using Umbraco.Web; using Umbraco.Web.Cache; using Umbraco.Web.PublishedCache; using Umbraco.Web.Routing; -using Current = Umbraco.Web.Composing.Current; namespace Umbraco.Tests.Cache { diff --git a/src/Umbraco.Tests/Published/ConvertersTests.cs b/src/Umbraco.Tests/Published/ConvertersTests.cs index d3c9eaf36d..840ec58f13 100644 --- a/src/Umbraco.Tests/Published/ConvertersTests.cs +++ b/src/Umbraco.Tests/Published/ConvertersTests.cs @@ -3,15 +3,11 @@ using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Moq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.Cache; -using Umbraco.Core.Composing; -using Umbraco.Core.IO; -using Umbraco.Core.Logging; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors; @@ -21,7 +17,6 @@ using Umbraco.Core.Strings; using Umbraco.Tests.PublishedContent; using Umbraco.Tests.TestHelpers; using Umbraco.Web; -using Umbraco.Web.Common.Builder; using Umbraco.Web.PublishedCache; namespace Umbraco.Tests.Published diff --git a/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs b/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs index 5ab6aeaa1d..4e1540a525 100644 --- a/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs +++ b/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs @@ -6,12 +6,9 @@ using Microsoft.Extensions.Logging; using Moq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.Cache; -using Umbraco.Core.Composing; using Umbraco.Core.Configuration.Models; using Umbraco.Core.Events; using Umbraco.Core.IO; -using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Persistence.Mappers; using Umbraco.Core.Scoping; @@ -21,7 +18,7 @@ using Umbraco.Tests.TestHelpers.Entities; using Umbraco.Web; using Current = Umbraco.Web.Composing.Current; using Microsoft.Extensions.DependencyInjection; -using Umbraco.Web.Common.Builder; +using Umbraco.Core.DependencyInjection; namespace Umbraco.Tests.Scoping { diff --git a/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs b/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs index a048c76022..6e27bdd07c 100644 --- a/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs +++ b/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs @@ -15,8 +15,8 @@ using Umbraco.Core.Persistence.Mappers; using Umbraco.Core.Persistence; using Umbraco.Persistance.SqlCe; using Umbraco.Web; -using Umbraco.Web.Common.Builder; using Current = Umbraco.Web.Composing.Current; +using Umbraco.Core.DependencyInjection; namespace Umbraco.Tests.TestHelpers { diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs index b780665c23..533966f5a9 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs @@ -1,14 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Web.Http.Validation; -using System.Web.Routing; -using System.Web.Security; -using System.Xml.Linq; -using Examine; +using Examine; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -16,20 +6,28 @@ using Microsoft.Extensions.Logging.Abstractions; using Moq; using NUnit.Framework; using Serilog; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Web.Routing; +using System.Web.Security; +using System.Xml.Linq; using Umbraco.Core; -using Umbraco.Core.Builder; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Composing.CompositionExtensions; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.Models; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Dictionary; using Umbraco.Core.Events; using Umbraco.Core.Hosting; using Umbraco.Core.IO; using Umbraco.Core.IO.MediaPathSchemes; using Umbraco.Core.Logging; -using Umbraco.Core.Logging.Serilog; using Umbraco.Core.Manifest; using Umbraco.Core.Mapping; using Umbraco.Core.Media; @@ -52,7 +50,6 @@ using Umbraco.Tests.TestHelpers.Stubs; using Umbraco.Web; using Umbraco.Web.Actions; using Umbraco.Web.AspNet; -using Umbraco.Web.Common.Builder; using Umbraco.Web.ContentApps; using Umbraco.Web.Hosting; using Umbraco.Web.Install; @@ -136,7 +133,7 @@ namespace Umbraco.Tests.Testing protected IPasswordHasher PasswordHasher => Factory.GetRequiredService(); protected Lazy PropertyEditorCollection => new Lazy(() => Factory.GetRequiredService()); protected ILocalizationService LocalizationService => Factory.GetRequiredService(); - protected ILocalizedTextService LocalizedTextService { get; private set; } + protected ILocalizedTextService LocalizedTextService { get; private set; } protected IShortStringHelper ShortStringHelper => Factory?.GetRequiredService() ?? TestHelper.ShortStringHelper; protected IImageUrlGenerator ImageUrlGenerator => Factory.GetRequiredService(); protected UploadAutoFillProperties UploadAutoFillProperties => Factory.GetRequiredService(); @@ -389,30 +386,30 @@ namespace Umbraco.Tests.Testing .ComposeCoreMappingProfiles(); } - protected virtual TypeLoader GetTypeLoader(IIOHelper ioHelper, ITypeFinder typeFinder, IAppPolicyCache runtimeCache, IHostingEnvironment hostingEnvironment, ILogger logger, IProfilingLogger profilingLogger , UmbracoTestOptions.TypeLoader option) + protected virtual TypeLoader GetTypeLoader(IIOHelper ioHelper, ITypeFinder typeFinder, IAppPolicyCache runtimeCache, IHostingEnvironment hostingEnvironment, ILogger logger, IProfilingLogger profilingLogger, UmbracoTestOptions.TypeLoader option) { switch (option) { case UmbracoTestOptions.TypeLoader.Default: - return _commonTypeLoader ?? (_commonTypeLoader = CreateCommonTypeLoader(typeFinder, runtimeCache, logger, profilingLogger , hostingEnvironment)); + return _commonTypeLoader ?? (_commonTypeLoader = CreateCommonTypeLoader(typeFinder, runtimeCache, logger, profilingLogger, hostingEnvironment)); case UmbracoTestOptions.TypeLoader.PerFixture: - return _featureTypeLoader ?? (_featureTypeLoader = CreateTypeLoader(ioHelper, typeFinder, runtimeCache, logger, profilingLogger , hostingEnvironment)); + return _featureTypeLoader ?? (_featureTypeLoader = CreateTypeLoader(ioHelper, typeFinder, runtimeCache, logger, profilingLogger, hostingEnvironment)); case UmbracoTestOptions.TypeLoader.PerTest: - return CreateTypeLoader(ioHelper, typeFinder, runtimeCache, logger, profilingLogger , hostingEnvironment); + return CreateTypeLoader(ioHelper, typeFinder, runtimeCache, logger, profilingLogger, hostingEnvironment); default: throw new ArgumentOutOfRangeException(nameof(option)); } } - protected virtual TypeLoader CreateTypeLoader(IIOHelper ioHelper, ITypeFinder typeFinder, IAppPolicyCache runtimeCache, ILogger logger, IProfilingLogger profilingLogger , IHostingEnvironment hostingEnvironment) + protected virtual TypeLoader CreateTypeLoader(IIOHelper ioHelper, ITypeFinder typeFinder, IAppPolicyCache runtimeCache, ILogger logger, IProfilingLogger profilingLogger, IHostingEnvironment hostingEnvironment) { - return CreateCommonTypeLoader(typeFinder, runtimeCache, logger, profilingLogger , hostingEnvironment); + return CreateCommonTypeLoader(typeFinder, runtimeCache, logger, profilingLogger, hostingEnvironment); } // common to all tests = cannot be overriden - private static TypeLoader CreateCommonTypeLoader(ITypeFinder typeFinder, IAppPolicyCache runtimeCache, ILogger logger, IProfilingLogger profilingLogger , IHostingEnvironment hostingEnvironment) + private static TypeLoader CreateCommonTypeLoader(ITypeFinder typeFinder, IAppPolicyCache runtimeCache, ILogger logger, IProfilingLogger profilingLogger, IHostingEnvironment hostingEnvironment) { - return new TypeLoader(typeFinder, runtimeCache, new DirectoryInfo(hostingEnvironment.LocalTempPath), logger, profilingLogger , false, new[] + return new TypeLoader(typeFinder, runtimeCache, new DirectoryInfo(hostingEnvironment.LocalTempPath), logger, profilingLogger, false, new[] { Assembly.Load("Umbraco.Core"), Assembly.Load("Umbraco.Web"), @@ -498,7 +495,7 @@ namespace Umbraco.Tests.Testing Builder.Services.AddUnique(factory => TestObjects.GetScopeProvider(_loggerFactory, factory.GetService(), factory.GetService(), factory.GetService())); - Builder.Services.AddUnique(factory => (IScopeAccessor) factory.GetRequiredService()); + Builder.Services.AddUnique(factory => (IScopeAccessor)factory.GetRequiredService()); Builder.ComposeServices(); From fdb6c210755696ff3d92c1fd85dd9671830c08dc Mon Sep 17 00:00:00 2001 From: Matthew Wise Date: Wed, 2 Dec 2020 14:21:05 +0000 Subject: [PATCH 7/9] Converted OutgoingEditorModelEventAttribute to a type filter --- .../Controllers/ContentController.cs | 79 ++++++++++--------- .../Controllers/DashboardController.cs | 2 +- .../Controllers/MediaController.cs | 10 +-- .../Controllers/MemberController.cs | 6 +- .../Controllers/UsersController.cs | 6 +- .../Filters/EditorModelEventManager.cs | 22 +++--- .../OutgoingEditorModelEventAttribute.cs | 57 +++++++------ 7 files changed, 98 insertions(+), 84 deletions(-) diff --git a/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs b/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs index 742838c224..fb993d1e4e 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs @@ -149,7 +149,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// [FilterAllowedOutgoingContent(typeof(IEnumerable))] - public IEnumerable GetByIds([FromQuery]int[] ids) + public IEnumerable GetByIds([FromQuery] int[] ids) { var foundContent = _contentService.GetByIds(ids); return foundContent.Select(MapToDisplay); @@ -164,7 +164,8 @@ namespace Umbraco.Web.BackOffice.Controllers /// Permission check is done for letter 'R' which is for which the user must have access to update /// public async Task>> PostSaveUserGroupPermissions(UserGroupPermissionsSave saveModel) - { if (saveModel.ContentId <= 0) return NotFound(); + { + if (saveModel.ContentId <= 0) return NotFound(); // TODO: Should non-admins be allowed to set granular permissions? @@ -347,7 +348,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// /// - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] [Authorize(Policy = AuthorizationPolicies.ContentPermissionBrowseById)] [DetermineAmbiguousActionByPassingParameters] public ContentItemDisplay GetById(int id) @@ -367,7 +368,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// /// - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] [Authorize(Policy = AuthorizationPolicies.ContentPermissionBrowseById)] [DetermineAmbiguousActionByPassingParameters] public ContentItemDisplay GetById(Guid id) @@ -388,7 +389,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// /// - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] [Authorize(Policy = AuthorizationPolicies.ContentPermissionBrowseById)] [DetermineAmbiguousActionByPassingParameters] public ContentItemDisplay GetById(Udi id) @@ -407,7 +408,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// /// - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] [DetermineAmbiguousActionByPassingParameters] public ContentItemDisplay GetEmpty(string contentTypeAlias, int parentId) { @@ -426,7 +427,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// /// - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] public ContentItemDisplay GetEmptyByKey(Guid contentTypeKey, int parentId) { var contentType = _contentTypeService.Get(contentTypeKey); @@ -454,7 +455,7 @@ namespace Umbraco.Web.BackOffice.Controllers return mapped; } - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] [DetermineAmbiguousActionByPassingParameters] public ContentItemDisplay GetEmpty(int blueprintId, int parentId) { @@ -598,7 +599,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// The name of the blueprint /// [HttpPost] - public ActionResult CreateBlueprintFromContent([FromQuery]int contentId, [FromQuery]string name) + public ActionResult CreateBlueprintFromContent([FromQuery] int contentId, [FromQuery] string name) { if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value cannot be null or whitespace.", nameof(name)); @@ -632,32 +633,32 @@ namespace Umbraco.Web.BackOffice.Controllers } } - /// - /// Saves content - /// - /// - [FileUploadCleanupFilter] - [ContentSaveValidation] - public async Task PostSaveBlueprint([ModelBinder(typeof(BlueprintItemBinder))] ContentItemSave contentItem) - { - var contentItemDisplay = await PostSaveInternal(contentItem, - content => - { - EnsureUniqueName(content.Name, content, "Name"); + /// + /// Saves content + /// + /// + [FileUploadCleanupFilter] + [ContentSaveValidation] + public async Task PostSaveBlueprint([ModelBinder(typeof(BlueprintItemBinder))] ContentItemSave contentItem) + { + var contentItemDisplay = await PostSaveInternal(contentItem, + content => + { + EnsureUniqueName(content.Name, content, "Name"); - _contentService.SaveBlueprint(contentItem.PersistedContent, _backofficeSecurityAccessor.BackOfficeSecurity.CurrentUser.Id); + _contentService.SaveBlueprint(contentItem.PersistedContent, _backofficeSecurityAccessor.BackOfficeSecurity.CurrentUser.Id); //we need to reuse the underlying logic so return the result that it wants return OperationResult.Succeed(new EventMessages()); - }, - content => - { - var display = MapToDisplay(content); - SetupBlueprint(display, content); - return display; - }); + }, + content => + { + var display = MapToDisplay(content); + SetupBlueprint(display, content); + return display; + }); - return contentItemDisplay; - } + return contentItemDisplay; + } /// /// Saves content @@ -665,7 +666,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// [FileUploadCleanupFilter] [ContentSaveValidation] - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] public async Task PostSave([ModelBinder(typeof(ContentItemBinder))] ContentItemSave contentItem) { var contentItemDisplay = await PostSaveInternal( @@ -1459,7 +1460,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// private string GetVariantName(string culture, string segment) { - if(culture.IsNullOrWhiteSpace() && segment.IsNullOrWhiteSpace()) + if (culture.IsNullOrWhiteSpace() && segment.IsNullOrWhiteSpace()) { // TODO: Get name for default variant from somewhere? return "Default"; @@ -1677,7 +1678,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// The content and variants to unpublish /// - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] public async Task> PostUnpublish(UnpublishContent model) { var foundContent = _contentService.GetById(model.Id); @@ -1685,7 +1686,7 @@ namespace Umbraco.Web.BackOffice.Controllers if (foundContent == null) { HandleContentNotFound(model.Id); - } + } // Authorize... var resource = new ContentPermissionsResource(foundContent, ActionUnpublish.ActionLetter); @@ -2309,7 +2310,7 @@ namespace Umbraco.Web.BackOffice.Controllers return notifications; } - public IActionResult PostNotificationOptions(int contentId, [FromQuery(Name="notifyOptions[]")] string[] notifyOptions) + public IActionResult PostNotificationOptions(int contentId, [FromQuery(Name = "notifyOptions[]")] string[] notifyOptions) { if (contentId <= 0) return NotFound(); var content = _contentService.GetById(contentId); @@ -2459,7 +2460,7 @@ namespace Umbraco.Web.BackOffice.Controllers // set up public access using role based access [Authorize(Policy = AuthorizationPolicies.ContentPermissionProtectById)] [HttpPost] - public IActionResult PostPublicAccess(int contentId, [FromQuery(Name = "groups[]")]string[] groups, [FromQuery(Name = "usernames[]")]string[] usernames, int loginPageId, int errorPageId) + public IActionResult PostPublicAccess(int contentId, [FromQuery(Name = "groups[]")] string[] groups, [FromQuery(Name = "usernames[]")] string[] usernames, int loginPageId, int errorPageId) { if ((groups == null || groups.Any() == false) && (usernames == null || usernames.Any() == false)) { @@ -2520,7 +2521,7 @@ namespace Umbraco.Web.BackOffice.Controllers } return _publicAccessService.Save(entry).Success - ? (IActionResult) Ok() + ? (IActionResult)Ok() : Problem(); } @@ -2541,7 +2542,7 @@ namespace Umbraco.Web.BackOffice.Controllers } return _publicAccessService.Delete(entry).Success - ? (IActionResult) Ok() + ? (IActionResult)Ok() : Problem(); } } diff --git a/src/Umbraco.Web.BackOffice/Controllers/DashboardController.cs b/src/Umbraco.Web.BackOffice/Controllers/DashboardController.cs index d96708b11d..a69cc6739b 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/DashboardController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/DashboardController.cs @@ -210,7 +210,7 @@ namespace Umbraco.Web.BackOffice.Controllers // return IDashboardSlim - we don't need sections nor access rules [ValidateAngularAntiForgeryToken] - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] public IEnumerable> GetDashboard(string section) { var currentUser = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser; diff --git a/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs b/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs index 409967fb67..49a20f1150 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs @@ -122,7 +122,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// /// - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] public MediaItemDisplay GetEmpty(string contentTypeAlias, int parentId) { var contentType = _mediaTypeService.Get(contentTypeAlias); @@ -170,7 +170,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// /// - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] [Authorize(Policy = AuthorizationPolicies.MediaPermissionPathById)] [DetermineAmbiguousActionByPassingParameters] public MediaItemDisplay GetById(int id) @@ -191,7 +191,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// /// - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] [Authorize(Policy = AuthorizationPolicies.MediaPermissionPathById)] [DetermineAmbiguousActionByPassingParameters] public MediaItemDisplay GetById(Guid id) @@ -212,7 +212,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// /// - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] [Authorize(Policy = AuthorizationPolicies.MediaPermissionPathById)] [DetermineAmbiguousActionByPassingParameters] public MediaItemDisplay GetById(Udi id) @@ -513,7 +513,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// [FileUploadCleanupFilter] [MediaItemSaveValidation] - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] public MediaItemDisplay PostSave( [ModelBinder(typeof(MediaItemBinder))] MediaItemSave contentItem) diff --git a/src/Umbraco.Web.BackOffice/Controllers/MemberController.cs b/src/Umbraco.Web.BackOffice/Controllers/MemberController.cs index a97ed9c2ad..267539c97f 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/MemberController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/MemberController.cs @@ -151,7 +151,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// /// - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] public MemberDisplay GetByKey(Guid key) { var foundMember = _memberService.GetByKey(key); @@ -167,7 +167,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// /// - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] public MemberDisplay GetEmpty(string contentTypeAlias = null) { IMember emptyContent; @@ -194,7 +194,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// [FileUploadCleanupFilter] - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] [MemberSaveValidation] public async Task> PostSave( [ModelBinder(typeof(MemberBinder))] diff --git a/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs b/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs index 1fb3010a7d..069338750a 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs @@ -225,7 +225,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// /// - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] [Authorize(Policy = AuthorizationPolicies.AdminUserEditsRequireAdmin)] public UserDisplay GetById(int id) { @@ -243,7 +243,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// /// - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] [Authorize(Policy = AuthorizationPolicies.AdminUserEditsRequireAdmin)] public IEnumerable GetByIds([FromJsonPath]int[] ids) { @@ -578,7 +578,7 @@ namespace Umbraco.Web.BackOffice.Controllers /// /// /// - [TypeFilter(typeof(OutgoingEditorModelEventAttribute))] + [OutgoingEditorModelEvent] public UserDisplay PostSaveUser(UserSave userSave) { if (userSave == null) throw new ArgumentNullException(nameof(userSave)); diff --git a/src/Umbraco.Web.BackOffice/Filters/EditorModelEventManager.cs b/src/Umbraco.Web.BackOffice/Filters/EditorModelEventManager.cs index d1856ee7d9..617e2804c5 100644 --- a/src/Umbraco.Web.BackOffice/Filters/EditorModelEventManager.cs +++ b/src/Umbraco.Web.BackOffice/Filters/EditorModelEventManager.cs @@ -12,38 +12,38 @@ namespace Umbraco.Web.BackOffice.Filters /// public sealed class EditorModelEventManager { - public static event TypedEventHandler> SendingContentModel; - public static event TypedEventHandler> SendingMediaModel; - public static event TypedEventHandler> SendingMemberModel; - public static event TypedEventHandler> SendingUserModel; + public static event TypedEventHandler> SendingContentModel; + public static event TypedEventHandler> SendingMediaModel; + public static event TypedEventHandler> SendingMemberModel; + public static event TypedEventHandler> SendingUserModel; - public static event TypedEventHandler>>> SendingDashboardSlimModel; + public static event TypedEventHandler>>> SendingDashboardSlimModel; - private static void OnSendingDashboardModel(ActionExecutedContext sender, EditorModelEventArgs>> e) + private static void OnSendingDashboardModel(ResultExecutedContext sender, EditorModelEventArgs>> e) { var handler = SendingDashboardSlimModel; handler?.Invoke(sender, e); } - private static void OnSendingUserModel(ActionExecutedContext sender, EditorModelEventArgs e) + private static void OnSendingUserModel(ResultExecutedContext sender, EditorModelEventArgs e) { var handler = SendingUserModel; handler?.Invoke(sender, e); } - private static void OnSendingContentModel(ActionExecutedContext sender, EditorModelEventArgs e) + private static void OnSendingContentModel(ResultExecutedContext sender, EditorModelEventArgs e) { var handler = SendingContentModel; handler?.Invoke(sender, e); } - private static void OnSendingMediaModel(ActionExecutedContext sender, EditorModelEventArgs e) + private static void OnSendingMediaModel(ResultExecutedContext sender, EditorModelEventArgs e) { var handler = SendingMediaModel; handler?.Invoke(sender, e); } - private static void OnSendingMemberModel(ActionExecutedContext sender, EditorModelEventArgs e) + private static void OnSendingMemberModel(ResultExecutedContext sender, EditorModelEventArgs e) { var handler = SendingMemberModel; handler?.Invoke(sender, e); @@ -54,7 +54,7 @@ namespace Umbraco.Web.BackOffice.Filters /// /// /// - internal static void EmitEvent(ActionExecutedContext sender, EditorModelEventArgs e) + internal static void EmitEvent(ResultExecutedContext sender, EditorModelEventArgs e) { if (e.Model is ContentItemDisplay) OnSendingContentModel(sender, new EditorModelEventArgs(e)); diff --git a/src/Umbraco.Web.BackOffice/Filters/OutgoingEditorModelEventAttribute.cs b/src/Umbraco.Web.BackOffice/Filters/OutgoingEditorModelEventAttribute.cs index d5df536dae..3cad31cdf7 100644 --- a/src/Umbraco.Web.BackOffice/Filters/OutgoingEditorModelEventAttribute.cs +++ b/src/Umbraco.Web.BackOffice/Filters/OutgoingEditorModelEventAttribute.cs @@ -4,47 +4,60 @@ using Microsoft.AspNetCore.Mvc.Filters; using Umbraco.Core; using Umbraco.Core.Security; using Umbraco.Web.Editors; -using Umbraco.Web.Security; namespace Umbraco.Web.BackOffice.Filters { /// /// Used to emit outgoing editor model events /// - internal sealed class OutgoingEditorModelEventAttribute : ActionFilterAttribute + internal sealed class OutgoingEditorModelEventAttribute : TypeFilterAttribute { - private readonly IUmbracoContextAccessor _umbracoContextAccessor; - private readonly IBackOfficeSecurityAccessor _backofficeSecurityAccessor; - - public OutgoingEditorModelEventAttribute(IUmbracoContextAccessor umbracoContextAccessor, IBackOfficeSecurityAccessor backofficeSecurityAccessor) + public OutgoingEditorModelEventAttribute() : base(typeof(OutgoingEditorModelEventFilter)) { - _umbracoContextAccessor = umbracoContextAccessor ?? throw new ArgumentNullException(nameof(umbracoContextAccessor)); - _backofficeSecurityAccessor = backofficeSecurityAccessor ?? throw new ArgumentNullException(nameof(backofficeSecurityAccessor)); } - public override void OnActionExecuted(ActionExecutedContext context) + + private class OutgoingEditorModelEventFilter : IResultFilter { - if (context.Result == null) return; - var umbracoContext = _umbracoContextAccessor.GetRequiredUmbracoContext(); - var user = _backofficeSecurityAccessor.BackOfficeSecurity.CurrentUser; - if (user == null) return; + private readonly IUmbracoContextAccessor _umbracoContextAccessor; - if (context.Result is ObjectResult objectContent) + private readonly IBackOfficeSecurityAccessor _backOfficeSecurityAccessor; + + public OutgoingEditorModelEventFilter( + IUmbracoContextAccessor umbracoContextAccessor, + IBackOfficeSecurityAccessor backOfficeSecurityAccessor) { - var model = objectContent.Value; + _umbracoContextAccessor = umbracoContextAccessor + ?? throw new ArgumentNullException(nameof(umbracoContextAccessor)); + _backOfficeSecurityAccessor = backOfficeSecurityAccessor + ?? throw new ArgumentNullException(nameof(backOfficeSecurityAccessor)); + } - if (model != null) + public void OnResultExecuted(ResultExecutedContext context) + { + if (context.Result == null) return; + + var umbracoContext = _umbracoContextAccessor.GetRequiredUmbracoContext(); + var user = _backOfficeSecurityAccessor.BackOfficeSecurity.CurrentUser; + if (user == null) return; + + if (context.Result is ObjectResult objectContent) { - var args = new EditorModelEventArgs( - model, - umbracoContext); - EditorModelEventManager.EmitEvent(context, args); - objectContent.Value = args.Model; + var model = objectContent.Value; + + if (model != null) + { + var args = new EditorModelEventArgs(model, umbracoContext); + EditorModelEventManager.EmitEvent(context, args); + objectContent.Value = args.Model; + } } } - base.OnActionExecuted(context); + public void OnResultExecuting(ResultExecutingContext context) + { + } } } } From 826e5a9bad94a8dd30a598d275e8ff5b3f30eb94 Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 3 Dec 2020 13:32:04 +0000 Subject: [PATCH 8/9] Update to match new rules. And fix dup usings --- .../IUmbracoBuilder.cs | 2 +- .../UmbracoBuilder.Events.cs | 9 ++-- .../UmbracoBuilder.cs | 9 ++-- .../Events/EventAggregator.Notifications.cs | 16 +++--- src/Umbraco.Core/Events/EventAggregator.cs | 21 ++++---- src/Umbraco.Core/Events/IEventAggregator.cs | 16 ++++-- src/Umbraco.Tests.Integration/RuntimeTests.cs | 22 ++------ .../UmbracoBuilderExtensions.cs | 6 +-- .../Testing/UmbracoIntegrationTest.cs | 49 ++++++++--------- .../Umbraco.Core/Components/ComponentTests.cs | 53 +++++++++++-------- .../Composing/CollectionBuildersTests.cs | 10 ++-- .../Events/EventAggregatorTests.cs | 20 +++---- .../Extensions/UmbracoBuilderExtensions.cs | 6 +-- .../AuthenticationBuilderExtensions.cs | 4 +- .../Builder/UmbracoBuilderExtensions.cs | 24 +++++---- 15 files changed, 138 insertions(+), 129 deletions(-) rename src/Umbraco.Core/{Builder => DependencyInjection}/IUmbracoBuilder.cs (91%) rename src/Umbraco.Core/{Builder => DependencyInjection}/UmbracoBuilder.Events.cs (87%) rename src/Umbraco.Core/{Builder => DependencyInjection}/UmbracoBuilder.cs (95%) diff --git a/src/Umbraco.Core/Builder/IUmbracoBuilder.cs b/src/Umbraco.Core/DependencyInjection/IUmbracoBuilder.cs similarity index 91% rename from src/Umbraco.Core/Builder/IUmbracoBuilder.cs rename to src/Umbraco.Core/DependencyInjection/IUmbracoBuilder.cs index d1bd991ef5..f532f8cdaa 100644 --- a/src/Umbraco.Core/Builder/IUmbracoBuilder.cs +++ b/src/Umbraco.Core/DependencyInjection/IUmbracoBuilder.cs @@ -1,4 +1,4 @@ -using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Umbraco.Core.Composing; diff --git a/src/Umbraco.Core/Builder/UmbracoBuilder.Events.cs b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.Events.cs similarity index 87% rename from src/Umbraco.Core/Builder/UmbracoBuilder.Events.cs rename to src/Umbraco.Core/DependencyInjection/UmbracoBuilder.Events.cs index 8a555d58dd..a21ae74976 100644 --- a/src/Umbraco.Core/Builder/UmbracoBuilder.Events.cs +++ b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.Events.cs @@ -1,15 +1,18 @@ -using Microsoft.Extensions.DependencyInjection; +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using Microsoft.Extensions.DependencyInjection; using Umbraco.Core.Events; namespace Umbraco.Core.DependencyInjection { /// - /// Contains extensions methods for . + /// Contains extensions methods for used for registering event handlers. /// public static partial class UmbracoBuilderExtensions { /// - /// Registers a notification handler against the Umbraco service collection. + /// Registers a notification handler against the Umbraco service collection. /// /// The type of notification. /// The type of notificiation handler. diff --git a/src/Umbraco.Core/Builder/UmbracoBuilder.cs b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs similarity index 95% rename from src/Umbraco.Core/Builder/UmbracoBuilder.cs rename to src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs index 9579d22a76..d56712cdcf 100644 --- a/src/Umbraco.Core/Builder/UmbracoBuilder.cs +++ b/src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs @@ -1,9 +1,12 @@ -using Microsoft.Extensions.Configuration; +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System; +using System.Collections.Generic; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; -using System; -using System.Collections.Generic; using Umbraco.Core.Composing; using Umbraco.Core.Events; diff --git a/src/Umbraco.Core/Events/EventAggregator.Notifications.cs b/src/Umbraco.Core/Events/EventAggregator.Notifications.cs index 1e6bf9901f..00982b52d7 100644 --- a/src/Umbraco.Core/Events/EventAggregator.Notifications.cs +++ b/src/Umbraco.Core/Events/EventAggregator.Notifications.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; @@ -12,13 +15,13 @@ namespace Umbraco.Core.Events /// public partial class EventAggregator : IEventAggregator { - private static readonly ConcurrentDictionary NotificationHandlers + private static readonly ConcurrentDictionary s_notificationHandlers = new ConcurrentDictionary(); private Task PublishNotificationAsync(INotification notification, CancellationToken cancellationToken = default) { - var notificationType = notification.GetType(); - var handler = NotificationHandlers.GetOrAdd( + Type notificationType = notification.GetType(); + NotificationHandlerWrapper handler = s_notificationHandlers.GetOrAdd( notificationType, t => (NotificationHandlerWrapper)Activator.CreateInstance(typeof(NotificationHandlerWrapperImpl<>).MakeGenericType(notificationType))); @@ -27,9 +30,10 @@ namespace Umbraco.Core.Events private async Task PublishCoreAsync( IEnumerable> allHandlers, - INotification notification, CancellationToken cancellationToken) + INotification notification, + CancellationToken cancellationToken) { - foreach (var handler in allHandlers) + foreach (Func handler in allHandlers) { await handler(notification, cancellationToken).ConfigureAwait(false); } diff --git a/src/Umbraco.Core/Events/EventAggregator.cs b/src/Umbraco.Core/Events/EventAggregator.cs index 384cb1f9ff..8d58175da4 100644 --- a/src/Umbraco.Core/Events/EventAggregator.cs +++ b/src/Umbraco.Core/Events/EventAggregator.cs @@ -1,10 +1,21 @@ -using System; +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; namespace Umbraco.Core.Events { + /// + /// A factory method used to resolve all services. + /// For multiple instances, it will resolve against . + /// + /// Type of service to resolve. + /// An instance of type . + public delegate object ServiceFactory(Type serviceType); + /// public partial class EventAggregator : IEventAggregator { @@ -31,14 +42,6 @@ namespace Umbraco.Core.Events } } - /// - /// A factory method used to resolve all services. - /// For multiple instances, it will resolve against . - /// - /// Type of service to resolve. - /// An instance of type . - public delegate object ServiceFactory(Type serviceType); - /// /// Extensions for . /// diff --git a/src/Umbraco.Core/Events/IEventAggregator.cs b/src/Umbraco.Core/Events/IEventAggregator.cs index fd8005aef8..bd01ad0b57 100644 --- a/src/Umbraco.Core/Events/IEventAggregator.cs +++ b/src/Umbraco.Core/Events/IEventAggregator.cs @@ -1,4 +1,7 @@ -using System.Threading; +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Threading; using System.Threading.Tasks; namespace Umbraco.Core.Events @@ -14,7 +17,7 @@ namespace Umbraco.Core.Events /// /// The type of notification being handled. /// The notification object. - /// An optional cancellation token + /// An optional cancellation token. /// A task that represents the publish operation. Task PublishAsync(TNotification notification, CancellationToken cancellationToken = default) where TNotification : INotification; @@ -23,10 +26,12 @@ namespace Umbraco.Core.Events /// /// A marker interface to represent a notification. /// - public interface INotification { } + public interface INotification + { + } /// - /// Defines a handler for a notification + /// Defines a handler for a notification. /// /// The type of notification being handled. public interface INotificationHandler @@ -36,7 +41,8 @@ namespace Umbraco.Core.Events /// Handles a notification /// /// The notification - /// Cancellation token + /// The cancellation token. + /// A representing the asynchronous operation. Task HandleAsync(TNotification notification, CancellationToken cancellationToken); } } diff --git a/src/Umbraco.Tests.Integration/RuntimeTests.cs b/src/Umbraco.Tests.Integration/RuntimeTests.cs index e930e12b9c..77ee27b8c4 100644 --- a/src/Umbraco.Tests.Integration/RuntimeTests.cs +++ b/src/Umbraco.Tests.Integration/RuntimeTests.cs @@ -1,29 +1,17 @@ -using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Options; -using Moq; -using NUnit.Framework; using Microsoft.Extensions.Logging; +using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.DependencyInjection; using Umbraco.Core.Cache; using Umbraco.Core.Composing; -using Umbraco.Core.Configuration.Models; -using Umbraco.Core.Logging; -using Umbraco.Core.Persistence; -using Umbraco.Core.Persistence.Mappers; -using Umbraco.Core.Runtime; +using Umbraco.Core.DependencyInjection; using Umbraco.Extensions; -using Umbraco.Tests.Common; using Umbraco.Tests.Integration.Extensions; using Umbraco.Tests.Integration.Implementations; -using Umbraco.Tests.Integration.Testing; -using Umbraco.Core.DependencyInjection; namespace Umbraco.Tests.Integration { @@ -70,8 +58,8 @@ namespace Umbraco.Tests.Integration AppCaches.NoCache, hostContext.Configuration, testHelper.Profiler); - - var builder = new UmbracoBuilder(services, hostContext.Configuration, typeLoader, testHelper.ConsoleLoggerFactory); + + var builder = new UmbracoBuilder(services, hostContext.Configuration, typeLoader, testHelper.ConsoleLoggerFactory); builder.Services.AddUnique(AppCaches.NoCache); builder.AddConfiguration(); builder.AddUmbracoCore(); @@ -109,7 +97,7 @@ namespace Umbraco.Tests.Integration var webHostEnvironment = testHelper.GetWebHostEnvironment(); services.AddSingleton(testHelper.DbProviderFactoryCreator); services.AddRequiredNetCoreServices(testHelper, webHostEnvironment); - + // Add it! var typeLoader = services.AddTypeLoader( diff --git a/src/Umbraco.Tests.Integration/TestServerTest/UmbracoBuilderExtensions.cs b/src/Umbraco.Tests.Integration/TestServerTest/UmbracoBuilderExtensions.cs index 16cf6a35f4..0fcf47978a 100644 --- a/src/Umbraco.Tests.Integration/TestServerTest/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Tests.Integration/TestServerTest/UmbracoBuilderExtensions.cs @@ -1,11 +1,9 @@ -using Moq; +using Moq; using Umbraco.Core; -using Umbraco.Core.DependencyInjection; using Umbraco.Core.Cache; -using Umbraco.Core.Logging; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Runtime; using Umbraco.Tests.Integration.Implementations; -using Umbraco.Core.DependencyInjection; namespace Umbraco.Tests.Integration.TestServerTest { diff --git a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs index 6ab11c839c..a8875de286 100644 --- a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs +++ b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs @@ -1,41 +1,35 @@ -using System; -using System.Threading.Tasks; +using System; +using System.Collections.Generic; +using System.Data.Common; +using System.Data.SqlClient; +using System.IO; using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; +using Moq; using NUnit.Framework; +using Serilog; +using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Composing; -using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.Models; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.IO; -using Umbraco.Core.Logging; using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Mappers; +using Umbraco.Core.Runtime; using Umbraco.Core.Scoping; using Umbraco.Core.Strings; +using Umbraco.Extensions; using Umbraco.Tests.Common.Builders; using Umbraco.Tests.Integration.Extensions; using Umbraco.Tests.Integration.Implementations; -using Umbraco.Extensions; using Umbraco.Tests.Testing; using Umbraco.Web; -using Umbraco.Core.Runtime; -using Umbraco.Core; -using Moq; -using System.Collections.Generic; -using Microsoft.Extensions.Configuration; -using System.Data.SqlClient; -using System.Data.Common; -using System.Diagnostics; -using System.IO; -using Umbraco.Core.Configuration.Models; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; -using Serilog; -using Umbraco.Core.DependencyInjection; -using Umbraco.Core.DependencyInjection; -using ConnectionStrings = Umbraco.Core.Configuration.Models.ConnectionStrings; namespace Umbraco.Tests.Integration.Testing { @@ -65,7 +59,8 @@ namespace Umbraco.Tests.Integration.Testing [OneTimeTearDown] public void FixtureTearDown() { - foreach (var a in _fixtureTeardown) a(); + foreach (var a in _fixtureTeardown) + a(); } [TearDown] @@ -73,7 +68,8 @@ namespace Umbraco.Tests.Integration.Testing { if (_testTeardown != null) { - foreach (var a in _testTeardown) a(); + foreach (var a in _testTeardown) + a(); } _testTeardown = null; FirstTestInFixture = false; @@ -161,7 +157,7 @@ namespace Umbraco.Tests.Integration.Testing }); return hostBuilder; } - + #endregion #region IStartup @@ -275,7 +271,8 @@ namespace Umbraco.Tests.Integration.Testing { lock (_dbLocker) { - if (_dbInstance != null) return _dbInstance; + if (_dbInstance != null) + return _dbInstance; var localDb = new LocalDb(); if (localDb.IsAvailable == false) diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs index 588d5d1f24..44aacab944 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Components/ComponentTests.cs @@ -1,19 +1,19 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; using Moq; using NUnit.Framework; using Umbraco.Core; -using Umbraco.Core.DependencyInjection; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Configuration.Models; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.Hosting; using Umbraco.Core.IO; using Umbraco.Core.Logging; @@ -21,7 +21,6 @@ using Umbraco.Core.Persistence; using Umbraco.Core.Persistence.Mappers; using Umbraco.Core.Scoping; using Umbraco.Tests.TestHelpers; -using Umbraco.Core.DependencyInjection; namespace Umbraco.Tests.UnitTests.Umbraco.Core.Components { @@ -49,12 +48,12 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Components var mediaFileSystem = Mock.Of(); var p = new ScopeProvider(f, fs, Options.Create(coreDebug), mediaFileSystem, loggerFactory.CreateLogger(), loggerFactory, typeFinder, NoAppCache.Instance); - mock.Setup(x => x.GetService(typeof (ILogger))).Returns(logger); + mock.Setup(x => x.GetService(typeof(ILogger))).Returns(logger); mock.Setup(x => x.GetService(typeof(ILogger))).Returns(loggerFactory.CreateLogger); mock.Setup(x => x.GetService(typeof(ILoggerFactory))).Returns(loggerFactory); - mock.Setup(x => x.GetService(typeof (IProfilingLogger))).Returns(new ProfilingLogger(loggerFactory.CreateLogger(), Mock.Of())); - mock.Setup(x => x.GetService(typeof (IUmbracoDatabaseFactory))).Returns(f); - mock.Setup(x => x.GetService(typeof (IScopeProvider))).Returns(p); + mock.Setup(x => x.GetService(typeof(IProfilingLogger))).Returns(new ProfilingLogger(loggerFactory.CreateLogger(), Mock.Of())); + mock.Setup(x => x.GetService(typeof(IUmbracoDatabaseFactory))).Returns(f); + mock.Setup(x => x.GetService(typeof(IScopeProvider))).Returns(p); setup?.Invoke(mock); return mock.Object; @@ -94,11 +93,16 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Components m.Setup(x => x.GetService(It.Is(t => t == typeof(ISomeResource)))).Returns(() => new SomeResource()); m.Setup(x => x.GetService(It.IsAny())).Returns((type) => { - if (type == typeof(Composer1)) return new Composer1(); - if (type == typeof(Composer5)) return new Composer5(); - if (type == typeof(Component5)) return new Component5(new SomeResource()); - if (type == typeof(IProfilingLogger)) return new ProfilingLogger(Mock.Of>(), Mock.Of()); - if (type == typeof(ILogger)) return Mock.Of>(); + if (type == typeof(Composer1)) + return new Composer1(); + if (type == typeof(Composer5)) + return new Composer5(); + if (type == typeof(Component5)) + return new Component5(new SomeResource()); + if (type == typeof(IProfilingLogger)) + return new ProfilingLogger(Mock.Of>(), Mock.Of()); + if (type == typeof(ILogger)) + return Mock.Of>(); throw new NotSupportedException(type.FullName); }); }); @@ -213,16 +217,23 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Components var typeLoader = MockTypeLoader(); var factory = MockFactory(m => { - m.Setup(x => x.GetService(It.Is(t => t == typeof (ISomeResource)))).Returns(() => new SomeResource()); + m.Setup(x => x.GetService(It.Is(t => t == typeof(ISomeResource)))).Returns(() => new SomeResource()); m.Setup(x => x.GetService(It.IsAny())).Returns((type) => { - if (type == typeof(Composer1)) return new Composer1(); - if (type == typeof(Composer5)) return new Composer5(); - if (type == typeof(Composer5a)) return new Composer5a(); - if (type == typeof(Component5)) return new Component5(new SomeResource()); - if (type == typeof(Component5a)) return new Component5a(); - if (type == typeof(IProfilingLogger)) return new ProfilingLogger(Mock.Of>(), Mock.Of()); - if (type == typeof(ILogger)) return Mock.Of>(); + if (type == typeof(Composer1)) + return new Composer1(); + if (type == typeof(Composer5)) + return new Composer5(); + if (type == typeof(Composer5a)) + return new Composer5a(); + if (type == typeof(Component5)) + return new Component5(new SomeResource()); + if (type == typeof(Component5a)) + return new Component5a(); + if (type == typeof(IProfilingLogger)) + return new ProfilingLogger(Mock.Of>(), Mock.Of()); + if (type == typeof(ILogger)) + return Mock.Of>(); throw new NotSupportedException(type.FullName); }); }); diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/CollectionBuildersTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/CollectionBuildersTests.cs index 5de3928486..b4131ca790 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/CollectionBuildersTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Composing/CollectionBuildersTests.cs @@ -1,18 +1,14 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Moq; using NUnit.Framework; -using Umbraco.Core; -using Umbraco.Core.DependencyInjection; -using Umbraco.Core.Cache; using Umbraco.Core.Composing; -using Umbraco.Core.Logging; +using Umbraco.Core.DependencyInjection; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.UnitTests.TestHelpers; -using Umbraco.Core.DependencyInjection; namespace Umbraco.Tests.UnitTests.Umbraco.Core.Composing { @@ -128,7 +124,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Composing //builder.Append(); // does not compile Assert.Throws(() => - builder.Append(new[] { typeof (Resolved4) }) // throws + builder.Append(new[] { typeof(Resolved4) }) // throws ); } diff --git a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Events/EventAggregatorTests.cs b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Events/EventAggregatorTests.cs index 84626612d9..08d78af59e 100644 --- a/src/Umbraco.Tests.UnitTests/Umbraco.Core/Events/EventAggregatorTests.cs +++ b/src/Umbraco.Tests.UnitTests/Umbraco.Core/Events/EventAggregatorTests.cs @@ -1,9 +1,12 @@ -using Microsoft.Extensions.Configuration; +// Copyright (c) Umbraco. +// See LICENSE for more details. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Moq; using NUnit.Framework; -using System.Threading; -using System.Threading.Tasks; using Umbraco.Core.DependencyInjection; using Umbraco.Core.Events; using Umbraco.Tests.TestHelpers; @@ -20,7 +23,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Events [SetUp] public void Setup() { - var register = TestHelper.GetServiceCollection(); + IServiceCollection register = TestHelper.GetServiceCollection(); _builder = new UmbracoBuilder(register, Mock.Of(), TestHelper.GetMockedTypeLoader()); } @@ -31,10 +34,10 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Events _builder.AddNotificationHandler(); _builder.AddNotificationHandler(); _builder.AddNotificationHandler(); - var provider = _builder.Services.BuildServiceProvider(); + ServiceProvider provider = _builder.Services.BuildServiceProvider(); var notification = new Notification(); - var aggregator = provider.GetService(); + IEventAggregator aggregator = provider.GetService(); await aggregator.PublishAsync(notification); Assert.AreEqual(A + B + C, notification.SubscriberCount); @@ -78,10 +81,7 @@ namespace Umbraco.Tests.UnitTests.Umbraco.Core.Events public class Adder { - public int Add(int a, int b) - { - return a + b; - } + public int Add(int a, int b) => a + b; } } } diff --git a/src/Umbraco.Web.BackOffice/Extensions/UmbracoBuilderExtensions.cs b/src/Umbraco.Web.BackOffice/Extensions/UmbracoBuilderExtensions.cs index 94f8577fa6..79c7a9d29a 100644 --- a/src/Umbraco.Web.BackOffice/Extensions/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Web.BackOffice/Extensions/UmbracoBuilderExtensions.cs @@ -1,11 +1,9 @@ -using System; +using System; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.Extensions.DependencyInjection; -using Microsoft.VisualBasic; using Umbraco.Core.DependencyInjection; using Umbraco.Web.BackOffice.Filters; using Umbraco.Web.BackOffice.Security; -using Umbraco.Core.DependencyInjection; namespace Umbraco.Extensions { @@ -36,7 +34,7 @@ namespace Umbraco.Extensions builder.Services .AddAuthentication() // This just creates a builder, nothing more - // Add our custom schemes which are cookie handlers + // Add our custom schemes which are cookie handlers .AddCookie(Core.Constants.Security.BackOfficeAuthenticationType) .AddCookie(Core.Constants.Security.BackOfficeExternalAuthenticationType, o => { diff --git a/src/Umbraco.Web.BackOffice/Security/AuthenticationBuilderExtensions.cs b/src/Umbraco.Web.BackOffice/Security/AuthenticationBuilderExtensions.cs index e2a7aeccaf..9949018d43 100644 --- a/src/Umbraco.Web.BackOffice/Security/AuthenticationBuilderExtensions.cs +++ b/src/Umbraco.Web.BackOffice/Security/AuthenticationBuilderExtensions.cs @@ -1,5 +1,5 @@ -using System; -using Umbraco.Core.Builder; +using System; +using Umbraco.Core.DependencyInjection; namespace Umbraco.Web.BackOffice.Security { diff --git a/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs b/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs index d69d886785..3bf4e9059b 100644 --- a/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs +++ b/src/Umbraco.Web.Common/Builder/UmbracoBuilderExtensions.cs @@ -1,18 +1,17 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Server.Kestrel.Core; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; using System; -using System.Collections.Generic; using System.Data.Common; using System.Data.SqlClient; using System.IO; using System.Reflection; using System.Runtime.InteropServices; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ApplicationModels; +using Microsoft.AspNetCore.Server.Kestrel.Core; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; @@ -20,12 +19,12 @@ using Serilog; using Smidge; using Smidge.Nuglify; using Umbraco.Core; -using Umbraco.Core.DependencyInjection; using Umbraco.Core.Cache; using Umbraco.Core.Composing; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.Models; using Umbraco.Core.Configuration.Models.Validation; +using Umbraco.Core.DependencyInjection; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Persistence; @@ -52,8 +51,10 @@ namespace Umbraco.Core.DependencyInjection IWebHostEnvironment webHostEnvironment, IConfiguration config) { - if (services is null) throw new ArgumentNullException(nameof(services)); - if (config is null) throw new ArgumentNullException(nameof(config)); + if (services is null) + throw new ArgumentNullException(nameof(services)); + if (config is null) + throw new ArgumentNullException(nameof(config)); var loggingConfig = new LoggingConfiguration(Path.Combine(webHostEnvironment.ContentRootPath, "umbraco", "logs")); @@ -79,7 +80,8 @@ namespace Umbraco.Core.DependencyInjection /// Composes Composers public static IUmbracoBuilder AddUmbracoCore(this IUmbracoBuilder builder) { - if (builder is null) throw new ArgumentNullException(nameof(builder)); + if (builder is null) + throw new ArgumentNullException(nameof(builder)); builder.Services.AddLazySupport(); From 946a4abc750a34e978fc0868ce403ba30f9b3e9e Mon Sep 17 00:00:00 2001 From: Matthew Wise Date: Thu, 3 Dec 2020 16:49:09 +0000 Subject: [PATCH 9/9] changed IResultFilter to IActionFilter --- .../Filters/EditorModelEventManager.cs | 22 +++++++++---------- .../OutgoingEditorModelEventAttribute.cs | 8 +++---- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Umbraco.Web.BackOffice/Filters/EditorModelEventManager.cs b/src/Umbraco.Web.BackOffice/Filters/EditorModelEventManager.cs index 617e2804c5..d1856ee7d9 100644 --- a/src/Umbraco.Web.BackOffice/Filters/EditorModelEventManager.cs +++ b/src/Umbraco.Web.BackOffice/Filters/EditorModelEventManager.cs @@ -12,38 +12,38 @@ namespace Umbraco.Web.BackOffice.Filters /// public sealed class EditorModelEventManager { - public static event TypedEventHandler> SendingContentModel; - public static event TypedEventHandler> SendingMediaModel; - public static event TypedEventHandler> SendingMemberModel; - public static event TypedEventHandler> SendingUserModel; + public static event TypedEventHandler> SendingContentModel; + public static event TypedEventHandler> SendingMediaModel; + public static event TypedEventHandler> SendingMemberModel; + public static event TypedEventHandler> SendingUserModel; - public static event TypedEventHandler>>> SendingDashboardSlimModel; + public static event TypedEventHandler>>> SendingDashboardSlimModel; - private static void OnSendingDashboardModel(ResultExecutedContext sender, EditorModelEventArgs>> e) + private static void OnSendingDashboardModel(ActionExecutedContext sender, EditorModelEventArgs>> e) { var handler = SendingDashboardSlimModel; handler?.Invoke(sender, e); } - private static void OnSendingUserModel(ResultExecutedContext sender, EditorModelEventArgs e) + private static void OnSendingUserModel(ActionExecutedContext sender, EditorModelEventArgs e) { var handler = SendingUserModel; handler?.Invoke(sender, e); } - private static void OnSendingContentModel(ResultExecutedContext sender, EditorModelEventArgs e) + private static void OnSendingContentModel(ActionExecutedContext sender, EditorModelEventArgs e) { var handler = SendingContentModel; handler?.Invoke(sender, e); } - private static void OnSendingMediaModel(ResultExecutedContext sender, EditorModelEventArgs e) + private static void OnSendingMediaModel(ActionExecutedContext sender, EditorModelEventArgs e) { var handler = SendingMediaModel; handler?.Invoke(sender, e); } - private static void OnSendingMemberModel(ResultExecutedContext sender, EditorModelEventArgs e) + private static void OnSendingMemberModel(ActionExecutedContext sender, EditorModelEventArgs e) { var handler = SendingMemberModel; handler?.Invoke(sender, e); @@ -54,7 +54,7 @@ namespace Umbraco.Web.BackOffice.Filters /// /// /// - internal static void EmitEvent(ResultExecutedContext sender, EditorModelEventArgs e) + internal static void EmitEvent(ActionExecutedContext sender, EditorModelEventArgs e) { if (e.Model is ContentItemDisplay) OnSendingContentModel(sender, new EditorModelEventArgs(e)); diff --git a/src/Umbraco.Web.BackOffice/Filters/OutgoingEditorModelEventAttribute.cs b/src/Umbraco.Web.BackOffice/Filters/OutgoingEditorModelEventAttribute.cs index 3cad31cdf7..4687d108a0 100644 --- a/src/Umbraco.Web.BackOffice/Filters/OutgoingEditorModelEventAttribute.cs +++ b/src/Umbraco.Web.BackOffice/Filters/OutgoingEditorModelEventAttribute.cs @@ -17,7 +17,7 @@ namespace Umbraco.Web.BackOffice.Filters } - private class OutgoingEditorModelEventFilter : IResultFilter + private class OutgoingEditorModelEventFilter : IActionFilter { private readonly IUmbracoContextAccessor _umbracoContextAccessor; @@ -34,7 +34,7 @@ namespace Umbraco.Web.BackOffice.Filters ?? throw new ArgumentNullException(nameof(backOfficeSecurityAccessor)); } - public void OnResultExecuted(ResultExecutedContext context) + public void OnActionExecuted(ActionExecutedContext context) { if (context.Result == null) return; @@ -54,8 +54,8 @@ namespace Umbraco.Web.BackOffice.Filters } } } - - public void OnResultExecuting(ResultExecutingContext context) + + public void OnActionExecuting(ActionExecutingContext context) { } }