Merge remote-tracking branch 'origin/v9/dev' into v10/dev
# Conflicts: # build/templates/UmbracoPackage/.template.config/template.json # build/templates/UmbracoProject/.template.config/template.json # src/Directory.Build.props # src/Umbraco.Core/DependencyInjection/UmbracoBuilder.cs # src/Umbraco.Infrastructure/HostedServices/ServerRegistration/TouchServerTask.cs # tests/Umbraco.Tests.UnitTests/Umbraco.Infrastructure/HostedServices/ServerRegistration/TouchServerTaskTests.cs
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Umbraco.Cms.Core.Composing;
|
||||
using Umbraco.Cms.Core.DependencyInjection;
|
||||
|
||||
namespace Umbraco.Cms.Web.UI.Composers
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds controllers to the service collection.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// Umbraco 9 out of the box, makes use of <see cref="DefaultControllerActivator"/> which doesn't resolve controller
|
||||
/// instances from the IOC container, instead it resolves the required dependencies of the controller and constructs an instance
|
||||
/// of the controller.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Some users may wish to switch to <see cref="ServiceBasedControllerActivator"/> (perhaps to make use of interception/decoration).
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This composer exists to help us detect ambiguous constructors in the CMS such that we do not cause unnecessary effort downstream.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// This Composer is not shipped by the Umbraco.Templates package.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public class ControllersAsServicesComposer : IComposer
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public void Compose(IUmbracoBuilder builder) => builder.Services
|
||||
.AddMvc()
|
||||
.AddControllersAsServicesWithoutChangingActivator();
|
||||
}
|
||||
|
||||
internal static class MvcBuilderExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="MvcCoreMvcBuilderExtensions.AddControllersAsServices"/> but without the replacement of
|
||||
/// <see cref="DefaultControllerActivator"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// We don't need to opt in to <see cref="ServiceBasedControllerActivator"/> to ensure container validation
|
||||
/// passes.
|
||||
/// </remarks>
|
||||
public static IMvcBuilder AddControllersAsServicesWithoutChangingActivator(this IMvcBuilder builder)
|
||||
{
|
||||
var feature = new ControllerFeature();
|
||||
builder.PartManager.PopulateFeature(feature);
|
||||
|
||||
foreach (Type controller in feature.Controllers.Select(c => c.AsType()))
|
||||
{
|
||||
builder.Services.TryAddTransient(controller, controller);
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,16 @@
|
||||
<ProjectReference Include="../Umbraco.Web.Website/Umbraco.Web.Website.csproj" />
|
||||
<ProjectReference Include="../Umbraco.Persistence.SqlCe/Umbraco.Persistence.SqlCe.csproj" Condition="'$(OS)' == 'Windows_NT'" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" />
|
||||
|
||||
<RuntimeHostConfigurationOption
|
||||
Condition="$(RuntimeIdentifier.StartsWith('linux')) Or $(RuntimeIdentifier.StartsWith('win')) Or ('$(RuntimeIdentifier)' == '' And !$([MSBuild]::IsOSPlatform('osx')))"
|
||||
Include="System.Globalization.AppLocalIcu"
|
||||
Value="68.2.0.9" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Plugins" />
|
||||
@@ -93,7 +103,7 @@
|
||||
<Message Text="JsonSchemaPath: $(JsonSchemaPath)" Importance="high" />
|
||||
<Message Text="BellePath: $(BellePath)" Importance="high" />
|
||||
|
||||
<!-- Build Belle, if building is Visual Studio and the build folder does not exist yet -->
|
||||
<!-- Build Belle, if building is Visual Studio and the build folder does not exist yet -->
|
||||
<Message Text="Skip Belle because UmbracoBuild is '$(UmbracoBuild)' (this is not Visual Studio)." Importance="High" Condition="'$(UmbracoBuild)' != ''" />
|
||||
<Message Text="Skip Belle because $(BellePath) exists." Importance="High" Condition="Exists('$(BellePath)')" />
|
||||
<Message Text="Build Belle because UmbracoBuild is empty (this is Visual Studio), and $(BellePath) does not exist." Importance="High" Condition="!Exists('$(BellePath)') and '$(UmbracoBuild)' == ''" />
|
||||
|
||||
Reference in New Issue
Block a user