AB3594 - Removed references from core to configuration

This commit is contained in:
Bjarke Berg
2019-11-14 11:47:34 +01:00
parent 73167029f0
commit 126380dcee
50 changed files with 248 additions and 118 deletions

View File

@@ -3,6 +3,8 @@ 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;
@@ -14,11 +16,26 @@ namespace Umbraco.Core
/// </summary>
public static class ConfigsExtensions
{
public static IGlobalSettings Global(this Configs configs)
=> configs.GetConfig<IGlobalSettings>();
public static IUmbracoSettingsSection Settings(this Configs configs)
=> configs.GetConfig<IUmbracoSettingsSection>();
public static IHealthChecks HealthChecks(this Configs configs)
=> configs.GetConfig<IHealthChecks>();
public static IGridConfig Grids(this Configs configs)
=> configs.GetConfig<IGridConfig>();
public static ICoreDebug CoreDebug(this Configs configs)
=> configs.GetConfig<ICoreDebug>();
public static void AddCoreConfigs(this Configs configs, IIOHelper ioHelper)
{
var configDir = new DirectoryInfo(ioHelper.MapPath(Constants.SystemDirectories.Config));
// GridConfig depends on runtime caches, manifest parsers... and cannot be available during composition
configs.Add<IGridConfig>(factory => new GridConfig(
factory.GetInstance<ILogger>(),

View File

@@ -1,7 +1,10 @@
namespace Umbraco.Core.Configuration.HealthChecks
using System.Runtime.Serialization;
namespace Umbraco.Core.Configuration.HealthChecks
{
public enum HealthCheckNotificationVerbosity
{
Summary,
Detailed
}

View File

@@ -0,0 +1,8 @@
namespace Umbraco.Core.Configuration
{
public interface ICoreDebug
{
bool LogUncompletedScopes { get; }
bool DumpOnTimeoutThreadAbort { get; }
}
}

View File

@@ -0,0 +1,56 @@
using System;
using Semver;
namespace Umbraco.Core.Configuration
{
public interface IUmbracoVersion
{
/// <summary>
/// Gets the non-semantic version of the Umbraco code.
/// </summary>
Version Current { get; }
/// <summary>
/// Gets the semantic version comments of the Umbraco code.
/// </summary>
string Comment { get; }
/// <summary>
/// Gets the assembly version of the Umbraco code.
/// </summary>
/// <remarks>
/// <para>The assembly version is the value of the <see cref="AssemblyVersionAttribute"/>.</para>
/// <para>Is the one that the CLR checks for compatibility. Therefore, it changes only on
/// hard-breaking changes (for instance, on new major versions).</para>
/// </remarks>
Version AssemblyVersion { get; }
/// <summary>
/// Gets the assembly file version of the Umbraco code.
/// </summary>
/// <remarks>
/// <para>The assembly version is the value of the <see cref="AssemblyFileVersionAttribute"/>.</para>
/// </remarks>
Version AssemblyFileVersion { get; }
/// <summary>
/// Gets the semantic version of the Umbraco code.
/// </summary>
/// <remarks>
/// <para>The semantic version is the value of the <see cref="AssemblyInformationalVersionAttribute"/>.</para>
/// <para>It is the full version of Umbraco, including comments.</para>
/// </remarks>
SemVersion SemanticVersion { get; }
/// <summary>
/// Gets the "local" version of the site.
/// </summary>
/// <remarks>
/// <para>Three things have a version, really: the executing code, the database model,
/// and the site/files. The database model version is entirely managed via migrations,
/// and changes during an upgrade. The executing code version changes when new code is
/// deployed. The site/files version changes during an upgrade.</para>
/// </remarks>
SemVersion LocalVersion { get; }
}
}

View File

@@ -8,9 +8,17 @@ namespace Umbraco.Core.Configuration
/// <summary>
/// Represents the version of the executing code.
/// </summary>
public static class UmbracoVersion
public class UmbracoVersion : IUmbracoVersion
{
static UmbracoVersion()
private readonly IGlobalSettings _globalSettings;
public UmbracoVersion(IGlobalSettings globalSettings)
:this()
{
_globalSettings = globalSettings;
}
public UmbracoVersion()
{
var umbracoCoreAssembly = typeof(SemVersion).Assembly;
@@ -32,12 +40,12 @@ namespace Umbraco.Core.Configuration
/// Gets the non-semantic version of the Umbraco code.
/// </summary>
// TODO: rename to Version
public static Version Current { get; }
public Version Current { get; }
/// <summary>
/// Gets the semantic version comments of the Umbraco code.
/// </summary>
public static string Comment => SemanticVersion.Prerelease;
public string Comment => SemanticVersion.Prerelease;
/// <summary>
/// Gets the assembly version of the Umbraco code.
@@ -47,7 +55,7 @@ namespace Umbraco.Core.Configuration
/// <para>Is the one that the CLR checks for compatibility. Therefore, it changes only on
/// hard-breaking changes (for instance, on new major versions).</para>
/// </remarks>
public static Version AssemblyVersion {get; }
public Version AssemblyVersion {get; }
/// <summary>
/// Gets the assembly file version of the Umbraco code.
@@ -55,7 +63,7 @@ namespace Umbraco.Core.Configuration
/// <remarks>
/// <para>The assembly version is the value of the <see cref="AssemblyFileVersionAttribute"/>.</para>
/// </remarks>
public static Version AssemblyFileVersion { get; }
public Version AssemblyFileVersion { get; }
/// <summary>
/// Gets the semantic version of the Umbraco code.
@@ -64,7 +72,7 @@ namespace Umbraco.Core.Configuration
/// <para>The semantic version is the value of the <see cref="AssemblyInformationalVersionAttribute"/>.</para>
/// <para>It is the full version of Umbraco, including comments.</para>
/// </remarks>
public static SemVersion SemanticVersion { get; }
public SemVersion SemanticVersion { get; }
/// <summary>
/// Gets the "local" version of the site.
@@ -75,21 +83,11 @@ namespace Umbraco.Core.Configuration
/// and changes during an upgrade. The executing code version changes when new code is
/// deployed. The site/files version changes during an upgrade.</para>
/// </remarks>
public static SemVersion LocalVersion
{
public SemVersion LocalVersion {
get
{
try
{
// TODO: https://github.com/umbraco/Umbraco-CMS/issues/4238 - stop having version in web.config appSettings
var value = ConfigurationManager.AppSettings[Constants.AppSettings.ConfigurationStatus];
return value.IsNullOrWhiteSpace() ? null : SemVersion.TryParse(value, out var semver) ? semver : null;
}
catch
{
return null;
}
}
}
var value = _globalSettings.ConfigurationStatus;
return value.IsNullOrWhiteSpace() ? null : SemVersion.TryParse(value, out var semver) ? semver : null;
} }
}
}

View File

@@ -1,28 +0,0 @@
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.Grid;
using Umbraco.Core.Configuration.HealthChecks;
using Umbraco.Core.Configuration.UmbracoSettings;
namespace Umbraco.Core
{
/// <summary>
/// Provides extension methods for the <see cref="Configs"/> class.
/// </summary>
public static class ConfigsExtensions
{
public static IGlobalSettings Global(this Configs configs)
=> configs.GetConfig<IGlobalSettings>();
public static IUmbracoSettingsSection Settings(this Configs configs)
=> configs.GetConfig<IUmbracoSettingsSection>();
public static IHealthChecks HealthChecks(this Configs configs)
=> configs.GetConfig<IHealthChecks>();
public static IGridConfig Grids(this Configs configs)
=> configs.GetConfig<IGridConfig>();
public static CoreDebug CoreDebug(this Configs configs)
=> configs.GetConfig<CoreDebug>();
}
}

View File

@@ -0,0 +1,17 @@

using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
namespace Umbraco.Core.Logging.Viewer
{
[RuntimeLevel(MinLevel = RuntimeLevel.Run)]
// ReSharper disable once UnusedMember.Global
public class ConfigurationComposer : ICoreComposer
{
public void Compose(Composition composition)
{
composition.RegisterUnique<IUmbracoVersion, UmbracoVersion>();
}
}
}

View File

@@ -0,0 +1,33 @@
using System.Configuration;
using Semver;
using Umbraco.Core;
using Umbraco.Core.Configuration;
namespace Umbraco.Configuration
{
public static class UmbracoVersionExtensions
{
/// <summary>
/// Gets the "local" version of the site.
/// </summary>
/// <remarks>
/// <para>Three things have a version, really: the executing code, the database model,
/// and the site/files. The database model version is entirely managed via migrations,
/// and changes during an upgrade. The executing code version changes when new code is
/// deployed. The site/files version changes during an upgrade.</para>
/// </remarks>
public static SemVersion LocalVersion(this IUmbracoVersion umbracoVersion)
{
try
{
// TODO: https://github.com/umbraco/Umbraco-CMS/issues/4238 - stop having version in web.config appSettings
var value = ConfigurationManager.AppSettings[Constants.AppSettings.ConfigurationStatus];
return value.IsNullOrWhiteSpace() ? null : SemVersion.TryParse(value, out var semver) ? semver : null;
}
catch
{
return null;
}
}
}
}

View File

@@ -207,6 +207,9 @@ namespace Umbraco.Core.Composing
public static readonly IIOHelper IOHelper = Umbraco.Core.IO.IOHelper.Default;
public static IUmbracoVersion UmbracoVersion
=> Factory.GetInstance<IUmbracoVersion>();
#endregion
}
}

View File

@@ -1,5 +1,6 @@
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Persistence;
@@ -22,7 +23,8 @@ namespace Umbraco.Core
TypeLoader typeLoader,
IRuntimeState state,
ITypeFinder typeFinder,
IIOHelper ioHelper)
IIOHelper ioHelper,
IUmbracoVersion umbracoVersion)
{
composition.RegisterUnique(logger);
composition.RegisterUnique(profiler);
@@ -35,6 +37,7 @@ namespace Umbraco.Core
composition.RegisterUnique(state);
composition.RegisterUnique(typeFinder);
composition.RegisterUnique(ioHelper);
composition.RegisterUnique(umbracoVersion);
}
}
}

