From eff10cdd66579f5d16c21fc432aed2f7094e2140 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Sat, 26 Sep 2015 17:11:29 -0700 Subject: [PATCH] Move `ModelStateDictionaryExtensions` into `Microsoft.AspNet.Mvc.ModelBinding` namespace - missed the inconsistency when reviewing - kept class in ViewFeatures assembly because it depends on `ExpressionHelper` nit: wrap some long lines --- .../ModelStateDictionaryExtensions.cs | 28 +++++++++++++------ .../ModelStateDictionaryExtensionsTest.cs | 3 +- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.AspNet.Mvc.ViewFeatures/ModelStateDictionaryExtensions.cs b/src/Microsoft.AspNet.Mvc.ViewFeatures/ModelStateDictionaryExtensions.cs index 1dfce56095..6cf6f24c1b 100644 --- a/src/Microsoft.AspNet.Mvc.ViewFeatures/ModelStateDictionaryExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.ViewFeatures/ModelStateDictionaryExtensions.cs @@ -4,10 +4,9 @@ using System; using System.Linq; using System.Linq.Expressions; -using Microsoft.AspNet.Mvc.ModelBinding; using Microsoft.AspNet.Mvc.ViewFeatures; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.ModelBinding { /// /// Extensions methods for . @@ -22,7 +21,10 @@ namespace Microsoft.AspNet.Mvc /// The instance this method extends. /// An expression to be evaluated against an item in the current model. /// The error message to add. - public static void AddModelError(this ModelStateDictionary modelState, Expression> expression, string errorMessage) + public static void AddModelError( + this ModelStateDictionary modelState, + Expression> expression, + string errorMessage) { modelState.AddModelError(GetExpressionText(expression), errorMessage); } @@ -35,7 +37,10 @@ namespace Microsoft.AspNet.Mvc /// The instance this method extends. /// An expression to be evaluated against an item in the current model. /// The to add. - public static void AddModelError(this ModelStateDictionary modelState, Expression> expression, Exception exception) + public static void AddModelError( + this ModelStateDictionary modelState, + Expression> expression, + Exception exception) { modelState.AddModelError(GetExpressionText(expression), exception); } @@ -50,18 +55,23 @@ namespace Microsoft.AspNet.Mvc /// true if the element is successfully removed; otherwise, false. /// This method also returns false if was not found in the model-state dictionary. /// - public static bool Remove(this ModelStateDictionary modelState, Expression> expression) + public static bool Remove( + this ModelStateDictionary modelState, + Expression> expression) { return modelState.Remove(GetExpressionText(expression)); } /// - /// Removes all the entries for the specified from the . + /// Removes all the entries for the specified from the + /// . /// /// The type of the model. /// The instance this method extends. /// An expression to be evaluated against an item in the current model. - public static void RemoveAll(this ModelStateDictionary modelState, Expression> expression) + public static void RemoveAll( + this ModelStateDictionary modelState, + Expression> expression) { string modelKey = GetExpressionText(expression); if (string.IsNullOrEmpty(modelKey)) @@ -98,7 +108,9 @@ namespace Microsoft.AspNet.Mvc if (IsConversionToObject(unaryExpression)) { - return ExpressionHelper.GetExpressionText(Expression.Lambda(unaryExpression.Operand, expression.Parameters[0])); + return ExpressionHelper.GetExpressionText(Expression.Lambda( + unaryExpression.Operand, + expression.Parameters[0])); } return ExpressionHelper.GetExpressionText(expression); diff --git a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ModelStateDictionaryExtensionsTest.cs b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ModelStateDictionaryExtensionsTest.cs index b1e49feeb0..cc1200e7a7 100644 --- a/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ModelStateDictionaryExtensionsTest.cs +++ b/test/Microsoft.AspNet.Mvc.ViewFeatures.Test/ModelStateDictionaryExtensionsTest.cs @@ -2,10 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.AspNet.Mvc.ModelBinding; using Xunit; -namespace Microsoft.AspNet.Mvc +namespace Microsoft.AspNet.Mvc.ModelBinding { public class ModelStateDictionaryExtensionsTest {