From fc1e4b182af1fe029fc9a9d7aae2fd23a4757396 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Wed, 6 Nov 2019 10:43:33 +0100 Subject: [PATCH 1/9] Move logging stuff --- .../Logging/DebugDiagnosticsLogger.cs | 21 ++++++++++------ .../Logging/IMessageTemplates.cs | 7 ++++++ .../Logging/LogProfiler.cs | 2 +- .../Logging/LoggingTaskExtension.cs | 0 .../Logging/VoidProfiler.cs | 2 +- src/Umbraco.Core/Composing/Current.cs | 2 +- src/Umbraco.Core/Logging/MessageTemplates.cs | 4 +-- src/Umbraco.Core/Umbraco.Core.csproj | 4 --- .../BulkInsertBenchmarks.cs | 2 +- .../Composing/TypeFinderTests.cs | 2 +- .../Migrations/AdvancedMigrationTests.cs | 10 ++++---- src/Umbraco.Tests/Models/ContentTests.cs | 4 +-- src/Umbraco.Tests/Models/ContentTypeTests.cs | 2 +- .../NPocoTests/NPocoBulkInsertTests.cs | 2 +- .../Runtimes/CoreRuntimeTests.cs | 2 +- src/Umbraco.Tests/Runtimes/StandaloneTests.cs | 4 +-- .../Scheduling/BackgroundTaskRunnerTests.cs | 2 +- .../Scheduling/BackgroundTaskRunnerTests2.cs | 4 +-- .../Services/ContentServicePerformanceTest.cs | 4 +-- .../Services/PerformanceTests.cs | 2 +- .../TestHelpers/ConsoleLogger.cs | 25 ++++++++++++------- src/Umbraco.Tests/Testing/UmbracoTestBase.cs | 2 +- 22 files changed, 63 insertions(+), 46 deletions(-) rename src/{Umbraco.Core => Umbraco.Abstractions}/Logging/DebugDiagnosticsLogger.cs (77%) create mode 100644 src/Umbraco.Abstractions/Logging/IMessageTemplates.cs rename src/{Umbraco.Core => Umbraco.Abstractions}/Logging/LogProfiler.cs (97%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Logging/LoggingTaskExtension.cs (100%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Logging/VoidProfiler.cs (92%) diff --git a/src/Umbraco.Core/Logging/DebugDiagnosticsLogger.cs b/src/Umbraco.Abstractions/Logging/DebugDiagnosticsLogger.cs similarity index 77% rename from src/Umbraco.Core/Logging/DebugDiagnosticsLogger.cs rename to src/Umbraco.Abstractions/Logging/DebugDiagnosticsLogger.cs index d1bde55306..552daba713 100644 --- a/src/Umbraco.Core/Logging/DebugDiagnosticsLogger.cs +++ b/src/Umbraco.Abstractions/Logging/DebugDiagnosticsLogger.cs @@ -7,6 +7,13 @@ namespace Umbraco.Core.Logging /// public class DebugDiagnosticsLogger : ILogger { + private readonly IMessageTemplates _messageTemplates; + + public DebugDiagnosticsLogger(IMessageTemplates messageTemplates) + { + _messageTemplates = messageTemplates; + } + public bool IsEnabled(Type reporting, LogLevel level) => true; @@ -31,7 +38,7 @@ namespace Umbraco.Core.Logging /// public void Fatal(Type reporting, Exception exception, string messageTemplate, params object[] propertyValues) { - System.Diagnostics.Debug.WriteLine(MessageTemplates.Render(messageTemplate, propertyValues) + Environment.NewLine + exception, reporting.FullName); + System.Diagnostics.Debug.WriteLine(_messageTemplates.Render(messageTemplate, propertyValues) + Environment.NewLine + exception, reporting.FullName); } /// @@ -61,7 +68,7 @@ namespace Umbraco.Core.Logging /// public void Error(Type reporting, Exception exception, string messageTemplate, params object[] propertyValues) { - System.Diagnostics.Debug.WriteLine(MessageTemplates.Render(messageTemplate, propertyValues) + Environment.NewLine + exception, reporting.FullName); + System.Diagnostics.Debug.WriteLine(_messageTemplates.Render(messageTemplate, propertyValues) + Environment.NewLine + exception, reporting.FullName); } /// @@ -79,7 +86,7 @@ namespace Umbraco.Core.Logging /// public void Warn(Type reporting, string message, params object[] propertyValues) { - System.Diagnostics.Debug.WriteLine(MessageTemplates.Render(message, propertyValues), reporting.FullName); + System.Diagnostics.Debug.WriteLine(_messageTemplates.Render(message, propertyValues), reporting.FullName); } /// @@ -91,7 +98,7 @@ namespace Umbraco.Core.Logging /// public void Warn(Type reporting, Exception exception, string message, params object[] propertyValues) { - System.Diagnostics.Debug.WriteLine(MessageTemplates.Render(message + Environment.NewLine + exception, propertyValues), reporting.FullName); + System.Diagnostics.Debug.WriteLine(_messageTemplates.Render(message + Environment.NewLine + exception, propertyValues), reporting.FullName); } /// @@ -103,7 +110,7 @@ namespace Umbraco.Core.Logging /// public void Info(Type reporting, string messageTemplate, params object[] propertyValues) { - System.Diagnostics.Debug.WriteLine(MessageTemplates.Render(messageTemplate, propertyValues), reporting.FullName); + System.Diagnostics.Debug.WriteLine(_messageTemplates.Render(messageTemplate, propertyValues), reporting.FullName); } /// @@ -115,7 +122,7 @@ namespace Umbraco.Core.Logging /// public void Debug(Type reporting, string messageTemplate, params object[] propertyValues) { - System.Diagnostics.Debug.WriteLine(MessageTemplates.Render(messageTemplate, propertyValues), reporting.FullName); + System.Diagnostics.Debug.WriteLine(_messageTemplates.Render(messageTemplate, propertyValues), reporting.FullName); } /// @@ -127,7 +134,7 @@ namespace Umbraco.Core.Logging /// public void Verbose(Type reporting, string messageTemplate, params object[] propertyValues) { - System.Diagnostics.Debug.WriteLine(MessageTemplates.Render(messageTemplate, propertyValues), reporting.FullName); + System.Diagnostics.Debug.WriteLine(_messageTemplates.Render(messageTemplate, propertyValues), reporting.FullName); } } } diff --git a/src/Umbraco.Abstractions/Logging/IMessageTemplates.cs b/src/Umbraco.Abstractions/Logging/IMessageTemplates.cs new file mode 100644 index 0000000000..60aa1035ad --- /dev/null +++ b/src/Umbraco.Abstractions/Logging/IMessageTemplates.cs @@ -0,0 +1,7 @@ +namespace Umbraco.Core.Logging +{ + public interface IMessageTemplates + { + string Render(string messageTemplate, params object[] args); + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Logging/LogProfiler.cs b/src/Umbraco.Abstractions/Logging/LogProfiler.cs similarity index 97% rename from src/Umbraco.Core/Logging/LogProfiler.cs rename to src/Umbraco.Abstractions/Logging/LogProfiler.cs index 74dae545b4..294f92dad3 100644 --- a/src/Umbraco.Core/Logging/LogProfiler.cs +++ b/src/Umbraco.Abstractions/Logging/LogProfiler.cs @@ -6,7 +6,7 @@ namespace Umbraco.Core.Logging /// /// Implements by writing profiling results to an . /// - internal class LogProfiler : IProfiler + public class LogProfiler : IProfiler { private readonly ILogger _logger; diff --git a/src/Umbraco.Core/Logging/LoggingTaskExtension.cs b/src/Umbraco.Abstractions/Logging/LoggingTaskExtension.cs similarity index 100% rename from src/Umbraco.Core/Logging/LoggingTaskExtension.cs rename to src/Umbraco.Abstractions/Logging/LoggingTaskExtension.cs diff --git a/src/Umbraco.Core/Logging/VoidProfiler.cs b/src/Umbraco.Abstractions/Logging/VoidProfiler.cs similarity index 92% rename from src/Umbraco.Core/Logging/VoidProfiler.cs rename to src/Umbraco.Abstractions/Logging/VoidProfiler.cs index 24eb8e81c3..51bec521a3 100644 --- a/src/Umbraco.Core/Logging/VoidProfiler.cs +++ b/src/Umbraco.Abstractions/Logging/VoidProfiler.cs @@ -2,7 +2,7 @@ namespace Umbraco.Core.Logging { - internal class VoidProfiler : IProfiler + public class VoidProfiler : IProfiler { private readonly VoidDisposable _disposable = new VoidDisposable(); diff --git a/src/Umbraco.Core/Composing/Current.cs b/src/Umbraco.Core/Composing/Current.cs index f12bf0dd63..ed64347816 100644 --- a/src/Umbraco.Core/Composing/Current.cs +++ b/src/Umbraco.Core/Composing/Current.cs @@ -113,7 +113,7 @@ namespace Umbraco.Core.Composing public static ILogger Logger => _logger ?? (_logger = _factory?.TryGetInstance() - ?? new DebugDiagnosticsLogger()); + ?? new DebugDiagnosticsLogger(new MessageTemplates())); public static IProfiler Profiler => _profiler ?? (_profiler = _factory?.TryGetInstance() diff --git a/src/Umbraco.Core/Logging/MessageTemplates.cs b/src/Umbraco.Core/Logging/MessageTemplates.cs index 47de1230ff..887aa1402d 100644 --- a/src/Umbraco.Core/Logging/MessageTemplates.cs +++ b/src/Umbraco.Core/Logging/MessageTemplates.cs @@ -11,7 +11,7 @@ namespace Umbraco.Core.Logging /// /// Provides tools to support message templates. /// - public static class MessageTemplates + public class MessageTemplates : IMessageTemplates { // Umbraco now uses Message Templates (https://messagetemplates.org/) for logging, which means // we cannot plainly use string.Format() to format them. There is a work-in-progress C# lib, @@ -21,7 +21,7 @@ namespace Umbraco.Core.Logging private static readonly Lazy MinimalLogger = new Lazy(() => new LoggerConfiguration().CreateLogger()); - public static string Render(string messageTemplate, params object[] args) + public string Render(string messageTemplate, params object[] args) { // by default, unless initialized otherwise, Log.Logger is SilentLogger which cannot bind message // templates. Log.Logger is set to a true Logger when initializing Umbraco's logger, but in case diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index d41240c586..25de78105f 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -572,13 +572,9 @@ - - - - diff --git a/src/Umbraco.Tests.Benchmarks/BulkInsertBenchmarks.cs b/src/Umbraco.Tests.Benchmarks/BulkInsertBenchmarks.cs index d6dc1f8c73..dc260c4a3b 100644 --- a/src/Umbraco.Tests.Benchmarks/BulkInsertBenchmarks.cs +++ b/src/Umbraco.Tests.Benchmarks/BulkInsertBenchmarks.cs @@ -49,7 +49,7 @@ namespace Umbraco.Tests.Benchmarks [GlobalSetup] public void Setup() { - var logger = new DebugDiagnosticsLogger(); + var logger = new DebugDiagnosticsLogger(new MessageTemplates()); var path = TestHelper.CurrentAssemblyDirectory; SetupSqlCe(path, logger); diff --git a/src/Umbraco.Tests/Composing/TypeFinderTests.cs b/src/Umbraco.Tests/Composing/TypeFinderTests.cs index ca622e9288..5511c5cba3 100644 --- a/src/Umbraco.Tests/Composing/TypeFinderTests.cs +++ b/src/Umbraco.Tests/Composing/TypeFinderTests.cs @@ -94,7 +94,7 @@ namespace Umbraco.Tests.Composing private static IProfilingLogger GetTestProfilingLogger() { - var logger = new DebugDiagnosticsLogger(); + var logger = new DebugDiagnosticsLogger(new MessageTemplates()); var profiler = new TestProfiler(); return new ProfilingLogger(logger, profiler); } diff --git a/src/Umbraco.Tests/Migrations/AdvancedMigrationTests.cs b/src/Umbraco.Tests/Migrations/AdvancedMigrationTests.cs index c13d141fa5..01c93a40ec 100644 --- a/src/Umbraco.Tests/Migrations/AdvancedMigrationTests.cs +++ b/src/Umbraco.Tests/Migrations/AdvancedMigrationTests.cs @@ -21,7 +21,7 @@ namespace Umbraco.Tests.Migrations [Test] public void CreateTableOfTDto() { - var logger = new DebugDiagnosticsLogger(); + var logger = new DebugDiagnosticsLogger(new MessageTemplates()); var builder = Mock.Of(); Mock.Get(builder) @@ -53,7 +53,7 @@ namespace Umbraco.Tests.Migrations [Test] public void DeleteKeysAndIndexesOfTDto() { - var logger = new DebugDiagnosticsLogger(); + var logger = new DebugDiagnosticsLogger(new MessageTemplates()); var builder = Mock.Of(); Mock.Get(builder) @@ -87,7 +87,7 @@ namespace Umbraco.Tests.Migrations [Test] public void CreateKeysAndIndexesOfTDto() { - var logger = new DebugDiagnosticsLogger(); + var logger = new DebugDiagnosticsLogger(new MessageTemplates()); var builder = Mock.Of(); Mock.Get(builder) @@ -124,7 +124,7 @@ namespace Umbraco.Tests.Migrations [Test] public void CreateKeysAndIndexes() { - var logger = new DebugDiagnosticsLogger(); + var logger = new DebugDiagnosticsLogger(new MessageTemplates()); var builder = Mock.Of(); Mock.Get(builder) @@ -161,7 +161,7 @@ namespace Umbraco.Tests.Migrations [Test] public void CreateColumn() { - var logger = new DebugDiagnosticsLogger(); + var logger = new DebugDiagnosticsLogger(new MessageTemplates()); var builder = Mock.Of(); Mock.Get(builder) diff --git a/src/Umbraco.Tests/Models/ContentTests.cs b/src/Umbraco.Tests/Models/ContentTests.cs index 3116087669..8dded05eab 100644 --- a/src/Umbraco.Tests/Models/ContentTests.cs +++ b/src/Umbraco.Tests/Models/ContentTests.cs @@ -55,7 +55,7 @@ namespace Umbraco.Tests.Models var mediaTypeService = Mock.Of(); var memberTypeService = Mock.Of(); Composition.Register(_ => ServiceContext.CreatePartial(dataTypeService: dataTypeService, contentTypeBaseServiceProvider: new ContentTypeBaseServiceProvider(_contentTypeService, mediaTypeService, memberTypeService))); - + } [Test] @@ -236,7 +236,7 @@ namespace Umbraco.Tests.Models private static IProfilingLogger GetTestProfilingLogger() { - var logger = new DebugDiagnosticsLogger(); + var logger = new DebugDiagnosticsLogger(new MessageTemplates()); var profiler = new TestProfiler(); return new ProfilingLogger(logger, profiler); } diff --git a/src/Umbraco.Tests/Models/ContentTypeTests.cs b/src/Umbraco.Tests/Models/ContentTypeTests.cs index 9c3b976bf3..74229dd5d6 100644 --- a/src/Umbraco.Tests/Models/ContentTypeTests.cs +++ b/src/Umbraco.Tests/Models/ContentTypeTests.cs @@ -129,7 +129,7 @@ namespace Umbraco.Tests.Models private static IProfilingLogger GetTestProfilingLogger() { - var logger = new DebugDiagnosticsLogger(); + var logger = new DebugDiagnosticsLogger(new MessageTemplates()); var profiler = new TestProfiler(); return new ProfilingLogger(logger, profiler); } diff --git a/src/Umbraco.Tests/Persistence/NPocoTests/NPocoBulkInsertTests.cs b/src/Umbraco.Tests/Persistence/NPocoTests/NPocoBulkInsertTests.cs index 2a6c1f4e12..85b07d4828 100644 --- a/src/Umbraco.Tests/Persistence/NPocoTests/NPocoBulkInsertTests.cs +++ b/src/Umbraco.Tests/Persistence/NPocoTests/NPocoBulkInsertTests.cs @@ -92,7 +92,7 @@ namespace Umbraco.Tests.Persistence.NPocoTests // create the db // prob not what we want, this is not a real database, but hey, the test is ignored anyways // we'll fix this when we have proper testing infrastructure - var dbSqlServer = TestObjects.GetUmbracoSqlServerDatabase(new DebugDiagnosticsLogger()); + var dbSqlServer = TestObjects.GetUmbracoSqlServerDatabase(new DebugDiagnosticsLogger(new MessageTemplates())); //drop the table dbSqlServer.Execute("DROP TABLE [umbracoServer]"); diff --git a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs index 5850153100..7cf3c008f1 100644 --- a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs +++ b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs @@ -89,7 +89,7 @@ namespace Umbraco.Tests.Runtimes // test runtime public class TestRuntime : CoreRuntime { - protected override ILogger GetLogger() => new DebugDiagnosticsLogger(); + protected override ILogger GetLogger() => new DebugDiagnosticsLogger(new MessageTemplates()); protected override IProfiler GetProfiler() => new TestProfiler(); // must override the database factory diff --git a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs index d0258a100f..fdeb743b6c 100644 --- a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs +++ b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs @@ -56,7 +56,7 @@ namespace Umbraco.Tests.Runtimes // FIXME: we need a better management of settings here (and, true config files?) // create the very basic and essential things we need - var logger = new ConsoleLogger(); + var logger = new ConsoleLogger(new MessageTemplates()); var profiler = new LogProfiler(logger); var profilingLogger = new ProfilingLogger(logger, profiler); var appCaches = new AppCaches(); // FIXME: has HttpRuntime stuff? @@ -244,7 +244,7 @@ namespace Umbraco.Tests.Runtimes // - assigning the factory to Current.Factory // create the very basic and essential things we need - var logger = new ConsoleLogger(); + var logger = new ConsoleLogger(new MessageTemplates()); var profiler = Mock.Of(); var profilingLogger = new ProfilingLogger(logger, profiler); var appCaches = AppCaches.Disabled; diff --git a/src/Umbraco.Tests/Scheduling/BackgroundTaskRunnerTests.cs b/src/Umbraco.Tests/Scheduling/BackgroundTaskRunnerTests.cs index 3664717af7..27abca7cbd 100644 --- a/src/Umbraco.Tests/Scheduling/BackgroundTaskRunnerTests.cs +++ b/src/Umbraco.Tests/Scheduling/BackgroundTaskRunnerTests.cs @@ -21,7 +21,7 @@ namespace Umbraco.Tests.Scheduling [OneTimeSetUp] public void InitializeFixture() { - _logger = new DebugDiagnosticsLogger(); + _logger = new DebugDiagnosticsLogger(new MessageTemplates()); } [Test] diff --git a/src/Umbraco.Tests/Scheduling/BackgroundTaskRunnerTests2.cs b/src/Umbraco.Tests/Scheduling/BackgroundTaskRunnerTests2.cs index 8e886d7dc9..6a65f3afbc 100644 --- a/src/Umbraco.Tests/Scheduling/BackgroundTaskRunnerTests2.cs +++ b/src/Umbraco.Tests/Scheduling/BackgroundTaskRunnerTests2.cs @@ -21,7 +21,7 @@ namespace Umbraco.Tests.Scheduling [Timeout(4000)] public async Task ThreadResumeIssue() { - var logger = new DebugDiagnosticsLogger(); + var logger = new DebugDiagnosticsLogger(new MessageTemplates()); var runner = new BackgroundTaskRunner(new BackgroundTaskRunnerOptions { KeepAlive = true, LongRunning = true }, logger); var work = new ThreadResumeIssueWorkItem(); runner.Add(work); @@ -76,7 +76,7 @@ namespace Umbraco.Tests.Scheduling [Ignore("Only runs in the debugger.")] public async Task DebuggerInterferenceIssue() { - var logger = new DebugDiagnosticsLogger(); + var logger = new DebugDiagnosticsLogger(new MessageTemplates()); var runner = new BackgroundTaskRunner(new BackgroundTaskRunnerOptions { KeepAlive = true, LongRunning = true }, logger); var taskCompleted = false; runner.TaskCompleted += (sender, args) => diff --git a/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs b/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs index ef80672baf..ace45fe356 100644 --- a/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs +++ b/src/Umbraco.Tests/Services/ContentServicePerformanceTest.cs @@ -47,7 +47,7 @@ namespace Umbraco.Tests.Services private static IProfilingLogger GetTestProfilingLogger() { - var logger = new DebugDiagnosticsLogger(); + var logger = new DebugDiagnosticsLogger(new MessageTemplates()); var profiler = new TestProfiler(); return new ProfilingLogger(logger, profiler); } @@ -268,7 +268,7 @@ namespace Umbraco.Tests.Services var tagRepo = new TagRepository((IScopeAccessor) provider, AppCaches.Disabled, Logger); var commonRepository = new ContentTypeCommonRepository((IScopeAccessor)provider, tRepository, AppCaches); var languageRepository = new LanguageRepository((IScopeAccessor)provider, AppCaches.Disabled, Logger); - var ctRepository = new ContentTypeRepository((IScopeAccessor) provider, AppCaches.Disabled, Logger, commonRepository, languageRepository); + var ctRepository = new ContentTypeRepository((IScopeAccessor) provider, AppCaches.Disabled, Logger, commonRepository, languageRepository); var repository = new DocumentRepository((IScopeAccessor) provider, AppCaches.Disabled, Logger, ctRepository, tRepository, tagRepo, languageRepository); // Act diff --git a/src/Umbraco.Tests/Services/PerformanceTests.cs b/src/Umbraco.Tests/Services/PerformanceTests.cs index 9cf38e1789..0ac6eeb863 100644 --- a/src/Umbraco.Tests/Services/PerformanceTests.cs +++ b/src/Umbraco.Tests/Services/PerformanceTests.cs @@ -60,7 +60,7 @@ namespace Umbraco.Tests.Services private static IProfilingLogger GetTestProfilingLogger() { - var logger = new DebugDiagnosticsLogger(); + var logger = new DebugDiagnosticsLogger(new MessageTemplates()); var profiler = new TestProfiler(); return new ProfilingLogger(logger, profiler); } diff --git a/src/Umbraco.Tests/TestHelpers/ConsoleLogger.cs b/src/Umbraco.Tests/TestHelpers/ConsoleLogger.cs index a3e36db363..53d6078e4b 100644 --- a/src/Umbraco.Tests/TestHelpers/ConsoleLogger.cs +++ b/src/Umbraco.Tests/TestHelpers/ConsoleLogger.cs @@ -5,6 +5,13 @@ namespace Umbraco.Tests.TestHelpers { public class ConsoleLogger : ILogger { + private readonly IMessageTemplates _messageTemplates; + + public ConsoleLogger(IMessageTemplates messageTemplates) + { + _messageTemplates = messageTemplates; + } + public bool IsEnabled(Type reporting, LogLevel level) => true; @@ -27,13 +34,13 @@ namespace Umbraco.Tests.TestHelpers public void Fatal(Type reporting, Exception exception, string messageTemplate, params object[] propertyValues) { - Console.WriteLine("FATAL {0} - {1}", reporting.Name, MessageTemplates.Render(messageTemplate, propertyValues)); + Console.WriteLine("FATAL {0} - {1}", reporting.Name, _messageTemplates.Render(messageTemplate, propertyValues)); Console.WriteLine(exception); } public void Fatal(Type reporting, string messageTemplate, params object[] propertyValues) { - Console.WriteLine("FATAL {0} - {1}", reporting.Name, MessageTemplates.Render(messageTemplate, propertyValues)); + Console.WriteLine("FATAL {0} - {1}", reporting.Name, _messageTemplates.Render(messageTemplate, propertyValues)); } public void Error(Type reporting, Exception exception, string message) @@ -55,13 +62,13 @@ namespace Umbraco.Tests.TestHelpers public void Error(Type reporting, Exception exception, string messageTemplate, params object[] propertyValues) { - Console.WriteLine("ERROR {0} - {1}", reporting.Name, MessageTemplates.Render(messageTemplate, propertyValues)); + Console.WriteLine("ERROR {0} - {1}", reporting.Name, _messageTemplates.Render(messageTemplate, propertyValues)); Console.WriteLine(exception); } public void Error(Type reporting, string messageTemplate, params object[] propertyValues) { - Console.WriteLine("ERROR {0} - {1}", reporting.Name, MessageTemplates.Render(messageTemplate, propertyValues)); + Console.WriteLine("ERROR {0} - {1}", reporting.Name, _messageTemplates.Render(messageTemplate, propertyValues)); } public void Warn(Type reporting, string message) @@ -71,7 +78,7 @@ namespace Umbraco.Tests.TestHelpers public void Warn(Type reporting, string message, params object[] propertyValues) { - Console.WriteLine("WARN {0} - {1}", reporting.Name, MessageTemplates.Render(message, propertyValues)); + Console.WriteLine("WARN {0} - {1}", reporting.Name, _messageTemplates.Render(message, propertyValues)); } public void Warn(Type reporting, Exception exception, string message) @@ -82,13 +89,13 @@ namespace Umbraco.Tests.TestHelpers public void Warn(Type reporting, Exception exception, string message, params object[] propertyValues) { - Console.WriteLine("WARN {0} - {1}", reporting.Name, MessageTemplates.Render(message, propertyValues)); + Console.WriteLine("WARN {0} - {1}", reporting.Name, _messageTemplates.Render(message, propertyValues)); Console.WriteLine(exception); } public void Info(Type reporting, string messageTemplate, params object[] propertyValues) { - Console.WriteLine("INFO {0} - {1}", reporting.Name, MessageTemplates.Render(messageTemplate, propertyValues)); + Console.WriteLine("INFO {0} - {1}", reporting.Name, _messageTemplates.Render(messageTemplate, propertyValues)); } public void Info(Type reporting, string message) @@ -103,7 +110,7 @@ namespace Umbraco.Tests.TestHelpers public void Debug(Type reporting, string messageTemplate, params object[] propertyValues) { - Console.WriteLine("DEBUG {0} - {1}", reporting.Name, MessageTemplates.Render(messageTemplate, propertyValues)); + Console.WriteLine("DEBUG {0} - {1}", reporting.Name, _messageTemplates.Render(messageTemplate, propertyValues)); } public void Verbose(Type reporting, string message) @@ -113,7 +120,7 @@ namespace Umbraco.Tests.TestHelpers public void Verbose(Type reporting, string messageTemplate, params object[] propertyValues) { - Console.WriteLine("VERBOSE {0} - {1}", reporting.Name, MessageTemplates.Render(messageTemplate, propertyValues)); + Console.WriteLine("VERBOSE {0} - {1}", reporting.Name, _messageTemplates.Render(messageTemplate, propertyValues)); } } } diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs index 7e72a5aefb..2f86bddb3b 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs @@ -190,7 +190,7 @@ namespace Umbraco.Tests.Testing profiler = new LogProfiler(logger); break; case UmbracoTestOptions.Logger.Console: - logger = new ConsoleLogger(); + logger = new ConsoleLogger(new MessageTemplates()); profiler = new LogProfiler(logger); break; default: From 8f4d4cb23f76e717c6356823c7ac58631f2be3d7 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Wed, 6 Nov 2019 10:56:11 +0100 Subject: [PATCH 2/9] Move a small part of current --- src/Umbraco.Abstractions/Composing/Current.cs | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/Umbraco.Abstractions/Composing/Current.cs diff --git a/src/Umbraco.Abstractions/Composing/Current.cs b/src/Umbraco.Abstractions/Composing/Current.cs new file mode 100644 index 0000000000..39a7f5c8be --- /dev/null +++ b/src/Umbraco.Abstractions/Composing/Current.cs @@ -0,0 +1,58 @@ +using System; +using Umbraco.Core.Logging; + +namespace Umbraco.Core.Composing +{ + /// + /// Provides a static service locator for most singletons. + /// + /// + /// This class is initialized with the container in UmbracoApplicationBase, + /// right after the container is created in UmbracoApplicationBase.HandleApplicationStart. + /// Obviously, this is a service locator, which some may consider an anti-pattern. And yet, + /// practically, it works. + /// + public static class CurrentCore + { + private static IFactory _factory; + + private static ILogger _logger; + private static IProfiler _profiler; + private static IProfilingLogger _profilingLogger; + + /// + /// Gets or sets the factory. + /// + public static IFactory Factory + { + get + { + if (_factory == null) throw new InvalidOperationException("No factory has been set."); + return _factory; + } + set + { + if (_factory != null) throw new InvalidOperationException("A factory has already been set."); + // if (_configs != null) throw new InvalidOperationException("Configs are unlocked."); + _factory = value; + } + } + + internal static bool HasFactory => _factory != null; + + #region Getters + + public static ILogger Logger + => _logger ?? (_logger = _factory?.TryGetInstance() ?? throw new Exception("TODO Fix")); //?? new DebugDiagnosticsLogger(new MessageTemplates())); + + public static IProfiler Profiler + => _profiler ?? (_profiler = _factory?.TryGetInstance() + ?? new LogProfiler(Logger)); + + public static IProfilingLogger ProfilingLogger + => _profilingLogger ?? (_profilingLogger = _factory?.TryGetInstance()) + ?? new ProfilingLogger(Logger, Profiler); + + #endregion + } +} From 934fa2748dce608bfe13fffb380b7fb3db41d65f Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Wed, 6 Nov 2019 13:35:34 +0100 Subject: [PATCH 3/9] Move events --- .../Composing/ComponentCollection.cs | 0 .../Composing/ComponentCollectionBuilder.cs | 0 src/Umbraco.Abstractions/Composing/Current.cs | 2 +- .../CancellableEnumerableObjectEventArgs.cs | 1 - ...ancellableObjectEventArgsOfTEventObject.cs | 0 .../Events/CopyEventArgs.cs | 0 .../Events/DeleteEventArgs.cs | 2 +- .../Events/DeleteRevisionsEventArgs.cs | 0 .../Events/EventExtensions.cs | 0 .../Events/MoveEventArgs.cs | 0 .../Events/NewEventArgs.cs | 0 .../Events/PublishEventArgs.cs | 0 .../Events/RecycleBinEventArgs.cs | 4 --- .../Events/RolesEventArgs.cs | 0 .../Events/RollbackEventArgs.cs | 0 .../Events/SaveEventArgs.cs | 0 .../Events/SendToPublishEventArgs.cs | 0 .../Events/TransientEventMessagesFactory.cs | 2 +- .../IIgnoreUserStartNodesConfig.cs | 2 +- .../Umbraco.Configuration.csproj | 31 +++++++++++++++++++ src/Umbraco.Core/ConfigsExtensions.cs | 2 +- .../Configuration/Grid/GridConfig.cs | 2 +- .../Configuration/Grid/GridEditorsConfig.cs | 4 +-- src/Umbraco.Core/Manifest/IManifestParser.cs | 23 ++++++++++++++ src/Umbraco.Core/Manifest/ManifestParser.cs | 6 ++-- .../IDataEditor.cs | 1 - .../ParameterEditorCollection.cs | 6 ++-- .../PropertyEditorCollection.cs | 6 ++-- .../Runtime/CoreInitialComposer.cs | 2 +- src/Umbraco.Core/Umbraco.Core.csproj | 25 +++------------ .../Manifest/ManifestParserTests.cs | 2 +- src/Umbraco.Tests/Testing/UmbracoTestBase.cs | 3 +- .../ContentAppFactoryCollectionBuilder.cs | 2 +- .../Dashboards/DashboardCollectionBuilder.cs | 2 +- .../Editors/BackOfficeController.cs | 4 +-- .../JavaScript/CssInitialization.cs | 4 +-- .../JavaScript/JsInitialization.cs | 4 +-- .../Sections/SectionCollectionBuilder.cs | 2 +- src/umbraco.sln | 6 ++++ 39 files changed, 94 insertions(+), 56 deletions(-) rename src/{Umbraco.Core => Umbraco.Abstractions}/Composing/ComponentCollection.cs (100%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Composing/ComponentCollectionBuilder.cs (100%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Events/CancellableEnumerableObjectEventArgs.cs (99%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Events/CancellableObjectEventArgsOfTEventObject.cs (100%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Events/CopyEventArgs.cs (100%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Events/DeleteEventArgs.cs (99%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Events/DeleteRevisionsEventArgs.cs (100%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Events/EventExtensions.cs (100%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Events/MoveEventArgs.cs (100%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Events/NewEventArgs.cs (100%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Events/PublishEventArgs.cs (100%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Events/RecycleBinEventArgs.cs (95%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Events/RolesEventArgs.cs (100%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Events/RollbackEventArgs.cs (100%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Events/SaveEventArgs.cs (100%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Events/SendToPublishEventArgs.cs (100%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Events/TransientEventMessagesFactory.cs (81%) rename src/{Umbraco.Core => Umbraco.Abstractions}/PropertyEditors/IIgnoreUserStartNodesConfig.cs (82%) create mode 100644 src/Umbraco.Configuration/Umbraco.Configuration.csproj create mode 100644 src/Umbraco.Core/Manifest/IManifestParser.cs rename src/Umbraco.Core/{PropertyEditors => Models}/IDataEditor.cs (99%) diff --git a/src/Umbraco.Core/Composing/ComponentCollection.cs b/src/Umbraco.Abstractions/Composing/ComponentCollection.cs similarity index 100% rename from src/Umbraco.Core/Composing/ComponentCollection.cs rename to src/Umbraco.Abstractions/Composing/ComponentCollection.cs diff --git a/src/Umbraco.Core/Composing/ComponentCollectionBuilder.cs b/src/Umbraco.Abstractions/Composing/ComponentCollectionBuilder.cs similarity index 100% rename from src/Umbraco.Core/Composing/ComponentCollectionBuilder.cs rename to src/Umbraco.Abstractions/Composing/ComponentCollectionBuilder.cs diff --git a/src/Umbraco.Abstractions/Composing/Current.cs b/src/Umbraco.Abstractions/Composing/Current.cs index 39a7f5c8be..9f8168f1a9 100644 --- a/src/Umbraco.Abstractions/Composing/Current.cs +++ b/src/Umbraco.Abstractions/Composing/Current.cs @@ -38,7 +38,7 @@ namespace Umbraco.Core.Composing } } - internal static bool HasFactory => _factory != null; + public static bool HasFactory => _factory != null; #region Getters diff --git a/src/Umbraco.Core/Events/CancellableEnumerableObjectEventArgs.cs b/src/Umbraco.Abstractions/Events/CancellableEnumerableObjectEventArgs.cs similarity index 99% rename from src/Umbraco.Core/Events/CancellableEnumerableObjectEventArgs.cs rename to src/Umbraco.Abstractions/Events/CancellableEnumerableObjectEventArgs.cs index 1d52d0d847..5ac77d6253 100644 --- a/src/Umbraco.Core/Events/CancellableEnumerableObjectEventArgs.cs +++ b/src/Umbraco.Abstractions/Events/CancellableEnumerableObjectEventArgs.cs @@ -6,7 +6,6 @@ namespace Umbraco.Core.Events { /// /// Represents event data, for events that support cancellation, and expose impacted objects. - /// /// The type of the exposed, impacted objects. public class CancellableEnumerableObjectEventArgs : CancellableObjectEventArgs>, IEquatable> { diff --git a/src/Umbraco.Core/Events/CancellableObjectEventArgsOfTEventObject.cs b/src/Umbraco.Abstractions/Events/CancellableObjectEventArgsOfTEventObject.cs similarity index 100% rename from src/Umbraco.Core/Events/CancellableObjectEventArgsOfTEventObject.cs rename to src/Umbraco.Abstractions/Events/CancellableObjectEventArgsOfTEventObject.cs diff --git a/src/Umbraco.Core/Events/CopyEventArgs.cs b/src/Umbraco.Abstractions/Events/CopyEventArgs.cs similarity index 100% rename from src/Umbraco.Core/Events/CopyEventArgs.cs rename to src/Umbraco.Abstractions/Events/CopyEventArgs.cs diff --git a/src/Umbraco.Core/Events/DeleteEventArgs.cs b/src/Umbraco.Abstractions/Events/DeleteEventArgs.cs similarity index 99% rename from src/Umbraco.Core/Events/DeleteEventArgs.cs rename to src/Umbraco.Abstractions/Events/DeleteEventArgs.cs index 07bbe562db..5be669886e 100644 --- a/src/Umbraco.Core/Events/DeleteEventArgs.cs +++ b/src/Umbraco.Abstractions/Events/DeleteEventArgs.cs @@ -100,7 +100,7 @@ namespace Umbraco.Core.Events public IEnumerable DeletedEntities { get => EventObject; - internal set => EventObject = value; + set => EventObject = value; } /// diff --git a/src/Umbraco.Core/Events/DeleteRevisionsEventArgs.cs b/src/Umbraco.Abstractions/Events/DeleteRevisionsEventArgs.cs similarity index 100% rename from src/Umbraco.Core/Events/DeleteRevisionsEventArgs.cs rename to src/Umbraco.Abstractions/Events/DeleteRevisionsEventArgs.cs diff --git a/src/Umbraco.Core/Events/EventExtensions.cs b/src/Umbraco.Abstractions/Events/EventExtensions.cs similarity index 100% rename from src/Umbraco.Core/Events/EventExtensions.cs rename to src/Umbraco.Abstractions/Events/EventExtensions.cs diff --git a/src/Umbraco.Core/Events/MoveEventArgs.cs b/src/Umbraco.Abstractions/Events/MoveEventArgs.cs similarity index 100% rename from src/Umbraco.Core/Events/MoveEventArgs.cs rename to src/Umbraco.Abstractions/Events/MoveEventArgs.cs diff --git a/src/Umbraco.Core/Events/NewEventArgs.cs b/src/Umbraco.Abstractions/Events/NewEventArgs.cs similarity index 100% rename from src/Umbraco.Core/Events/NewEventArgs.cs rename to src/Umbraco.Abstractions/Events/NewEventArgs.cs diff --git a/src/Umbraco.Core/Events/PublishEventArgs.cs b/src/Umbraco.Abstractions/Events/PublishEventArgs.cs similarity index 100% rename from src/Umbraco.Core/Events/PublishEventArgs.cs rename to src/Umbraco.Abstractions/Events/PublishEventArgs.cs diff --git a/src/Umbraco.Core/Events/RecycleBinEventArgs.cs b/src/Umbraco.Abstractions/Events/RecycleBinEventArgs.cs similarity index 95% rename from src/Umbraco.Core/Events/RecycleBinEventArgs.cs rename to src/Umbraco.Abstractions/Events/RecycleBinEventArgs.cs index 796952de98..3f0f3784a2 100644 --- a/src/Umbraco.Core/Events/RecycleBinEventArgs.cs +++ b/src/Umbraco.Abstractions/Events/RecycleBinEventArgs.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using Umbraco.Core.Models; namespace Umbraco.Core.Events { diff --git a/src/Umbraco.Core/Events/RolesEventArgs.cs b/src/Umbraco.Abstractions/Events/RolesEventArgs.cs similarity index 100% rename from src/Umbraco.Core/Events/RolesEventArgs.cs rename to src/Umbraco.Abstractions/Events/RolesEventArgs.cs diff --git a/src/Umbraco.Core/Events/RollbackEventArgs.cs b/src/Umbraco.Abstractions/Events/RollbackEventArgs.cs similarity index 100% rename from src/Umbraco.Core/Events/RollbackEventArgs.cs rename to src/Umbraco.Abstractions/Events/RollbackEventArgs.cs diff --git a/src/Umbraco.Core/Events/SaveEventArgs.cs b/src/Umbraco.Abstractions/Events/SaveEventArgs.cs similarity index 100% rename from src/Umbraco.Core/Events/SaveEventArgs.cs rename to src/Umbraco.Abstractions/Events/SaveEventArgs.cs diff --git a/src/Umbraco.Core/Events/SendToPublishEventArgs.cs b/src/Umbraco.Abstractions/Events/SendToPublishEventArgs.cs similarity index 100% rename from src/Umbraco.Core/Events/SendToPublishEventArgs.cs rename to src/Umbraco.Abstractions/Events/SendToPublishEventArgs.cs diff --git a/src/Umbraco.Core/Events/TransientEventMessagesFactory.cs b/src/Umbraco.Abstractions/Events/TransientEventMessagesFactory.cs similarity index 81% rename from src/Umbraco.Core/Events/TransientEventMessagesFactory.cs rename to src/Umbraco.Abstractions/Events/TransientEventMessagesFactory.cs index bd2e12dc17..7a0947c990 100644 --- a/src/Umbraco.Core/Events/TransientEventMessagesFactory.cs +++ b/src/Umbraco.Abstractions/Events/TransientEventMessagesFactory.cs @@ -3,7 +3,7 @@ /// /// A simple/default transient messages factory /// - internal class TransientEventMessagesFactory : IEventMessagesFactory + public class TransientEventMessagesFactory : IEventMessagesFactory { public EventMessages Get() { diff --git a/src/Umbraco.Core/PropertyEditors/IIgnoreUserStartNodesConfig.cs b/src/Umbraco.Abstractions/PropertyEditors/IIgnoreUserStartNodesConfig.cs similarity index 82% rename from src/Umbraco.Core/PropertyEditors/IIgnoreUserStartNodesConfig.cs rename to src/Umbraco.Abstractions/PropertyEditors/IIgnoreUserStartNodesConfig.cs index bef3f42f46..28ce8654c3 100644 --- a/src/Umbraco.Core/PropertyEditors/IIgnoreUserStartNodesConfig.cs +++ b/src/Umbraco.Abstractions/PropertyEditors/IIgnoreUserStartNodesConfig.cs @@ -3,7 +3,7 @@ /// /// Marker interface for any editor configuration that supports Ignoring user start nodes /// - internal interface IIgnoreUserStartNodesConfig + public interface IIgnoreUserStartNodesConfig { bool IgnoreUserStartNodes { get; set; } } diff --git a/src/Umbraco.Configuration/Umbraco.Configuration.csproj b/src/Umbraco.Configuration/Umbraco.Configuration.csproj new file mode 100644 index 0000000000..15c6ac263f --- /dev/null +++ b/src/Umbraco.Configuration/Umbraco.Configuration.csproj @@ -0,0 +1,31 @@ + + + + netstandard2.0 + + + + + + + + + + + + + + + + <_UnmanagedRegistrationCache Remove="obj\Umbraco.Configuration.csproj.UnmanagedRegistration.cache" /> + + + + + + + + + + + diff --git a/src/Umbraco.Core/ConfigsExtensions.cs b/src/Umbraco.Core/ConfigsExtensions.cs index d1672c6c7f..5699540389 100644 --- a/src/Umbraco.Core/ConfigsExtensions.cs +++ b/src/Umbraco.Core/ConfigsExtensions.cs @@ -46,7 +46,7 @@ namespace Umbraco.Core factory.GetInstance(), factory.GetInstance(), configDir, - factory.GetInstance(), + factory.GetInstance(), factory.GetInstance().Debug)); } } diff --git a/src/Umbraco.Core/Configuration/Grid/GridConfig.cs b/src/Umbraco.Core/Configuration/Grid/GridConfig.cs index 9aead74886..9691c749df 100644 --- a/src/Umbraco.Core/Configuration/Grid/GridConfig.cs +++ b/src/Umbraco.Core/Configuration/Grid/GridConfig.cs @@ -7,7 +7,7 @@ namespace Umbraco.Core.Configuration.Grid { class GridConfig : IGridConfig { - public GridConfig(ILogger logger, AppCaches appCaches, DirectoryInfo configFolder, ManifestParser manifestParser, bool isDebug) + public GridConfig(ILogger logger, AppCaches appCaches, DirectoryInfo configFolder, IManifestParser manifestParser, bool isDebug) { EditorsConfig = new GridEditorsConfig(logger, appCaches, configFolder, manifestParser, isDebug); } diff --git a/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs b/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs index d434da8c70..cab58a6d63 100644 --- a/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs +++ b/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs @@ -13,10 +13,10 @@ namespace Umbraco.Core.Configuration.Grid private readonly ILogger _logger; private readonly AppCaches _appCaches; private readonly DirectoryInfo _configFolder; - private readonly ManifestParser _manifestParser; + private readonly IManifestParser _manifestParser; private readonly bool _isDebug; - public GridEditorsConfig(ILogger logger, AppCaches appCaches, DirectoryInfo configFolder, ManifestParser manifestParser, bool isDebug) + public GridEditorsConfig(ILogger logger, AppCaches appCaches, DirectoryInfo configFolder, IManifestParser manifestParser, bool isDebug) { _logger = logger; _appCaches = appCaches; diff --git a/src/Umbraco.Core/Manifest/IManifestParser.cs b/src/Umbraco.Core/Manifest/IManifestParser.cs new file mode 100644 index 0000000000..3641396e0a --- /dev/null +++ b/src/Umbraco.Core/Manifest/IManifestParser.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using Umbraco.Core.PropertyEditors; + +namespace Umbraco.Core.Manifest +{ + public interface IManifestParser + { + string Path { get; set; } + + /// + /// Gets all manifests, merged into a single manifest object. + /// + /// + PackageManifest Manifest { get; } + + /// + /// Parses a manifest. + /// + PackageManifest ParseManifest(string text); + + IEnumerable ParseGridEditors(string text); + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Manifest/ManifestParser.cs b/src/Umbraco.Core/Manifest/ManifestParser.cs index efd9e92b1f..2e55d07059 100644 --- a/src/Umbraco.Core/Manifest/ManifestParser.cs +++ b/src/Umbraco.Core/Manifest/ManifestParser.cs @@ -15,7 +15,7 @@ namespace Umbraco.Core.Manifest /// /// Parses the Main.js file and replaces all tokens accordingly. /// - public class ManifestParser + public class ManifestParser : IManifestParser { private static readonly string Utf8Preamble = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble()); @@ -153,7 +153,7 @@ namespace Umbraco.Core.Manifest /// /// Parses a manifest. /// - internal PackageManifest ParseManifest(string text) + public PackageManifest ParseManifest(string text) { if (string.IsNullOrWhiteSpace(text)) throw new ArgumentNullOrEmptyException(nameof(text)); @@ -179,7 +179,7 @@ namespace Umbraco.Core.Manifest } // purely for tests - internal IEnumerable ParseGridEditors(string text) + public IEnumerable ParseGridEditors(string text) { return JsonConvert.DeserializeObject>(text); } diff --git a/src/Umbraco.Core/PropertyEditors/IDataEditor.cs b/src/Umbraco.Core/Models/IDataEditor.cs similarity index 99% rename from src/Umbraco.Core/PropertyEditors/IDataEditor.cs rename to src/Umbraco.Core/Models/IDataEditor.cs index 3685cc6494..5d1aece6e5 100644 --- a/src/Umbraco.Core/PropertyEditors/IDataEditor.cs +++ b/src/Umbraco.Core/Models/IDataEditor.cs @@ -52,7 +52,6 @@ namespace Umbraco.Core.PropertyEditors /// Gets a configured value editor. /// IDataValueEditor GetValueEditor(object configuration); - /// /// Gets the configuration for the value editor. /// diff --git a/src/Umbraco.Core/PropertyEditors/ParameterEditorCollection.cs b/src/Umbraco.Core/PropertyEditors/ParameterEditorCollection.cs index 4dd4a75c22..dacda815ec 100644 --- a/src/Umbraco.Core/PropertyEditors/ParameterEditorCollection.cs +++ b/src/Umbraco.Core/PropertyEditors/ParameterEditorCollection.cs @@ -6,7 +6,7 @@ namespace Umbraco.Core.PropertyEditors { public class ParameterEditorCollection : BuilderCollectionBase { - public ParameterEditorCollection(DataEditorCollection dataEditors, ManifestParser manifestParser) + public ParameterEditorCollection(DataEditorCollection dataEditors, IManifestParser manifestParser) : base(dataEditors .Where(x => (x.Type & EditorType.MacroParameter) > 0) .Union(manifestParser.Manifest.PropertyEditors)) @@ -15,11 +15,11 @@ namespace Umbraco.Core.PropertyEditors // note: virtual so it can be mocked public virtual IDataEditor this[string alias] => this.SingleOrDefault(x => x.Alias == alias); - + public virtual bool TryGet(string alias, out IDataEditor editor) { editor = this.FirstOrDefault(x => x.Alias == alias); return editor != null; } } -} \ No newline at end of file +} diff --git a/src/Umbraco.Core/PropertyEditors/PropertyEditorCollection.cs b/src/Umbraco.Core/PropertyEditors/PropertyEditorCollection.cs index 712a66e55d..86cfde2ee4 100644 --- a/src/Umbraco.Core/PropertyEditors/PropertyEditorCollection.cs +++ b/src/Umbraco.Core/PropertyEditors/PropertyEditorCollection.cs @@ -6,7 +6,7 @@ namespace Umbraco.Core.PropertyEditors { public class PropertyEditorCollection : BuilderCollectionBase { - public PropertyEditorCollection(DataEditorCollection dataEditors, ManifestParser manifestParser) + public PropertyEditorCollection(DataEditorCollection dataEditors, IManifestParser manifestParser) : base(dataEditors .Where(x => (x.Type & EditorType.PropertyValue) > 0) .Union(manifestParser.Manifest.PropertyEditors)) @@ -20,11 +20,11 @@ namespace Umbraco.Core.PropertyEditors // note: virtual so it can be mocked public virtual IDataEditor this[string alias] => this.SingleOrDefault(x => x.Alias == alias); - + public virtual bool TryGet(string alias, out IDataEditor editor) { editor = this.FirstOrDefault(x => x.Alias == alias); return editor != null; } } -} \ No newline at end of file +} diff --git a/src/Umbraco.Core/Runtime/CoreInitialComposer.cs b/src/Umbraco.Core/Runtime/CoreInitialComposer.cs index 1f004846d0..7ae5211876 100644 --- a/src/Umbraco.Core/Runtime/CoreInitialComposer.cs +++ b/src/Umbraco.Core/Runtime/CoreInitialComposer.cs @@ -55,7 +55,7 @@ namespace Umbraco.Core.Runtime composition.Register(); // register manifest parser, will be injected in collection builders where needed - composition.RegisterUnique(); + composition.RegisterUnique(); // register our predefined validators composition.ManifestValueValidators() diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 25de78105f..7fd5ebd75e 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -166,8 +166,6 @@ - - @@ -178,24 +176,14 @@ - - - - - - - - - - @@ -208,6 +196,7 @@ + @@ -248,6 +237,7 @@ + @@ -288,8 +278,9 @@ + + - @@ -297,12 +288,9 @@ - - - @@ -381,8 +369,6 @@ - - @@ -551,10 +537,7 @@ - - - diff --git a/src/Umbraco.Tests/Manifest/ManifestParserTests.cs b/src/Umbraco.Tests/Manifest/ManifestParserTests.cs index 1c90f68d62..0a187c5a8a 100644 --- a/src/Umbraco.Tests/Manifest/ManifestParserTests.cs +++ b/src/Umbraco.Tests/Manifest/ManifestParserTests.cs @@ -19,7 +19,7 @@ namespace Umbraco.Tests.Manifest [TestFixture] public class ManifestParserTests { - private ManifestParser _parser; + private IManifestParser _parser; [SetUp] public void Setup() diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs index 2f86bddb3b..75522112b8 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs @@ -365,7 +365,8 @@ namespace Umbraco.Tests.Testing // somehow property editor ends up wanting this Composition.WithCollectionBuilder(); - Composition.RegisterUnique(); + + Composition.RegisterUnique(); // note - don't register collections, use builders Composition.WithCollectionBuilder(); diff --git a/src/Umbraco.Web/ContentApps/ContentAppFactoryCollectionBuilder.cs b/src/Umbraco.Web/ContentApps/ContentAppFactoryCollectionBuilder.cs index 170b9169ef..233a5f5ac6 100644 --- a/src/Umbraco.Web/ContentApps/ContentAppFactoryCollectionBuilder.cs +++ b/src/Umbraco.Web/ContentApps/ContentAppFactoryCollectionBuilder.cs @@ -26,7 +26,7 @@ namespace Umbraco.Web.ContentApps // get the manifest parser just-in-time - injecting it in the ctor would mean that // simply getting the builder in order to configure the collection, would require // its dependencies too, and that can create cycles or other oddities - var manifestParser = factory.GetInstance(); + var manifestParser = factory.GetInstance(); return base.CreateItems(factory).Concat(manifestParser.Manifest.ContentApps.Select(x => new ManifestContentAppFactory(x))); } diff --git a/src/Umbraco.Web/Dashboards/DashboardCollectionBuilder.cs b/src/Umbraco.Web/Dashboards/DashboardCollectionBuilder.cs index 36a417e957..d790b04d46 100644 --- a/src/Umbraco.Web/Dashboards/DashboardCollectionBuilder.cs +++ b/src/Umbraco.Web/Dashboards/DashboardCollectionBuilder.cs @@ -16,7 +16,7 @@ namespace Umbraco.Web.Dashboards // get the manifest parser just-in-time - injecting it in the ctor would mean that // simply getting the builder in order to configure the collection, would require // its dependencies too, and that can create cycles or other oddities - var manifestParser = factory.GetInstance(); + var manifestParser = factory.GetInstance(); var dashboardSections = Merge(base.CreateItems(factory), manifestParser.Manifest.Dashboards); diff --git a/src/Umbraco.Web/Editors/BackOfficeController.cs b/src/Umbraco.Web/Editors/BackOfficeController.cs index e77a1b70f2..68f234a22a 100644 --- a/src/Umbraco.Web/Editors/BackOfficeController.cs +++ b/src/Umbraco.Web/Editors/BackOfficeController.cs @@ -39,13 +39,13 @@ namespace Umbraco.Web.Editors [DisableBrowserCache] public class BackOfficeController : UmbracoController { - private readonly ManifestParser _manifestParser; + private readonly IManifestParser _manifestParser; private readonly UmbracoFeatures _features; private readonly IRuntimeState _runtimeState; private BackOfficeUserManager _userManager; private BackOfficeSignInManager _signInManager; - public BackOfficeController(ManifestParser manifestParser, UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper) + public BackOfficeController(IManifestParser manifestParser, UmbracoFeatures features, IGlobalSettings globalSettings, IUmbracoContextAccessor umbracoContextAccessor, ServiceContext services, AppCaches appCaches, IProfilingLogger profilingLogger, IRuntimeState runtimeState, UmbracoHelper umbracoHelper) : base(globalSettings, umbracoContextAccessor, services, appCaches, profilingLogger, umbracoHelper) { _manifestParser = manifestParser; diff --git a/src/Umbraco.Web/JavaScript/CssInitialization.cs b/src/Umbraco.Web/JavaScript/CssInitialization.cs index 172244038d..8cf9067606 100644 --- a/src/Umbraco.Web/JavaScript/CssInitialization.cs +++ b/src/Umbraco.Web/JavaScript/CssInitialization.cs @@ -10,9 +10,9 @@ namespace Umbraco.Web.JavaScript { internal class CssInitialization : AssetInitialization { - private readonly ManifestParser _parser; + private readonly IManifestParser _parser; - public CssInitialization(ManifestParser parser) + public CssInitialization(IManifestParser parser) { _parser = parser; } diff --git a/src/Umbraco.Web/JavaScript/JsInitialization.cs b/src/Umbraco.Web/JavaScript/JsInitialization.cs index 17e4f7b094..6956864ea3 100644 --- a/src/Umbraco.Web/JavaScript/JsInitialization.cs +++ b/src/Umbraco.Web/JavaScript/JsInitialization.cs @@ -17,9 +17,9 @@ namespace Umbraco.Web.JavaScript /// internal class JsInitialization : AssetInitialization { - private readonly ManifestParser _parser; + private readonly IManifestParser _parser; - public JsInitialization(ManifestParser parser) + public JsInitialization(IManifestParser parser) { _parser = parser; } diff --git a/src/Umbraco.Web/Sections/SectionCollectionBuilder.cs b/src/Umbraco.Web/Sections/SectionCollectionBuilder.cs index e38da85cfa..de883db83a 100644 --- a/src/Umbraco.Web/Sections/SectionCollectionBuilder.cs +++ b/src/Umbraco.Web/Sections/SectionCollectionBuilder.cs @@ -16,7 +16,7 @@ namespace Umbraco.Web.Sections // get the manifest parser just-in-time - injecting it in the ctor would mean that // simply getting the builder in order to configure the collection, would require // its dependencies too, and that can create cycles or other oddities - var manifestParser = factory.GetInstance(); + var manifestParser = factory.GetInstance(); return base.CreateItems(factory).Concat(manifestParser.Manifest.Sections); } diff --git a/src/umbraco.sln b/src/umbraco.sln index b89daf1925..07ed63c7a3 100644 --- a/src/umbraco.sln +++ b/src/umbraco.sln @@ -111,6 +111,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.ModelsBuilder.Embed EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Infrastructure", "Umbraco.Infrastructure\Umbraco.Infrastructure.csproj", "{3AE7BF57-966B-45A5-910A-954D7C554441}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Configuration", "Umbraco.Configuration\Umbraco.Configuration.csproj", "{FBE7C065-DAC0-4025-A78B-63B24D3AB00B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -155,6 +157,10 @@ Global {3AE7BF57-966B-45A5-910A-954D7C554441}.Debug|Any CPU.Build.0 = Debug|Any CPU {3AE7BF57-966B-45A5-910A-954D7C554441}.Release|Any CPU.ActiveCfg = Release|Any CPU {3AE7BF57-966B-45A5-910A-954D7C554441}.Release|Any CPU.Build.0 = Release|Any CPU + {FBE7C065-DAC0-4025-A78B-63B24D3AB00B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FBE7C065-DAC0-4025-A78B-63B24D3AB00B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FBE7C065-DAC0-4025-A78B-63B24D3AB00B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FBE7C065-DAC0-4025-A78B-63B24D3AB00B}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From f1d85be6bb56dec1268445b0ebee0a2d91acde4d Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Wed, 6 Nov 2019 14:18:06 +0100 Subject: [PATCH 4/9] Move slim entities --- .../Models/Entities/EntityExtensions.cs | 7 +++---- .../Models/Entities/IMediaEntitySlim.cs | 0 .../Models/Entities/IMemberEntitySlim.cs | 0 .../Models/Entities/MediaEntitySlim.cs | 0 .../Models/Entities/MemberEntitySlim.cs | 0 src/Umbraco.Core/Umbraco.Core.csproj | 9 ++------- 6 files changed, 5 insertions(+), 11 deletions(-) rename src/{Umbraco.Core => Umbraco.Abstractions}/Models/Entities/EntityExtensions.cs (86%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Models/Entities/IMediaEntitySlim.cs (100%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Models/Entities/IMemberEntitySlim.cs (100%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Models/Entities/MediaEntitySlim.cs (100%) rename src/{Umbraco.Core => Umbraco.Abstractions}/Models/Entities/MemberEntitySlim.cs (100%) diff --git a/src/Umbraco.Core/Models/Entities/EntityExtensions.cs b/src/Umbraco.Abstractions/Models/Entities/EntityExtensions.cs similarity index 86% rename from src/Umbraco.Core/Models/Entities/EntityExtensions.cs rename to src/Umbraco.Abstractions/Models/Entities/EntityExtensions.cs index 2ee6a2d5ed..2df08f207d 100644 --- a/src/Umbraco.Core/Models/Entities/EntityExtensions.cs +++ b/src/Umbraco.Abstractions/Models/Entities/EntityExtensions.cs @@ -2,16 +2,15 @@ namespace Umbraco.Core.Models.Entities { - internal static class EntityExtensions + public static class EntityExtensions { /// /// Updates the entity when it is being saved. /// - internal static void UpdatingEntity(this IEntity entity) + public static void UpdatingEntity(this IEntity entity) { var now = DateTime.Now; - // just in case if (entity.CreateDate == default) { entity.CreateDate = now; @@ -27,7 +26,7 @@ namespace Umbraco.Core.Models.Entities /// /// Updates the entity when it is being saved for the first time. /// - internal static void AddingEntity(this IEntity entity) + public static void AddingEntity(this IEntity entity) { var now = DateTime.Now; var canBeDirty = entity as ICanBeDirty; diff --git a/src/Umbraco.Core/Models/Entities/IMediaEntitySlim.cs b/src/Umbraco.Abstractions/Models/Entities/IMediaEntitySlim.cs similarity index 100% rename from src/Umbraco.Core/Models/Entities/IMediaEntitySlim.cs rename to src/Umbraco.Abstractions/Models/Entities/IMediaEntitySlim.cs diff --git a/src/Umbraco.Core/Models/Entities/IMemberEntitySlim.cs b/src/Umbraco.Abstractions/Models/Entities/IMemberEntitySlim.cs similarity index 100% rename from src/Umbraco.Core/Models/Entities/IMemberEntitySlim.cs rename to src/Umbraco.Abstractions/Models/Entities/IMemberEntitySlim.cs diff --git a/src/Umbraco.Core/Models/Entities/MediaEntitySlim.cs b/src/Umbraco.Abstractions/Models/Entities/MediaEntitySlim.cs similarity index 100% rename from src/Umbraco.Core/Models/Entities/MediaEntitySlim.cs rename to src/Umbraco.Abstractions/Models/Entities/MediaEntitySlim.cs diff --git a/src/Umbraco.Core/Models/Entities/MemberEntitySlim.cs b/src/Umbraco.Abstractions/Models/Entities/MemberEntitySlim.cs similarity index 100% rename from src/Umbraco.Core/Models/Entities/MemberEntitySlim.cs rename to src/Umbraco.Abstractions/Models/Entities/MemberEntitySlim.cs diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 7fd5ebd75e..bb2ad5dec4 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -220,7 +220,6 @@ - @@ -258,10 +257,6 @@ - - - - @@ -274,10 +269,10 @@ - - + + From c6157b8765483bda4a7284f2938af2bcca5a00da Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Wed, 6 Nov 2019 15:37:03 +0100 Subject: [PATCH 5/9] Move Configs to abstractions, and injected factory all over to create one because we need to inject stuff from system.configuration --- src/Umbraco.Abstractions/Composing/Current.cs | 2 ++ .../RegisterExtensions.cs | 0 src/Umbraco.Core/Composing/Composition.cs | 9 +----- src/Umbraco.Core/Composing/ConfigsFactory.cs | 14 +++++++++ src/Umbraco.Core/Composing/Current.cs | 4 +-- src/Umbraco.Core/Composing/IConfigsFactory.cs | 9 ++++++ src/Umbraco.Core/Runtime/CoreRuntime.cs | 5 ++-- src/Umbraco.Core/Umbraco.Core.csproj | 6 ++-- .../DistributedCache/DistributedCacheTests.cs | 2 +- .../Components/ComponentTests.cs | 30 ++++++++++--------- .../Composing/CollectionBuildersTests.cs | 2 +- .../Composing/CompositionTests.cs | 2 +- .../Composing/LazyCollectionBuilderTests.cs | 10 +++---- .../Composing/PackageActionCollectionTests.cs | 4 +-- src/Umbraco.Tests/IO/FileSystemsTests.cs | 2 +- src/Umbraco.Tests/Macros/MacroTests.cs | 2 +- src/Umbraco.Tests/Models/MacroTests.cs | 2 +- src/Umbraco.Tests/Models/MemberTests.cs | 2 +- src/Umbraco.Tests/Models/UserTests.cs | 2 +- src/Umbraco.Tests/Models/VariationTests.cs | 8 ++--- .../PropertyEditors/ImageCropperTest.cs | 2 +- .../PropertyEditorValueEditorTests.cs | 2 +- .../Published/ConvertersTests.cs | 2 +- .../PublishedContent/NuCacheChildrenTests.cs | 12 ++++---- .../PublishedContent/NuCacheTests.cs | 2 +- .../Runtimes/CoreRuntimeTests.cs | 2 +- src/Umbraco.Tests/Runtimes/StandaloneTests.cs | 6 ++-- .../Scoping/ScopeEventDispatcherTests.cs | 2 +- .../TestHelpers/BaseUsingSqlCeSyntax.cs | 2 +- src/Umbraco.Tests/Testing/UmbracoTestBase.cs | 2 +- 30 files changed, 87 insertions(+), 64 deletions(-) rename src/{Umbraco.Core => Umbraco.Abstractions}/RegisterExtensions.cs (100%) create mode 100644 src/Umbraco.Core/Composing/ConfigsFactory.cs create mode 100644 src/Umbraco.Core/Composing/IConfigsFactory.cs diff --git a/src/Umbraco.Abstractions/Composing/Current.cs b/src/Umbraco.Abstractions/Composing/Current.cs index 9f8168f1a9..a1ae87d49f 100644 --- a/src/Umbraco.Abstractions/Composing/Current.cs +++ b/src/Umbraco.Abstractions/Composing/Current.cs @@ -1,5 +1,6 @@ using System; using Umbraco.Core.Logging; +using Umbraco.Core.Strings; namespace Umbraco.Core.Composing { @@ -42,6 +43,7 @@ namespace Umbraco.Core.Composing #region Getters + public static ILogger Logger => _logger ?? (_logger = _factory?.TryGetInstance() ?? throw new Exception("TODO Fix")); //?? new DebugDiagnosticsLogger(new MessageTemplates())); diff --git a/src/Umbraco.Core/RegisterExtensions.cs b/src/Umbraco.Abstractions/RegisterExtensions.cs similarity index 100% rename from src/Umbraco.Core/RegisterExtensions.cs rename to src/Umbraco.Abstractions/RegisterExtensions.cs diff --git a/src/Umbraco.Core/Composing/Composition.cs b/src/Umbraco.Core/Composing/Composition.cs index 34c5296dce..7ff8901fc1 100644 --- a/src/Umbraco.Core/Composing/Composition.cs +++ b/src/Umbraco.Core/Composing/Composition.cs @@ -27,19 +27,12 @@ namespace Umbraco.Core.Composing /// A logger. /// The runtime state. /// Optional configs. - public Composition(IRegister register, TypeLoader typeLoader, IProfilingLogger logger, IRuntimeState runtimeState, Configs configs = null) + public Composition(IRegister register, TypeLoader typeLoader, IProfilingLogger logger, IRuntimeState runtimeState, Configs configs) { _register = register; TypeLoader = typeLoader; Logger = logger; RuntimeState = runtimeState; - - if (configs == null) - { - configs = new Configs(); - configs.AddCoreConfigs(); - } - Configs = configs; } diff --git a/src/Umbraco.Core/Composing/ConfigsFactory.cs b/src/Umbraco.Core/Composing/ConfigsFactory.cs new file mode 100644 index 0000000000..995ab4e3aa --- /dev/null +++ b/src/Umbraco.Core/Composing/ConfigsFactory.cs @@ -0,0 +1,14 @@ +using System.Configuration; +using Umbraco.Core.Configuration; + +namespace Umbraco.Core.Composing +{ + public class ConfigsFactory : IConfigsFactory + { + public Configs Create() { + var configs = new Configs(section => ConfigurationManager.GetSection(section)); + configs.AddCoreConfigs(); + return configs; + } + } +} diff --git a/src/Umbraco.Core/Composing/Current.cs b/src/Umbraco.Core/Composing/Current.cs index ed64347816..01fcbaa9e8 100644 --- a/src/Umbraco.Core/Composing/Current.cs +++ b/src/Umbraco.Core/Composing/Current.cs @@ -93,11 +93,11 @@ namespace Umbraco.Core.Composing /// Unlocks so that it is possible to add configurations /// directly to without having to wire composition. /// - public static void UnlockConfigs() + public static void UnlockConfigs(IConfigsFactory configsFactory) { if (_factory != null) throw new InvalidOperationException("Cannot unlock configs when a factory has been set."); - _configs = new Configs(); + _configs = configsFactory.Create(); } internal static event EventHandler Resetted; diff --git a/src/Umbraco.Core/Composing/IConfigsFactory.cs b/src/Umbraco.Core/Composing/IConfigsFactory.cs new file mode 100644 index 0000000000..1b12f5e157 --- /dev/null +++ b/src/Umbraco.Core/Composing/IConfigsFactory.cs @@ -0,0 +1,9 @@ +using Umbraco.Core.Configuration; + +namespace Umbraco.Core.Composing +{ + public interface IConfigsFactory + { + Configs Create(); + } +} diff --git a/src/Umbraco.Core/Runtime/CoreRuntime.cs b/src/Umbraco.Core/Runtime/CoreRuntime.cs index 5b069641c4..d9c8ff05d3 100644 --- a/src/Umbraco.Core/Runtime/CoreRuntime.cs +++ b/src/Umbraco.Core/Runtime/CoreRuntime.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Configuration; using System.Diagnostics; using System.Web; using System.Web.Hosting; @@ -345,8 +346,8 @@ namespace Umbraco.Core.Runtime /// protected virtual Configs GetConfigs() { - var configs = new Configs(); - configs.AddCoreConfigs(); + var configs = new ConfigsFactory().Create(); + return configs; } diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index bb2ad5dec4..f40f81ef71 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -158,7 +158,9 @@ + + @@ -254,6 +256,7 @@ + @@ -316,7 +319,6 @@ - @@ -361,7 +363,6 @@ - @@ -596,7 +597,6 @@ - diff --git a/src/Umbraco.Tests/Cache/DistributedCache/DistributedCacheTests.cs b/src/Umbraco.Tests/Cache/DistributedCache/DistributedCacheTests.cs index 650cc64720..54318ace15 100644 --- a/src/Umbraco.Tests/Cache/DistributedCache/DistributedCacheTests.cs +++ b/src/Umbraco.Tests/Cache/DistributedCache/DistributedCacheTests.cs @@ -25,7 +25,7 @@ namespace Umbraco.Tests.Cache.DistributedCache { var register = RegisterFactory.Create(); - var composition = new Composition(register, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run)); + var composition = new Composition(register, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), new ConfigsFactory().Create()); composition.RegisterUnique(_ => new TestServerRegistrar()); composition.RegisterUnique(_ => new TestServerMessenger()); diff --git a/src/Umbraco.Tests/Components/ComponentTests.cs b/src/Umbraco.Tests/Components/ComponentTests.cs index 2ba94d8c78..73fc4bb4af 100644 --- a/src/Umbraco.Tests/Components/ComponentTests.cs +++ b/src/Umbraco.Tests/Components/ComponentTests.cs @@ -7,6 +7,7 @@ using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Compose; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.IO; using Umbraco.Core.Logging; using Umbraco.Core.Persistence; @@ -23,6 +24,7 @@ namespace Umbraco.Tests.Components private static readonly List Composed = new List(); private static readonly List Initialized = new List(); private static readonly List Terminated = new List(); + private static readonly Configs Configs = new ConfigsFactory().Create(); private static IFactory MockFactory(Action> setup = null) { @@ -65,7 +67,7 @@ namespace Umbraco.Tests.Components public void Boot1A() { var register = MockRegister(); - var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown)); + var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), new ConfigsFactory().Create()); var types = TypeArray(); var composers = new Composers(composition, types, Mock.Of()); @@ -104,7 +106,7 @@ namespace Umbraco.Tests.Components public void Boot1B() { var register = MockRegister(); - var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Run)); + var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Run), new ConfigsFactory().Create()); var types = TypeArray(); var composers = new Composers(composition, types, Mock.Of()); @@ -120,7 +122,7 @@ namespace Umbraco.Tests.Components public void Boot2() { var register = MockRegister(); - var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown)); + var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), new ConfigsFactory().Create()); var types = TypeArray(); var composers = new Composers(composition, types, Mock.Of()); @@ -135,7 +137,7 @@ namespace Umbraco.Tests.Components public void Boot3() { var register = MockRegister(); - var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown)); + var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), new ConfigsFactory().Create()); var types = TypeArray(); var composers = new Composers(composition, types, Mock.Of()); @@ -152,7 +154,7 @@ namespace Umbraco.Tests.Components public void BrokenRequire() { var register = MockRegister(); - var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown)); + var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), new ConfigsFactory().Create()); var types = TypeArray(); var composers = new Composers(composition, types, Mock.Of()); @@ -175,7 +177,7 @@ namespace Umbraco.Tests.Components public void BrokenRequired() { var register = MockRegister(); - var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown)); + var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), new ConfigsFactory().Create()); var types = TypeArray(); var composers = new Composers(composition, types, Mock.Of()); @@ -210,7 +212,7 @@ namespace Umbraco.Tests.Components throw new NotSupportedException(type.FullName); }); }); - var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown)); + var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), new ConfigsFactory().Create()); var types = new[] { typeof(Composer1), typeof(Composer5), typeof(Composer5a) }; var composers = new Composers(composition, types, Mock.Of()); @@ -236,7 +238,7 @@ namespace Umbraco.Tests.Components public void Requires1() { var register = MockRegister(); - var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown)); + var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), new ConfigsFactory().Create()); var types = new[] { typeof(Composer6), typeof(Composer7), typeof(Composer8) }; var composers = new Composers(composition, types, Mock.Of()); @@ -251,7 +253,7 @@ namespace Umbraco.Tests.Components public void Requires2A() { var register = MockRegister(); - var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown)); + var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), Configs); var types = new[] { typeof(Composer9), typeof(Composer2), typeof(Composer4) }; var composers = new Composers(composition, types, Mock.Of()); @@ -268,7 +270,7 @@ namespace Umbraco.Tests.Components { var register = MockRegister(); var factory = MockFactory(); - var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Run)); + var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Run), Configs); var types = new[] { typeof(Composer9), typeof(Composer2), typeof(Composer4) }; var composers = new Composers(composition, types, Mock.Of()); @@ -287,7 +289,7 @@ namespace Umbraco.Tests.Components public void WeakDependencies() { var register = MockRegister(); - var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown)); + var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), Configs); var types = new[] { typeof(Composer10) }; var composers = new Composers(composition, types, Mock.Of()); @@ -326,7 +328,7 @@ namespace Umbraco.Tests.Components public void DisableMissing() { var register = MockRegister(); - var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown)); + var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), Configs); var types = new[] { typeof(Composer6), typeof(Composer8) }; // 8 disables 7 which is not in the list var composers = new Composers(composition, types, Mock.Of()); @@ -341,7 +343,7 @@ namespace Umbraco.Tests.Components public void AttributesPriorities() { var register = MockRegister(); - var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown)); + var composition = new Composition(register, MockTypeLoader(), Mock.Of(), MockRuntimeState(RuntimeLevel.Unknown), Configs); var types = new[] { typeof(Composer26) }; // 26 disabled by assembly attribute var composers = new Composers(composition, types, Mock.Of()); @@ -364,7 +366,7 @@ namespace Umbraco.Tests.Components var typeLoader = new TypeLoader(AppCaches.Disabled.RuntimeCache, IOHelper.MapPath("~/App_Data/TEMP"), Mock.Of()); var register = MockRegister(); - var composition = new Composition(register, typeLoader, Mock.Of(), MockRuntimeState(RuntimeLevel.Run)); + var composition = new Composition(register, typeLoader, Mock.Of(), MockRuntimeState(RuntimeLevel.Run), Configs); var types = typeLoader.GetTypes().Where(x => x.FullName.StartsWith("Umbraco.Core.") || x.FullName.StartsWith("Umbraco.Web")); var composers = new Composers(composition, types, Mock.Of()); diff --git a/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs b/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs index ec757e09f0..4303f59916 100644 --- a/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs +++ b/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs @@ -21,7 +21,7 @@ namespace Umbraco.Tests.Composing Current.Reset(); var register = RegisterFactory.Create(); - _composition = new Composition(register, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run)); + _composition = new Composition(register, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), new ConfigsFactory().Create()); } [TearDown] diff --git a/src/Umbraco.Tests/Composing/CompositionTests.cs b/src/Umbraco.Tests/Composing/CompositionTests.cs index 33855a8bfb..72f7e99ca6 100644 --- a/src/Umbraco.Tests/Composing/CompositionTests.cs +++ b/src/Umbraco.Tests/Composing/CompositionTests.cs @@ -37,7 +37,7 @@ namespace Umbraco.Tests.Composing var logger = new ProfilingLogger(Mock.Of(), Mock.Of()); var typeLoader = new TypeLoader(Mock.Of(), IOHelper.MapPath("~/App_Data/TEMP"), logger); - var composition = new Composition(mockedRegister, typeLoader, logger, Mock.Of()); + var composition = new Composition(mockedRegister, typeLoader, logger, Mock.Of(), new ConfigsFactory().Create()); // create the factory, ensure it is the mocked factory var factory = composition.CreateFactory(); diff --git a/src/Umbraco.Tests/Composing/LazyCollectionBuilderTests.cs b/src/Umbraco.Tests/Composing/LazyCollectionBuilderTests.cs index 3996eba89f..69e8524b7c 100644 --- a/src/Umbraco.Tests/Composing/LazyCollectionBuilderTests.cs +++ b/src/Umbraco.Tests/Composing/LazyCollectionBuilderTests.cs @@ -40,7 +40,7 @@ namespace Umbraco.Tests.Composing public void LazyCollectionBuilderHandlesTypes() { var container = CreateRegister(); - var composition = new Composition(container, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run)); + var composition = new Composition(container, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), new ConfigsFactory().Create()); composition.WithCollectionBuilder() .Add() @@ -66,7 +66,7 @@ namespace Umbraco.Tests.Composing public void LazyCollectionBuilderHandlesProducers() { var container = CreateRegister(); - var composition = new Composition(container, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run)); + var composition = new Composition(container, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), new ConfigsFactory().Create()); composition.WithCollectionBuilder() .Add(() => new[] { typeof(TransientObject3), typeof(TransientObject2) }) @@ -91,7 +91,7 @@ namespace Umbraco.Tests.Composing public void LazyCollectionBuilderHandlesTypesAndProducers() { var container = CreateRegister(); - var composition = new Composition(container, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run)); + var composition = new Composition(container, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), new ConfigsFactory().Create()); composition.WithCollectionBuilder() .Add() @@ -117,7 +117,7 @@ namespace Umbraco.Tests.Composing public void LazyCollectionBuilderThrowsOnIllegalTypes() { var container = CreateRegister(); - var composition = new Composition(container, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run)); + var composition = new Composition(container, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), new ConfigsFactory().Create()); composition.WithCollectionBuilder() .Add() @@ -139,7 +139,7 @@ namespace Umbraco.Tests.Composing public void LazyCollectionBuilderCanExcludeTypes() { var container = CreateRegister(); - var composition = new Composition(container, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run)); + var composition = new Composition(container, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), new ConfigsFactory().Create()); composition.WithCollectionBuilder() .Add() diff --git a/src/Umbraco.Tests/Composing/PackageActionCollectionTests.cs b/src/Umbraco.Tests/Composing/PackageActionCollectionTests.cs index 07db4be3d3..57f691eea5 100644 --- a/src/Umbraco.Tests/Composing/PackageActionCollectionTests.cs +++ b/src/Umbraco.Tests/Composing/PackageActionCollectionTests.cs @@ -19,8 +19,8 @@ namespace Umbraco.Tests.Composing public void PackageActionCollectionBuilderWorks() { var container = RegisterFactory.Create(); - - var composition = new Composition(container, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run)); + + var composition = new Composition(container, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), new ConfigsFactory().Create()); composition.WithCollectionBuilder() .Add(() => TypeLoader.GetPackageActions()); diff --git a/src/Umbraco.Tests/IO/FileSystemsTests.cs b/src/Umbraco.Tests/IO/FileSystemsTests.cs index b21faec586..28c1817862 100644 --- a/src/Umbraco.Tests/IO/FileSystemsTests.cs +++ b/src/Umbraco.Tests/IO/FileSystemsTests.cs @@ -28,7 +28,7 @@ namespace Umbraco.Tests.IO { _register = RegisterFactory.Create(); - var composition = new Composition(_register, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run)); + var composition = new Composition(_register, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), new ConfigsFactory().Create()); composition.Register(_ => Mock.Of()); composition.Register(_ => Mock.Of()); diff --git a/src/Umbraco.Tests/Macros/MacroTests.cs b/src/Umbraco.Tests/Macros/MacroTests.cs index 9cc1d14954..4700edc64b 100644 --- a/src/Umbraco.Tests/Macros/MacroTests.cs +++ b/src/Umbraco.Tests/Macros/MacroTests.cs @@ -23,7 +23,7 @@ namespace Umbraco.Tests.Macros //Current.ApplicationContext = new ApplicationContext(cacheHelper, new ProfilingLogger(Mock.Of(), Mock.Of())); Current.Reset(); - Current.UnlockConfigs(); + Current.UnlockConfigs(new ConfigsFactory()); Current.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); } diff --git a/src/Umbraco.Tests/Models/MacroTests.cs b/src/Umbraco.Tests/Models/MacroTests.cs index d980cd1d58..117301815e 100644 --- a/src/Umbraco.Tests/Models/MacroTests.cs +++ b/src/Umbraco.Tests/Models/MacroTests.cs @@ -15,7 +15,7 @@ namespace Umbraco.Tests.Models public void Init() { Current.Reset(); - Current.UnlockConfigs(); + Current.UnlockConfigs(new ConfigsFactory()); Current.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); } diff --git a/src/Umbraco.Tests/Models/MemberTests.cs b/src/Umbraco.Tests/Models/MemberTests.cs index 5e92ad7ccf..9b478304d1 100644 --- a/src/Umbraco.Tests/Models/MemberTests.cs +++ b/src/Umbraco.Tests/Models/MemberTests.cs @@ -17,7 +17,7 @@ namespace Umbraco.Tests.Models public void Setup() { Current.Reset(); - Current.UnlockConfigs(); + Current.UnlockConfigs(new ConfigsFactory()); Current.Configs.Add(SettingsForTests.GetDefaultGlobalSettings); Current.Configs.Add(SettingsForTests.GetDefaultUmbracoSettings); } diff --git a/src/Umbraco.Tests/Models/UserTests.cs b/src/Umbraco.Tests/Models/UserTests.cs index 797b79381a..8cc66d5eb0 100644 --- a/src/Umbraco.Tests/Models/UserTests.cs +++ b/src/Umbraco.Tests/Models/UserTests.cs @@ -16,7 +16,7 @@ namespace Umbraco.Tests.Models public void Setup() { Current.Reset(); - Current.UnlockConfigs(); + Current.UnlockConfigs(new ConfigsFactory()); Current.Configs.Add(SettingsForTests.GetDefaultGlobalSettings); } diff --git a/src/Umbraco.Tests/Models/VariationTests.cs b/src/Umbraco.Tests/Models/VariationTests.cs index ab5f726894..ce78287d6d 100644 --- a/src/Umbraco.Tests/Models/VariationTests.cs +++ b/src/Umbraco.Tests/Models/VariationTests.cs @@ -28,7 +28,7 @@ namespace Umbraco.Tests.Models Current.Reset(); - var configs = new Configs(); + var configs = new ConfigsFactory().Create(); configs.Add(SettingsForTests.GetDefaultGlobalSettings); configs.Add(SettingsForTests.GetDefaultUmbracoSettings); @@ -75,7 +75,7 @@ namespace Umbraco.Tests.Models // 1. if exact is set to true: culture cannot be null when the ContentVariation.Culture flag is set // 2. if wildcards is set to false: fail when "*" is passed in as either culture or segment. // 3. ContentVariation flag is ignored when wildcards are used. - // 4. Empty string is considered the same as null + // 4. Empty string is considered the same as null #region Nothing @@ -141,7 +141,7 @@ namespace Umbraco.Tests.Models #endregion #region CultureAndSegment - + Assert4B(ContentVariation.CultureAndSegment, null, null, false, true, false, true); Assert4B(ContentVariation.CultureAndSegment, null, "", false, true, false, true); Assert4B(ContentVariation.CultureAndSegment, null, "*", false, false, false, true); @@ -163,7 +163,7 @@ namespace Umbraco.Tests.Models } /// - /// Asserts the result of + /// Asserts the result of /// /// /// diff --git a/src/Umbraco.Tests/PropertyEditors/ImageCropperTest.cs b/src/Umbraco.Tests/PropertyEditors/ImageCropperTest.cs index 8d2ab84d35..dcf225d952 100644 --- a/src/Umbraco.Tests/PropertyEditors/ImageCropperTest.cs +++ b/src/Umbraco.Tests/PropertyEditors/ImageCropperTest.cs @@ -70,7 +70,7 @@ namespace Umbraco.Tests.PropertyEditors try { var container = RegisterFactory.Create(); - var composition = new Composition(container, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run)); + var composition = new Composition(container, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), new ConfigsFactory().Create()); composition.WithCollectionBuilder(); diff --git a/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs b/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs index 764f6ac4a4..348305fbf5 100644 --- a/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs +++ b/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs @@ -24,7 +24,7 @@ namespace Umbraco.Tests.PropertyEditors Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture; var register = RegisterFactory.Create(); - var composition = new Composition(register, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run)); + var composition = new Composition(register, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), new ConfigsFactory().Create()); register.Register(_ => new DefaultShortStringHelper(new DefaultShortStringHelperConfig().WithDefault(SettingsForTests.GetDefaultUmbracoSettings()))); diff --git a/src/Umbraco.Tests/Published/ConvertersTests.cs b/src/Umbraco.Tests/Published/ConvertersTests.cs index 671129848c..f3dd459ba3 100644 --- a/src/Umbraco.Tests/Published/ConvertersTests.cs +++ b/src/Umbraco.Tests/Published/ConvertersTests.cs @@ -178,7 +178,7 @@ namespace Umbraco.Tests.Published Current.Reset(); var register = RegisterFactory.Create(); - var composition = new Composition(register, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run)); + var composition = new Composition(register, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), new ConfigsFactory().Create()); composition.WithCollectionBuilder() .Append() diff --git a/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs b/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs index 5d32606ee7..f08d77a80f 100644 --- a/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs +++ b/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs @@ -54,7 +54,7 @@ namespace Umbraco.Tests.PublishedContent var factory = Mock.Of(); Current.Factory = factory; - var configs = new Configs(); + var configs = new ConfigsFactory().Create(); Mock.Get(factory).Setup(x => x.GetInstance(typeof(Configs))).Returns(configs); var globalSettings = new GlobalSettings(); configs.Add(SettingsForTests.GenerateMockUmbracoSettings); @@ -1114,7 +1114,7 @@ namespace Umbraco.Tests.PublishedContent _snapshotService.Notify(new[] { - new ContentCacheRefresher.JsonPayload(1, Guid.Empty, TreeChangeTypes.RefreshNode) + new ContentCacheRefresher.JsonPayload(1, Guid.Empty, TreeChangeTypes.RefreshNode) }, out _, out _); Assert.AreEqual(2, contentStore.Test.LiveGen); @@ -1134,7 +1134,7 @@ namespace Umbraco.Tests.PublishedContent /// 2) Save and publish it /// 3) Publish it with descendants /// 4) Repeat steps 2 and 3 - /// + /// /// Which has caused an exception. To replicate this test: /// 1) RefreshBranch with kits for a branch where the top most node is unpublished /// 2) RefreshBranch with kits for the branch where the top most node is published @@ -1162,7 +1162,7 @@ namespace Umbraco.Tests.PublishedContent //children of 1 yield return CreateInvariantKit(20, 1, 1, paths); - yield return CreateInvariantKit(30, 1, 2, paths); + yield return CreateInvariantKit(30, 1, 2, paths); yield return CreateInvariantKit(40, 1, 3, paths); } @@ -1199,12 +1199,12 @@ namespace Umbraco.Tests.PublishedContent var (gen, contentNode) = contentStore.Test.GetValues(1)[0]; Assert.AreEqual(assertGen, gen); //even when unpublishing/re-publishing/etc... the linked list is always maintained - AssertLinkedNode(contentNode, 100, 2, 3, 20, 40); + AssertLinkedNode(contentNode, 100, 2, 3, 20, 40); } //unpublish the root ChangePublishFlagOfRoot(false, 2, TreeChangeTypes.RefreshBranch); - + //publish the root (since it's not published, it will cause a RefreshBranch) ChangePublishFlagOfRoot(true, 3, TreeChangeTypes.RefreshBranch); diff --git a/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs b/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs index 0e05e6baad..7dba201b0a 100644 --- a/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs +++ b/src/Umbraco.Tests/PublishedContent/NuCacheTests.cs @@ -49,7 +49,7 @@ namespace Umbraco.Tests.PublishedContent var factory = Mock.Of(); Current.Factory = factory; - var configs = new Configs(); + var configs = new ConfigsFactory().Create(); Mock.Get(factory).Setup(x => x.GetInstance(typeof(Configs))).Returns(configs); var globalSettings = new GlobalSettings(); configs.Add(SettingsForTests.GenerateMockUmbracoSettings); diff --git a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs index 7cf3c008f1..449cddfcc6 100644 --- a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs +++ b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs @@ -104,7 +104,7 @@ namespace Umbraco.Tests.Runtimes protected override Configs GetConfigs() { - var configs = new Configs(); + var configs = new ConfigsFactory().Create(); configs.Add(SettingsForTests.GetDefaultGlobalSettings); configs.Add(SettingsForTests.GetDefaultUmbracoSettings); return configs; diff --git a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs index fdeb743b6c..60e86ad5b0 100644 --- a/src/Umbraco.Tests/Runtimes/StandaloneTests.cs +++ b/src/Umbraco.Tests/Runtimes/StandaloneTests.cs @@ -64,10 +64,11 @@ namespace Umbraco.Tests.Runtimes var typeLoader = new TypeLoader(appCaches.RuntimeCache, IOHelper.MapPath("~/App_Data/TEMP"), profilingLogger); var mainDom = new SimpleMainDom(); var runtimeState = new RuntimeState(logger, null, null, new Lazy(() => mainDom), new Lazy(() => factory.GetInstance())); + var configs = new ConfigsFactory().Create(); // create the register and the composition var register = RegisterFactory.Create(); - var composition = new Composition(register, typeLoader, profilingLogger, runtimeState); + var composition = new Composition(register, typeLoader, profilingLogger, runtimeState, configs); composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState); // create the core runtime and have it compose itself @@ -254,10 +255,11 @@ namespace Umbraco.Tests.Runtimes Mock.Get(runtimeState).Setup(x => x.Level).Returns(RuntimeLevel.Run); var mainDom = Mock.Of(); Mock.Get(mainDom).Setup(x => x.IsMainDom).Returns(true); + var configs = new ConfigsFactory().Create(); // create the register and the composition var register = RegisterFactory.Create(); - var composition = new Composition(register, typeLoader, profilingLogger, runtimeState); + var composition = new Composition(register, typeLoader, profilingLogger, runtimeState, configs); composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState); // create the core runtime and have it compose itself diff --git a/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs b/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs index 001553a8ae..b964f89be8 100644 --- a/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs +++ b/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs @@ -32,7 +32,7 @@ namespace Umbraco.Tests.Scoping var register = RegisterFactory.Create(); - var composition = new Composition(register, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run)); + var composition = new Composition(register, new TypeLoader(), Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), new ConfigsFactory().Create()); _testObjects = new TestObjects(register); diff --git a/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs b/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs index f62effcb62..a042803639 100644 --- a/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs +++ b/src/Umbraco.Tests/TestHelpers/BaseUsingSqlCeSyntax.cs @@ -42,7 +42,7 @@ namespace Umbraco.Tests.TestHelpers logger, false); - var composition = new Composition(container, typeLoader, Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run)); + var composition = new Composition(container, typeLoader, Mock.Of(), ComponentTests.MockRuntimeState(RuntimeLevel.Run), new ConfigsFactory().Create()); composition.RegisterUnique(_ => Mock.Of()); composition.RegisterUnique(_ => Mock.Of()); diff --git a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs index 75522112b8..5e21f5de63 100644 --- a/src/Umbraco.Tests/Testing/UmbracoTestBase.cs +++ b/src/Umbraco.Tests/Testing/UmbracoTestBase.cs @@ -134,7 +134,7 @@ namespace Umbraco.Tests.Testing var register = RegisterFactory.Create(); - Composition = new Composition(register, typeLoader, proflogger, ComponentTests.MockRuntimeState(RuntimeLevel.Run)); + Composition = new Composition(register, typeLoader, proflogger, ComponentTests.MockRuntimeState(RuntimeLevel.Run), new ConfigsFactory().Create()); Composition.RegisterUnique(typeLoader); Composition.RegisterUnique(logger); From 70aefc4ede4d29f301048b4df6f62e18f0be624a Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Thu, 7 Nov 2019 08:00:48 +0100 Subject: [PATCH 6/9] Move Configs to abstractions --- .../Configuration/Configs.cs | 20 ++++++++++++------- .../Configuration}/IConfigsFactory.cs | 4 +--- src/Umbraco.Abstractions/Services/IRuntime.cs | 3 ++- .../ConfigsFactory.cs | 3 +-- src/Umbraco.Core/Configuration/CoreDebug.cs | 3 ++- src/Umbraco.Core/Runtime/CoreRuntime.cs | 12 +++++------ src/Umbraco.Core/Umbraco.Core.csproj | 3 +-- .../DistributedCache/DistributedCacheTests.cs | 1 + .../Composing/CollectionBuildersTests.cs | 1 + .../Composing/CompositionTests.cs | 1 + .../Composing/PackageActionCollectionTests.cs | 1 + src/Umbraco.Tests/IO/FileSystemsTests.cs | 1 + src/Umbraco.Tests/Macros/MacroTests.cs | 1 + src/Umbraco.Tests/Models/MacroTests.cs | 1 + src/Umbraco.Tests/Models/MemberTests.cs | 1 + src/Umbraco.Tests/Models/UserTests.cs | 1 + .../PropertyEditorValueEditorTests.cs | 1 + .../Published/ConvertersTests.cs | 1 + .../Runtimes/CoreRuntimeTests.cs | 8 ++++---- .../Scoping/ScopeEventDispatcherTests.cs | 1 + src/Umbraco.Web/Runtime/WebRuntime.cs | 4 ++-- src/Umbraco.Web/UmbracoApplicationBase.cs | 3 ++- 22 files changed, 46 insertions(+), 29 deletions(-) rename src/{Umbraco.Core => Umbraco.Abstractions}/Configuration/Configs.cs (83%) rename src/{Umbraco.Core/Composing => Umbraco.Abstractions/Configuration}/IConfigsFactory.cs (53%) rename src/Umbraco.Core/{Composing => Configuration}/ConfigsFactory.cs (81%) diff --git a/src/Umbraco.Core/Configuration/Configs.cs b/src/Umbraco.Abstractions/Configuration/Configs.cs similarity index 83% rename from src/Umbraco.Core/Configuration/Configs.cs rename to src/Umbraco.Abstractions/Configuration/Configs.cs index 51e1a327a0..e08c4097e4 100644 --- a/src/Umbraco.Core/Configuration/Configs.cs +++ b/src/Umbraco.Abstractions/Configuration/Configs.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -using System.Configuration; using Umbraco.Core.Composing; -using Umbraco.Core.Logging; namespace Umbraco.Core.Configuration { @@ -15,6 +13,13 @@ namespace Umbraco.Core.Configuration /// public class Configs { + private readonly Func _configGetter; + + public Configs(Func configGetter) + { + _configGetter = configGetter; + } + private readonly Dictionary> _configs = new Dictionary>(); private Dictionary> _registerings = new Dictionary>(); @@ -60,7 +65,7 @@ namespace Umbraco.Core.Configuration _configs[typeOfConfig] = new Lazy(() => { - if (Current.HasFactory) return Current.Factory.GetInstance(); + if (CurrentCore.HasFactory) return CurrentCore.Factory.GetInstance(); throw new InvalidOperationException($"Cannot get configuration of type {typeOfConfig} during composition."); }); _registerings[typeOfConfig] = register => register.Register(configFactory, Lifetime.Singleton); @@ -75,7 +80,7 @@ namespace Umbraco.Core.Configuration Add(() => GetConfig(sectionName)); } - private static TConfig GetConfig(string sectionName) + private TConfig GetConfig(string sectionName) where TConfig : class { // note: need to use SafeCallContext here because ConfigurationManager.GetSection ends up getting AppDomain.Evidence @@ -83,10 +88,11 @@ namespace Umbraco.Core.Configuration using (new SafeCallContext()) { - if ((ConfigurationManager.GetSection(sectionName) is TConfig config)) + if ((_configGetter(sectionName) is TConfig config)) return config; - var ex = new ConfigurationErrorsException($"Could not get configuration section \"{sectionName}\" from config files."); - Current.Logger.Error(ex, "Config error"); +// var ex = new ConfigurationErrorsException($"Could not get configuration section \"{sectionName}\" from config files."); + var ex = new Exception($"Could not get configuration section \"{sectionName}\" from config files."); +// Current.Logger.Error(ex, "Config error"); throw ex; } } diff --git a/src/Umbraco.Core/Composing/IConfigsFactory.cs b/src/Umbraco.Abstractions/Configuration/IConfigsFactory.cs similarity index 53% rename from src/Umbraco.Core/Composing/IConfigsFactory.cs rename to src/Umbraco.Abstractions/Configuration/IConfigsFactory.cs index 1b12f5e157..3e36f3fb55 100644 --- a/src/Umbraco.Core/Composing/IConfigsFactory.cs +++ b/src/Umbraco.Abstractions/Configuration/IConfigsFactory.cs @@ -1,6 +1,4 @@ -using Umbraco.Core.Configuration; - -namespace Umbraco.Core.Composing +namespace Umbraco.Core.Configuration { public interface IConfigsFactory { diff --git a/src/Umbraco.Abstractions/Services/IRuntime.cs b/src/Umbraco.Abstractions/Services/IRuntime.cs index d433dde12d..a7944ad256 100644 --- a/src/Umbraco.Abstractions/Services/IRuntime.cs +++ b/src/Umbraco.Abstractions/Services/IRuntime.cs @@ -1,4 +1,5 @@ using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; namespace Umbraco.Core { @@ -12,7 +13,7 @@ namespace Umbraco.Core /// /// The application register. /// The application factory. - IFactory Boot(IRegister register); + IFactory Boot(IRegister register, IConfigsFactory configsFactory); /// /// Gets the runtime state. diff --git a/src/Umbraco.Core/Composing/ConfigsFactory.cs b/src/Umbraco.Core/Configuration/ConfigsFactory.cs similarity index 81% rename from src/Umbraco.Core/Composing/ConfigsFactory.cs rename to src/Umbraco.Core/Configuration/ConfigsFactory.cs index 995ab4e3aa..aeeef1e653 100644 --- a/src/Umbraco.Core/Composing/ConfigsFactory.cs +++ b/src/Umbraco.Core/Configuration/ConfigsFactory.cs @@ -1,7 +1,6 @@ using System.Configuration; -using Umbraco.Core.Configuration; -namespace Umbraco.Core.Composing +namespace Umbraco.Core.Configuration { public class ConfigsFactory : IConfigsFactory { diff --git a/src/Umbraco.Core/Configuration/CoreDebug.cs b/src/Umbraco.Core/Configuration/CoreDebug.cs index b24e8a3329..aa95a25990 100644 --- a/src/Umbraco.Core/Configuration/CoreDebug.cs +++ b/src/Umbraco.Core/Configuration/CoreDebug.cs @@ -1,4 +1,5 @@ using System; +using System.Configuration; namespace Umbraco.Core.Configuration { @@ -6,7 +7,7 @@ namespace Umbraco.Core.Configuration { public CoreDebug() { - var appSettings = System.Configuration.ConfigurationManager.AppSettings; + var appSettings = ConfigurationManager.AppSettings; LogUncompletedScopes = string.Equals("true", appSettings[Constants.AppSettings.Debug.LogUncompletedScopes], StringComparison.OrdinalIgnoreCase); DumpOnTimeoutThreadAbort = string.Equals("true", appSettings[Constants.AppSettings.Debug.DumpOnTimeoutThreadAbort], StringComparison.OrdinalIgnoreCase); } diff --git a/src/Umbraco.Core/Runtime/CoreRuntime.cs b/src/Umbraco.Core/Runtime/CoreRuntime.cs index d9c8ff05d3..237dcece64 100644 --- a/src/Umbraco.Core/Runtime/CoreRuntime.cs +++ b/src/Umbraco.Core/Runtime/CoreRuntime.cs @@ -47,7 +47,7 @@ namespace Umbraco.Core.Runtime public IRuntimeState State => _state; /// - public virtual IFactory Boot(IRegister register) + public virtual IFactory Boot(IRegister register, IConfigsFactory configsFactory) { // create and register the essential services // ie the bare minimum required to boot @@ -82,7 +82,7 @@ namespace Umbraco.Core.Runtime ConfigureUnhandledException(); ConfigureApplicationRootPath(); - Boot(register, timer); + Boot(register, timer, configsFactory); } return _factory; @@ -91,7 +91,7 @@ namespace Umbraco.Core.Runtime /// /// Boots the runtime within a timer. /// - protected virtual IFactory Boot(IRegister register, DisposableTimer timer) + protected virtual IFactory Boot(IRegister register, DisposableTimer timer, IConfigsFactory configsFactory) { Composition composition = null; @@ -110,7 +110,7 @@ namespace Umbraco.Core.Runtime var databaseFactory = GetDatabaseFactory(); // configs - var configs = GetConfigs(); + var configs = GetConfigs(configsFactory); // type loader var typeLoader = new TypeLoader(appCaches.RuntimeCache, configs.Global().LocalTempPath, ProfilingLogger); @@ -344,9 +344,9 @@ namespace Umbraco.Core.Runtime /// /// Gets the configurations. /// - protected virtual Configs GetConfigs() + protected virtual Configs GetConfigs(IConfigsFactory configsFactory) { - var configs = new ConfigsFactory().Create(); + var configs = configsFactory.Create(); return configs; } diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index f40f81ef71..5755532cd6 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -158,9 +158,7 @@ - - @@ -176,6 +174,7 @@ + diff --git a/src/Umbraco.Tests/Cache/DistributedCache/DistributedCacheTests.cs b/src/Umbraco.Tests/Cache/DistributedCache/DistributedCacheTests.cs index 54318ace15..b752cb6a90 100644 --- a/src/Umbraco.Tests/Cache/DistributedCache/DistributedCacheTests.cs +++ b/src/Umbraco.Tests/Cache/DistributedCache/DistributedCacheTests.cs @@ -6,6 +6,7 @@ using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Logging; using Umbraco.Core.Sync; using Umbraco.Tests.Components; diff --git a/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs b/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs index 4303f59916..25d46a3cdc 100644 --- a/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs +++ b/src/Umbraco.Tests/Composing/CollectionBuildersTests.cs @@ -5,6 +5,7 @@ using Moq; using NUnit.Framework; using Umbraco.Core.Composing; using Umbraco.Core; +using Umbraco.Core.Configuration; using Umbraco.Core.Logging; using Umbraco.Tests.Components; diff --git a/src/Umbraco.Tests/Composing/CompositionTests.cs b/src/Umbraco.Tests/Composing/CompositionTests.cs index 72f7e99ca6..06c9c0b786 100644 --- a/src/Umbraco.Tests/Composing/CompositionTests.cs +++ b/src/Umbraco.Tests/Composing/CompositionTests.cs @@ -4,6 +4,7 @@ using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.IO; using Umbraco.Core.Logging; diff --git a/src/Umbraco.Tests/Composing/PackageActionCollectionTests.cs b/src/Umbraco.Tests/Composing/PackageActionCollectionTests.cs index 57f691eea5..0073a4d624 100644 --- a/src/Umbraco.Tests/Composing/PackageActionCollectionTests.cs +++ b/src/Umbraco.Tests/Composing/PackageActionCollectionTests.cs @@ -6,6 +6,7 @@ using Moq; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Logging; using Umbraco.Core.PackageActions; using Umbraco.Tests.Components; diff --git a/src/Umbraco.Tests/IO/FileSystemsTests.cs b/src/Umbraco.Tests/IO/FileSystemsTests.cs index 28c1817862..2a32a1bc27 100644 --- a/src/Umbraco.Tests/IO/FileSystemsTests.cs +++ b/src/Umbraco.Tests/IO/FileSystemsTests.cs @@ -13,6 +13,7 @@ using Umbraco.Core.Services; using Umbraco.Tests.Components; using Umbraco.Tests.TestHelpers; using Umbraco.Core.Composing.CompositionExtensions; +using Umbraco.Core.Configuration; using FileSystems = Umbraco.Core.IO.FileSystems; namespace Umbraco.Tests.IO diff --git a/src/Umbraco.Tests/Macros/MacroTests.cs b/src/Umbraco.Tests/Macros/MacroTests.cs index 4700edc64b..e813424ad6 100644 --- a/src/Umbraco.Tests/Macros/MacroTests.cs +++ b/src/Umbraco.Tests/Macros/MacroTests.cs @@ -2,6 +2,7 @@ using Umbraco.Core; using Umbraco.Core.Cache; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Models; using Umbraco.Tests.TestHelpers; using Umbraco.Web.Macros; diff --git a/src/Umbraco.Tests/Models/MacroTests.cs b/src/Umbraco.Tests/Models/MacroTests.cs index 117301815e..e96a8c7915 100644 --- a/src/Umbraco.Tests/Models/MacroTests.cs +++ b/src/Umbraco.Tests/Models/MacroTests.cs @@ -2,6 +2,7 @@ using System.Linq; using NUnit.Framework; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Models; using Umbraco.Core.Models.Entities; using Umbraco.Tests.TestHelpers; diff --git a/src/Umbraco.Tests/Models/MemberTests.cs b/src/Umbraco.Tests/Models/MemberTests.cs index 9b478304d1..666b9a8ab1 100644 --- a/src/Umbraco.Tests/Models/MemberTests.cs +++ b/src/Umbraco.Tests/Models/MemberTests.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Linq; using NUnit.Framework; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Models; using Umbraco.Core.Serialization; using Umbraco.Tests.TestHelpers; diff --git a/src/Umbraco.Tests/Models/UserTests.cs b/src/Umbraco.Tests/Models/UserTests.cs index 8cc66d5eb0..b8151fc944 100644 --- a/src/Umbraco.Tests/Models/UserTests.cs +++ b/src/Umbraco.Tests/Models/UserTests.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.Linq; using NUnit.Framework; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Models.Membership; using Umbraco.Core.Serialization; using Umbraco.Tests.TestHelpers; diff --git a/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs b/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs index 348305fbf5..c1b80b97b1 100644 --- a/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs +++ b/src/Umbraco.Tests/PropertyEditors/PropertyEditorValueEditorTests.cs @@ -4,6 +4,7 @@ using Moq; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.PropertyEditors; diff --git a/src/Umbraco.Tests/Published/ConvertersTests.cs b/src/Umbraco.Tests/Published/ConvertersTests.cs index f3dd459ba3..01e14edf12 100644 --- a/src/Umbraco.Tests/Published/ConvertersTests.cs +++ b/src/Umbraco.Tests/Published/ConvertersTests.cs @@ -5,6 +5,7 @@ using Moq; using NUnit.Framework; using Umbraco.Core; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; diff --git a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs index 449cddfcc6..daf4f4afe6 100644 --- a/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs +++ b/src/Umbraco.Tests/Runtimes/CoreRuntimeTests.cs @@ -102,9 +102,9 @@ namespace Umbraco.Tests.Runtimes return mock.Object; } - protected override Configs GetConfigs() + protected override Configs GetConfigs(IConfigsFactory configsFactory) { - var configs = new ConfigsFactory().Create(); + var configs = configsFactory.Create(); configs.Add(SettingsForTests.GetDefaultGlobalSettings); configs.Add(SettingsForTests.GetDefaultUmbracoSettings); return configs; @@ -142,9 +142,9 @@ namespace Umbraco.Tests.Runtimes private IMainDom _mainDom; - public override IFactory Boot(IRegister container) + public override IFactory Boot(IRegister container, IConfigsFactory configsFactory) { - var factory = base.Boot(container); + var factory = base.Boot(container, configsFactory); _mainDom = factory.GetInstance(); return factory; } diff --git a/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs b/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs index b964f89be8..1597ef35cc 100644 --- a/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs +++ b/src/Umbraco.Tests/Scoping/ScopeEventDispatcherTests.cs @@ -11,6 +11,7 @@ using Umbraco.Core.Scoping; using Umbraco.Tests.TestHelpers; using Umbraco.Tests.TestHelpers.Entities; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Persistence.Mappers; using Umbraco.Core.Services; using Umbraco.Tests.Components; diff --git a/src/Umbraco.Web/Runtime/WebRuntime.cs b/src/Umbraco.Web/Runtime/WebRuntime.cs index 13cd717fd1..ede500e599 100644 --- a/src/Umbraco.Web/Runtime/WebRuntime.cs +++ b/src/Umbraco.Web/Runtime/WebRuntime.cs @@ -27,7 +27,7 @@ namespace Umbraco.Web.Runtime } /// - public override IFactory Boot(IRegister register) + public override IFactory Boot(IRegister register, IConfigsFactory configsFactory) { // create and start asap to profile boot var debug = GlobalSettings.DebugMode; @@ -43,7 +43,7 @@ namespace Umbraco.Web.Runtime _webProfiler = new VoidProfiler(); } - var factory = base.Boot(register); + var factory = base.Boot(register, configsFactory); // now (and only now) is the time to switch over to perWebRequest scopes. // up until that point we may not have a request, and scoped services would diff --git a/src/Umbraco.Web/UmbracoApplicationBase.cs b/src/Umbraco.Web/UmbracoApplicationBase.cs index 59b5b1779b..24800500a8 100644 --- a/src/Umbraco.Web/UmbracoApplicationBase.cs +++ b/src/Umbraco.Web/UmbracoApplicationBase.cs @@ -5,6 +5,7 @@ using System.Web; using System.Web.Hosting; using Umbraco.Core; using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; using Umbraco.Core.Logging; using Umbraco.Core.Logging.Serilog; @@ -62,7 +63,7 @@ namespace Umbraco.Web // the boot manager is responsible for registrations var register = GetRegister(); _runtime = GetRuntime(); - _runtime.Boot(register); + _runtime.Boot(register, new ConfigsFactory()); } // called by ASP.NET (auto event wireup) once per app domain From 7a0dc23867038a8dde5150edbddff75a2b5c4671 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Thu, 7 Nov 2019 10:08:16 +0100 Subject: [PATCH 7/9] Move some of the config to Umbraco.Configuration --- build/NuSpecs/tools/Web.config.install.xdt | 4 +- .../Properties/AssemblyInfo.cs | 35 +++++++++++ .../Umbraco.Abstractions.csproj | 4 ++ .../CaseInsensitiveEnumConfigConverter.cs | 0 .../CommaDelimitedConfigurationElement.cs | 2 +- .../DisabledHealthCheckElement.cs | 0 .../DisabledHealthChecksElementCollection.cs | 0 .../HealthCheckNotificationSettingsElement.cs | 0 .../HealthCheckNotificationVerbosity.cs | 0 .../HealthChecks/HealthChecksSection.cs | 0 .../HealthChecks/IDisabledHealthCheck.cs | 0 .../IHealthCheckNotificationSettings.cs | 0 .../HealthChecks/IHealthChecks.cs | 0 .../HealthChecks/INotificationMethod.cs | 0 .../INotificationMethodSettings.cs | 0 .../HealthChecks/NotificationMethodElement.cs | 0 .../NotificationMethodSettingsElement.cs | 0 ...ficationMethodSettingsElementCollection.cs | 0 .../NotificationMethodsElementCollection.cs | 0 ...ionalCommaDelimitedConfigurationElement.cs | 2 +- .../OptionalInnerTextConfigurationElement.cs | 2 +- .../Properties/AssemblyInfo.cs | 10 ++++ .../RawXmlConfigurationElement.cs | 2 +- .../Umbraco.Configuration.csproj | 8 +++ .../UmbracoConfigurationSection.cs | 0 .../UmbracoSettings/BackOfficeElement.cs | 2 +- .../UmbracoSettings/CharCollection.cs | 2 +- .../UmbracoSettings/CharElement.cs | 2 +- .../UmbracoSettings/ContentElement.cs | 4 +- .../ContentError404Collection.cs | 2 +- .../ContentErrorPageElement.cs | 2 +- .../UmbracoSettings/ContentErrorsElement.cs | 2 +- .../ContentSectionExtensions.cs | 0 .../ImagingAutoFillPropertiesCollection.cs | 2 +- .../ImagingAutoFillUploadFieldElement.cs | 2 +- .../UmbracoSettings/LoggingElement.cs | 2 +- .../UmbracoSettings/NotificationsElement.cs | 2 +- .../UmbracoSettings/SecurityElement.cs | 2 +- .../UmbracoSettings/TourConfigElement.cs | 2 +- .../UmbracoConfigurationElement.cs | 2 +- .../UmbracoSettings/UmbracoSettingsSection.cs | 12 ++-- .../UmbracoSettings/UrlReplacingElement.cs | 2 +- .../UmbracoSettings/WebRoutingElement.cs | 2 +- .../UmbracoVersion.cs | 2 +- .../Configuration/ConfigsExtensions.cs | 34 +++++++++++ src/Umbraco.Core/Umbraco.Core.csproj | 60 ++++--------------- .../Configurations/UmbracoSettings/web.config | 8 +-- src/Umbraco.Tests/Umbraco.Tests.csproj | 5 ++ src/Umbraco.Web.UI/web.Template.config | 4 +- src/Umbraco.Web/Umbraco.Web.csproj | 4 ++ 50 files changed, 146 insertions(+), 86 deletions(-) create mode 100644 src/Umbraco.Abstractions/Properties/AssemblyInfo.cs rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/CaseInsensitiveEnumConfigConverter.cs (100%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/CommaDelimitedConfigurationElement.cs (93%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/HealthChecks/DisabledHealthCheckElement.cs (100%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/HealthChecks/DisabledHealthChecksElementCollection.cs (100%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/HealthChecks/HealthCheckNotificationSettingsElement.cs (100%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/HealthChecks/HealthCheckNotificationVerbosity.cs (100%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/HealthChecks/HealthChecksSection.cs (100%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/HealthChecks/IDisabledHealthCheck.cs (100%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/HealthChecks/IHealthCheckNotificationSettings.cs (100%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/HealthChecks/IHealthChecks.cs (100%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/HealthChecks/INotificationMethod.cs (100%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/HealthChecks/INotificationMethodSettings.cs (100%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/HealthChecks/NotificationMethodElement.cs (100%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/HealthChecks/NotificationMethodSettingsElement.cs (100%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/HealthChecks/NotificationMethodSettingsElementCollection.cs (100%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/HealthChecks/NotificationMethodsElementCollection.cs (100%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/OptionalCommaDelimitedConfigurationElement.cs (92%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/OptionalInnerTextConfigurationElement.cs (88%) create mode 100644 src/Umbraco.Configuration/Properties/AssemblyInfo.cs rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/RawXmlConfigurationElement.cs (90%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoConfigurationSection.cs (100%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/BackOfficeElement.cs (76%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/CharCollection.cs (90%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/CharElement.cs (87%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/ContentElement.cs (98%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/ContentError404Collection.cs (89%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/ContentErrorPageElement.cs (92%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/ContentErrorsElement.cs (95%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/ContentSectionExtensions.cs (100%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/ImagingAutoFillPropertiesCollection.cs (88%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/ImagingAutoFillUploadFieldElement.cs (93%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/LoggingElement.cs (80%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/NotificationsElement.cs (86%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/SecurityElement.cs (97%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/TourConfigElement.cs (85%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/UmbracoConfigurationElement.cs (95%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/UmbracoSettingsSection.cs (64%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/UrlReplacingElement.cs (92%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/WebRoutingElement.cs (94%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoVersion.cs (98%) create mode 100644 src/Umbraco.Core/Configuration/ConfigsExtensions.cs diff --git a/build/NuSpecs/tools/Web.config.install.xdt b/build/NuSpecs/tools/Web.config.install.xdt index 2b79f95c70..f118fa8c3a 100644 --- a/build/NuSpecs/tools/Web.config.install.xdt +++ b/build/NuSpecs/tools/Web.config.install.xdt @@ -5,9 +5,9 @@ -
+
-
+
diff --git a/src/Umbraco.Abstractions/Properties/AssemblyInfo.cs b/src/Umbraco.Abstractions/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..6d5520f975 --- /dev/null +++ b/src/Umbraco.Abstractions/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: ComVisible(false)] +[assembly: Guid("DA322714-FB89-4943-92BD-BB122B82F66B")] + +// Umbraco Cms +[assembly: InternalsVisibleTo("Umbraco.Web")] +[assembly: InternalsVisibleTo("Umbraco.Web.UI")] +[assembly: InternalsVisibleTo("Umbraco.Examine")] +[assembly: InternalsVisibleTo("Umbraco.ModelsBuilder.Embedded")] + +[assembly: InternalsVisibleTo("Umbraco.Tests")] +[assembly: InternalsVisibleTo("Umbraco.Tests.Benchmarks")] + +// Allow this to be mocked in our unit tests +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] + +// Umbraco Deploy +[assembly: InternalsVisibleTo("Umbraco.Deploy")] +[assembly: InternalsVisibleTo("Umbraco.Deploy.UI")] +[assembly: InternalsVisibleTo("Umbraco.Deploy.Cloud")] + +// Umbraco Forms +[assembly: InternalsVisibleTo("Umbraco.Forms.Core")] +[assembly: InternalsVisibleTo("Umbraco.Forms.Core.Providers")] +[assembly: InternalsVisibleTo("Umbraco.Forms.Web")] + +// Umbraco Headless +[assembly: InternalsVisibleTo("Umbraco.Cloud.Headless")] + +// code analysis +// IDE1006 is broken, wants _value syntax for consts, etc - and it's even confusing ppl at MS, kill it +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "~_~")] diff --git a/src/Umbraco.Abstractions/Umbraco.Abstractions.csproj b/src/Umbraco.Abstractions/Umbraco.Abstractions.csproj index 4a3654ede6..4ffd6ec08b 100644 --- a/src/Umbraco.Abstractions/Umbraco.Abstractions.csproj +++ b/src/Umbraco.Abstractions/Umbraco.Abstractions.csproj @@ -4,6 +4,10 @@ netstandard2.0 7.3 Umbraco.Core + 9.0.0 + 9.0.0 + 9.0.0 + Umbraco CMS diff --git a/src/Umbraco.Core/Configuration/CaseInsensitiveEnumConfigConverter.cs b/src/Umbraco.Configuration/CaseInsensitiveEnumConfigConverter.cs similarity index 100% rename from src/Umbraco.Core/Configuration/CaseInsensitiveEnumConfigConverter.cs rename to src/Umbraco.Configuration/CaseInsensitiveEnumConfigConverter.cs diff --git a/src/Umbraco.Core/Configuration/CommaDelimitedConfigurationElement.cs b/src/Umbraco.Configuration/CommaDelimitedConfigurationElement.cs similarity index 93% rename from src/Umbraco.Core/Configuration/CommaDelimitedConfigurationElement.cs rename to src/Umbraco.Configuration/CommaDelimitedConfigurationElement.cs index 3ced2fab46..00dde5f206 100644 --- a/src/Umbraco.Core/Configuration/CommaDelimitedConfigurationElement.cs +++ b/src/Umbraco.Configuration/CommaDelimitedConfigurationElement.cs @@ -8,7 +8,7 @@ namespace Umbraco.Core.Configuration /// /// Defines a configuration section that contains inner text that is comma delimited /// - internal class CommaDelimitedConfigurationElement : InnerTextConfigurationElement, IEnumerable + public class CommaDelimitedConfigurationElement : InnerTextConfigurationElement, IEnumerable { public override CommaDelimitedStringCollection Value { diff --git a/src/Umbraco.Core/Configuration/HealthChecks/DisabledHealthCheckElement.cs b/src/Umbraco.Configuration/HealthChecks/DisabledHealthCheckElement.cs similarity index 100% rename from src/Umbraco.Core/Configuration/HealthChecks/DisabledHealthCheckElement.cs rename to src/Umbraco.Configuration/HealthChecks/DisabledHealthCheckElement.cs diff --git a/src/Umbraco.Core/Configuration/HealthChecks/DisabledHealthChecksElementCollection.cs b/src/Umbraco.Configuration/HealthChecks/DisabledHealthChecksElementCollection.cs similarity index 100% rename from src/Umbraco.Core/Configuration/HealthChecks/DisabledHealthChecksElementCollection.cs rename to src/Umbraco.Configuration/HealthChecks/DisabledHealthChecksElementCollection.cs diff --git a/src/Umbraco.Core/Configuration/HealthChecks/HealthCheckNotificationSettingsElement.cs b/src/Umbraco.Configuration/HealthChecks/HealthCheckNotificationSettingsElement.cs similarity index 100% rename from src/Umbraco.Core/Configuration/HealthChecks/HealthCheckNotificationSettingsElement.cs rename to src/Umbraco.Configuration/HealthChecks/HealthCheckNotificationSettingsElement.cs diff --git a/src/Umbraco.Core/Configuration/HealthChecks/HealthCheckNotificationVerbosity.cs b/src/Umbraco.Configuration/HealthChecks/HealthCheckNotificationVerbosity.cs similarity index 100% rename from src/Umbraco.Core/Configuration/HealthChecks/HealthCheckNotificationVerbosity.cs rename to src/Umbraco.Configuration/HealthChecks/HealthCheckNotificationVerbosity.cs diff --git a/src/Umbraco.Core/Configuration/HealthChecks/HealthChecksSection.cs b/src/Umbraco.Configuration/HealthChecks/HealthChecksSection.cs similarity index 100% rename from src/Umbraco.Core/Configuration/HealthChecks/HealthChecksSection.cs rename to src/Umbraco.Configuration/HealthChecks/HealthChecksSection.cs diff --git a/src/Umbraco.Core/Configuration/HealthChecks/IDisabledHealthCheck.cs b/src/Umbraco.Configuration/HealthChecks/IDisabledHealthCheck.cs similarity index 100% rename from src/Umbraco.Core/Configuration/HealthChecks/IDisabledHealthCheck.cs rename to src/Umbraco.Configuration/HealthChecks/IDisabledHealthCheck.cs diff --git a/src/Umbraco.Core/Configuration/HealthChecks/IHealthCheckNotificationSettings.cs b/src/Umbraco.Configuration/HealthChecks/IHealthCheckNotificationSettings.cs similarity index 100% rename from src/Umbraco.Core/Configuration/HealthChecks/IHealthCheckNotificationSettings.cs rename to src/Umbraco.Configuration/HealthChecks/IHealthCheckNotificationSettings.cs diff --git a/src/Umbraco.Core/Configuration/HealthChecks/IHealthChecks.cs b/src/Umbraco.Configuration/HealthChecks/IHealthChecks.cs similarity index 100% rename from src/Umbraco.Core/Configuration/HealthChecks/IHealthChecks.cs rename to src/Umbraco.Configuration/HealthChecks/IHealthChecks.cs diff --git a/src/Umbraco.Core/Configuration/HealthChecks/INotificationMethod.cs b/src/Umbraco.Configuration/HealthChecks/INotificationMethod.cs similarity index 100% rename from src/Umbraco.Core/Configuration/HealthChecks/INotificationMethod.cs rename to src/Umbraco.Configuration/HealthChecks/INotificationMethod.cs diff --git a/src/Umbraco.Core/Configuration/HealthChecks/INotificationMethodSettings.cs b/src/Umbraco.Configuration/HealthChecks/INotificationMethodSettings.cs similarity index 100% rename from src/Umbraco.Core/Configuration/HealthChecks/INotificationMethodSettings.cs rename to src/Umbraco.Configuration/HealthChecks/INotificationMethodSettings.cs diff --git a/src/Umbraco.Core/Configuration/HealthChecks/NotificationMethodElement.cs b/src/Umbraco.Configuration/HealthChecks/NotificationMethodElement.cs similarity index 100% rename from src/Umbraco.Core/Configuration/HealthChecks/NotificationMethodElement.cs rename to src/Umbraco.Configuration/HealthChecks/NotificationMethodElement.cs diff --git a/src/Umbraco.Core/Configuration/HealthChecks/NotificationMethodSettingsElement.cs b/src/Umbraco.Configuration/HealthChecks/NotificationMethodSettingsElement.cs similarity index 100% rename from src/Umbraco.Core/Configuration/HealthChecks/NotificationMethodSettingsElement.cs rename to src/Umbraco.Configuration/HealthChecks/NotificationMethodSettingsElement.cs diff --git a/src/Umbraco.Core/Configuration/HealthChecks/NotificationMethodSettingsElementCollection.cs b/src/Umbraco.Configuration/HealthChecks/NotificationMethodSettingsElementCollection.cs similarity index 100% rename from src/Umbraco.Core/Configuration/HealthChecks/NotificationMethodSettingsElementCollection.cs rename to src/Umbraco.Configuration/HealthChecks/NotificationMethodSettingsElementCollection.cs diff --git a/src/Umbraco.Core/Configuration/HealthChecks/NotificationMethodsElementCollection.cs b/src/Umbraco.Configuration/HealthChecks/NotificationMethodsElementCollection.cs similarity index 100% rename from src/Umbraco.Core/Configuration/HealthChecks/NotificationMethodsElementCollection.cs rename to src/Umbraco.Configuration/HealthChecks/NotificationMethodsElementCollection.cs diff --git a/src/Umbraco.Core/Configuration/OptionalCommaDelimitedConfigurationElement.cs b/src/Umbraco.Configuration/OptionalCommaDelimitedConfigurationElement.cs similarity index 92% rename from src/Umbraco.Core/Configuration/OptionalCommaDelimitedConfigurationElement.cs rename to src/Umbraco.Configuration/OptionalCommaDelimitedConfigurationElement.cs index 610067d2db..b6771f98b0 100644 --- a/src/Umbraco.Core/Configuration/OptionalCommaDelimitedConfigurationElement.cs +++ b/src/Umbraco.Configuration/OptionalCommaDelimitedConfigurationElement.cs @@ -6,7 +6,7 @@ namespace Umbraco.Core.Configuration /// /// Used for specifying default values for comma delimited config /// - internal class OptionalCommaDelimitedConfigurationElement : CommaDelimitedConfigurationElement + public class OptionalCommaDelimitedConfigurationElement : CommaDelimitedConfigurationElement { private readonly CommaDelimitedConfigurationElement _wrapped; private readonly string[] _defaultValue; diff --git a/src/Umbraco.Core/Configuration/OptionalInnerTextConfigurationElement.cs b/src/Umbraco.Configuration/OptionalInnerTextConfigurationElement.cs similarity index 88% rename from src/Umbraco.Core/Configuration/OptionalInnerTextConfigurationElement.cs rename to src/Umbraco.Configuration/OptionalInnerTextConfigurationElement.cs index b15e33019d..08dffd5975 100644 --- a/src/Umbraco.Core/Configuration/OptionalInnerTextConfigurationElement.cs +++ b/src/Umbraco.Configuration/OptionalInnerTextConfigurationElement.cs @@ -4,7 +4,7 @@ /// This is used to supply optional/default values when using InnerTextConfigurationElement ///
/// - internal class OptionalInnerTextConfigurationElement : InnerTextConfigurationElement + public class OptionalInnerTextConfigurationElement : InnerTextConfigurationElement { private readonly InnerTextConfigurationElement _wrapped; private readonly T _defaultValue; diff --git a/src/Umbraco.Configuration/Properties/AssemblyInfo.cs b/src/Umbraco.Configuration/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..d10dd929da --- /dev/null +++ b/src/Umbraco.Configuration/Properties/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Umbraco Cms +[assembly: InternalsVisibleTo("Umbraco.Tests")] +[assembly: InternalsVisibleTo("Umbraco.Tests.Benchmarks")] + +// Allow this to be mocked in our unit tests +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] diff --git a/src/Umbraco.Core/Configuration/RawXmlConfigurationElement.cs b/src/Umbraco.Configuration/RawXmlConfigurationElement.cs similarity index 90% rename from src/Umbraco.Core/Configuration/RawXmlConfigurationElement.cs rename to src/Umbraco.Configuration/RawXmlConfigurationElement.cs index 5bc6ad3d32..d7f0ed0332 100644 --- a/src/Umbraco.Core/Configuration/RawXmlConfigurationElement.cs +++ b/src/Umbraco.Configuration/RawXmlConfigurationElement.cs @@ -8,7 +8,7 @@ namespace Umbraco.Core.Configuration /// A configuration section that simply exposes the entire raw xml of the section itself which inheritors can use /// to do with as they please. /// - internal abstract class RawXmlConfigurationElement : ConfigurationElement + public abstract class RawXmlConfigurationElement : ConfigurationElement { protected RawXmlConfigurationElement() { diff --git a/src/Umbraco.Configuration/Umbraco.Configuration.csproj b/src/Umbraco.Configuration/Umbraco.Configuration.csproj index 15c6ac263f..04f8eb14d3 100644 --- a/src/Umbraco.Configuration/Umbraco.Configuration.csproj +++ b/src/Umbraco.Configuration/Umbraco.Configuration.csproj @@ -18,6 +18,8 @@ <_UnmanagedRegistrationCache Remove="obj\Umbraco.Configuration.csproj.UnmanagedRegistration.cache" /> + <_UnmanagedRegistrationCache Remove="obj\Umbraco.Configuration.csproj.UnmanagedRegistration.cache" /> + <_UnmanagedRegistrationCache Remove="obj\Umbraco.Configuration.csproj.UnmanagedRegistration.cache" /> @@ -28,4 +30,10 @@ + + + C:\Users\Bjarke\AppData\Local\Temp\Temporary ASP.NET Files\root\408beac9\de517473\assembly\dl3\77bf709f\48ac59e4_3595d501\Umbraco.Core.dll + + + diff --git a/src/Umbraco.Core/Configuration/UmbracoConfigurationSection.cs b/src/Umbraco.Configuration/UmbracoConfigurationSection.cs similarity index 100% rename from src/Umbraco.Core/Configuration/UmbracoConfigurationSection.cs rename to src/Umbraco.Configuration/UmbracoConfigurationSection.cs diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/BackOfficeElement.cs b/src/Umbraco.Configuration/UmbracoSettings/BackOfficeElement.cs similarity index 76% rename from src/Umbraco.Core/Configuration/UmbracoSettings/BackOfficeElement.cs rename to src/Umbraco.Configuration/UmbracoSettings/BackOfficeElement.cs index 79bff51d05..1a939d4c9e 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/BackOfficeElement.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/BackOfficeElement.cs @@ -2,7 +2,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class BackOfficeElement : UmbracoConfigurationElement, IBackOfficeSection + public class BackOfficeElement : UmbracoConfigurationElement, IBackOfficeSection { [ConfigurationProperty("tours")] internal TourConfigElement Tours => (TourConfigElement)this["tours"]; diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/CharCollection.cs b/src/Umbraco.Configuration/UmbracoSettings/CharCollection.cs similarity index 90% rename from src/Umbraco.Core/Configuration/UmbracoSettings/CharCollection.cs rename to src/Umbraco.Configuration/UmbracoSettings/CharCollection.cs index 7b62fcc123..3926e700c1 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/CharCollection.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/CharCollection.cs @@ -3,7 +3,7 @@ using System.Configuration; namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class CharCollection : ConfigurationElementCollection, IEnumerable + public class CharCollection : ConfigurationElementCollection, IEnumerable { internal void Add(CharElement c) { diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/CharElement.cs b/src/Umbraco.Configuration/UmbracoSettings/CharElement.cs similarity index 87% rename from src/Umbraco.Core/Configuration/UmbracoSettings/CharElement.cs rename to src/Umbraco.Configuration/UmbracoSettings/CharElement.cs index 1ff63ac017..2971228d9e 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/CharElement.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/CharElement.cs @@ -1,6 +1,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class CharElement : InnerTextConfigurationElement, IChar + public class CharElement : InnerTextConfigurationElement, IChar { private string _char; private string _replacement; diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs b/src/Umbraco.Configuration/UmbracoSettings/ContentElement.cs similarity index 98% rename from src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs rename to src/Umbraco.Configuration/UmbracoSettings/ContentElement.cs index 77ad7df0dc..1e1ecb4d0c 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentElement.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/ContentElement.cs @@ -4,7 +4,7 @@ using Umbraco.Core.Macros; namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class ContentElement : UmbracoConfigurationElement, IContentSection + public class ContentElement : UmbracoConfigurationElement, IContentSection { private const string DefaultPreviewBadge = @"
Preview modeClick to end
"; @@ -33,7 +33,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings [ConfigurationProperty("allowedUploadFiles")] internal CommaDelimitedConfigurationElement AllowedUploadFiles => GetOptionalDelimitedElement("allowedUploadFiles", new string[0]); - + [ConfigurationProperty("showDeprecatedPropertyEditors")] internal InnerTextConfigurationElement ShowDeprecatedPropertyEditors => GetOptionalTextElement("showDeprecatedPropertyEditors", false); diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentError404Collection.cs b/src/Umbraco.Configuration/UmbracoSettings/ContentError404Collection.cs similarity index 89% rename from src/Umbraco.Core/Configuration/UmbracoSettings/ContentError404Collection.cs rename to src/Umbraco.Configuration/UmbracoSettings/ContentError404Collection.cs index bdbcb27b4c..da146b14ec 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentError404Collection.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/ContentError404Collection.cs @@ -3,7 +3,7 @@ using System.Configuration; namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class ContentError404Collection : ConfigurationElementCollection, IEnumerable + public class ContentError404Collection : ConfigurationElementCollection, IEnumerable { internal void Add(ContentErrorPageElement element) { diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentErrorPageElement.cs b/src/Umbraco.Configuration/UmbracoSettings/ContentErrorPageElement.cs similarity index 92% rename from src/Umbraco.Core/Configuration/UmbracoSettings/ContentErrorPageElement.cs rename to src/Umbraco.Configuration/UmbracoSettings/ContentErrorPageElement.cs index 96cea71a8e..8f5a5b3259 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentErrorPageElement.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/ContentErrorPageElement.cs @@ -3,7 +3,7 @@ using System.Xml.Linq; namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class ContentErrorPageElement : InnerTextConfigurationElement, IContentErrorPage + public class ContentErrorPageElement : InnerTextConfigurationElement, IContentErrorPage { public ContentErrorPageElement(XElement rawXml) : base(rawXml) diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentErrorsElement.cs b/src/Umbraco.Configuration/UmbracoSettings/ContentErrorsElement.cs similarity index 95% rename from src/Umbraco.Core/Configuration/UmbracoSettings/ContentErrorsElement.cs rename to src/Umbraco.Configuration/UmbracoSettings/ContentErrorsElement.cs index 5b5b54380d..a393267b9d 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentErrorsElement.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/ContentErrorsElement.cs @@ -3,7 +3,7 @@ using System.Linq; namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class ContentErrorsElement : RawXmlConfigurationElement + public class ContentErrorsElement : RawXmlConfigurationElement { public IEnumerable Error404Collection diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentSectionExtensions.cs b/src/Umbraco.Configuration/UmbracoSettings/ContentSectionExtensions.cs similarity index 100% rename from src/Umbraco.Core/Configuration/UmbracoSettings/ContentSectionExtensions.cs rename to src/Umbraco.Configuration/UmbracoSettings/ContentSectionExtensions.cs diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ImagingAutoFillPropertiesCollection.cs b/src/Umbraco.Configuration/UmbracoSettings/ImagingAutoFillPropertiesCollection.cs similarity index 88% rename from src/Umbraco.Core/Configuration/UmbracoSettings/ImagingAutoFillPropertiesCollection.cs rename to src/Umbraco.Configuration/UmbracoSettings/ImagingAutoFillPropertiesCollection.cs index 0bac9721a3..69680251af 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/ImagingAutoFillPropertiesCollection.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/ImagingAutoFillPropertiesCollection.cs @@ -3,7 +3,7 @@ using System.Configuration; namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class ImagingAutoFillPropertiesCollection : ConfigurationElementCollection, IEnumerable + public class ImagingAutoFillPropertiesCollection : ConfigurationElementCollection, IEnumerable { protected override ConfigurationElement CreateNewElement() diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ImagingAutoFillUploadFieldElement.cs b/src/Umbraco.Configuration/UmbracoSettings/ImagingAutoFillUploadFieldElement.cs similarity index 93% rename from src/Umbraco.Core/Configuration/UmbracoSettings/ImagingAutoFillUploadFieldElement.cs rename to src/Umbraco.Configuration/UmbracoSettings/ImagingAutoFillUploadFieldElement.cs index 9b4c45b5c6..ec3dc43caf 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/ImagingAutoFillUploadFieldElement.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/ImagingAutoFillUploadFieldElement.cs @@ -2,7 +2,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class ImagingAutoFillUploadFieldElement : UmbracoConfigurationElement, IImagingAutoFillUploadField + public class ImagingAutoFillUploadFieldElement : UmbracoConfigurationElement, IImagingAutoFillUploadField { /// /// Allow setting internally so we can create a default diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/LoggingElement.cs b/src/Umbraco.Configuration/UmbracoSettings/LoggingElement.cs similarity index 80% rename from src/Umbraco.Core/Configuration/UmbracoSettings/LoggingElement.cs rename to src/Umbraco.Configuration/UmbracoSettings/LoggingElement.cs index 106b6cc134..daa45cf114 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/LoggingElement.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/LoggingElement.cs @@ -3,7 +3,7 @@ using System.Configuration; namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class LoggingElement : UmbracoConfigurationElement, ILoggingSection + public class LoggingElement : UmbracoConfigurationElement, ILoggingSection { [ConfigurationProperty("maxLogAge")] diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/NotificationsElement.cs b/src/Umbraco.Configuration/UmbracoSettings/NotificationsElement.cs similarity index 86% rename from src/Umbraco.Core/Configuration/UmbracoSettings/NotificationsElement.cs rename to src/Umbraco.Configuration/UmbracoSettings/NotificationsElement.cs index afadff5654..cc76b2cb00 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/NotificationsElement.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/NotificationsElement.cs @@ -2,7 +2,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class NotificationsElement : UmbracoConfigurationElement + public class NotificationsElement : UmbracoConfigurationElement { [ConfigurationProperty("email")] internal InnerTextConfigurationElement NotificationEmailAddress => (InnerTextConfigurationElement)this["email"]; diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/SecurityElement.cs b/src/Umbraco.Configuration/UmbracoSettings/SecurityElement.cs similarity index 97% rename from src/Umbraco.Core/Configuration/UmbracoSettings/SecurityElement.cs rename to src/Umbraco.Configuration/UmbracoSettings/SecurityElement.cs index d45a3e7d85..42bafe4bd1 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/SecurityElement.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/SecurityElement.cs @@ -2,7 +2,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class SecurityElement : UmbracoConfigurationElement, ISecuritySection + public class SecurityElement : UmbracoConfigurationElement, ISecuritySection { [ConfigurationProperty("keepUserLoggedIn")] internal InnerTextConfigurationElement KeepUserLoggedIn => GetOptionalTextElement("keepUserLoggedIn", true); diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/TourConfigElement.cs b/src/Umbraco.Configuration/UmbracoSettings/TourConfigElement.cs similarity index 85% rename from src/Umbraco.Core/Configuration/UmbracoSettings/TourConfigElement.cs rename to src/Umbraco.Configuration/UmbracoSettings/TourConfigElement.cs index dab69f3da0..f62d766d76 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/TourConfigElement.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/TourConfigElement.cs @@ -2,7 +2,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class TourConfigElement : UmbracoConfigurationElement, ITourSection + public class TourConfigElement : UmbracoConfigurationElement, ITourSection { //disabled by default so that upgraders don't get it enabled by default // TODO: we probably just want to disable the initial one from automatically loading ? diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/UmbracoConfigurationElement.cs b/src/Umbraco.Configuration/UmbracoSettings/UmbracoConfigurationElement.cs similarity index 95% rename from src/Umbraco.Core/Configuration/UmbracoSettings/UmbracoConfigurationElement.cs rename to src/Umbraco.Configuration/UmbracoSettings/UmbracoConfigurationElement.cs index 670f620b15..30cc33a260 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/UmbracoConfigurationElement.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/UmbracoConfigurationElement.cs @@ -6,7 +6,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings /// /// Base class with shared helper methods /// - internal class UmbracoConfigurationElement : ConfigurationElement + public class UmbracoConfigurationElement : ConfigurationElement { /// /// Used so the RawElement types are not re-created every time they are accessed diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/UmbracoSettingsSection.cs b/src/Umbraco.Configuration/UmbracoSettings/UmbracoSettingsSection.cs similarity index 64% rename from src/Umbraco.Core/Configuration/UmbracoSettings/UmbracoSettingsSection.cs rename to src/Umbraco.Configuration/UmbracoSettings/UmbracoSettingsSection.cs index 7cf8096345..bc91dfd48a 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/UmbracoSettingsSection.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/UmbracoSettingsSection.cs @@ -5,23 +5,23 @@ namespace Umbraco.Core.Configuration.UmbracoSettings public class UmbracoSettingsSection : ConfigurationSection, IUmbracoSettingsSection { [ConfigurationProperty("backOffice")] - internal BackOfficeElement BackOffice => (BackOfficeElement)this["backOffice"]; + public BackOfficeElement BackOffice => (BackOfficeElement)this["backOffice"]; [ConfigurationProperty("content")] - internal ContentElement Content => (ContentElement)this["content"]; + public ContentElement Content => (ContentElement)this["content"]; [ConfigurationProperty("security")] - internal SecurityElement Security => (SecurityElement)this["security"]; + public SecurityElement Security => (SecurityElement)this["security"]; [ConfigurationProperty("requestHandler")] - internal RequestHandlerElement RequestHandler => (RequestHandlerElement)this["requestHandler"]; + public RequestHandlerElement RequestHandler => (RequestHandlerElement)this["requestHandler"]; [ConfigurationProperty("logging")] - internal LoggingElement Logging => (LoggingElement)this["logging"]; + public LoggingElement Logging => (LoggingElement)this["logging"]; [ConfigurationProperty("web.routing")] - internal WebRoutingElement WebRouting => (WebRoutingElement)this["web.routing"]; + public WebRoutingElement WebRouting => (WebRoutingElement)this["web.routing"]; IContentSection IUmbracoSettingsSection.Content => Content; diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/UrlReplacingElement.cs b/src/Umbraco.Configuration/UmbracoSettings/UrlReplacingElement.cs similarity index 92% rename from src/Umbraco.Core/Configuration/UmbracoSettings/UrlReplacingElement.cs rename to src/Umbraco.Configuration/UmbracoSettings/UrlReplacingElement.cs index 3e12d106ff..45fe2c4294 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/UrlReplacingElement.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/UrlReplacingElement.cs @@ -3,7 +3,7 @@ using System.Configuration; namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class UrlReplacingElement : ConfigurationElement + public class UrlReplacingElement : ConfigurationElement { [ConfigurationProperty("removeDoubleDashes", DefaultValue = true)] internal bool RemoveDoubleDashes => (bool) base["removeDoubleDashes"]; diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/WebRoutingElement.cs b/src/Umbraco.Configuration/UmbracoSettings/WebRoutingElement.cs similarity index 94% rename from src/Umbraco.Core/Configuration/UmbracoSettings/WebRoutingElement.cs rename to src/Umbraco.Configuration/UmbracoSettings/WebRoutingElement.cs index 7b7102f2e7..4c74398e25 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/WebRoutingElement.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/WebRoutingElement.cs @@ -2,7 +2,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class WebRoutingElement : ConfigurationElement, IWebRoutingSection + public class WebRoutingElement : ConfigurationElement, IWebRoutingSection { [ConfigurationProperty("trySkipIisCustomErrors", DefaultValue = "false")] public bool TrySkipIisCustomErrors => (bool) base["trySkipIisCustomErrors"]; diff --git a/src/Umbraco.Core/Configuration/UmbracoVersion.cs b/src/Umbraco.Configuration/UmbracoVersion.cs similarity index 98% rename from src/Umbraco.Core/Configuration/UmbracoVersion.cs rename to src/Umbraco.Configuration/UmbracoVersion.cs index 2f615d26b3..d7058fda01 100644 --- a/src/Umbraco.Core/Configuration/UmbracoVersion.cs +++ b/src/Umbraco.Configuration/UmbracoVersion.cs @@ -12,7 +12,7 @@ namespace Umbraco.Core.Configuration { static UmbracoVersion() { - var umbracoCoreAssembly = typeof(UmbracoVersion).Assembly; + var umbracoCoreAssembly = typeof(SemVersion).Assembly; // gets the value indicated by the AssemblyVersion attribute AssemblyVersion = umbracoCoreAssembly.GetName().Version; diff --git a/src/Umbraco.Core/Configuration/ConfigsExtensions.cs b/src/Umbraco.Core/Configuration/ConfigsExtensions.cs new file mode 100644 index 0000000000..4761b14d1e --- /dev/null +++ b/src/Umbraco.Core/Configuration/ConfigsExtensions.cs @@ -0,0 +1,34 @@ +using System.IO; +using Umbraco.Core.Cache; +using Umbraco.Core.Composing; +using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.Grid; +using Umbraco.Core.Configuration.UmbracoSettings; +using Umbraco.Core.IO; +using Umbraco.Core.Logging; +using Umbraco.Core.Manifest; + +namespace Umbraco.Core +{ + /// + /// Provides extension methods for the class. + /// + public static class ConfigsExtensions + { + + + + public static void AddCoreConfigs(this Configs configs) + { + var configDir = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Config)); + + // GridConfig depends on runtime caches, manifest parsers... and cannot be available during composition + configs.Add(factory => new GridConfig( + factory.GetInstance(), + factory.GetInstance(), + configDir, + factory.GetInstance(), + factory.GetInstance().Debug)); + } + } +} diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 5755532cd6..859a618b74 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -174,8 +174,11 @@ - - + + + + + @@ -275,6 +278,7 @@ + @@ -315,53 +319,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -991,7 +948,6 @@ - @@ -1183,6 +1139,10 @@ {29aa69d9-b597-4395-8d42-43b1263c240a} Umbraco.Abstractions + + {fbe7c065-dac0-4025-a78b-63b24d3ab00b} + Umbraco.Configuration + \ No newline at end of file diff --git a/src/Umbraco.Tests/Configurations/UmbracoSettings/web.config b/src/Umbraco.Tests/Configurations/UmbracoSettings/web.config index 3b247ecbff..5ac2d56d14 100644 --- a/src/Umbraco.Tests/Configurations/UmbracoSettings/web.config +++ b/src/Umbraco.Tests/Configurations/UmbracoSettings/web.config @@ -1,10 +1,10 @@  - + -
-
+
+
@@ -13,4 +13,4 @@ - \ No newline at end of file + diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index de76b94ff1..4f4a20d94e 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -107,6 +107,7 @@ + @@ -552,6 +553,10 @@ {29aa69d9-b597-4395-8d42-43b1263c240a} Umbraco.Abstractions + + {fbe7c065-dac0-4025-a78b-63b24d3ab00b} + Umbraco.Configuration + {31785BC3-256C-4613-B2F5-A1B0BDDED8C1} Umbraco.Core diff --git a/src/Umbraco.Web.UI/web.Template.config b/src/Umbraco.Web.UI/web.Template.config index 6d68ea845a..e694afe5ff 100644 --- a/src/Umbraco.Web.UI/web.Template.config +++ b/src/Umbraco.Web.UI/web.Template.config @@ -11,8 +11,8 @@
-
-
+
+
diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index 317786b970..788a6dd737 100755 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -104,6 +104,10 @@ {29aa69d9-b597-4395-8d42-43b1263c240a} Umbraco.Abstractions + + {fbe7c065-dac0-4025-a78b-63b24d3ab00b} + Umbraco.Configuration + {31785bc3-256c-4613-b2f5-a1b0bdded8c1} Umbraco.Core From bd7a2d670a39c19d501edab6ee8fb9c571a8aee3 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Thu, 7 Nov 2019 10:10:12 +0100 Subject: [PATCH 8/9] Move some of the config to Umbraco.Configuration --- .../ConfigsExtensions.cs | 28 ++++++++++ src/Umbraco.Configuration/ConfigsFactory.cs | 21 ++++++++ .../CoreDebug.cs | 2 +- .../InnerTextConfigurationElement.cs | 2 +- .../UmbracoSettings/ContentImagingElement.cs | 6 +-- .../UmbracoSettings/RequestHandlerElement.cs | 4 +- src/Umbraco.Core/ConfigsExtensions.cs | 53 ------------------- .../Configuration/ConfigsFactory.cs | 13 ----- 8 files changed, 56 insertions(+), 73 deletions(-) create mode 100644 src/Umbraco.Configuration/ConfigsExtensions.cs create mode 100644 src/Umbraco.Configuration/ConfigsFactory.cs rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/CoreDebug.cs (97%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/InnerTextConfigurationElement.cs (96%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/ContentImagingElement.cs (91%) rename src/{Umbraco.Core/Configuration => Umbraco.Configuration}/UmbracoSettings/RequestHandlerElement.cs (95%) delete mode 100644 src/Umbraco.Core/ConfigsExtensions.cs delete mode 100644 src/Umbraco.Core/Configuration/ConfigsFactory.cs diff --git a/src/Umbraco.Configuration/ConfigsExtensions.cs b/src/Umbraco.Configuration/ConfigsExtensions.cs new file mode 100644 index 0000000000..0ecfc46896 --- /dev/null +++ b/src/Umbraco.Configuration/ConfigsExtensions.cs @@ -0,0 +1,28 @@ +using Umbraco.Core.Configuration; +using Umbraco.Core.Configuration.Grid; +using Umbraco.Core.Configuration.HealthChecks; +using Umbraco.Core.Configuration.UmbracoSettings; + +namespace Umbraco.Core +{ + /// + /// Provides extension methods for the class. + /// + public static class ConfigsExtensions + { + public static IGlobalSettings Global(this Configs configs) + => configs.GetConfig(); + + public static IUmbracoSettingsSection Settings(this Configs configs) + => configs.GetConfig(); + + public static IHealthChecks HealthChecks(this Configs configs) + => configs.GetConfig(); + + public static IGridConfig Grids(this Configs configs) + => configs.GetConfig(); + + public static CoreDebug CoreDebug(this Configs configs) + => configs.GetConfig(); + } +} diff --git a/src/Umbraco.Configuration/ConfigsFactory.cs b/src/Umbraco.Configuration/ConfigsFactory.cs new file mode 100644 index 0000000000..fbfefc132e --- /dev/null +++ b/src/Umbraco.Configuration/ConfigsFactory.cs @@ -0,0 +1,21 @@ +using System.Configuration; +using Umbraco.Core.Configuration.HealthChecks; +using Umbraco.Core.Configuration.UmbracoSettings; + +namespace Umbraco.Core.Configuration +{ + public class ConfigsFactory : IConfigsFactory + { + public Configs Create() { + var configs = new Configs(section => ConfigurationManager.GetSection(section)); + configs.Add(() => new GlobalSettings()); + configs.Add("umbracoConfiguration/settings"); + configs.Add("umbracoConfiguration/HealthChecks"); + + configs.Add(() => new CoreDebug()); + configs.Add("umbracoConfiguration/HealthChecks"); + configs.AddCoreConfigs(); + return configs; + } + } +} diff --git a/src/Umbraco.Core/Configuration/CoreDebug.cs b/src/Umbraco.Configuration/CoreDebug.cs similarity index 97% rename from src/Umbraco.Core/Configuration/CoreDebug.cs rename to src/Umbraco.Configuration/CoreDebug.cs index aa95a25990..e81ca14873 100644 --- a/src/Umbraco.Core/Configuration/CoreDebug.cs +++ b/src/Umbraco.Configuration/CoreDebug.cs @@ -3,7 +3,7 @@ using System.Configuration; namespace Umbraco.Core.Configuration { - internal class CoreDebug + public class CoreDebug { public CoreDebug() { diff --git a/src/Umbraco.Core/Configuration/InnerTextConfigurationElement.cs b/src/Umbraco.Configuration/InnerTextConfigurationElement.cs similarity index 96% rename from src/Umbraco.Core/Configuration/InnerTextConfigurationElement.cs rename to src/Umbraco.Configuration/InnerTextConfigurationElement.cs index 6a125f2c1b..3ff0c4d735 100644 --- a/src/Umbraco.Core/Configuration/InnerTextConfigurationElement.cs +++ b/src/Umbraco.Configuration/InnerTextConfigurationElement.cs @@ -9,7 +9,7 @@ namespace Umbraco.Core.Configuration /// {element}MyValue{/element} instead of as attribute values. ///
/// - internal class InnerTextConfigurationElement : RawXmlConfigurationElement + public class InnerTextConfigurationElement : RawXmlConfigurationElement { public InnerTextConfigurationElement() { diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentImagingElement.cs b/src/Umbraco.Configuration/UmbracoSettings/ContentImagingElement.cs similarity index 91% rename from src/Umbraco.Core/Configuration/UmbracoSettings/ContentImagingElement.cs rename to src/Umbraco.Configuration/UmbracoSettings/ContentImagingElement.cs index 67562c411a..91eb180d08 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/ContentImagingElement.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/ContentImagingElement.cs @@ -2,7 +2,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class ContentImagingElement : ConfigurationElement + public class ContentImagingElement : ConfigurationElement { [ConfigurationProperty("imageFileTypes")] @@ -12,7 +12,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings //set the default GetDefaultImageFileTypes()); - internal static string[] GetDefaultImageFileTypes() + public static string[] GetDefaultImageFileTypes() { return new[] {"jpeg", "jpg", "gif", "bmp", "png", "tiff", "tif"}; } @@ -49,7 +49,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings } } - internal static ImagingAutoFillPropertiesCollection GetDefaultImageAutoFillProperties() + public static ImagingAutoFillPropertiesCollection GetDefaultImageAutoFillProperties() { return new ImagingAutoFillPropertiesCollection { diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/RequestHandlerElement.cs b/src/Umbraco.Configuration/UmbracoSettings/RequestHandlerElement.cs similarity index 95% rename from src/Umbraco.Core/Configuration/UmbracoSettings/RequestHandlerElement.cs rename to src/Umbraco.Configuration/UmbracoSettings/RequestHandlerElement.cs index 263a822381..e5350bf596 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/RequestHandlerElement.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/RequestHandlerElement.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class RequestHandlerElement : UmbracoConfigurationElement, IRequestHandlerSection + public class RequestHandlerElement : UmbracoConfigurationElement, IRequestHandlerSection { [ConfigurationProperty("addTrailingSlash")] public InnerTextConfigurationElement AddTrailingSlash => GetOptionalTextElement("addTrailingSlash", true); @@ -38,7 +38,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings } } - internal static CharCollection GetDefaultCharReplacements() + public static CharCollection GetDefaultCharReplacements() { var dictionary = new Dictionary() { diff --git a/src/Umbraco.Core/ConfigsExtensions.cs b/src/Umbraco.Core/ConfigsExtensions.cs deleted file mode 100644 index 5699540389..0000000000 --- a/src/Umbraco.Core/ConfigsExtensions.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.IO; -using Umbraco.Core.Cache; -using Umbraco.Core.Composing; -using Umbraco.Core.Configuration; -using Umbraco.Core.Configuration.Grid; -using Umbraco.Core.Configuration.HealthChecks; -using Umbraco.Core.Configuration.UmbracoSettings; -using Umbraco.Core.IO; -using Umbraco.Core.Logging; -using Umbraco.Core.Manifest; - -namespace Umbraco.Core -{ - /// - /// Provides extension methods for the class. - /// - public static class ConfigsExtensions - { - public static IGlobalSettings Global(this Configs configs) - => configs.GetConfig(); - - public static IUmbracoSettingsSection Settings(this Configs configs) - => configs.GetConfig(); - - public static IHealthChecks HealthChecks(this Configs configs) - => configs.GetConfig(); - - public static IGridConfig Grids(this Configs configs) - => configs.GetConfig(); - - internal static CoreDebug CoreDebug(this Configs configs) - => configs.GetConfig(); - - public static void AddCoreConfigs(this Configs configs) - { - var configDir = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Config)); - - configs.Add(() => new GlobalSettings()); - configs.Add("umbracoConfiguration/settings"); - configs.Add("umbracoConfiguration/HealthChecks"); - - configs.Add(() => new CoreDebug()); - - // GridConfig depends on runtime caches, manifest parsers... and cannot be available during composition - configs.Add(factory => new GridConfig( - factory.GetInstance(), - factory.GetInstance(), - configDir, - factory.GetInstance(), - factory.GetInstance().Debug)); - } - } -} diff --git a/src/Umbraco.Core/Configuration/ConfigsFactory.cs b/src/Umbraco.Core/Configuration/ConfigsFactory.cs deleted file mode 100644 index aeeef1e653..0000000000 --- a/src/Umbraco.Core/Configuration/ConfigsFactory.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Configuration; - -namespace Umbraco.Core.Configuration -{ - public class ConfigsFactory : IConfigsFactory - { - public Configs Create() { - var configs = new Configs(section => ConfigurationManager.GetSection(section)); - configs.AddCoreConfigs(); - return configs; - } - } -} From 914d6f3f2e5df53d93df4321b9cadd17d23cabcf Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Thu, 7 Nov 2019 12:58:56 +0100 Subject: [PATCH 9/9] More config movement --- .../Configuration/ConfigsExtensions.cs | 2 - .../Configuration}/ConfigsFactory.cs | 1 - .../Configuration/Grid/GridEditorsConfig.cs | 6 +- src/Umbraco.Core/Manifest/IManifestFilter.cs | 2 +- src/Umbraco.Core/Manifest/IManifestParser.cs | 9 +- src/Umbraco.Core/Manifest/IPackageManifest.cs | 65 ++++++++ .../Manifest/ManifestFilterCollection.cs | 2 +- src/Umbraco.Core/Manifest/ManifestParser.cs | 15 +- src/Umbraco.Core/Manifest/PackageManifest.cs | 140 +++++++++--------- src/Umbraco.Core/Umbraco.Core.csproj | 2 + src/Umbraco.Tests/Published/ModelTypeTests.cs | 2 +- 11 files changed, 156 insertions(+), 90 deletions(-) rename src/{Umbraco.Configuration => Umbraco.Core/Configuration}/ConfigsFactory.cs (90%) create mode 100644 src/Umbraco.Core/Manifest/IPackageManifest.cs diff --git a/src/Umbraco.Core/Configuration/ConfigsExtensions.cs b/src/Umbraco.Core/Configuration/ConfigsExtensions.cs index 4761b14d1e..e54e360021 100644 --- a/src/Umbraco.Core/Configuration/ConfigsExtensions.cs +++ b/src/Umbraco.Core/Configuration/ConfigsExtensions.cs @@ -16,8 +16,6 @@ namespace Umbraco.Core public static class ConfigsExtensions { - - public static void AddCoreConfigs(this Configs configs) { var configDir = new DirectoryInfo(IOHelper.MapPath(SystemDirectories.Config)); diff --git a/src/Umbraco.Configuration/ConfigsFactory.cs b/src/Umbraco.Core/Configuration/ConfigsFactory.cs similarity index 90% rename from src/Umbraco.Configuration/ConfigsFactory.cs rename to src/Umbraco.Core/Configuration/ConfigsFactory.cs index fbfefc132e..c0e80d3798 100644 --- a/src/Umbraco.Configuration/ConfigsFactory.cs +++ b/src/Umbraco.Core/Configuration/ConfigsFactory.cs @@ -13,7 +13,6 @@ namespace Umbraco.Core.Configuration configs.Add("umbracoConfiguration/HealthChecks"); configs.Add(() => new CoreDebug()); - configs.Add("umbracoConfiguration/HealthChecks"); configs.AddCoreConfigs(); return configs; } diff --git a/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs b/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs index cab58a6d63..a1ebf008fc 100644 --- a/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs +++ b/src/Umbraco.Core/Configuration/Grid/GridEditorsConfig.cs @@ -29,9 +29,9 @@ namespace Umbraco.Core.Configuration.Grid { get { - List GetResult() + List GetResult() { - var editors = new List(); + var editors = new List(); var gridConfig = Path.Combine(_configFolder.FullName, "grid.editors.config.js"); if (File.Exists(gridConfig)) { @@ -59,7 +59,7 @@ namespace Umbraco.Core.Configuration.Grid //cache the result if debugging is disabled var result = _isDebug ? GetResult() - : _appCaches.RuntimeCache.GetCacheItem>(typeof(GridEditorsConfig) + ".Editors",GetResult, TimeSpan.FromMinutes(10)); + : _appCaches.RuntimeCache.GetCacheItem>(typeof(GridEditorsConfig) + ".Editors",GetResult, TimeSpan.FromMinutes(10)); return result; } diff --git a/src/Umbraco.Core/Manifest/IManifestFilter.cs b/src/Umbraco.Core/Manifest/IManifestFilter.cs index 505f13d385..f1e2c633c8 100644 --- a/src/Umbraco.Core/Manifest/IManifestFilter.cs +++ b/src/Umbraco.Core/Manifest/IManifestFilter.cs @@ -14,6 +14,6 @@ namespace Umbraco.Core.Manifest /// /// It is possible to remove, change, or add manifests. /// - void Filter(List manifests); + void Filter(List manifests); } } diff --git a/src/Umbraco.Core/Manifest/IManifestParser.cs b/src/Umbraco.Core/Manifest/IManifestParser.cs index 3641396e0a..367ee3be77 100644 --- a/src/Umbraco.Core/Manifest/IManifestParser.cs +++ b/src/Umbraco.Core/Manifest/IManifestParser.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Umbraco.Core.Configuration.Grid; using Umbraco.Core.PropertyEditors; namespace Umbraco.Core.Manifest @@ -11,13 +12,13 @@ namespace Umbraco.Core.Manifest /// Gets all manifests, merged into a single manifest object. ///
/// - PackageManifest Manifest { get; } + IPackageManifest Manifest { get; } /// /// Parses a manifest. /// - PackageManifest ParseManifest(string text); + IPackageManifest ParseManifest(string text); - IEnumerable ParseGridEditors(string text); + IEnumerable ParseGridEditors(string text); } -} \ No newline at end of file +} diff --git a/src/Umbraco.Core/Manifest/IPackageManifest.cs b/src/Umbraco.Core/Manifest/IPackageManifest.cs new file mode 100644 index 0000000000..01b0be70db --- /dev/null +++ b/src/Umbraco.Core/Manifest/IPackageManifest.cs @@ -0,0 +1,65 @@ +using System.Runtime.Serialization; +using Umbraco.Core.PropertyEditors; + +namespace Umbraco.Core.Manifest +{ + public interface IPackageManifest + { + /// + /// Gets the source path of the manifest. + /// + /// + /// Gets the full absolute file path of the manifest, + /// using system directory separators. + /// + string Source { get; set; } + + /// + /// Gets or sets the scripts listed in the manifest. + /// + [DataMember(Name = "javascript")] + string[] Scripts { get; set; } + + /// + /// Gets or sets the stylesheets listed in the manifest. + /// + [DataMember(Name = "css")] + string[] Stylesheets { get; set; } + + /// + /// Gets or sets the property editors listed in the manifest. + /// + [DataMember(Name = "propertyEditors")] + IDataEditor[] PropertyEditors { get; set; } + + /// + /// Gets or sets the parameter editors listed in the manifest. + /// + [DataMember(Name = "parameterEditors")] + IDataEditor[] ParameterEditors { get; set; } + + /// + /// Gets or sets the grid editors listed in the manifest. + /// + [DataMember(Name = "gridEditors")] + GridEditor[] GridEditors { get; set; } + + /// + /// Gets or sets the content apps listed in the manifest. + /// + [DataMember(Name = "contentApps")] + ManifestContentAppDefinition[] ContentApps { get; set; } + + /// + /// Gets or sets the dashboards listed in the manifest. + /// + [DataMember(Name = "dashboards")] + ManifestDashboard[] Dashboards { get; set; } + + /// + /// Gets or sets the sections listed in the manifest. + /// + [DataMember(Name = "sections")] + ManifestSection[] Sections { get; set; } + } +} diff --git a/src/Umbraco.Core/Manifest/ManifestFilterCollection.cs b/src/Umbraco.Core/Manifest/ManifestFilterCollection.cs index febdb7e356..0f49c96094 100644 --- a/src/Umbraco.Core/Manifest/ManifestFilterCollection.cs +++ b/src/Umbraco.Core/Manifest/ManifestFilterCollection.cs @@ -19,7 +19,7 @@ namespace Umbraco.Core.Manifest /// Filters package manifests. /// /// The package manifests. - public void Filter(List manifests) + public void Filter(List manifests) { foreach (var filter in this) filter.Filter(manifests); diff --git a/src/Umbraco.Core/Manifest/ManifestParser.cs b/src/Umbraco.Core/Manifest/ManifestParser.cs index 2e55d07059..4e2ca1f2b6 100644 --- a/src/Umbraco.Core/Manifest/ManifestParser.cs +++ b/src/Umbraco.Core/Manifest/ManifestParser.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using Newtonsoft.Json; using Umbraco.Core.Cache; +using Umbraco.Core.Configuration.Grid; using Umbraco.Core.Exceptions; using Umbraco.Core.IO; using Umbraco.Core.Logging; @@ -57,8 +58,8 @@ namespace Umbraco.Core.Manifest /// Gets all manifests, merged into a single manifest object. /// /// - public PackageManifest Manifest - => _cache.GetCacheItem("Umbraco.Core.Manifest.ManifestParser::Manifests", () => + public IPackageManifest Manifest + => _cache.GetCacheItem("Umbraco.Core.Manifest.ManifestParser::Manifests", () => { var manifests = GetManifests(); return MergeManifests(manifests); @@ -67,9 +68,9 @@ namespace Umbraco.Core.Manifest /// /// Gets all manifests. /// - private IEnumerable GetManifests() + private IEnumerable GetManifests() { - var manifests = new List(); + var manifests = new List(); foreach (var path in GetManifestFiles()) { @@ -97,7 +98,7 @@ namespace Umbraco.Core.Manifest /// /// Merges all manifests into one. /// - private static PackageManifest MergeManifests(IEnumerable manifests) + private static IPackageManifest MergeManifests(IEnumerable manifests) { var scripts = new HashSet(); var stylesheets = new HashSet(); @@ -153,7 +154,7 @@ namespace Umbraco.Core.Manifest /// /// Parses a manifest. /// - public PackageManifest ParseManifest(string text) + public IPackageManifest ParseManifest(string text) { if (string.IsNullOrWhiteSpace(text)) throw new ArgumentNullOrEmptyException(nameof(text)); @@ -179,7 +180,7 @@ namespace Umbraco.Core.Manifest } // purely for tests - public IEnumerable ParseGridEditors(string text) + public IEnumerable ParseGridEditors(string text) { return JsonConvert.DeserializeObject>(text); } diff --git a/src/Umbraco.Core/Manifest/PackageManifest.cs b/src/Umbraco.Core/Manifest/PackageManifest.cs index e50eb69467..a81021432d 100644 --- a/src/Umbraco.Core/Manifest/PackageManifest.cs +++ b/src/Umbraco.Core/Manifest/PackageManifest.cs @@ -1,70 +1,70 @@ -using System; -using Newtonsoft.Json; -using Umbraco.Core.PropertyEditors; - -namespace Umbraco.Core.Manifest -{ - /// - /// Represents the content of a package manifest. - /// - public class PackageManifest - { - /// - /// Gets the source path of the manifest. - /// - /// - /// Gets the full absolute file path of the manifest, - /// using system directory separators. - /// - [JsonIgnore] - public string Source { get; set; } - - /// - /// Gets or sets the scripts listed in the manifest. - /// - [JsonProperty("javascript")] - public string[] Scripts { get; set; } = Array.Empty(); - - /// - /// Gets or sets the stylesheets listed in the manifest. - /// - [JsonProperty("css")] - public string[] Stylesheets { get; set; } = Array.Empty(); - - /// - /// Gets or sets the property editors listed in the manifest. - /// - [JsonProperty("propertyEditors")] - public IDataEditor[] PropertyEditors { get; set; } = Array.Empty(); - - /// - /// Gets or sets the parameter editors listed in the manifest. - /// - [JsonProperty("parameterEditors")] - public IDataEditor[] ParameterEditors { get; set; } = Array.Empty(); - - /// - /// Gets or sets the grid editors listed in the manifest. - /// - [JsonProperty("gridEditors")] - public GridEditor[] GridEditors { get; set; } = Array.Empty(); - - /// - /// Gets or sets the content apps listed in the manifest. - /// - [JsonProperty("contentApps")] - public ManifestContentAppDefinition[] ContentApps { get; set; } = Array.Empty(); - - /// - /// Gets or sets the dashboards listed in the manifest. - /// - [JsonProperty("dashboards")] - public ManifestDashboard[] Dashboards { get; set; } = Array.Empty(); - - /// - /// Gets or sets the sections listed in the manifest. - /// - [JsonProperty("sections")] - public ManifestSection[] Sections { get; set; } = Array.Empty(); - } -} +using System; +using Newtonsoft.Json; +using Umbraco.Core.PropertyEditors; + +namespace Umbraco.Core.Manifest +{ + /// + /// Represents the content of a package manifest. + /// + public class PackageManifest : IPackageManifest + { + /// + /// Gets the source path of the manifest. + /// + /// + /// Gets the full absolute file path of the manifest, + /// using system directory separators. + /// + [JsonIgnore] + public string Source { get; set; } + + /// + /// Gets or sets the scripts listed in the manifest. + /// + [JsonProperty("javascript")] + public string[] Scripts { get; set; } = Array.Empty(); + + /// + /// Gets or sets the stylesheets listed in the manifest. + /// + [JsonProperty("css")] + public string[] Stylesheets { get; set; } = Array.Empty(); + + /// + /// Gets or sets the property editors listed in the manifest. + /// + [JsonProperty("propertyEditors")] + public IDataEditor[] PropertyEditors { get; set; } = Array.Empty(); + + /// + /// Gets or sets the parameter editors listed in the manifest. + /// + [JsonProperty("parameterEditors")] + public IDataEditor[] ParameterEditors { get; set; } = Array.Empty(); + + /// + /// Gets or sets the grid editors listed in the manifest. + /// + [JsonProperty("gridEditors")] + public GridEditor[] GridEditors { get; set; } = Array.Empty(); + + /// + /// Gets or sets the content apps listed in the manifest. + /// + [JsonProperty("contentApps")] + public ManifestContentAppDefinition[] ContentApps { get; set; } = Array.Empty(); + + /// + /// Gets or sets the dashboards listed in the manifest. + /// + [JsonProperty("dashboards")] + public ManifestDashboard[] Dashboards { get; set; } = Array.Empty(); + + /// + /// Gets or sets the sections listed in the manifest. + /// + [JsonProperty("sections")] + public ManifestSection[] Sections { get; set; } = Array.Empty(); + } +} diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 859a618b74..dc1828fe6d 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -175,6 +175,7 @@ + @@ -201,6 +202,7 @@ + diff --git a/src/Umbraco.Tests/Published/ModelTypeTests.cs b/src/Umbraco.Tests/Published/ModelTypeTests.cs index 622bebdf78..1dab67b351 100644 --- a/src/Umbraco.Tests/Published/ModelTypeTests.cs +++ b/src/Umbraco.Tests/Published/ModelTypeTests.cs @@ -53,7 +53,7 @@ namespace Umbraco.Tests.Published // there's an "*" there because the arrays are not true SZArray - but that changes when we map Assert.AreEqual("{alias1}[*]", ModelType.For("alias1").MakeArrayType().FullName); // note the inner assembly qualified name - Assert.AreEqual("System.Collections.Generic.IEnumerable`1[[{alias1}[*], Umbraco.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]", typeof(IEnumerable<>).MakeGenericType(ModelType.For("alias1").MakeArrayType()).FullName); + Assert.AreEqual("System.Collections.Generic.IEnumerable`1[[{alias1}[*], Umbraco.Abstractions, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null]]", typeof(IEnumerable<>).MakeGenericType(ModelType.For("alias1").MakeArrayType()).FullName); } [Test]