View File

@@ -20,7 +20,7 @@ namespace Umbraco.Core.Configuration
configs.Add<IUmbracoSettingsSection>("umbracoConfiguration/settings");
configs.Add<IHealthChecks>("umbracoConfiguration/HealthChecks");
configs.Add(() => new CoreDebug());
configs.Add<ICoreDebug>(() => new CoreDebug());
configs.AddCoreConfigs(_ioHelper);
return configs;
}

View File

@@ -3,7 +3,7 @@ using System.Configuration;
namespace Umbraco.Core.Configuration
{
public class CoreDebug
public class CoreDebug : ICoreDebug
{
public CoreDebug()
{

View File

@@ -1,6 +1,7 @@
using System;
using System.Configuration;
using Semver;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Migrations.Upgrade.Common;
using Umbraco.Core.Migrations.Upgrade.V_8_0_0;
@@ -17,6 +18,7 @@ namespace Umbraco.Core.Migrations.Upgrade
private const string InitPrefix = "{init-";
private const string InitSuffix = "}";
private IUmbracoVersion UmbracoVersion => Current.UmbracoVersion;
/// <summary>
/// Initializes a new instance of the <see cref="UmbracoPlan"/> class.
/// </summary>

View File

@@ -4,6 +4,7 @@ using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.Serialization;
using Umbraco.Core.Composing;
namespace Umbraco.Core.Models.Packaging
{
@@ -69,8 +70,8 @@ namespace Umbraco.Core.Models.Packaging
/// The minimum umbraco version that this package requires
/// </summary>
[DataMember(Name = "umbracoVersion")]
public Version UmbracoVersion { get; set; } = Configuration.UmbracoVersion.Current;
public Version UmbracoVersion { get; set; } = Current.UmbracoVersion.Current;
[DataMember(Name = "author")]
[Required]
public string Author { get; set; } = string.Empty;
@@ -131,7 +132,7 @@ namespace Umbraco.Core.Models.Packaging
[DataMember(Name = "iconUrl")]
public string IconUrl { get; set; } = string.Empty;
}

View File

@@ -548,6 +548,7 @@ namespace Umbraco.Core.Packaging
private static XElement GetPackageInfoXml(PackageDefinition definition)
{
var info = new XElement("info");
//Package info
@@ -564,9 +565,9 @@ namespace Umbraco.Core.Packaging
var requirements = new XElement("requirements");
requirements.Add(new XElement("major", definition.UmbracoVersion == null ? UmbracoVersion.SemanticVersion.Major.ToInvariantString() : definition.UmbracoVersion.Major.ToInvariantString()));
requirements.Add(new XElement("minor", definition.UmbracoVersion == null ? UmbracoVersion.SemanticVersion.Minor.ToInvariantString() : definition.UmbracoVersion.Minor.ToInvariantString()));
requirements.Add(new XElement("patch", definition.UmbracoVersion == null ? UmbracoVersion.SemanticVersion.Patch.ToInvariantString() : definition.UmbracoVersion.Build.ToInvariantString()));
requirements.Add(new XElement("major", definition.UmbracoVersion == null ? Current.UmbracoVersion.SemanticVersion.Major.ToInvariantString() : definition.UmbracoVersion.Major.ToInvariantString()));
requirements.Add(new XElement("minor", definition.UmbracoVersion == null ? Current.UmbracoVersion.SemanticVersion.Minor.ToInvariantString() : definition.UmbracoVersion.Minor.ToInvariantString()));
requirements.Add(new XElement("patch", definition.UmbracoVersion == null ? Current.UmbracoVersion.SemanticVersion.Patch.ToInvariantString() : definition.UmbracoVersion.Build.ToInvariantString()));
if (definition.UmbracoVersion != null)
requirements.Add(new XAttribute("type", RequirementsType.Strict.ToString()));

View File

@@ -5,6 +5,7 @@ using System.Diagnostics;
using System.IO;
using System.Web;
using System.Web.Hosting;
using Semver;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
@@ -89,8 +90,9 @@ namespace Umbraco.Core.Runtime
// are NOT disposed - which is not a big deal as long as they remain lightweight
// objects.
var umbracoVersion = new UmbracoVersion();
using (var timer = profilingLogger.TraceDuration<CoreRuntime>(
$"Booting Umbraco {UmbracoVersion.SemanticVersion.ToSemanticString()}.",
$"Booting Umbraco {umbracoVersion.SemanticVersion.ToSemanticString()}.",
"Booted.",
"Boot failed."))
{
@@ -135,6 +137,7 @@ namespace Umbraco.Core.Runtime
// configs
var configs = GetConfigs();
var umbracoVersion = GetUmbracoVersion(configs.Global());
// type finder/loader
var typeLoader = new TypeLoader(IOHelper, TypeFinder, appCaches.RuntimeCache, new DirectoryInfo(configs.Global().LocalTempPath), ProfilingLogger);
@@ -144,7 +147,8 @@ namespace Umbraco.Core.Runtime
_state = new RuntimeState(Logger,
configs.Settings(), configs.Global(),
new Lazy<IMainDom>(() => _factory.GetInstance<IMainDom>()),
new Lazy<IServerRegistrar>(() => _factory.GetInstance<IServerRegistrar>()))
new Lazy<IServerRegistrar>(() => _factory.GetInstance<IServerRegistrar>()),
umbracoVersion)
{
Level = RuntimeLevel.Boot
};
@@ -154,7 +158,7 @@ namespace Umbraco.Core.Runtime
// create the composition
composition = new Composition(register, typeLoader, ProfilingLogger, _state, configs);
composition.RegisterEssentials(Logger, Profiler, ProfilingLogger, mainDom, appCaches, databaseFactory, typeLoader, _state, TypeFinder, IOHelper);
composition.RegisterEssentials(Logger, Profiler, ProfilingLogger, mainDom, appCaches, databaseFactory, typeLoader, _state, TypeFinder, IOHelper, umbracoVersion);
// run handlers
RuntimeOptions.DoRuntimeEssentials(composition, appCaches, typeLoader, databaseFactory);
@@ -218,6 +222,11 @@ namespace Umbraco.Core.Runtime
return _factory;
}
private IUmbracoVersion GetUmbracoVersion(IGlobalSettings globalSettings)
{
return new UmbracoVersion(globalSettings);
}
protected virtual void ConfigureUnhandledException()
{
//take care of unhandled exceptions - there is nothing we can do to

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Threading;
using System.Web;
using Semver;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.Exceptions;
@@ -25,18 +26,20 @@ namespace Umbraco.Core
private readonly HashSet<string> _applicationUrls = new HashSet<string>();
private readonly Lazy<IMainDom> _mainDom;
private readonly Lazy<IServerRegistrar> _serverRegistrar;
private readonly IUmbracoVersion _umbracoVersion;
/// <summary>
/// Initializes a new instance of the <see cref="RuntimeState"/> class.
/// </summary>
public RuntimeState(ILogger logger, IUmbracoSettingsSection settings, IGlobalSettings globalSettings,
Lazy<IMainDom> mainDom, Lazy<IServerRegistrar> serverRegistrar)
Lazy<IMainDom> mainDom, Lazy<IServerRegistrar> serverRegistrar, IUmbracoVersion umbracoVersion)
{
_logger = logger;
_settings = settings;
_globalSettings = globalSettings;
_mainDom = mainDom;
_serverRegistrar = serverRegistrar;
_umbracoVersion = umbracoVersion;
}
/// <summary>
@@ -56,13 +59,13 @@ namespace Umbraco.Core
public IMainDom MainDom => _mainDom.Value;
/// <inheritdoc />
public Version Version => UmbracoVersion.Current;
public Version Version => _umbracoVersion.Current;
/// <inheritdoc />
public string VersionComment => UmbracoVersion.Comment;
public string VersionComment => _umbracoVersion.Comment;
/// <inheritdoc />
public SemVersion SemanticVersion => UmbracoVersion.SemanticVersion;
public SemVersion SemanticVersion => _umbracoVersion.SemanticVersion;
/// <inheritdoc />
public bool Debug { get; } = GlobalSettings.DebugMode;
@@ -125,7 +128,7 @@ namespace Umbraco.Core
/// </summary>
public void DetermineRuntimeLevel(IUmbracoDatabaseFactory databaseFactory, ILogger logger)
{
var localVersion = UmbracoVersion.LocalVersion; // the local, files, version
var localVersion = _umbracoVersion.LocalVersion; // the local, files, version
var codeVersion = SemanticVersion; // the executing code version
var connect = false;

View File

@@ -1,5 +1,6 @@
using System;
using System.Linq;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
using Umbraco.Core.Logging;
using Umbraco.Core.Migrations;
@@ -39,7 +40,7 @@ namespace Umbraco.Core.Services.Implement
// if already running 8, either following an upgrade or an install,
// then everything should be ok (the table should exist, etc)
if (UmbracoVersion.LocalVersion != null && UmbracoVersion.LocalVersion.Major >= 8)
if (Current.UmbracoVersion.LocalVersion != null && Current.UmbracoVersion.LocalVersion.Major >= 8)
{
_initialized = true;
return;
@@ -202,9 +203,7 @@ namespace Umbraco.Core.Services.Implement
/// <remarks>Used by <see cref="Runtime.CoreRuntime"/> to determine the runtime state.</remarks>
internal static string GetValue(IUmbracoDatabase database, string key)
{
// not 8 yet = no key/value table, no value
if (UmbracoVersion.LocalVersion.Major < 8)
return null;
if (database is null) return null;
var sql = database.SqlContext.Sql()
.Select<KeyValueDto>()

View File

@@ -136,11 +136,8 @@
<Compile Include="Composing\ComposeAfterAttribute.cs" />
<Compile Include="Composing\ComposeBeforeAttribute.cs" />
<Compile Include="Composing\Composers.cs" />
<Compile Include="Composing\Composition.cs" />
<Compile Include="Composing\IComposer.cs" />
<Compile Include="Composing\RegisterFactory.cs" />
<Compile Include="CompositionExtensions.cs" />
<Compile Include="Composing\ICoreComposer.cs" />
<Compile Include="Composing\IUserComposer.cs" />
<Compile Include="Compose\ManifestWatcherComposer.cs" />
<Compile Include="Compose\RelateOnCopyComposer.cs" />
@@ -152,8 +149,8 @@
<Compile Include="Composing\CompositionExtensions\Services.cs" />
<Compile Include="CompositionExtensions_Essentials.cs" />
<Compile Include="CompositionExtensions_FileSystems.cs" />
<Compile Include="CompositionExtensions_Uniques.cs" />
<Compile Include="Configuration\ConfigsFactory.cs" />
<Compile Include="Configuration\CoreDebug.cs" />
<Compile Include="Configuration\GlobalSettings.cs" />
<Compile Include="ConventionsHelper.cs" />
<Compile Include="Events\ContentPublishedEventArgs.cs" />
@@ -1020,10 +1017,6 @@
<Project>{29aa69d9-b597-4395-8d42-43b1263c240a}</Project>
<Name>Umbraco.Abstractions</Name>
</ProjectReference>
<ProjectReference Include="..\Umbraco.Configuration\Umbraco.Configuration.csproj">
<Project>{fbe7c065-dac0-4025-a78b-63b24d3ab00b}</Project>
<Name>Umbraco.Configuration</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -36,7 +36,7 @@ namespace Umbraco.Tests.Configurations
[Test]
public void Is_Version_From_Assembly_Correct()
{
Assert.That(UmbracoVersion.SemanticVersion, Is.EqualTo("6.0.0"));
Assert.That(Current.UmbracoVersion.SemanticVersion, Is.EqualTo("6.0.0"));
}
[TestCase("~/umbraco", "/", "umbraco")]

View File

@@ -27,7 +27,7 @@ namespace Umbraco.Tests.Misc
[Test]
public void NoApplicationUrlByDefault()
{
var state = new RuntimeState(Mock.Of<ILogger>(), Mock.Of<IUmbracoSettingsSection>(), Mock.Of<IGlobalSettings>(), new Lazy<IMainDom>(), new Lazy<IServerRegistrar>());
var state = new RuntimeState(Mock.Of<ILogger>(), Mock.Of<IUmbracoSettingsSection>(), Mock.Of<IGlobalSettings>(), new Lazy<IMainDom>(), new Lazy<IServerRegistrar>(), TestHelper.GetUmbracoVersion());
Assert.IsNull(state.ApplicationUrl);
}
@@ -45,7 +45,7 @@ namespace Umbraco.Tests.Misc
var registrar = new Mock<IServerRegistrar>();
registrar.Setup(x => x.GetCurrentServerUmbracoApplicationUrl()).Returns("http://server1.com/umbraco");
var state = new RuntimeState(Mock.Of<ILogger>(), settings, globalConfig.Object, new Lazy<IMainDom>(), new Lazy<IServerRegistrar>(() => registrar.Object));
var state = new RuntimeState(Mock.Of<ILogger>(), settings, globalConfig.Object, new Lazy<IMainDom>(), new Lazy<IServerRegistrar>(() => registrar.Object), TestHelper.GetUmbracoVersion());
state.EnsureApplicationUrl();
@@ -67,7 +67,7 @@ namespace Umbraco.Tests.Misc
var state = new RuntimeState(Mock.Of<ILogger>(), settings, globalConfig.Object, new Lazy<IMainDom>(), new Lazy<IServerRegistrar>(() => Mock.Of<IServerRegistrar>()));
var state = new RuntimeState(Mock.Of<ILogger>(), settings, globalConfig.Object, new Lazy<IMainDom>(), new Lazy<IServerRegistrar>(() => Mock.Of<IServerRegistrar>()), TestHelper.GetUmbracoVersion());
state.EnsureApplicationUrl();
@@ -90,7 +90,7 @@ namespace Umbraco.Tests.Misc
// still NOT set
Assert.IsNull(url);
}
[Test]
public void SetApplicationUrlFromWrSettingsSsl()
{

View File

@@ -32,8 +32,9 @@ namespace Umbraco.Tests.Routing
//create the module
var logger = Mock.Of<ILogger>();
var globalSettings = TestObjects.GetGlobalSettings();
var umbracoVersion = TestHelper.GetUmbracoVersion();
var runtime = new RuntimeState(logger, Mock.Of<IUmbracoSettingsSection>(), globalSettings,
new Lazy<IMainDom>(), new Lazy<IServerRegistrar>());
new Lazy<IMainDom>(), new Lazy<IServerRegistrar>(), umbracoVersion);
_module = new UmbracoInjectedModule
(
@@ -62,7 +63,7 @@ namespace Umbraco.Tests.Routing
// do not test for /base here as it's handled before EnsureUmbracoRoutablePage is called
[TestCase("/umbraco_client/Tree/treeIcons.css", false)]
[TestCase("/umbraco_client/Tree/Themes/umbraco/style.css?cdv=37", false)]
[TestCase("/umbraco_client/Tree/Themes/umbraco/style.css?cdv=37", false)]
[TestCase("/umbraco/editContent.aspx", false)]
[TestCase("/install/default.aspx", false)]
[TestCase("/install/?installStep=license", false)]

View File

@@ -65,12 +65,13 @@ namespace Umbraco.Tests.Runtimes
var ioHelper = IOHelper.Default;
var typeLoader = new TypeLoader(ioHelper, typeFinder, appCaches.RuntimeCache, new DirectoryInfo(ioHelper.MapPath("~/App_Data/TEMP")), profilingLogger);
var mainDom = new SimpleMainDom();
var runtimeState = new RuntimeState(logger, null, null, new Lazy<IMainDom>(() => mainDom), new Lazy<IServerRegistrar>(() => factory.GetInstance<IServerRegistrar>()));
var umbracoVersion = TestHelper.GetUmbracoVersion();
var runtimeState = new RuntimeState(logger, null, null, new Lazy<IMainDom>(() => mainDom), new Lazy<IServerRegistrar>(() => factory.GetInstance<IServerRegistrar>()), umbracoVersion);
// create the register and the composition
var register = RegisterFactory.Create();
var composition = new Composition(register, typeLoader, profilingLogger, runtimeState, TestHelper.GetConfigs());
composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState, typeFinder, ioHelper);
composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState, typeFinder, ioHelper, umbracoVersion);
// create the core runtime and have it compose itself
var coreRuntime = new CoreRuntime();
@@ -262,7 +263,8 @@ namespace Umbraco.Tests.Runtimes
// create the register and the composition
var register = RegisterFactory.Create();
var composition = new Composition(register, typeLoader, profilingLogger, runtimeState, TestHelper.GetConfigs());
composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState, typeFinder, ioHelper);
var umbracoVersion = TestHelper.GetUmbracoVersion();
composition.RegisterEssentials(logger, profiler, profilingLogger, mainDom, appCaches, databaseFactory, typeLoader, runtimeState, typeFinder, ioHelper, umbracoVersion);
// create the core runtime and have it compose itself
var coreRuntime = new CoreRuntime();

View File

@@ -15,7 +15,7 @@ namespace Umbraco.Tests.TestHelpers
{
var config = Mock.Of<IGlobalSettings>(
settings =>
settings.ConfigurationStatus == UmbracoVersion.SemanticVersion.ToSemanticString() &&
settings.ConfigurationStatus == TestHelper.GetUmbracoVersion().SemanticVersion.ToSemanticString() &&
settings.UseHttps == false &&
settings.HideTopLevelNodeFromPath == false &&
settings.Path == Current.IOHelper.ResolveUrl("~/umbraco") &&

View File

@@ -276,5 +276,9 @@ namespace Umbraco.Tests.TestHelpers
}
public static IUmbracoVersion GetUmbracoVersion()
{
return new UmbracoVersion(GetConfigs().Global());
}
}
}

View File

@@ -246,5 +246,6 @@ namespace Umbraco.Tests.TestHelpers
var scopeProvider = new ScopeProvider(databaseFactory, fileSystems, logger, typeFinder);
return scopeProvider;
}
}
}

