From ed9a6d3f22deb9aef33ca2be5d3430567de66b85 Mon Sep 17 00:00:00 2001 From: Shannon Date: Mon, 25 Nov 2019 23:10:54 +1100 Subject: [PATCH] Moves culture dictionary implementation to Core instead of web since it has nothing to do with Web really, fixes tests # Conflicts: # src/Umbraco.Core/Persistence/Repositories/Implement/UserRepository.cs # src/Umbraco.Core/Runtime/CoreInitialComposer.cs # src/Umbraco.Web/Editors/AuthenticationController.cs # src/Umbraco.Web/Install/InstallSteps/NewInstallStep.cs --- .../Composing/CompositionExtensions/Services.cs | 1 + .../Dictionary/UmbracoCultureDictionary.cs | 5 ++--- .../Dictionary/UmbracoCultureDictionaryFactory.cs | 6 +++--- .../Repositories/Implement/UserRepository.cs | 4 ++-- src/Umbraco.Core/Runtime/CoreInitialComposer.cs | 3 +++ src/Umbraco.Core/Umbraco.Core.csproj | 2 ++ .../Models/Mapping/ContentWebModelMappingTests.cs | 3 --- src/Umbraco.Web/Runtime/WebFinalComposer.cs | 10 ---------- src/Umbraco.Web/Runtime/WebInitialComposer.cs | 3 --- src/Umbraco.Web/Umbraco.Web.csproj | 2 -- 10 files changed, 13 insertions(+), 26 deletions(-) rename src/{Umbraco.Web => Umbraco.Core}/Dictionary/UmbracoCultureDictionary.cs (97%) rename src/{Umbraco.Web => Umbraco.Core}/Dictionary/UmbracoCultureDictionaryFactory.cs (79%) diff --git a/src/Umbraco.Core/Composing/CompositionExtensions/Services.cs b/src/Umbraco.Core/Composing/CompositionExtensions/Services.cs index ba8442f8d7..b0cd80d93f 100644 --- a/src/Umbraco.Core/Composing/CompositionExtensions/Services.cs +++ b/src/Umbraco.Core/Composing/CompositionExtensions/Services.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using Umbraco.Core.Cache; using Umbraco.Core.Configuration; +using Umbraco.Core.Dictionary; using Umbraco.Core.Events; using Umbraco.Core.IO; using Umbraco.Core.Logging; diff --git a/src/Umbraco.Web/Dictionary/UmbracoCultureDictionary.cs b/src/Umbraco.Core/Dictionary/UmbracoCultureDictionary.cs similarity index 97% rename from src/Umbraco.Web/Dictionary/UmbracoCultureDictionary.cs rename to src/Umbraco.Core/Dictionary/UmbracoCultureDictionary.cs index f11b2dcfcb..b0690c944b 100644 --- a/src/Umbraco.Web/Dictionary/UmbracoCultureDictionary.cs +++ b/src/Umbraco.Core/Dictionary/UmbracoCultureDictionary.cs @@ -5,9 +5,8 @@ using System.Linq; using Umbraco.Core.Cache; using Umbraco.Core.Models; using Umbraco.Core.Services; -using Umbraco.Web.Composing; -namespace Umbraco.Web.Dictionary +namespace Umbraco.Core.Dictionary { /// @@ -18,7 +17,7 @@ namespace Umbraco.Web.Dictionary /// The ILocalizationService is the service used for interacting with this data from the database which isn't all that fast /// (even though there is caching involved, if there's lots of dictionary items the caching is not great) /// - public class DefaultCultureDictionary : Core.Dictionary.ICultureDictionary + public class DefaultCultureDictionary : ICultureDictionary { private readonly ILocalizationService _localizationService; private readonly IAppCache _requestCache; diff --git a/src/Umbraco.Web/Dictionary/UmbracoCultureDictionaryFactory.cs b/src/Umbraco.Core/Dictionary/UmbracoCultureDictionaryFactory.cs similarity index 79% rename from src/Umbraco.Web/Dictionary/UmbracoCultureDictionaryFactory.cs rename to src/Umbraco.Core/Dictionary/UmbracoCultureDictionaryFactory.cs index d66bd99f83..a2d1fa12d3 100644 --- a/src/Umbraco.Web/Dictionary/UmbracoCultureDictionaryFactory.cs +++ b/src/Umbraco.Core/Dictionary/UmbracoCultureDictionaryFactory.cs @@ -1,7 +1,7 @@ using Umbraco.Core.Cache; using Umbraco.Core.Services; -namespace Umbraco.Web.Dictionary +namespace Umbraco.Core.Dictionary { /// /// A culture dictionary factory used to create an Umbraco.Core.Dictionary.ICultureDictionary. @@ -9,7 +9,7 @@ namespace Umbraco.Web.Dictionary /// /// In the future this will allow use to potentially store dictionary items elsewhere and allows for maximum flexibility. /// - internal class DefaultCultureDictionaryFactory : Umbraco.Core.Dictionary.ICultureDictionaryFactory + internal class DefaultCultureDictionaryFactory : ICultureDictionaryFactory { private readonly ILocalizationService _localizationService; private readonly AppCaches _appCaches; @@ -20,7 +20,7 @@ namespace Umbraco.Web.Dictionary _appCaches = appCaches; } - public Umbraco.Core.Dictionary.ICultureDictionary CreateDictionary() + public ICultureDictionary CreateDictionary() { return new DefaultCultureDictionary(_localizationService, _appCaches.RequestCache); } diff --git a/src/Umbraco.Core/Persistence/Repositories/Implement/UserRepository.cs b/src/Umbraco.Core/Persistence/Repositories/Implement/UserRepository.cs index 96abc37662..cea1475d3a 100644 --- a/src/Umbraco.Core/Persistence/Repositories/Implement/UserRepository.cs +++ b/src/Umbraco.Core/Persistence/Repositories/Implement/UserRepository.cs @@ -44,8 +44,8 @@ namespace Umbraco.Core.Persistence.Repositories.Implement public UserRepository(IScopeAccessor scopeAccessor, AppCaches appCaches, ILogger logger, IMapperCollection mapperCollection, IGlobalSettings globalSettings) : base(scopeAccessor, appCaches, logger) { - _mapperCollection = mapperCollection; - _globalSettings = globalSettings; + _mapperCollection = mapperCollection ?? throw new ArgumentNullException(nameof(mapperCollection)); + _globalSettings = globalSettings ?? throw new ArgumentNullException(nameof(globalSettings)); } // for tests diff --git a/src/Umbraco.Core/Runtime/CoreInitialComposer.cs b/src/Umbraco.Core/Runtime/CoreInitialComposer.cs index 2ab0de14ce..72d16de608 100644 --- a/src/Umbraco.Core/Runtime/CoreInitialComposer.cs +++ b/src/Umbraco.Core/Runtime/CoreInitialComposer.cs @@ -4,6 +4,7 @@ using Umbraco.Core.Composing; using Umbraco.Core.Composing.CompositionExtensions; using Umbraco.Core.Configuration; using Umbraco.Core.Configuration.UmbracoSettings; +using Umbraco.Core.Dictionary; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Manifest; @@ -130,6 +131,8 @@ namespace Umbraco.Core.Runtime // by default, register a noop rebuilder composition.RegisterUnique(); + composition.SetCultureDictionaryFactory(); + composition.Register(f => f.GetInstance().CreateDictionary(), Lifetime.Singleton); } } } diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 00f9032bd7..e43b3c9861 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -147,6 +147,8 @@ + + diff --git a/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs b/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs index 9a47ad1b4a..66d3b570b0 100644 --- a/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs +++ b/src/Umbraco.Tests/Models/Mapping/ContentWebModelMappingTests.cs @@ -31,9 +31,6 @@ namespace Umbraco.Tests.Models.Mapping { base.Compose(); - Composition.RegisterUnique(f => Mock.Of()); - - Composition.Register(_ => Mock.Of()); Composition.ComposeFileSystems(); Composition.Register(_ => Mock.Of()); diff --git a/src/Umbraco.Web/Runtime/WebFinalComposer.cs b/src/Umbraco.Web/Runtime/WebFinalComposer.cs index f0178413a0..3f9fd2bbc4 100644 --- a/src/Umbraco.Web/Runtime/WebFinalComposer.cs +++ b/src/Umbraco.Web/Runtime/WebFinalComposer.cs @@ -10,15 +10,5 @@ namespace Umbraco.Web.Runtime [ComposeAfter(typeof(ICoreComposer))] public class WebFinalComposer : ComponentComposer { - - public override void Compose(Composition composition) - { - base.Compose(composition); - - // now that user composers have had a chance to register their own factory, we can add the result of the factory - // to the container. - composition.Register(f => f.GetInstance().CreateDictionary(), Lifetime.Singleton); - } - } } diff --git a/src/Umbraco.Web/Runtime/WebInitialComposer.cs b/src/Umbraco.Web/Runtime/WebInitialComposer.cs index 046b8381d2..a5e8aeb4ae 100644 --- a/src/Umbraco.Web/Runtime/WebInitialComposer.cs +++ b/src/Umbraco.Web/Runtime/WebInitialComposer.cs @@ -20,7 +20,6 @@ using Umbraco.Web.Cache; using Umbraco.Web.Composing.CompositionExtensions; using Umbraco.Web.ContentApps; using Umbraco.Web.Dashboards; -using Umbraco.Web.Dictionary; using Umbraco.Web.Editors; using Umbraco.Web.Features; using Umbraco.Web.HealthCheck; @@ -202,8 +201,6 @@ namespace Umbraco.Web.Runtime composition.RegisterUnique(); - composition.SetCultureDictionaryFactory(); - // register *all* checks, except those marked [HideFromTypeFinder] of course composition.WithCollectionBuilder() .Add(() => composition.TypeLoader.GetTypes()); diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index a732dfeb10..e980a3c894 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -1044,8 +1044,6 @@ - -