From 557974b948b0d345d4f9ec003a25fcbf8b98d38c Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Fri, 17 Oct 2014 19:50:17 -0700 Subject: [PATCH] Removing BodyParameterInfo and ParameterBindingInfo These have been superceded by the BinderMetadata property on ParameterDescriptor. --- .../BodyParameterInfo.cs | 17 ----- .../ControllerActionDescriptorProvider.cs | 14 +---- .../DefaultApiDescriptionProvider.cs | 22 +++---- .../ParameterBindingInfo.cs | 20 ------ .../ParameterDescriptor.cs | 5 -- .../OverloadActionConstraint.cs | 2 +- ...ControllerActionDescriptorProviderTests.cs | 62 ++++++------------- .../ControllerActionInvokerTest.cs | 16 ++--- .../DefaultApiDescriptionProviderTest.cs | 12 ++-- .../InputObjectBindingTests.cs | 16 ++--- .../ControllerActionArgumentBinderTests.cs | 14 ++--- .../OverloadActionConstraintTest.cs | 60 +++++++++--------- .../ValidateBodyParameterAttribute.cs | 3 +- 13 files changed, 91 insertions(+), 172 deletions(-) delete mode 100644 src/Microsoft.AspNet.Mvc.Core/BodyParameterInfo.cs delete mode 100644 src/Microsoft.AspNet.Mvc.Core/ParameterBindingInfo.cs diff --git a/src/Microsoft.AspNet.Mvc.Core/BodyParameterInfo.cs b/src/Microsoft.AspNet.Mvc.Core/BodyParameterInfo.cs deleted file mode 100644 index 99da7a67f7..0000000000 --- a/src/Microsoft.AspNet.Mvc.Core/BodyParameterInfo.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; - -namespace Microsoft.AspNet.Mvc -{ - public class BodyParameterInfo - { - public BodyParameterInfo(Type parameterType) - { - ParameterType = parameterType; - } - - public Type ParameterType { get; private set; } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/ControllerActionDescriptorProvider.cs b/src/Microsoft.AspNet.Mvc.Core/ControllerActionDescriptorProvider.cs index 103c726959..e29fd4f882 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ControllerActionDescriptorProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ControllerActionDescriptorProvider.cs @@ -513,21 +513,9 @@ namespace Microsoft.AspNet.Mvc BinderMetadata = parameter.BinderMetadata, IsOptional = parameter.IsOptional, Name = parameter.ParameterName, + ParameterType = parameter.ParameterInfo.ParameterType, }; - var isFromBody = parameter.Attributes.OfType().Any(); - if (isFromBody) - { - parameterDescriptor.BodyParameterInfo = new BodyParameterInfo( - parameter.ParameterInfo.ParameterType); - } - else - { - parameterDescriptor.ParameterBindingInfo = new ParameterBindingInfo( - parameter.ParameterName, - parameter.ParameterInfo.ParameterType); - } - return parameterDescriptor; } diff --git a/src/Microsoft.AspNet.Mvc.Core/Description/DefaultApiDescriptionProvider.cs b/src/Microsoft.AspNet.Mvc.Core/Description/DefaultApiDescriptionProvider.cs index ad8e03f8d1..febdaf2e29 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Description/DefaultApiDescriptionProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Description/DefaultApiDescriptionProvider.cs @@ -137,7 +137,7 @@ namespace Microsoft.AspNet.Mvc.Description // Process together parameters that appear on the path template and on the // action descriptor and do not come from the body. TemplatePart templateParameter = null; - if (parameter.BodyParameterInfo == null) + if (parameter.BinderMetadata as IFormatterBinderMetadata == null) { templateParameter = templateParameters .FirstOrDefault(p => p.Name.Equals(parameter.Name, StringComparison.OrdinalIgnoreCase)); @@ -266,18 +266,16 @@ namespace Microsoft.AspNet.Mvc.Description IsOptional = parameter.IsOptional, Name = parameter.Name, ParameterDescriptor = parameter, + Type = parameter.ParameterType, }; - if (parameter.ParameterBindingInfo != null) + if (parameter.BinderMetadata as IFormatterBinderMetadata != null) + { + resourceParameter.Source = ApiParameterSource.Body; + } + else { resourceParameter.Source = ApiParameterSource.Query; - resourceParameter.Type = parameter.ParameterBindingInfo.ParameterType; - } - - if (parameter.BodyParameterInfo != null) - { - resourceParameter.Type = parameter.BodyParameterInfo.ParameterType; - resourceParameter.Source = ApiParameterSource.Body; } return resourceParameter; @@ -295,13 +293,9 @@ namespace Microsoft.AspNet.Mvc.Description ParameterDescriptor = parameter, Constraint = templateParameter.InlineConstraint, DefaultValue = templateParameter.DefaultValue, + Type = parameter.ParameterType, }; - if (parameter.ParameterBindingInfo != null) - { - resourceParameter.Type = parameter.ParameterBindingInfo.ParameterType; - } - return resourceParameter; } diff --git a/src/Microsoft.AspNet.Mvc.Core/ParameterBindingInfo.cs b/src/Microsoft.AspNet.Mvc.Core/ParameterBindingInfo.cs deleted file mode 100644 index 860f8ee5c1..0000000000 --- a/src/Microsoft.AspNet.Mvc.Core/ParameterBindingInfo.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; - -namespace Microsoft.AspNet.Mvc -{ - public class ParameterBindingInfo - { - public ParameterBindingInfo(string prefix, Type parameterType) - { - Prefix = prefix; - ParameterType = parameterType; - } - - public string Prefix { get; private set; } - - public Type ParameterType { get; private set; } - } -} diff --git a/src/Microsoft.AspNet.Mvc.Core/ParameterDescriptor.cs b/src/Microsoft.AspNet.Mvc.Core/ParameterDescriptor.cs index 8e2f8c8bf7..6a0ee3e646 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ParameterDescriptor.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ParameterDescriptor.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using System.Collections.Generic; using Microsoft.AspNet.Mvc.ModelBinding; namespace Microsoft.AspNet.Mvc @@ -15,10 +14,6 @@ namespace Microsoft.AspNet.Mvc public Type ParameterType { get; set; } - public ParameterBindingInfo ParameterBindingInfo { get; set; } - public IBinderMetadata BinderMetadata { get; set; } - - public BodyParameterInfo BodyParameterInfo { get; set; } } } diff --git a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/OverloadActionConstraint.cs b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/OverloadActionConstraint.cs index daa414dfe3..99d6bed121 100644 --- a/src/Microsoft.AspNet.Mvc.WebApiCompatShim/OverloadActionConstraint.cs +++ b/src/Microsoft.AspNet.Mvc.WebApiCompatShim/OverloadActionConstraint.cs @@ -94,7 +94,7 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim if ((parameter.BinderMetadata is IRouteDataValueProviderMetadata || parameter.BinderMetadata is IQueryValueProviderMetadata) && !parameter.IsOptional && - ValueProviderResult.CanConvertFromString(parameter.ParameterBindingInfo.ParameterType)) + ValueProviderResult.CanConvertFromString(parameter.ParameterType)) { var nameProvider = parameter.BinderMetadata as IModelNameProvider; var prefix = nameProvider?.Name ?? parameter.Name; diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionDescriptorProviderTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionDescriptorProviderTests.cs index 20f048aaf2..ec041df64f 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionDescriptorProviderTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionDescriptorProviderTests.cs @@ -127,11 +127,8 @@ namespace Microsoft.AspNet.Mvc.Test Assert.Equal("id", id.Name); Assert.False(id.IsOptional); - Assert.Null(id.BodyParameterInfo); - - Assert.NotNull(id.ParameterBindingInfo); - Assert.Equal("id", id.ParameterBindingInfo.Prefix); - Assert.Equal(typeof(int), id.ParameterBindingInfo.ParameterType); + Assert.Null(id.BinderMetadata); + Assert.Equal(typeof(int), id.ParameterType); } [Fact] @@ -150,20 +147,15 @@ namespace Microsoft.AspNet.Mvc.Test Assert.Equal("id", id.Name); Assert.False(id.IsOptional); - Assert.Null(id.BodyParameterInfo); - - Assert.NotNull(id.ParameterBindingInfo); - Assert.Equal("id", id.ParameterBindingInfo.Prefix); - Assert.Equal(typeof(int), id.ParameterBindingInfo.ParameterType); + Assert.Null(id.BinderMetadata); + Assert.Equal(typeof(int), id.ParameterType); var entity = Assert.Single(main.Parameters, p => p.Name == "entity"); Assert.Equal("entity", entity.Name); Assert.False(entity.IsOptional); - Assert.Null(entity.ParameterBindingInfo); - - Assert.NotNull(entity.BodyParameterInfo); - Assert.Equal(typeof(TestActionParameter), entity.BodyParameterInfo.ParameterType); + Assert.IsType(entity.BinderMetadata); + Assert.Equal(typeof(TestActionParameter), entity.ParameterType); } [Fact] @@ -182,31 +174,22 @@ namespace Microsoft.AspNet.Mvc.Test Assert.Equal("id", id.Name); Assert.False(id.IsOptional); - Assert.Null(id.BodyParameterInfo); - - Assert.NotNull(id.ParameterBindingInfo); - Assert.Equal("id", id.ParameterBindingInfo.Prefix); - Assert.Equal(typeof(int), id.ParameterBindingInfo.ParameterType); + Assert.Null(id.BinderMetadata); + Assert.Equal(typeof(int), id.ParameterType); var upperCaseId = Assert.Single(main.Parameters, p => p.Name == "ID"); Assert.Equal("ID", upperCaseId.Name); Assert.False(upperCaseId.IsOptional); - Assert.Null(upperCaseId.BodyParameterInfo); - - Assert.NotNull(upperCaseId.ParameterBindingInfo); - Assert.Equal("ID", upperCaseId.ParameterBindingInfo.Prefix); - Assert.Equal(typeof(int), upperCaseId.ParameterBindingInfo.ParameterType); + Assert.Null(upperCaseId.BinderMetadata); + Assert.Equal(typeof(int), upperCaseId.ParameterType); var pascalCaseId = Assert.Single(main.Parameters, p => p.Name == "Id"); Assert.Equal("Id", pascalCaseId.Name); Assert.False(pascalCaseId.IsOptional); - Assert.Null(pascalCaseId.BodyParameterInfo); - - Assert.NotNull(pascalCaseId.ParameterBindingInfo); - Assert.Equal("Id", pascalCaseId.ParameterBindingInfo.Prefix); - Assert.Equal(typeof(int), pascalCaseId.ParameterBindingInfo.ParameterType); + Assert.Null(id.BinderMetadata); + Assert.Equal(typeof(int), pascalCaseId.ParameterType); } [Theory] @@ -229,11 +212,8 @@ namespace Microsoft.AspNet.Mvc.Test Assert.Equal("id", id.Name); Assert.True(id.IsOptional); - Assert.Null(id.BodyParameterInfo); - - Assert.NotNull(id.ParameterBindingInfo); - Assert.Equal("id", id.ParameterBindingInfo.Prefix); - Assert.Equal(parameterType, id.ParameterBindingInfo.ParameterType); + Assert.Null(id.BinderMetadata); + Assert.Equal(parameterType, id.ParameterType); } [Fact] @@ -254,11 +234,8 @@ namespace Microsoft.AspNet.Mvc.Test Assert.Equal("entity", entity.Name); Assert.False(entity.IsOptional); - - Assert.NotNull(entity.BodyParameterInfo); - Assert.Equal(typeof(TestActionParameter), entity.BodyParameterInfo.ParameterType); - - Assert.Null(entity.ParameterBindingInfo); + Assert.IsType(entity.BinderMetadata); + Assert.Equal(typeof(TestActionParameter), entity.ParameterType); } [Fact] @@ -279,11 +256,8 @@ namespace Microsoft.AspNet.Mvc.Test Assert.Equal("entity", entity.Name); Assert.False(entity.IsOptional); - Assert.Null(entity.BodyParameterInfo); - - Assert.NotNull(entity.ParameterBindingInfo); - Assert.Equal("entity", entity.ParameterBindingInfo.Prefix); - Assert.Equal(typeof(TestActionParameter), entity.ParameterBindingInfo.ParameterType); + Assert.Null(entity.BinderMetadata); + Assert.Equal(typeof(TestActionParameter), entity.ParameterType); } [Fact] diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionInvokerTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionInvokerTest.cs index a9a57548ce..ed5e65b0af 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionInvokerTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ControllerActionInvokerTest.cs @@ -1348,7 +1348,7 @@ namespace Microsoft.AspNet.Mvc return invoker; } - + [Fact] public async Task Invoke_UsesDefaultValuesIfNotBound() @@ -1360,13 +1360,13 @@ namespace Microsoft.AspNet.Mvc .DeclaredMethods .First(m => m.Name.Equals("ActionMethodWithDefaultValues", StringComparison.Ordinal)), Parameters = new List - { - new ParameterDescriptor - { - Name = "value", - ParameterBindingInfo = new ParameterBindingInfo("value", typeof(int)) - } - }, + { + new ParameterDescriptor + { + Name = "value", + ParameterType = typeof(int), + } + }, FilterDescriptors = new List() }; diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Description/DefaultApiDescriptionProviderTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Description/DefaultApiDescriptionProviderTest.cs index 514431a1e0..88fd3c30bd 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Description/DefaultApiDescriptionProviderTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Description/DefaultApiDescriptionProviderTest.cs @@ -122,12 +122,13 @@ namespace Microsoft.AspNet.Mvc.Description { Name = "id", IsOptional = true, - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)), + ParameterType = typeof(int), }, new ParameterDescriptor() { + BinderMetadata = new FromBodyAttribute(), Name = "username", - BodyParameterInfo = new BodyParameterInfo(typeof(string)), + ParameterType = typeof(string), } }; @@ -224,7 +225,7 @@ namespace Microsoft.AspNet.Mvc.Description { Name = "id", IsOptional = true, - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)) + ParameterType = typeof(int), }; action.Parameters = new List { parameterDescriptor }; @@ -277,9 +278,10 @@ namespace Microsoft.AspNet.Mvc.Description var parameterDescriptor = new ParameterDescriptor { + BinderMetadata = new FromBodyAttribute(), Name = "id", IsOptional = false, - BodyParameterInfo = new BodyParameterInfo(typeof(int)) + ParameterType = typeof(int), }; action.Parameters = new List { parameterDescriptor }; @@ -334,7 +336,7 @@ namespace Microsoft.AspNet.Mvc.Description { Name = "id", IsOptional = isDescriptorParameterOptional, - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)) + ParameterType = typeof(int), }; action.Parameters = new List { parameterDescriptor }; diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/InputObjectBindingTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/InputObjectBindingTests.cs index 62d1f6cad8..5f675d23fe 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/InputObjectBindingTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/InputObjectBindingTests.cs @@ -37,13 +37,14 @@ namespace Microsoft.AspNet.Mvc { MethodInfo = method.Method, Parameters = new List - { - new ParameterDescriptor - { - Name = "foo", - BodyParameterInfo = new BodyParameterInfo(parameterType) - } - } + { + new ParameterDescriptor + { + BinderMetadata = new FromBodyAttribute(), + Name = "foo", + ParameterType = parameterType, + } + } }; var metadataProvider = new EmptyModelMetadataProvider(); @@ -83,6 +84,7 @@ namespace Microsoft.AspNet.Mvc new RouteData(), actionDescriptor); } + private static HttpContext GetHttpContext(byte[] contentBytes, string contentType) { diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ParameterBinding/ControllerActionArgumentBinderTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ParameterBinding/ControllerActionArgumentBinderTests.cs index f317876c1e..d1c54a1a94 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ParameterBinding/ControllerActionArgumentBinderTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ParameterBinding/ControllerActionArgumentBinderTests.cs @@ -172,13 +172,13 @@ namespace Microsoft.AspNet.Mvc.Core.Test { MethodInfo = method.Method, Parameters = new List - { - new ParameterDescriptor - { - Name = "foo", - ParameterBindingInfo = new ParameterBindingInfo("foo", typeof(object)) - } - } + { + new ParameterDescriptor + { + Name = "foo", + ParameterType = typeof(object), + } + } }; var binder = new Mock(); binder.Setup(b => b.BindModelAsync(It.IsAny())) diff --git a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/OverloadActionConstraintTest.cs b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/OverloadActionConstraintTest.cs index 1725d77fd8..c76012ca7b 100644 --- a/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/OverloadActionConstraintTest.cs +++ b/test/Microsoft.AspNet.Mvc.WebApiCompatShimTest/OverloadActionConstraintTest.cs @@ -24,7 +24,7 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim { BinderMetadata = new FromUriAttribute(), Name = "id", - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)), + ParameterType = typeof(int), }, }; @@ -54,13 +54,13 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim { BinderMetadata = new FromUriAttribute(), Name = "id", - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)), + ParameterType = typeof(int), }, new ParameterDescriptor() { BinderMetadata = new FromUriAttribute(), Name = "quantity", - ParameterBindingInfo = new ParameterBindingInfo("quantity", typeof(int)), + ParameterType = typeof(int), }, }; @@ -90,13 +90,13 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim { BinderMetadata = new FromUriAttribute(), Name = "id", - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)), + ParameterType = typeof(int), }, new ParameterDescriptor() { BinderMetadata = new FromUriAttribute(), Name = "quantity", - ParameterBindingInfo = new ParameterBindingInfo("quantity", typeof(int)), + ParameterType = typeof(int), }, }; @@ -126,13 +126,13 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim { BinderMetadata = new FromUriAttribute(), Name = "id", - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)), + ParameterType = typeof(int), }, new ParameterDescriptor() { BinderMetadata = new FromUriAttribute(), Name = "quantity", - ParameterBindingInfo = new ParameterBindingInfo("quantity", typeof(int)), + ParameterType = typeof(int), }, }; @@ -162,14 +162,14 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim { BinderMetadata = new FromUriAttribute(), Name = "id", - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)), + ParameterType = typeof(int), }, new ParameterDescriptor() { BinderMetadata = new FromUriAttribute(), Name = "quantity", IsOptional = true, - ParameterBindingInfo = new ParameterBindingInfo("quantity", typeof(int)), + ParameterType = typeof(int), }, }; @@ -199,13 +199,13 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim { BinderMetadata = new FromUriAttribute(), Name = "id", - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)), + ParameterType = typeof(int), }, new ParameterDescriptor() { BinderMetadata = new FromUriAttribute(), Name = "quantity", - ParameterBindingInfo = new ParameterBindingInfo("quantity", typeof(int)), + ParameterType = typeof(int), }, }; @@ -216,13 +216,13 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim { BinderMetadata = new FromUriAttribute(), Name = "id", - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)), + ParameterType = typeof(int), }, new ParameterDescriptor() { BinderMetadata = new FromUriAttribute(), Name = "quantity_ordered", - ParameterBindingInfo = new ParameterBindingInfo("quantity_ordered", typeof(int)), + ParameterType = typeof(int), }, }; @@ -256,7 +256,7 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim { BinderMetadata = new FromUriAttribute(), Name = "id", - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)), + ParameterType = typeof(int), }, }; @@ -267,13 +267,13 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim { BinderMetadata = new FromUriAttribute(), Name = "id", - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)), + ParameterType = typeof(int), }, new ParameterDescriptor() { BinderMetadata = new FromUriAttribute(), Name = "quantity", - ParameterBindingInfo = new ParameterBindingInfo("quantity", typeof(int)), + ParameterType = typeof(int), }, }; @@ -304,14 +304,14 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim { BinderMetadata = new FromUriAttribute(), Name = "id", - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)), + ParameterType = typeof(int), }, new ParameterDescriptor() { BinderMetadata = new FromUriAttribute(), Name = "quantity", IsOptional = true, - ParameterBindingInfo = new ParameterBindingInfo("quantity", typeof(int)), + ParameterType = typeof(int), }, }; @@ -322,13 +322,13 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim { BinderMetadata = new FromUriAttribute(), Name = "id", - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)), + ParameterType = typeof(int), }, new ParameterDescriptor() { BinderMetadata = new FromUriAttribute(), Name = "quantity", - ParameterBindingInfo = new ParameterBindingInfo("quantity", typeof(int)), + ParameterType = typeof(int), }, }; @@ -359,13 +359,13 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim { BinderMetadata = new FromUriAttribute(), Name = "id", - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)), + ParameterType = typeof(int), }, new ParameterDescriptor() { BinderMetadata = new FromUriAttribute(), Name = "quantity", - ParameterBindingInfo = new ParameterBindingInfo("quantity", typeof(int)), + ParameterType = typeof(int), }, }; @@ -376,13 +376,13 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim { BinderMetadata = new FromUriAttribute(), Name = "id", - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)), + ParameterType = typeof(int), }, new ParameterDescriptor() { BinderMetadata = new FromUriAttribute(), Name = "price", - ParameterBindingInfo = new ParameterBindingInfo("price", typeof(decimal)), + ParameterType = typeof(decimal), }, }; @@ -416,7 +416,7 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim { BinderMetadata = new FromUriAttribute(), Name = "id", - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)), + ParameterType = typeof(int), }, }; @@ -427,14 +427,14 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim { BinderMetadata = new FromUriAttribute(), Name = "id", - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)), + ParameterType = typeof(int), }, new ParameterDescriptor() { BinderMetadata = new FromUriAttribute(), IsOptional = true, Name = "quantity", - ParameterBindingInfo = new ParameterBindingInfo("quantity", typeof(int)), + ParameterType = typeof(int), }, }; @@ -465,7 +465,7 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim { BinderMetadata = new FromUriAttribute(), Name = "id", - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)), + ParameterType = typeof(int), }, }; @@ -476,13 +476,13 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim { BinderMetadata = new FromUriAttribute(), Name = "id", - ParameterBindingInfo = new ParameterBindingInfo("id", typeof(int)), + ParameterType = typeof(int), }, new ParameterDescriptor() { BinderMetadata = new FromBodyAttribute(), Name = "quantity", - ParameterBindingInfo = new ParameterBindingInfo("quantity", typeof(int)), + ParameterType = typeof(int), }, }; diff --git a/test/WebSites/FormatterWebSite/ValidateBodyParameterAttribute.cs b/test/WebSites/FormatterWebSite/ValidateBodyParameterAttribute.cs index 9a65f4b95e..e8bbc43271 100644 --- a/test/WebSites/FormatterWebSite/ValidateBodyParameterAttribute.cs +++ b/test/WebSites/FormatterWebSite/ValidateBodyParameterAttribute.cs @@ -3,6 +3,7 @@ using System.Linq; using Microsoft.AspNet.Mvc; +using Microsoft.AspNet.Mvc.ModelBinding; namespace FormatterWebSite { @@ -14,7 +15,7 @@ namespace FormatterWebSite { var bodyParameter = context.ActionDescriptor .Parameters - .FirstOrDefault(parameter => parameter.BodyParameterInfo != null); + .FirstOrDefault(parameter => parameter.BinderMetadata is IFormatterBinderMetadata); if (bodyParameter != null) { var parameterBindingErrors = context.ModelState[bodyParameter.Name].Errors;