View File

@@ -132,7 +132,7 @@ namespace Umbraco.Tests.TestHelpers
// ensure the configuration matches the current version for tests
var globalSettingsMock = Mock.Get(Factory.GetInstance<IGlobalSettings>()); //this will modify the IGlobalSettings instance stored in the container
globalSettingsMock.Setup(x => x.ConfigurationStatus).Returns(UmbracoVersion.Current.ToString(3));
globalSettingsMock.Setup(x => x.ConfigurationStatus).Returns(Current.UmbracoVersion.Current.ToString(3));
using (ProfilingLogger.TraceDuration<TestWithDatabaseBase>("Initialize database."))
{

View File

@@ -100,6 +100,7 @@ namespace Umbraco.Tests.Testing
protected ILogger Logger => Factory.GetInstance<ILogger>();
protected IIOHelper IOHelper { get; private set; }
protected IUmbracoVersion UmbracoVersion { get; private set; }
protected ITypeFinder TypeFinder { get; private set; }
@@ -134,9 +135,11 @@ namespace Umbraco.Tests.Testing
var (logger, profiler) = GetLoggers(Options.Logger);
var proflogger = new ProfilingLogger(logger, profiler);
IOHelper = Umbraco.Core.IO.IOHelper.Default;
TypeFinder = new TypeFinder(logger);
var appCaches = GetAppCaches();
var globalSettings = SettingsForTests.GetDefaultGlobalSettings();
UmbracoVersion = new UmbracoVersion(globalSettings);
var typeLoader = GetTypeLoader(IOHelper, TypeFinder, appCaches.RuntimeCache, globalSettings, proflogger, Options.TypeLoader);
var register = RegisterFactory.Create();
@@ -145,6 +148,7 @@ namespace Umbraco.Tests.Testing
Composition.RegisterUnique(IOHelper);
Composition.RegisterUnique(UmbracoVersion);
Composition.RegisterUnique(TypeFinder);
Composition.RegisterUnique(typeLoader);
Composition.RegisterUnique(logger);

View File

@@ -227,6 +227,7 @@ namespace Umbraco.Web.Composing
public static IVariationContextAccessor VariationContextAccessor => CoreCurrent.VariationContextAccessor;
public static IIOHelper IOHelper => CoreCurrent.IOHelper;
public static IUmbracoVersion UmbracoVersion => CoreCurrent.UmbracoVersion;
#endregion
}

