From 1927730f4099873c279c23ec8ca38e02785f2008 Mon Sep 17 00:00:00 2001 From: Ajay Bhargav Baaskaran Date: Thu, 5 Nov 2015 17:13:50 -0800 Subject: [PATCH] [Fixes #3426] Removed defensive copy in CompositeModelBinder and CompositeModelValidatorProvider --- .../ModelBinding/CompositeModelBinder.cs | 6 +++--- .../Validation/CompositeModelValidatorProvider.cs | 6 +++--- .../TestModelValidatorProvider.cs | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/CompositeModelBinder.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/CompositeModelBinder.cs index 7efc8abfa9..26d4f227d8 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/CompositeModelBinder.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/CompositeModelBinder.cs @@ -23,18 +23,18 @@ namespace Microsoft.AspNet.Mvc.ModelBinding /// Initializes a new instance of the CompositeModelBinder class. /// /// A collection of instances. - public CompositeModelBinder(IEnumerable modelBinders) + public CompositeModelBinder(IList modelBinders) { if (modelBinders == null) { throw new ArgumentNullException(nameof(modelBinders)); } - ModelBinders = new List(modelBinders); + ModelBinders = modelBinders; } /// - public IReadOnlyList ModelBinders { get; } + public IList ModelBinders { get; } public virtual Task BindModelAsync(ModelBindingContext bindingContext) { diff --git a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/Validation/CompositeModelValidatorProvider.cs b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/Validation/CompositeModelValidatorProvider.cs index f43bea00ae..8e65c8e38c 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ModelBinding/Validation/CompositeModelValidatorProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ModelBinding/Validation/CompositeModelValidatorProvider.cs @@ -17,20 +17,20 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation /// /// A collection of instances. /// - public CompositeModelValidatorProvider(IEnumerable providers) + public CompositeModelValidatorProvider(IList providers) { if (providers == null) { throw new ArgumentNullException(nameof(providers)); } - ValidatorProviders = new List(providers); + ValidatorProviders = providers; } /// /// Gets the list of instances. /// - public IReadOnlyList ValidatorProviders { get; } + public IList ValidatorProviders { get; } /// public void GetValidators(ModelValidatorProviderContext context) diff --git a/test/Microsoft.AspNet.Mvc.TestCommon/TestModelValidatorProvider.cs b/test/Microsoft.AspNet.Mvc.TestCommon/TestModelValidatorProvider.cs index 906a5f7f10..9f347ec3eb 100644 --- a/test/Microsoft.AspNet.Mvc.TestCommon/TestModelValidatorProvider.cs +++ b/test/Microsoft.AspNet.Mvc.TestCommon/TestModelValidatorProvider.cs @@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Validation return new TestModelValidatorProvider(providers); } - public TestModelValidatorProvider(IEnumerable providers) + public TestModelValidatorProvider(IList providers) : base(providers) { }