Merge remote-tracking branch 'origin/v10/dev' into v10/feature/nullable-reference-types-in-Umbraco.Web.Backoffice

# Conflicts:
#	src/Umbraco.Core/DependencyInjection/UmbracoBuilder.Collections.cs
#	src/Umbraco.Core/Extensions/PublishedContentExtensions.cs
#	src/Umbraco.Core/Telemetry/Models/TelemetryReportData.cs
#	src/Umbraco.Infrastructure/PropertyEditors/ValueConverters/MultiUrlPickerValueConverter.cs
#	src/Umbraco.PublishedCache.NuCache/ContentStore.cs
#	src/Umbraco.Web.BackOffice/Trees/MemberTypeTreeController.cs
#	src/Umbraco.Web.Common/ModelsBuilder/InMemoryModelFactory.cs
#	src/Umbraco.Web.Common/Security/MemberManager.cs
#	src/Umbraco.Web.Website/Routing/ControllerActionSearcher.cs
#	src/Umbraco.Web.Website/Routing/IControllerActionSearcher.cs
#	src/Umbraco.Web.Website/Routing/UmbracoRouteValueTransformer.cs
This commit is contained in:
Nikolaj Geisle
2022-04-21 10:26:51 +02:00
172 changed files with 4578 additions and 1710 deletions

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Http;
@@ -31,13 +32,20 @@ namespace Umbraco.Cms.Web.Website.Routing
_actionSelector = actionSelector;
}
/// <summary>
/// Determines if a custom controller can hijack the current route
/// </summary>
/// <typeparam name="T">The controller type to find</typeparam>
public ControllerActionDescriptor? Find<T>(HttpContext httpContext, string? controller, string? action)
public ControllerActionDescriptor Find<T>(HttpContext httpContext, string controller, string action) => Find<T>(httpContext, controller, action, null);
/// <summary>
/// Determines if a custom controller can hijack the current route
/// </summary>
/// <typeparam name="T">The controller type to find</typeparam>
public ControllerActionDescriptor? Find<T>(HttpContext httpContext, string? controller, string? action, string? area)
{
IReadOnlyList<ControllerActionDescriptor>? candidates = FindControllerCandidates<T>(httpContext, controller, action, DefaultActionName);
IReadOnlyList<ControllerActionDescriptor>? candidates = FindControllerCandidates<T>(httpContext, controller, action, DefaultActionName, area);
if (candidates?.Count > 0)
{
@@ -47,6 +55,7 @@ namespace Umbraco.Cms.Web.Website.Routing
return null;
}
/// <summary>
/// Return a list of controller candidates that match the custom controller and action names
/// </summary>
@@ -54,7 +63,8 @@ namespace Umbraco.Cms.Web.Website.Routing
HttpContext httpContext,
string? customControllerName,
string? customActionName,
string defaultActionName)
string? defaultActionName,
string? area = null)
{
// Use aspnetcore's IActionSelector to do the finding since it uses an optimized cache lookup
var routeValues = new RouteValueDictionary
@@ -62,6 +72,12 @@ namespace Umbraco.Cms.Web.Website.Routing
[ControllerToken] = customControllerName,
[ActionToken] = customActionName, // first try to find the custom action
};
if (area != null)
{
routeValues[AreaToken] = area;
}
var routeData = new RouteData(routeValues);
var routeContext = new RouteContext(httpContext)
{

View File

@@ -1,3 +1,4 @@
using System;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Controllers;
@@ -5,6 +6,11 @@ namespace Umbraco.Cms.Web.Website.Routing
{
public interface IControllerActionSearcher
{
ControllerActionDescriptor? Find<T>(HttpContext httpContext, string? controller, string? action);
ControllerActionDescriptor? Find<T>(HttpContext httpContext, string controller, string action);
ControllerActionDescriptor? Find<T>(HttpContext httpContext, string controller, string action, string area)
=> Find<T>(httpContext, controller, action);
}
}

View File

@@ -240,7 +240,7 @@ namespace Umbraco.Cms.Web.Website.Routing
[ActionToken] = postedInfo.ActionName
};
ControllerActionDescriptor? surfaceControllerDescriptor = _controllerActionSearcher.Find<SurfaceController>(httpContext, postedInfo.ControllerName, postedInfo.ActionName);
ControllerActionDescriptor? surfaceControllerDescriptor = _controllerActionSearcher.Find<SurfaceController>(httpContext, postedInfo.ControllerName, postedInfo.ActionName, postedInfo.Area);
if (surfaceControllerDescriptor == null)
{