[Fixes #3426] Removed defensive copy in CompositeModelBinder and CompositeModelValidatorProvider

This commit is contained in:
Ajay Bhargav Baaskaran 2015-11-05 17:13:50 -08:00
parent decf882341
commit 1927730f40
3 changed files with 7 additions and 7 deletions

View File

@ -23,18 +23,18 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
/// Initializes a new instance of the CompositeModelBinder class. /// Initializes a new instance of the CompositeModelBinder class.
/// </summary> /// </summary>
/// <param name="modelBinders">A collection of <see cref="IModelBinder"/> instances.</param> /// <param name="modelBinders">A collection of <see cref="IModelBinder"/> instances.</param>
public CompositeModelBinder(IEnumerable<IModelBinder> modelBinders) public CompositeModelBinder(IList<IModelBinder> modelBinders)
{ {
if (modelBinders == null) if (modelBinders == null)
{ {
throw new ArgumentNullException(nameof(modelBinders)); throw new ArgumentNullException(nameof(modelBinders));
} }
ModelBinders = new List<IModelBinder>(modelBinders); ModelBinders = modelBinders;
} }
/// <inheritdoc /> /// <inheritdoc />
public IReadOnlyList<IModelBinder> ModelBinders { get; } public IList<IModelBinder> ModelBinders { get; }
public virtual Task<ModelBindingResult> BindModelAsync(ModelBindingContext bindingContext) public virtual Task<ModelBindingResult> BindModelAsync(ModelBindingContext bindingContext)
{ {

View File

@ -17,20 +17,20 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
/// <param name="providers"> /// <param name="providers">
/// A collection of <see cref="IModelValidatorProvider"/> instances. /// A collection of <see cref="IModelValidatorProvider"/> instances.
/// </param> /// </param>
public CompositeModelValidatorProvider(IEnumerable<IModelValidatorProvider> providers) public CompositeModelValidatorProvider(IList<IModelValidatorProvider> providers)
{ {
if (providers == null) if (providers == null)
{ {
throw new ArgumentNullException(nameof(providers)); throw new ArgumentNullException(nameof(providers));
} }
ValidatorProviders = new List<IModelValidatorProvider>(providers); ValidatorProviders = providers;
} }
/// <summary> /// <summary>
/// Gets the list of <see cref="IModelValidatorProvider"/> instances. /// Gets the list of <see cref="IModelValidatorProvider"/> instances.
/// </summary> /// </summary>
public IReadOnlyList<IModelValidatorProvider> ValidatorProviders { get; } public IList<IModelValidatorProvider> ValidatorProviders { get; }
/// <inheritdoc /> /// <inheritdoc />
public void GetValidators(ModelValidatorProviderContext context) public void GetValidators(ModelValidatorProviderContext context)

View File

@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation
return new TestModelValidatorProvider(providers); return new TestModelValidatorProvider(providers);
} }
public TestModelValidatorProvider(IEnumerable<IModelValidatorProvider> providers) public TestModelValidatorProvider(IList<IModelValidatorProvider> providers)
: base(providers) : base(providers)
{ {
} }