View File

@@ -442,10 +442,10 @@ namespace Umbraco.Web.Editors
// add versions - see UmbracoVersion for details & differences
// the complete application version (eg "8.1.2-alpha.25")
{ "version", UmbracoVersion.SemanticVersion.ToSemanticString() },
{ "version", Current.UmbracoVersion.SemanticVersion.ToSemanticString() },
// the assembly version (eg "8.0.0")
{ "assemblyVersion", UmbracoVersion.AssemblyVersion.ToString() }
{ "assemblyVersion", Current.UmbracoVersion.AssemblyVersion.ToString() }
};
var version = _runtimeState.SemanticVersion.ToSemanticString();

View File

@@ -11,6 +11,7 @@ using System.Linq;
using System.Net;
using System.Text;
using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Web.WebApi;
using Umbraco.Web.WebApi.Filters;
using Umbraco.Core.Logging;
@@ -51,7 +52,7 @@ namespace Umbraco.Web.Editors
var user = Security.CurrentUser;
var allowedSections = string.Join(",", user.AllowedSections);
var language = user.Language;
var version = UmbracoVersion.SemanticVersion.ToSemanticString();
var version = Current.UmbracoVersion.SemanticVersion.ToSemanticString();
var url = string.Format(baseUrl + "{0}?section={0}&allowed={1}&lang={2}&version={3}", section, allowedSections, language, version);
var key = "umbraco-dynamic-dashboard-" + language + allowedSections.Replace(",", "-") + section;

