Merge branch 'netcore/dev' into netcore/7668-remove-repository-concerns-from-services

# Conflicts:
#	src/Umbraco.Infrastructure/Composing/CompositionExtensions/Repositories.cs
This commit is contained in:
Andy Butland
2020-03-05 07:36:14 +01:00
1742 changed files with 7047 additions and 5733 deletions
+9 -3
View File
@@ -25,16 +25,22 @@ dotnet_naming_rule.private_members_with_underscore.severity = suggestion
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
# dotnet_naming_symbols.private_fields.required_modifiers = abstract,async,readonly,static # all except const
dotnet_naming_style.prefix_underscore.capitalization = camel_case
dotnet_naming_style.prefix_underscore.required_prefix = _
# https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/ide/editorconfig-code-style-settings-reference.md
[*.cs]
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:suggestion
csharp_prefer_braces = false : none
csharp_prefer_braces = false : none
[*.{js,less}]
trim_trailing_whitespace = false
[*.{js,less}]
trim_trailing_whitespace = false
+2
View File
@@ -43,6 +43,8 @@ If you only see a build.bat-file, you're probably on the wrong branch. If you sw
You might run into [Powershell quirks](#powershell-quirks).
If it runs without errors; Hooray! Now you can continue with [the next step](CONTRIBUTING.md#how-do-i-begin) and open the solution and build it.
### Build Infrastructure
The Umbraco Build infrastructure relies on a PowerShell object. The object can be retrieved with:
+2 -2
View File
@@ -28,7 +28,7 @@ This project and everyone participating in it, is governed by the [our Code of C
[Working with the code](#working-with-the-code)
* [Building Umbraco from source code](#building-umbraco-from-source-code)
* [Working with the source code](#working-with-the-source-code)
* [Making changes after the PR was opened](#making-changes-after-the-pr-was-opened)
* [Making changes after the PR is open](#making-changes-after-the-pr-is-open)
* [Which branch should I target for my contributions?](#which-branch-should-i-target-for-my-contributions)
* [Keeping your Umbraco fork in sync with the main repository](#keeping-your-umbraco-fork-in-sync-with-the-main-repository)
@@ -65,7 +65,7 @@ Great question! The short version goes like this:
* **Change** - make your changes, experiment, have fun, explore and learn, and don't be afraid. We welcome all contributions and will [happily give feedback](#questions)
* **Commit** - done? Yay! 🎉 **Important:** create a new branch now and name it after the issue you're fixing, we usually follow the format: `temp-12345`. This means it's a temporary branch for the particular issue you're working on, in this case `12345`. When you have a branch, commit your changes. Don't commit to `v8/contrib`, create a new branch first.
* **Push** - great, now you can push the changes up to your fork on GitHub
* **Create pull request** - exciting! You're ready to show us your changes (or not quite ready, you just need some feedback to progress - you can now make use of GitHub's draft pull request status, detailed [here] (https://github.blog/2019-02-14-introducing-draft-pull-requests/)). GitHub has picked up on the new branch you've pushed and will offer to create a Pull Request. Click that green button and away you go.
* **Create pull request** - exciting! You're ready to show us your changes (or not quite ready, you just need some feedback to progress - you can now make use of GitHub's draft pull request status, detailed [here](https://github.blog/2019-02-14-introducing-draft-pull-requests/)). GitHub has picked up on the new branch you've pushed and will offer to create a Pull Request. Click that green button and away you go.
![Create a pull request](img/createpullrequest.png)
+1 -1
View File
@@ -2,7 +2,7 @@
using System.Resources;
[assembly: AssemblyCompany("Umbraco")]
[assembly: AssemblyCopyright("Copyright © Umbraco 2019")]
[assembly: AssemblyCopyright("Copyright © Umbraco 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
using Umbraco.Core.Composing;
namespace Umbraco.Core
{
public static partial class CompositionExtensions
{
#region Collection Builders
/// <summary>
/// Gets the components collection builder.
/// </summary>
public static ComponentCollectionBuilder Components(this Composition composition)
=> composition.WithCollectionBuilder<ComponentCollectionBuilder>();
#endregion
}
}
@@ -1,19 +0,0 @@
namespace Umbraco.Core.PropertyEditors
{
/// <summary>
/// Must be implemented by property editors that store media and return media paths
/// </summary>
/// <remarks>
/// Currently there are only 2x core editors that do this: upload and image cropper.
/// It would be possible for developers to know implement their own media property editors whereas previously this was not possible.
/// </remarks>
public interface IDataEditorWithMediaPath
{
/// <summary>
/// Returns the media path for the value stored for a property
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
string GetMediaPath(object value);
}
}
@@ -1,13 +0,0 @@
using Umbraco.Core.Models.Membership;
namespace Umbraco.Core.Models.Identity
{
public interface ICurrentUserAccessor
{
/// <summary>
/// Returns the current user or null if no user is currently authenticated.
/// </summary>
/// <returns>The current user or null</returns>
IUser TryGetCurrentUser();
}
}
@@ -1,18 +0,0 @@
using System;
using System.Runtime.Serialization;
namespace Umbraco.Core.Models
{
/// <summary>
/// Enum for the various types of Macros
/// </summary>
[Serializable]
[DataContract(IsReference = true)]
public enum MacroTypes
{
[EnumMember]
Unknown = 4,
[EnumMember]
PartialView = 7
}
}
@@ -0,0 +1,15 @@
using System.Configuration;
using Umbraco.Core.Configuration;
namespace Umbraco.Configuration
{
public class ActiveDirectorySettings : IActiveDirectorySettings
{
public ActiveDirectorySettings()
{
ActiveDirectoryDomain = ConfigurationManager.AppSettings["ActiveDirectoryDomain"];
}
public string ActiveDirectoryDomain { get; }
}
}
+20 -6
View File
@@ -1,4 +1,5 @@
using System.Configuration;
using Umbraco.Configuration;
using Umbraco.Core.Configuration.HealthChecks;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.IO;
@@ -7,14 +8,16 @@ namespace Umbraco.Core.Configuration
{
public class ConfigsFactory : IConfigsFactory
{
public ConfigsFactory()
{
}
public IHostingSettings HostingSettings { get; } = new HostingSettings();
public ICoreDebug CoreDebug { get; } = new CoreDebug();
public IMachineKeyConfig MachineKeyConfig { get; } = new MachineKeyConfig();
public IIndexCreatorSettings IndexCreatorSettings { get; } = new IndexCreatorSettings();
public INuCacheSettings NuCacheSettings { get; } = new NuCacheSettings();
public ITypeFinderSettings TypeFinderSettings { get; } = new TypeFinderSettings();
public IRuntimeSettings RuntimeSettings { get; } = new RuntimeSettings();
public IActiveDirectorySettings ActiveDirectorySettings { get; } = new ActiveDirectorySettings();
public IExceptionFilterSettings ExceptionFilterSettings { get; } = new ExceptionFilterSettings();
public IUmbracoSettingsSection UmbracoSettings { get; }
@@ -32,7 +35,18 @@ namespace Umbraco.Core.Configuration
configs.AddPasswordConfigurations();
configs.Add(() => CoreDebug);
configs.Add<IConnectionStrings>(() => new ConnectionStrings());
configs.Add(() => MachineKeyConfig);
configs.Add<IConnectionStrings>(() => new ConnectionStrings(ioHelper));
configs.Add<IModelsBuilderConfig>(() => new ModelsBuilderConfig(ioHelper));
configs.Add<IIndexCreatorSettings>(() => IndexCreatorSettings);
configs.Add<INuCacheSettings>(() => NuCacheSettings);
configs.Add<ITypeFinderSettings>(() => TypeFinderSettings);
configs.Add<IRuntimeSettings>(() => RuntimeSettings);
configs.Add<IActiveDirectorySettings>(() => ActiveDirectorySettings);
configs.Add<IExceptionFilterSettings>(() => ExceptionFilterSettings);
configs.AddCoreConfigs(ioHelper);
return configs;
}
@@ -8,6 +8,13 @@ namespace Umbraco.Core.Configuration
{
public class ConnectionStrings : IConnectionStrings
{
private readonly IIOHelper _ioHelper;
public ConnectionStrings(IIOHelper ioHelper)
{
_ioHelper = ioHelper;
}
public ConfigConnectionString this[string key]
{
get
@@ -17,5 +24,22 @@ namespace Umbraco.Core.Configuration
return new ConfigConnectionString(settings.ConnectionString, settings.ProviderName, settings.Name);
}
}
public void RemoveConnectionString(string key)
{
var fileName = _ioHelper.MapPath(string.Format("{0}/web.config", _ioHelper.Root));
var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);
var appSettings = xml.Root.DescendantsAndSelf("appSettings").Single();
var setting = appSettings.Descendants("add").FirstOrDefault(s => s.Attribute("key").Value == key);
if (setting != null)
{
setting.Remove();
xml.Save(fileName, SaveOptions.DisableFormatting);
ConfigurationManager.RefreshSection("appSettings");
}
var settings = ConfigurationManager.ConnectionStrings[key];
}
}
}
@@ -0,0 +1,18 @@
using System.Configuration;
using Umbraco.Core.Configuration;
namespace Umbraco.Configuration
{
public class ExceptionFilterSettings : IExceptionFilterSettings
{
public ExceptionFilterSettings()
{
if (bool.TryParse(ConfigurationManager.AppSettings["Umbraco.Web.DisableModelBindingExceptionFilter"],
out var disabled))
{
Disabled = disabled;
}
}
public bool Disabled { get; }
}
}
+5 -21
View File
@@ -254,27 +254,7 @@ namespace Umbraco.Core.Configuration
ConfigurationManager.RefreshSection("appSettings");
}
/// <summary>
/// Removes a setting from the configuration file.
/// </summary>
/// <param name="key">Key of the setting to be removed.</param>
public static void RemoveSetting(string key, IIOHelper ioHelper)
{
var fileName = ioHelper.MapPath(string.Format("{0}/web.config", ioHelper.Root));
var xml = XDocument.Load(fileName, LoadOptions.PreserveWhitespace);
var appSettings = xml.Root.DescendantsAndSelf("appSettings").Single();
var setting = appSettings.Descendants("add").FirstOrDefault(s => s.Attribute("key").Value == key);
if (setting != null)
{
setting.Remove();
xml.Save(fileName, SaveOptions.DisableFormatting);
ConfigurationManager.RefreshSection("appSettings");
}
}
/// <summary>
/// Gets the time out in minutes.
/// </summary>
@@ -402,6 +382,10 @@ namespace Umbraco.Core.Configuration
private string _databaseFactoryServerVersion;
public string DatabaseFactoryServerVersion => GetterWithDefaultValue(Constants.AppSettings.Debug.DatabaseFactoryServerVersion, string.Empty, ref _databaseFactoryServerVersion);
private string _mainDomLock;
public string MainDomLock => GetterWithDefaultValue(Constants.AppSettings.MainDomLock, string.Empty, ref _mainDomLock);
private T GetterWithDefaultValue<T>(string appSettingKey, T defaultValue, ref T backingField)
{
if (backingField != null) return backingField;
@@ -0,0 +1,15 @@
using System.Configuration;
using Umbraco.Core.Configuration;
namespace Umbraco.Configuration
{
public class IndexCreatorSettings : IIndexCreatorSettings
{
public IndexCreatorSettings()
{
LuceneDirectoryFactory = ConfigurationManager.AppSettings["Umbraco.Examine.LuceneDirectoryFactory"];
}
public string LuceneDirectoryFactory { get; }
}
}
@@ -0,0 +1,20 @@
using System.Configuration;
using Umbraco.Core.Configuration;
namespace Umbraco.Configuration
{
public class MachineKeyConfig : IMachineKeyConfig
{
//TODO all the machineKey stuff should be replaced: https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/compatibility/replacing-machinekey?view=aspnetcore-3.1
public bool HasMachineKey
{
get
{
var machineKeySection =
ConfigurationManager.GetSection("system.web/machineKey") as ConfigurationSection;
return !(machineKeySection?.ElementInformation?.Source is null);
}
}
}
}
@@ -2,11 +2,11 @@
using System.Configuration;
using System.IO;
using System.Threading;
using System.Web.Configuration;
using Umbraco.Core.Configuration;
using Umbraco.Core;
using Umbraco.Core.IO;
namespace Umbraco.ModelsBuilder.Embedded.Configuration
namespace Umbraco.Configuration
{
/// <summary>
/// Represents the models builder configuration.
@@ -21,7 +21,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Configuration
private object _flagOutOfDateModelsLock;
private bool _flagOutOfDateModelsConfigured;
private bool _flagOutOfDateModels;
public const string DefaultModelsNamespace = "Umbraco.Web.PublishedModels";
public string DefaultModelsDirectory => _ioHelper.MapPath("~/App_Data/Models");
@@ -37,7 +37,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Configuration
Enable = ConfigurationManager.AppSettings[Prefix + "Enable"] == "true";
// ensure defaults are initialized for tests
ModelsNamespace = DefaultModelsNamespace;
ModelsNamespace = Constants.ModelsBuilder.DefaultModelsNamespace;
ModelsDirectory = DefaultModelsDirectory;
DebugLevel = 0;
@@ -95,7 +95,7 @@ namespace Umbraco.ModelsBuilder.Embedded.Configuration
Enable = enable;
_modelsMode = modelsMode;
ModelsNamespace = string.IsNullOrWhiteSpace(modelsNamespace) ? DefaultModelsNamespace : modelsNamespace;
ModelsNamespace = string.IsNullOrWhiteSpace(modelsNamespace) ? Constants.ModelsBuilder.DefaultModelsNamespace : modelsNamespace;
EnableFactory = enableFactory;
_flagOutOfDateModels = flagOutOfDateModels;
ModelsDirectory = string.IsNullOrWhiteSpace(modelsDirectory) ? DefaultModelsDirectory : modelsDirectory;
@@ -174,8 +174,13 @@ namespace Umbraco.ModelsBuilder.Embedded.Configuration
{
get
{
var section = (CompilationSection)ConfigurationManager.GetSection("system.web/compilation");
return section != null && section.Debug;
if (ConfigurationManager.GetSection("system.web/compilation") is ConfigurationSection section &&
bool.TryParse(section.ElementInformation.Properties["debug"].Value.ToString(), out var isDebug))
{
return isDebug;
}
return false;
}
}
@@ -0,0 +1,14 @@
using System.Configuration;
using Umbraco.Core.Configuration;
namespace Umbraco.Configuration
{
public class NuCacheSettings : INuCacheSettings
{
public NuCacheSettings()
{
BTreeBlockSize = ConfigurationManager.AppSettings["Umbraco.Web.PublishedCache.NuCache.BTree.BlockSize"];
}
public string BTreeBlockSize { get; }
}
}
@@ -0,0 +1,29 @@
using System.Configuration;
using Umbraco.Core.Configuration;
namespace Umbraco.Configuration
{
public class RuntimeSettings : IRuntimeSettings
{
public RuntimeSettings()
{
if (ConfigurationManager.GetSection("system.web/httpRuntime") is ConfigurationSection section)
{
var maxRequestLengthProperty = section.ElementInformation.Properties["maxRequestLength"];
if (maxRequestLengthProperty != null && maxRequestLengthProperty.Value is int requestLength)
{
MaxRequestLength = requestLength;
}
var maxQueryStringProperty = section.ElementInformation.Properties["maxQueryStringLength"];
if (maxQueryStringProperty != null && maxQueryStringProperty.Value is int maxQueryStringLength)
{
MaxQueryStringLength = maxQueryStringLength;
}
}
}
public int? MaxQueryStringLength { get; }
public int? MaxRequestLength { get; }
}
}
@@ -0,0 +1,17 @@
using System.Configuration;
using Umbraco.Core.Configuration;
using Umbraco.Core;
namespace Umbraco.Configuration
{
public class TypeFinderSettings : ITypeFinderSettings
{
public TypeFinderSettings()
{
AssembliesAcceptingLoadExceptions = ConfigurationManager.AppSettings[
Constants.AppSettings.AssembliesAcceptingLoadExceptions];
}
public string AssembliesAcceptingLoadExceptions { get; }
}
}
@@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>8</LangVersion>
</PropertyGroup>
<ItemGroup>
@@ -25,7 +26,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Umbraco.Abstractions\Umbraco.Abstractions.csproj" />
<ProjectReference Include="..\Umbraco.Core\Umbraco.Core.csproj" />
</ItemGroup>
</Project>
@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Text.RegularExpressions;
@@ -101,5 +102,9 @@ namespace Umbraco.Core.Cache
var compiled = new Regex(regex, RegexOptions.Compiled);
_items.RemoveAll(kvp => compiled.IsMatch(kvp.Key));
}
public IEnumerator<KeyValuePair<string, object>> GetEnumerator() => _items.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}
@@ -171,5 +171,20 @@ namespace Umbraco.Core.Cache
}
#endregion
public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
{
if (!TryGetContextItems(out var items))
{
yield break;
}
foreach (DictionaryEntry item in items)
{
yield return new KeyValuePair<string, object>(item.Key.ToString(), item.Value);
}
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}
@@ -1,6 +1,8 @@
using System.Collections.Generic;
namespace Umbraco.Core.Cache
{
public interface IRequestCache : IAppCache
public interface IRequestCache : IAppCache, IEnumerable<KeyValuePair<string, object>>
{
bool Set(string key, object value);
bool Remove(string key);
@@ -7,7 +7,7 @@ using Umbraco.Core.Serialization;
namespace Umbraco.Web.Cache
{
public sealed class MacroCacheRefresher : JsonCacheRefresherBase<MacroCacheRefresher, MacroCacheRefresher.JsonPayload>
public sealed class MacroCacheRefresher : PayloadCacheRefresherBase<MacroCacheRefresher, MacroCacheRefresher.JsonPayload>
{
public MacroCacheRefresher(AppCaches appCaches, IJsonSerializer jsonSerializer)
: base(appCaches, jsonSerializer)
@@ -53,7 +53,7 @@ namespace Umbraco.Web.Cache
{
macroRepoCache.Result.Clear(RepositoryCacheKeys.GetKey<IMacro>(payload.Id));
}
};
}
base.Refresh(json);
}
@@ -6,7 +6,7 @@ using Umbraco.Core.Serialization;
namespace Umbraco.Web.Cache
{
public sealed class MemberGroupCacheRefresher : JsonCacheRefresherBase<MemberGroupCacheRefresher, MemberGroupCacheRefresher.JsonPayload>
public sealed class MemberGroupCacheRefresher : PayloadCacheRefresherBase<MemberGroupCacheRefresher, MemberGroupCacheRefresher.JsonPayload>
{
public MemberGroupCacheRefresher(AppCaches appCaches, IJsonSerializer jsonSerializer)
: base(appCaches, jsonSerializer)
@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@@ -84,5 +85,9 @@ namespace Umbraco.Core.Cache
/// <inheritdoc />
public virtual void ClearByRegex(string regex)
{ }
public IEnumerator<KeyValuePair<string, object>> GetEnumerator() => new Dictionary<string, object>().GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}

Some files were not shown because too many files have changed in this diff Show More