Fix #4803 - Move some types internal
Moves IControllerArgumentBinder and IControllerPropertyActivator into .Internal. Also renames ControllerArgumentBinder -> DefaultControllerArgumentBinder for consistency with other controller extensibility types. We don't think these are 100% baked for our long term maintenance of the product, and want to reserve the ability to make changes in the future.
This commit is contained in:
parent
22232bc1bf
commit
baf0b6a5c7
|
|
@ -4,8 +4,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Core;
|
using Microsoft.AspNetCore.Mvc.Core;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Internal;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.Controllers
|
namespace Microsoft.AspNetCore.Mvc.Controllers
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
ServiceDescriptor.Transient<IActionInvokerProvider, ControllerActionInvokerProvider>());
|
ServiceDescriptor.Transient<IActionInvokerProvider, ControllerActionInvokerProvider>());
|
||||||
|
|
||||||
// These are stateless
|
// These are stateless
|
||||||
services.TryAddSingleton<IControllerArgumentBinder, ControllerArgumentBinder>();
|
services.TryAddSingleton<IControllerArgumentBinder, DefaultControllerArgumentBinder>();
|
||||||
services.TryAddSingleton<ControllerActionInvokerCache>();
|
services.TryAddSingleton<ControllerActionInvokerCache>();
|
||||||
services.TryAddEnumerable(
|
services.TryAddEnumerable(
|
||||||
ServiceDescriptor.Singleton<IFilterProvider, DefaultFilterProvider>());
|
ServiceDescriptor.Singleton<IFilterProvider, DefaultFilterProvider>());
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Mvc.Abstractions;
|
using Microsoft.AspNetCore.Mvc.Abstractions;
|
||||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Core;
|
using Microsoft.AspNetCore.Mvc.Core;
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||||
|
|
@ -18,17 +17,17 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
/// Provides a default implementation of <see cref="IControllerArgumentBinder"/>.
|
/// Provides a default implementation of <see cref="IControllerArgumentBinder"/>.
|
||||||
/// Uses ModelBinding to populate action parameters.
|
/// Uses ModelBinding to populate action parameters.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ControllerArgumentBinder : IControllerArgumentBinder
|
public class DefaultControllerArgumentBinder : IControllerArgumentBinder
|
||||||
{
|
{
|
||||||
private static readonly MethodInfo CallPropertyAddRangeOpenGenericMethod =
|
private static readonly MethodInfo CallPropertyAddRangeOpenGenericMethod =
|
||||||
typeof(ControllerArgumentBinder).GetTypeInfo().GetDeclaredMethod(
|
typeof(DefaultControllerArgumentBinder).GetTypeInfo().GetDeclaredMethod(
|
||||||
nameof(CallPropertyAddRange));
|
nameof(CallPropertyAddRange));
|
||||||
|
|
||||||
private readonly IModelBinderFactory _modelBinderFactory;
|
private readonly IModelBinderFactory _modelBinderFactory;
|
||||||
private readonly IModelMetadataProvider _modelMetadataProvider;
|
private readonly IModelMetadataProvider _modelMetadataProvider;
|
||||||
private readonly IObjectModelValidator _validator;
|
private readonly IObjectModelValidator _validator;
|
||||||
|
|
||||||
public ControllerArgumentBinder(
|
public DefaultControllerArgumentBinder(
|
||||||
IModelMetadataProvider modelMetadataProvider,
|
IModelMetadataProvider modelMetadataProvider,
|
||||||
IModelBinderFactory modelBinderFactory,
|
IModelBinderFactory modelBinderFactory,
|
||||||
IObjectModelValidator validator)
|
IObjectModelValidator validator)
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.Controllers
|
namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides a dictionary of action arguments.
|
/// Provides a dictionary of action arguments.
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.Controllers
|
namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
{
|
{
|
||||||
public interface IControllerPropertyActivator
|
public interface IControllerPropertyActivator
|
||||||
{
|
{
|
||||||
|
|
@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.ApplicationParts;
|
using Microsoft.AspNetCore.Mvc.ApplicationParts;
|
||||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||||
using Microsoft.AspNetCore.Mvc.Formatters;
|
using Microsoft.AspNetCore.Mvc.Formatters;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Internal;
|
||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||||
using Microsoft.AspNetCore.Mvc.ViewComponents;
|
using Microsoft.AspNetCore.Mvc.ViewComponents;
|
||||||
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
using Microsoft.AspNetCore.Mvc.ViewEngines;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
using Microsoft.AspNetCore.Mvc.Internal;
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||||
using Microsoft.Extensions.Internal;
|
using Microsoft.Extensions.Internal;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2458,7 +2458,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
|
|
||||||
var metadataProvider = new EmptyModelMetadataProvider();
|
var metadataProvider = new EmptyModelMetadataProvider();
|
||||||
|
|
||||||
var argumentBinder = new ControllerArgumentBinder(
|
var argumentBinder = new DefaultControllerArgumentBinder(
|
||||||
metadataProvider,
|
metadataProvider,
|
||||||
TestModelBinderFactory.CreateDefault(metadataProvider),
|
TestModelBinderFactory.CreateDefault(metadataProvider),
|
||||||
new DefaultObjectValidator(metadataProvider, new IModelValidatorProvider[0]));
|
new DefaultObjectValidator(metadataProvider, new IModelValidatorProvider[0]));
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.Internal
|
namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
{
|
{
|
||||||
public class ControllerArgumentBinderTests
|
public class DefaultControllerArgumentBinderTests
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task BindActionArgumentsAsync_DoesNotAddActionArguments_IfBinderReturnsNull()
|
public async Task BindActionArgumentsAsync_DoesNotAddActionArguments_IfBinderReturnsNull()
|
||||||
|
|
@ -645,7 +645,11 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
})
|
})
|
||||||
.Returns(modelBinder.Object);
|
.Returns(modelBinder.Object);
|
||||||
|
|
||||||
var argumentBinder = new ControllerArgumentBinder(metadataProvider, factory.Object, CreateMockValidator());
|
var argumentBinder = new DefaultControllerArgumentBinder(
|
||||||
|
metadataProvider,
|
||||||
|
factory.Object,
|
||||||
|
CreateMockValidator());
|
||||||
|
|
||||||
var controllerContext = GetControllerContext();
|
var controllerContext = GetControllerContext();
|
||||||
controllerContext.ActionDescriptor.Parameters.Add(parameterDescriptor);
|
controllerContext.ActionDescriptor.Parameters.Add(parameterDescriptor);
|
||||||
|
|
||||||
|
|
@ -688,7 +692,11 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
})
|
})
|
||||||
.Returns(modelBinder.Object);
|
.Returns(modelBinder.Object);
|
||||||
|
|
||||||
var argumentBinder = new ControllerArgumentBinder(metadataProvider, factory.Object, CreateMockValidator());
|
var argumentBinder = new DefaultControllerArgumentBinder(
|
||||||
|
metadataProvider,
|
||||||
|
factory.Object,
|
||||||
|
CreateMockValidator());
|
||||||
|
|
||||||
var valueProvider = new SimpleValueProvider
|
var valueProvider = new SimpleValueProvider
|
||||||
{
|
{
|
||||||
{ expectedModelName, new object() },
|
{ expectedModelName, new object() },
|
||||||
|
|
@ -752,7 +760,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
return TestModelBinderFactory.Create(provider.Object);
|
return TestModelBinderFactory.Create(provider.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ControllerArgumentBinder GetArgumentBinder(
|
private static DefaultControllerArgumentBinder GetArgumentBinder(
|
||||||
IModelBinderFactory factory = null,
|
IModelBinderFactory factory = null,
|
||||||
IObjectModelValidator validator = null)
|
IObjectModelValidator validator = null)
|
||||||
{
|
{
|
||||||
|
|
@ -766,7 +774,7 @@ namespace Microsoft.AspNetCore.Mvc.Internal
|
||||||
factory = TestModelBinderFactory.CreateDefault();
|
factory = TestModelBinderFactory.CreateDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ControllerArgumentBinder(
|
return new DefaultControllerArgumentBinder(
|
||||||
TestModelMetadataProvider.CreateDefaultProvider(),
|
TestModelMetadataProvider.CreateDefaultProvider(),
|
||||||
factory,
|
factory,
|
||||||
validator);
|
validator);
|
||||||
|
|
@ -40,7 +40,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ControllerArgumentBinder GetArgumentBinder(
|
public static DefaultControllerArgumentBinder GetArgumentBinder(
|
||||||
MvcOptions options = null,
|
MvcOptions options = null,
|
||||||
IModelBinderProvider binderProvider = null)
|
IModelBinderProvider binderProvider = null)
|
||||||
{
|
{
|
||||||
|
|
@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ControllerArgumentBinder GetArgumentBinder(
|
public static DefaultControllerArgumentBinder GetArgumentBinder(
|
||||||
IModelMetadataProvider metadataProvider,
|
IModelMetadataProvider metadataProvider,
|
||||||
IModelBinderProvider binderProvider = null)
|
IModelBinderProvider binderProvider = null)
|
||||||
{
|
{
|
||||||
|
|
@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests
|
||||||
options.Value.ModelBinderProviders.Insert(0, binderProvider);
|
options.Value.ModelBinderProviders.Insert(0, binderProvider);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ControllerArgumentBinder(
|
return new DefaultControllerArgumentBinder(
|
||||||
metadataProvider,
|
metadataProvider,
|
||||||
new ModelBinderFactory(metadataProvider, options),
|
new ModelBinderFactory(metadataProvider, options),
|
||||||
GetObjectValidator(metadataProvider, options));
|
GetObjectValidator(metadataProvider, options));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue