diff --git a/src/Hosting/Hosting/src/Properties/Resources.Designer.cs b/src/Hosting/Hosting/src/Properties/Resources.Designer.cs
index 088072729c..4dcdd4b244 100644
--- a/src/Hosting/Hosting/src/Properties/Resources.Designer.cs
+++ b/src/Hosting/Hosting/src/Properties/Resources.Designer.cs
@@ -15,64 +15,56 @@ namespace Microsoft.AspNetCore.Hosting
///
internal static string ErrorPageHtml_Title
{
- get { return GetString("ErrorPageHtml_Title"); }
+ get => GetString("ErrorPageHtml_Title");
}
///
/// Internal Server Error
///
internal static string FormatErrorPageHtml_Title()
- {
- return GetString("ErrorPageHtml_Title");
- }
+ => GetString("ErrorPageHtml_Title");
///
/// An error occurred while starting the application.
///
internal static string ErrorPageHtml_UnhandledException
{
- get { return GetString("ErrorPageHtml_UnhandledException"); }
+ get => GetString("ErrorPageHtml_UnhandledException");
}
///
/// An error occurred while starting the application.
///
internal static string FormatErrorPageHtml_UnhandledException()
- {
- return GetString("ErrorPageHtml_UnhandledException");
- }
+ => GetString("ErrorPageHtml_UnhandledException");
///
/// Unknown location
///
internal static string ErrorPageHtml_UnknownLocation
{
- get { return GetString("ErrorPageHtml_UnknownLocation"); }
+ get => GetString("ErrorPageHtml_UnknownLocation");
}
///
/// Unknown location
///
internal static string FormatErrorPageHtml_UnknownLocation()
- {
- return GetString("ErrorPageHtml_UnknownLocation");
- }
+ => GetString("ErrorPageHtml_UnknownLocation");
///
/// WebHostBuilder allows creation only of a single instance of WebHost
///
internal static string WebHostBuilder_SingleInstance
{
- get { return GetString("WebHostBuilder_SingleInstance"); }
+ get => GetString("WebHostBuilder_SingleInstance");
}
///
/// WebHostBuilder allows creation only of a single instance of WebHost
///
internal static string FormatWebHostBuilder_SingleInstance()
- {
- return GetString("WebHostBuilder_SingleInstance");
- }
+ => GetString("WebHostBuilder_SingleInstance");
private static string GetString(string name, params string[] formatterNames)
{
diff --git a/src/Middleware/Localization/src/Properties/Resources.Designer.cs b/src/Middleware/Localization/src/Properties/Resources.Designer.cs
index 581e3cda17..49608c3eaa 100644
--- a/src/Middleware/Localization/src/Properties/Resources.Designer.cs
+++ b/src/Middleware/Localization/src/Properties/Resources.Designer.cs
@@ -1,6 +1,7 @@
//
namespace Microsoft.AspNetCore.Localization
{
+ using System.Globalization;
using System.Reflection;
using System.Resources;
@@ -14,9 +15,15 @@ namespace Microsoft.AspNetCore.Localization
///
internal static string Exception_CulturesShouldNotBeEmpty
{
- get { return GetString("Exception_CulturesShouldNotBeEmpty"); }
+ get => GetString("Exception_CulturesShouldNotBeEmpty");
}
+ ///
+ /// Please provide at least one culture.
+ ///
+ internal static string FormatException_CulturesShouldNotBeEmpty()
+ => GetString("Exception_CulturesShouldNotBeEmpty");
+
private static string GetString(string name, params string[] formatterNames)
{
var value = _resourceManager.GetString(name);
diff --git a/src/Middleware/Session/src/Properties/Resources.Designer.cs b/src/Middleware/Session/src/Properties/Resources.Designer.cs
index d071f6b698..425ab7bc39 100644
--- a/src/Middleware/Session/src/Properties/Resources.Designer.cs
+++ b/src/Middleware/Session/src/Properties/Resources.Designer.cs
@@ -15,96 +15,84 @@ namespace Microsoft.AspNetCore.Session
///
internal static string Exception_KeyLengthIsExceeded
{
- get { return GetString("Exception_KeyLengthIsExceeded"); }
+ get => GetString("Exception_KeyLengthIsExceeded");
}
///
/// The key cannot be longer than '{0}' when encoded with UTF-8.
///
internal static string FormatException_KeyLengthIsExceeded(object p0)
- {
- return string.Format(CultureInfo.CurrentCulture, GetString("Exception_KeyLengthIsExceeded"), p0);
- }
+ => string.Format(CultureInfo.CurrentCulture, GetString("Exception_KeyLengthIsExceeded"), p0);
///
/// The session cannot be established after the response has started.
///
internal static string Exception_InvalidSessionEstablishment
{
- get { return GetString("Exception_InvalidSessionEstablishment"); }
+ get => GetString("Exception_InvalidSessionEstablishment");
}
///
/// The session cannot be established after the response has started.
///
internal static string FormatException_InvalidSessionEstablishment()
- {
- return GetString("Exception_InvalidSessionEstablishment");
- }
+ => GetString("Exception_InvalidSessionEstablishment");
///
/// The value cannot be serialized in two bytes.
///
internal static string Exception_InvalidToSerializeIn2Bytes
{
- get { return GetString("Exception_InvalidToSerializeIn2Bytes"); }
+ get => GetString("Exception_InvalidToSerializeIn2Bytes");
}
///
/// The value cannot be serialized in two bytes.
///
internal static string FormatException_InvalidToSerializeIn2Bytes()
- {
- return GetString("Exception_InvalidToSerializeIn2Bytes");
- }
+ => GetString("Exception_InvalidToSerializeIn2Bytes");
///
/// The value cannot be serialized in three bytes.
///
internal static string Exception_InvalidToSerializeIn3Bytes
{
- get { return GetString("Exception_InvalidToSerializeIn3Bytes"); }
+ get => GetString("Exception_InvalidToSerializeIn3Bytes");
}
///
/// The value cannot be serialized in three bytes.
///
internal static string FormatException_InvalidToSerializeIn3Bytes()
- {
- return GetString("Exception_InvalidToSerializeIn3Bytes");
- }
+ => GetString("Exception_InvalidToSerializeIn3Bytes");
///
/// The value cannot be negative.
///
internal static string Exception_NumberShouldNotBeNegative
{
- get { return GetString("Exception_NumberShouldNotBeNegative"); }
+ get => GetString("Exception_NumberShouldNotBeNegative");
}
///
/// The value cannot be negative.
///
internal static string FormatException_NumberShouldNotBeNegative()
- {
- return GetString("Exception_NumberShouldNotBeNegative");
- }
+ => GetString("Exception_NumberShouldNotBeNegative");
///
/// Argument cannot be null or empty string.
///
internal static string ArgumentCannotBeNullOrEmpty
{
- get { return GetString("ArgumentCannotBeNullOrEmpty"); }
+ get => GetString("ArgumentCannotBeNullOrEmpty");
}
///
/// Argument cannot be null or empty string.
///
internal static string FormatArgumentCannotBeNullOrEmpty()
- {
- return GetString("ArgumentCannotBeNullOrEmpty");
- }
+ => GetString("ArgumentCannotBeNullOrEmpty");
private static string GetString(string name, params string[] formatterNames)
{
diff --git a/src/Mvc/Mvc.ApiExplorer/test/DefaultApiDescriptionProviderTest.cs b/src/Mvc/Mvc.ApiExplorer/test/DefaultApiDescriptionProviderTest.cs
index 010d18a5b2..95f80b1812 100644
--- a/src/Mvc/Mvc.ApiExplorer/test/DefaultApiDescriptionProviderTest.cs
+++ b/src/Mvc/Mvc.ApiExplorer/test/DefaultApiDescriptionProviderTest.cs
@@ -191,8 +191,6 @@ namespace Microsoft.AspNetCore.Mvc.Description
var action = CreateActionDescriptor(nameof(FromRouting));
action.AttributeRouteInfo = new AttributeRouteInfo { Template = template };
- var parameterDescriptor = action.Parameters[0];
-
// Act
var descriptions = GetApiDescriptions(action);
@@ -1511,7 +1509,6 @@ namespace Microsoft.AspNetCore.Mvc.Description
{
// Arrange
var action = CreateActionDescriptor(nameof(AcceptsHasCollection));
- var parameterDescriptor = action.Parameters.Single();
// Act
var descriptions = GetApiDescriptions(action);
@@ -1531,7 +1528,6 @@ namespace Microsoft.AspNetCore.Mvc.Description
{
// Arrange
var action = CreateActionDescriptor(nameof(AcceptsHasCollection_Complex));
- var parameterDescriptor = action.Parameters.Single();
// Act
var descriptions = GetApiDescriptions(action);
diff --git a/src/Mvc/Mvc.Core/src/ModelBinding/Binders/ArrayModelBinder.cs b/src/Mvc/Mvc.Core/src/ModelBinding/Binders/ArrayModelBinder.cs
index 29705d88a6..035a0d0f80 100644
--- a/src/Mvc/Mvc.Core/src/ModelBinding/Binders/ArrayModelBinder.cs
+++ b/src/Mvc/Mvc.Core/src/ModelBinding/Binders/ArrayModelBinder.cs
@@ -52,6 +52,36 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
{
}
+ ///
+ /// Creates a new .
+ ///
+ ///
+ /// The for binding .
+ ///
+ /// The .
+ ///
+ /// Indication that validation of top-level models is enabled. If and
+ /// is for a top-level model, the binder
+ /// adds a error when the model is not bound.
+ ///
+ /// The .
+ ///
+ /// This is the preferred constructor.
+ ///
+ /// The parameter is currently ignored.
+ /// is always
+ /// in .
+ ///
+ ///
+ public ArrayModelBinder(
+ IModelBinder elementBinder,
+ ILoggerFactory loggerFactory,
+ bool allowValidatingTopLevelNodes,
+ MvcOptions mvcOptions)
+ : base(elementBinder, loggerFactory, allowValidatingTopLevelNodes: true, mvcOptions)
+ {
+ }
+
///
public override bool CanCreateInstance(Type targetType)
{
diff --git a/src/Mvc/Mvc.Core/src/ModelBinding/Binders/ArrayModelBinderProvider.cs b/src/Mvc/Mvc.Core/src/ModelBinding/Binders/ArrayModelBinderProvider.cs
index 4eb195b7ab..eacedb17ba 100644
--- a/src/Mvc/Mvc.Core/src/ModelBinding/Binders/ArrayModelBinderProvider.cs
+++ b/src/Mvc/Mvc.Core/src/ModelBinding/Binders/ArrayModelBinderProvider.cs
@@ -4,6 +4,7 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
{
@@ -23,15 +24,17 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
if (context.Metadata.ModelType.IsArray)
{
var elementType = context.Metadata.ElementMetadata.ModelType;
+ var binderType = typeof(ArrayModelBinder<>).MakeGenericType(elementType);
var elementBinder = context.CreateBinder(context.Metadata.ElementMetadata);
- var binderType = typeof(ArrayModelBinder<>).MakeGenericType(elementType);
var loggerFactory = context.Services.GetRequiredService();
+ var mvcOptions = context.Services.GetRequiredService>().Value;
return (IModelBinder)Activator.CreateInstance(
binderType,
elementBinder,
loggerFactory,
- true /* allowValidatingTopLevelNodes */);
+ true /* allowValidatingTopLevelNodes */,
+ mvcOptions);
}
return null;
diff --git a/src/Mvc/Mvc.Core/src/ModelBinding/Binders/CollectionModelBinder.cs b/src/Mvc/Mvc.Core/src/ModelBinding/Binders/CollectionModelBinder.cs
index 8746cd487e..38955e2a9c 100644
--- a/src/Mvc/Mvc.Core/src/ModelBinding/Binders/CollectionModelBinder.cs
+++ b/src/Mvc/Mvc.Core/src/ModelBinding/Binders/CollectionModelBinder.cs
@@ -9,6 +9,8 @@ using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc.Core;
+using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
using Microsoft.Extensions.Logging;
@@ -21,12 +23,15 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
public class CollectionModelBinder : ICollectionModelBinder
{
private static readonly IValueProvider EmptyValueProvider = new CompositeValueProvider();
+ private readonly int _maxModelBindingCollectionSize = MvcOptions.DefaultMaxModelBindingCollectionSize;
private Func