View File

@@ -118,7 +118,7 @@ namespace Umbraco.Web.Editors
if (ins.UmbracoVersionRequirementsType == RequirementsType.Strict)
{
var packageMinVersion = ins.UmbracoVersion;
if (UmbracoVersion.Current < packageMinVersion)
if (Current.UmbracoVersion.Current < packageMinVersion)
{
model.IsCompatible = false;
}
@@ -215,7 +215,7 @@ namespace Umbraco.Web.Editors
{
var packageFile = await Services.PackagingService.FetchPackageFileAsync(
Guid.Parse(packageGuid),
UmbracoVersion.Current,
Current.UmbracoVersion.Current,
Security.GetUserId().ResultOr(0));
fileName = packageFile.Name;
@@ -259,7 +259,7 @@ namespace Umbraco.Web.Editors
if (packageInfo.UmbracoVersionRequirementsType == RequirementsType.Strict)
{
var packageMinVersion = packageInfo.UmbracoVersion;
if (UmbracoVersion.Current < packageMinVersion)
if (Current.UmbracoVersion.Current < packageMinVersion)
throw new HttpResponseException(Request.CreateNotificationValidationErrorResponse(
Services.TextService.Localize("packager/targetVersionMismatch", new[] {packageMinVersion.ToString()})));
}
@@ -366,7 +366,7 @@ namespace Umbraco.Web.Editors
//bump cdf to be safe
var clientDependencyConfig = new ClientDependencyConfiguration(Logger);
var clientDependencyUpdated = clientDependencyConfig.UpdateVersionNumber(
UmbracoVersion.SemanticVersion, DateTime.UtcNow, "yyyyMMdd");
Current.UmbracoVersion.SemanticVersion, DateTime.UtcNow, "yyyyMMdd");
var redirectUrl = "";
if (!packageInfo.PackageView.IsNullOrWhiteSpace())

View File

@@ -26,10 +26,10 @@ namespace Umbraco.Web.Editors
{
var check = new org.umbraco.update.CheckForUpgrade { Timeout = 2000 };
var result = check.CheckUpgrade(UmbracoVersion.Current.Major,
UmbracoVersion.Current.Minor,
UmbracoVersion.Current.Build,
UmbracoVersion.Comment);
var result = check.CheckUpgrade(Current.UmbracoVersion.Current.Major,
Current.UmbracoVersion.Current.Minor,
Current.UmbracoVersion.Current.Build,
Current.UmbracoVersion.Comment);
return new UpgradeCheckResponse(result.UpgradeType.ToString(), result.Comment, result.UpgradeUrl);
}

View File

@@ -48,7 +48,7 @@ namespace Umbraco.Web.Install.Controllers
// Update ClientDependency version
var clientDependencyConfig = new ClientDependencyConfiguration(_logger);
var clientDependencyUpdated = clientDependencyConfig.UpdateVersionNumber(
UmbracoVersion.SemanticVersion, DateTime.UtcNow, "yyyyMMdd");
Current.UmbracoVersion.SemanticVersion, DateTime.UtcNow, "yyyyMMdd");
// Delete ClientDependency temp directories to make sure we get fresh caches
var clientDependencyTempFilesDeleted = clientDependencyConfig.ClearTempFiles(HttpContext);

