diff --git a/src/Umbraco.Abstractions/Composing/Current.cs b/src/Umbraco.Abstractions/Composing/Current.cs
index a1ae87d49f..a01302f3e3 100644
--- a/src/Umbraco.Abstractions/Composing/Current.cs
+++ b/src/Umbraco.Abstractions/Composing/Current.cs
@@ -39,6 +39,22 @@ namespace Umbraco.Core.Composing
}
}
+ ///
+ /// Resets . Indented for testing only, and not supported in production code.
+ ///
+ ///
+ /// For UNIT TESTS exclusively.
+ /// Resets everything that is 'current'.
+ ///
+ public static void Reset()
+ {
+ _factory.DisposeIfDisposable();
+ _factory = null;
+
+ _logger = null;
+ _profiler = null;
+ _profilingLogger = null;
+ }
public static bool HasFactory => _factory != null;
#region Getters
diff --git a/src/Umbraco.Core/Configuration/ConfigsExtensions.cs b/src/Umbraco.Core/Configuration/ConfigsExtensions.cs
index 19fd899a0f..ae3341aff8 100644
--- a/src/Umbraco.Core/Configuration/ConfigsExtensions.cs
+++ b/src/Umbraco.Core/Configuration/ConfigsExtensions.cs
@@ -1,9 +1,7 @@
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;
@@ -16,9 +14,9 @@ namespace Umbraco.Core
public static class ConfigsExtensions
{
- public static void AddCoreConfigs(this Configs configs)
+ public static void AddCoreConfigs(this Configs configs, IIOHelper ioHelper)
{
- var configDir = new DirectoryInfo(Current.IOHelper.MapPath(SystemDirectories.Config));
+ 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(
diff --git a/src/Umbraco.Core/Configuration/ConfigsFactory.cs b/src/Umbraco.Core/Configuration/ConfigsFactory.cs
index c0e80d3798..4d8b1cd3aa 100644
--- a/src/Umbraco.Core/Configuration/ConfigsFactory.cs
+++ b/src/Umbraco.Core/Configuration/ConfigsFactory.cs
@@ -1,4 +1,5 @@
using System.Configuration;
+using Umbraco.Core.Composing;
using Umbraco.Core.Configuration.HealthChecks;
using Umbraco.Core.Configuration.UmbracoSettings;
@@ -6,6 +7,8 @@ namespace Umbraco.Core.Configuration
{
public class ConfigsFactory : IConfigsFactory
{
+
+
public Configs Create() {
var configs = new Configs(section => ConfigurationManager.GetSection(section));
configs.Add(() => new GlobalSettings());
@@ -13,7 +16,7 @@ namespace Umbraco.Core.Configuration
configs.Add("umbracoConfiguration/HealthChecks");
configs.Add(() => new CoreDebug());
- configs.AddCoreConfigs();
+ configs.AddCoreConfigs(Current.IOHelper);
return configs;
}
}
diff --git a/src/Umbraco.Core/Manifest/ManifestParser.cs b/src/Umbraco.Core/Manifest/ManifestParser.cs
index 21f1d71196..c3251da7f5 100644
--- a/src/Umbraco.Core/Manifest/ManifestParser.cs
+++ b/src/Umbraco.Core/Manifest/ManifestParser.cs
@@ -6,7 +6,6 @@ using System.Text;
using Newtonsoft.Json;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration.Grid;
-using Umbraco.Core.Composing;
using Umbraco.Core.Exceptions;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
@@ -23,6 +22,7 @@ namespace Umbraco.Core.Manifest
private readonly IAppPolicyCache _cache;
private readonly ILogger _logger;
+ private readonly IIOHelper _ioHelper;
private readonly ManifestValueValidatorCollection _validators;
private readonly ManifestFilterCollection _filters;
@@ -31,28 +31,30 @@ namespace Umbraco.Core.Manifest
///
/// Initializes a new instance of the class.
///
- public ManifestParser(AppCaches appCaches, ManifestValueValidatorCollection validators, ManifestFilterCollection filters, ILogger logger)
- : this(appCaches, validators, filters, "~/App_Plugins", logger)
+ public ManifestParser(AppCaches appCaches, ManifestValueValidatorCollection validators, ManifestFilterCollection filters, ILogger logger, IIOHelper ioHelper)
+ : this(appCaches, validators, filters, SystemDirectories.AppPlugins, logger, ioHelper)
{ }
///
/// Initializes a new instance of the class.
///
- private ManifestParser(AppCaches appCaches, ManifestValueValidatorCollection validators, ManifestFilterCollection filters, string path, ILogger logger)
+ private ManifestParser(AppCaches appCaches, ManifestValueValidatorCollection validators, ManifestFilterCollection filters, string path, ILogger logger, IIOHelper ioHelper)
{
if (appCaches == null) throw new ArgumentNullException(nameof(appCaches));
_cache = appCaches.RuntimeCache;
_validators = validators ?? throw new ArgumentNullException(nameof(validators));
_filters = filters ?? throw new ArgumentNullException(nameof(filters));
if (string.IsNullOrWhiteSpace(path)) throw new ArgumentNullOrEmptyException(nameof(path));
+ _ioHelper = ioHelper;
Path = path;
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
+
}
public string Path
{
get => _path;
- set => _path = value.StartsWith("~/") ? Current.IOHelper.MapPath(value) : value;
+ set => _path = value.StartsWith("~/") ? _ioHelper.MapPath(value) : value;
}
///
@@ -167,9 +169,9 @@ namespace Umbraco.Core.Manifest
// scripts and stylesheets are raw string, must process here
for (var i = 0; i < manifest.Scripts.Length; i++)
- manifest.Scripts[i] = Current.IOHelper.ResolveVirtualUrl(manifest.Scripts[i]);
+ manifest.Scripts[i] = _ioHelper.ResolveVirtualUrl(manifest.Scripts[i]);
for (var i = 0; i < manifest.Stylesheets.Length; i++)
- manifest.Stylesheets[i] = Current.IOHelper.ResolveVirtualUrl(manifest.Stylesheets[i]);
+ manifest.Stylesheets[i] = _ioHelper.ResolveVirtualUrl(manifest.Stylesheets[i]);
// add property editors that are also parameter editors, to the parameter editors list
// (the manifest format is kinda legacy)
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index 6852a95a3b..412458915b 100755
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -244,7 +244,10 @@
+
+
+
@@ -538,11 +541,6 @@
-
-
-
-
-
diff --git a/src/Umbraco.Tests/Manifest/ManifestParserTests.cs b/src/Umbraco.Tests/Manifest/ManifestParserTests.cs
index f01e307b4b..bf4ee433ee 100644
--- a/src/Umbraco.Tests/Manifest/ManifestParserTests.cs
+++ b/src/Umbraco.Tests/Manifest/ManifestParserTests.cs
@@ -13,6 +13,7 @@ using Umbraco.Core.PropertyEditors;
using Umbraco.Core.PropertyEditors.Validators;
using Umbraco.Core.Services;
using Umbraco.Core.Dashboards;
+using Umbraco.Core.IO;
namespace Umbraco.Tests.Manifest
{
@@ -25,6 +26,7 @@ namespace Umbraco.Tests.Manifest
public void Setup()
{
Current.Reset();
+ CurrentCore.Reset();
var factory = Mock.Of();
Current.Factory = factory;
CurrentCore.Factory = factory;
@@ -45,7 +47,7 @@ namespace Umbraco.Tests.Manifest
new RequiredValidator(Mock.Of()),
new RegexValidator(Mock.Of(), null)
};
- _parser = new ManifestParser(AppCaches.Disabled, new ManifestValueValidatorCollection(validators), new ManifestFilterCollection(Array.Empty()), Mock.Of());
+ _parser = new ManifestParser(AppCaches.Disabled, new ManifestValueValidatorCollection(validators), new ManifestFilterCollection(Array.Empty()), Mock.Of(), Mock.Of());
}
[Test]