View File

@@ -75,10 +75,10 @@ namespace Umbraco.Web.Install
IsBrandNewInstall == false,
isCompleted,
DateTime.Now,
UmbracoVersion.Current.Major,
UmbracoVersion.Current.Minor,
UmbracoVersion.Current.Build,
UmbracoVersion.Comment,
Current.UmbracoVersion.Current.Major,
Current.UmbracoVersion.Current.Minor,
Current.UmbracoVersion.Current.Build,
Current.UmbracoVersion.Comment,
errorMsg,
userAgent,
dbProvider);
@@ -141,7 +141,7 @@ namespace Umbraco.Web.Install
var packages = new List<Package>();
try
{
var requestUri = $"https://our.umbraco.com/webapi/StarterKit/Get/?umbracoVersion={UmbracoVersion.Current}";
var requestUri = $"https://our.umbraco.com/webapi/StarterKit/Get/?umbracoVersion={Current.UmbracoVersion.Current}";
using (var request = new HttpRequestMessage(HttpMethod.Get, requestUri))
{

View File

@@ -61,7 +61,7 @@ namespace Umbraco.Web.Install.InstallSteps
}
// Update configurationStatus
_globalSettings.ConfigurationStatus = UmbracoVersion.SemanticVersion.ToSemanticString();
_globalSettings.ConfigurationStatus = Current.UmbracoVersion.SemanticVersion.ToSemanticString();
//reports the ended install
_installHelper.InstallStatus(true, "");

View File

@@ -64,7 +64,7 @@ namespace Umbraco.Web.Install.InstallSteps
private async Task<(string packageFile, int packageId)> DownloadPackageFilesAsync(Guid kitGuid)
{
//Go get the package file from the package repo
var packageFile = await _packageService.FetchPackageFileAsync(kitGuid, UmbracoVersion.Current, _umbracoContextAccessor.UmbracoContext.Security.GetUserId().ResultOr(0));
var packageFile = await _packageService.FetchPackageFileAsync(kitGuid, Current.UmbracoVersion.Current, _umbracoContextAccessor.UmbracoContext.Security.GetUserId().ResultOr(0));
if (packageFile == null) throw new InvalidOperationException("Could not fetch package file " + kitGuid);
//add an entry to the installedPackages.config

View File

@@ -25,9 +25,9 @@ namespace Umbraco.Web.Install.InstallSteps
// that was a "normal" way to force the upgrader to execute, and we would detect the current
// version via the DB like DatabaseSchemaResult.DetermineInstalledVersion - magic, do we really
// need this now?
var currentVersion = (UmbracoVersion.LocalVersion ?? new Semver.SemVersion(0)).ToString();
var currentVersion = (Current.UmbracoVersion.LocalVersion ?? new Semver.SemVersion(0)).ToString();
var newVersion = UmbracoVersion.SemanticVersion.ToString();
var newVersion = Current.UmbracoVersion.SemanticVersion.ToString();
string FormatGuidState(string value)
{

View File

@@ -5,6 +5,7 @@ using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using Umbraco.Core.Composing;
using Umbraco.Core.Configuration;
namespace Umbraco.Web.Models
@@ -26,7 +27,7 @@ namespace Umbraco.Web.Models
{
Type = upgradeType;
Comment = upgradeComment;
Url = upgradeUrl + "?version=" + HttpUtility.UrlEncode(UmbracoVersion.Current.ToString(3));
Url = upgradeUrl + "?version=" + HttpUtility.UrlEncode(Current.UmbracoVersion.Current.ToString(3));
}
}
}

View File

@@ -355,7 +355,7 @@ namespace Umbraco.Web.Security.Providers
// http://issues.umbraco.org/issue/U4-3451
// when upgrading from 7.2 to 7.3 trying to save will throw
if (UmbracoVersion.Current >= new Version(7, 3, 0, 0))
if (Current.UmbracoVersion.Current >= new Version(7, 3, 0, 0))
MemberService.Save(member, false);
}
@@ -595,7 +595,7 @@ namespace Umbraco.Web.Security.Providers
// for this type of thing (i.e. UpdateLastLogin or similar).
// when upgrading from 7.2 to 7.3 trying to save will throw
if (UmbracoVersion.Current >= new Version(7, 3, 0, 0))
if (Current.UmbracoVersion.Current >= new Version(7, 3, 0, 0))
MemberService.Save(member, false);
return new ValidateUserResult

View File

@@ -1,7 +1,4 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2005
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29209.152
MinimumVisualStudioVersion = 10.0.40219.1