diff --git a/samples/MvcSample.Web/Views/Shared/EditorTemplates/Decimal.cshtml b/samples/MvcSample.Web/Views/Shared/EditorTemplates/Decimal.cshtml index ee875197ef..bd5dbd5b24 100644 --- a/samples/MvcSample.Web/Views/Shared/EditorTemplates/Decimal.cshtml +++ b/samples/MvcSample.Web/Views/Shared/EditorTemplates/Decimal.cshtml @@ -13,6 +13,6 @@ } @Html.TextBox( - name: null, + expression: null, value: FormattedValue, htmlAttributes: new { @class = "text-box single-line", style = "font-weight: bold", }) \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Expressions/CachedExpressionCompiler.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Expressions/CachedExpressionCompiler.cs index c78e75bf5c..9a5cbcdac6 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Expressions/CachedExpressionCompiler.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Expressions/CachedExpressionCompiler.cs @@ -15,54 +15,56 @@ namespace Microsoft.AspNet.Mvc.Rendering.Expressions // relying on cache lookups and other techniques to save time if appropriate. // If the provided expression is particularly obscure and the system doesn't know // how to handle it, we'll just compile the expression as normal. - public static Func Process( - [NotNull] Expression> lambdaExpression) + public static Func Process( + [NotNull] Expression> expression) { - return Compiler.Compile(lambdaExpression); + return Compiler.Compile(expression); } - private static class Compiler + private static class Compiler { - private static Func _identityFunc; + private static Func _identityFunc; - private static readonly ConcurrentDictionary> _simpleMemberAccessDict = - new ConcurrentDictionary>(); + private static readonly ConcurrentDictionary> _simpleMemberAccessDict = + new ConcurrentDictionary>(); - private static readonly ConcurrentDictionary> _constMemberAccessDict = - new ConcurrentDictionary>(); + private static readonly ConcurrentDictionary> _constMemberAccessDict = + new ConcurrentDictionary>(); - public static Func Compile([NotNull] Expression> expr) + public static Func Compile([NotNull] Expression> expression) { - return CompileFromIdentityFunc(expr) - ?? CompileFromConstLookup(expr) - ?? CompileFromMemberAccess(expr) - ?? CompileSlow(expr); + return CompileFromIdentityFunc(expression) + ?? CompileFromConstLookup(expression) + ?? CompileFromMemberAccess(expression) + ?? CompileSlow(expression); } - private static Func CompileFromConstLookup([NotNull] Expression> expr) + private static Func CompileFromConstLookup( + [NotNull] Expression> expression) { - var constExpr = expr.Body as ConstantExpression; - if (constExpr != null) + var constantExpression = expression.Body as ConstantExpression; + if (constantExpression != null) { // model => {const} - var constantValue = (TOut)constExpr.Value; + var constantValue = (TResult)constantExpression.Value; return _ => constantValue; } return null; } - private static Func CompileFromIdentityFunc([NotNull] Expression> expr) + private static Func CompileFromIdentityFunc( + [NotNull] Expression> expression) { - if (expr.Body == expr.Parameters[0]) + if (expression.Body == expression.Parameters[0]) { // model => model // Don't need to lock, as all identity funcs are identical. if (_identityFunc == null) { - _identityFunc = expr.Compile(); + _identityFunc = expression.Compile(); } return _identityFunc; @@ -71,7 +73,8 @@ namespace Microsoft.AspNet.Mvc.Rendering.Expressions return null; } - private static Func CompileFromMemberAccess([NotNull] Expression> expr) + private static Func CompileFromMemberAccess( + [NotNull] Expression> expression) { // Performance tests show that on the x64 platform, special-casing static member and // captured local variable accesses is faster than letting the fingerprinting system @@ -79,42 +82,43 @@ namespace Microsoft.AspNet.Mvc.Rendering.Expressions // by around one microsecond, so it's not worth it to complicate the logic here with // an architecture check. - var memberExpr = expr.Body as MemberExpression; - if (memberExpr != null) + var memberExpression = expression.Body as MemberExpression; + if (memberExpression != null) { - if (memberExpr.Expression == expr.Parameters[0] || memberExpr.Expression == null) + if (memberExpression.Expression == expression.Parameters[0] || memberExpression.Expression == null) { // model => model.Member or model => StaticMember - return _simpleMemberAccessDict.GetOrAdd(memberExpr.Member, _ => expr.Compile()); + return _simpleMemberAccessDict.GetOrAdd(memberExpression.Member, _ => expression.Compile()); } - var constExpr = memberExpr.Expression as ConstantExpression; - if (constExpr != null) + var constantExpression = memberExpression.Expression as ConstantExpression; + if (constantExpression != null) { // model => {const}.Member (captured local variable) - var del = _constMemberAccessDict.GetOrAdd(memberExpr.Member, _ => + var compiledExpression = _constMemberAccessDict.GetOrAdd(memberExpression.Member, _ => { // rewrite as capturedLocal => ((TDeclaringType)capturedLocal).Member - var constParamExpr = Expression.Parameter(typeof(object), "capturedLocal"); - var constCastExpr = Expression.Convert(constParamExpr, memberExpr.Member.DeclaringType); - var newMemberAccessExpr = memberExpr.Update(constCastExpr); - var newLambdaExpr = - Expression.Lambda>(newMemberAccessExpr, constParamExpr); - return newLambdaExpr.Compile(); + var parameterExpression = Expression.Parameter(typeof(object), "capturedLocal"); + var castExpression = + Expression.Convert(parameterExpression, memberExpression.Member.DeclaringType); + var newMemberExpression = memberExpression.Update(castExpression); + var newExpression = + Expression.Lambda>(newMemberExpression, parameterExpression); + return newExpression.Compile(); }); - var capturedLocal = constExpr.Value; - return _ => del(capturedLocal); + var capturedLocal = constantExpression.Value; + return _ => compiledExpression(capturedLocal); } } return null; } - private static Func CompileSlow([NotNull] Expression> expr) + private static Func CompileSlow([NotNull] Expression> expression) { // fallback compilation system - just compile the expression directly - return expr.Compile(); + return expression.Compile(); } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Expressions/ExpressionHelper.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Expressions/ExpressionHelper.cs index 54fa228845..84a3177522 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Expressions/ExpressionHelper.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Expressions/ExpressionHelper.cs @@ -16,10 +16,7 @@ namespace Microsoft.AspNet.Mvc.Rendering.Expressions public static string GetExpressionText(string expression) { // If it's exactly "model", then give them an empty string, to replicate the lambda behavior. - return - string.Equals(expression, "model", StringComparison.OrdinalIgnoreCase) - ? string.Empty - : expression; + return string.Equals(expression, "model", StringComparison.OrdinalIgnoreCase) ? string.Empty : expression; } public static string GetExpressionText([NotNull] LambdaExpression expression) @@ -91,7 +88,8 @@ namespace Microsoft.AspNet.Mvc.Rendering.Expressions return string.Empty; } - private static string GetIndexerInvocation([NotNull] Expression expression, + private static string GetIndexerInvocation( + [NotNull] Expression expression, [NotNull] ParameterExpression[] parameters) { var converted = Expression.Convert(expression, typeof(object)); diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Expressions/ExpressionMetadataProvider.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Expressions/ExpressionMetadataProvider.cs index afac7e94d6..69f6860d3f 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Expressions/ExpressionMetadataProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Expressions/ExpressionMetadataProvider.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.Linq; using System.Linq.Expressions; using System.Reflection; using Microsoft.AspNet.Mvc.Core; @@ -12,9 +11,9 @@ namespace Microsoft.AspNet.Mvc.Rendering.Expressions { public static class ExpressionMetadataProvider { - public static ModelMetadata FromLambdaExpression( - [NotNull] Expression> expression, - [NotNull] ViewDataDictionary viewData, + public static ModelMetadata FromLambdaExpression( + [NotNull] Expression> expression, + [NotNull] ViewDataDictionary viewData, IModelMetadataProvider metadataProvider) { string propertyName = null; @@ -70,7 +69,7 @@ namespace Microsoft.AspNet.Mvc.Rendering.Expressions return GetMetadataFromProvider( modelAccessor, - typeof(TValue), + typeof(TResult), propertyName, container, containerType, diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultDisplayTemplates.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultDisplayTemplates.cs index 03e2b32be6..a9b57a07ad 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultDisplayTemplates.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultDisplayTemplates.cs @@ -15,16 +15,16 @@ namespace Microsoft.AspNet.Mvc.Rendering { public static class DefaultDisplayTemplates { - public static string BooleanTemplate(IHtmlHelper html) + public static string BooleanTemplate(IHtmlHelper htmlHelper) { bool? value = null; - if (html.ViewData.Model != null) + if (htmlHelper.ViewData.Model != null) { - value = Convert.ToBoolean(html.ViewData.Model, CultureInfo.InvariantCulture); + value = Convert.ToBoolean(htmlHelper.ViewData.Model, CultureInfo.InvariantCulture); } - return html.ViewData.ModelMetadata.IsNullableValueType ? - BooleanTemplateDropDownList(html, value) : + return htmlHelper.ViewData.ModelMetadata.IsNullableValueType ? + BooleanTemplateDropDownList(htmlHelper, value) : BooleanTemplateCheckbox(value ?? false); } @@ -42,7 +42,7 @@ namespace Microsoft.AspNet.Mvc.Rendering return inputTag.ToString(TagRenderMode.SelfClosing); } - private static string BooleanTemplateDropDownList(IHtmlHelper html, bool? value) + private static string BooleanTemplateDropDownList(IHtmlHelper htmlHelper, bool? value) { var selectTag = new TagBuilder("select"); selectTag.AddCssClass("list-box"); @@ -54,7 +54,7 @@ namespace Microsoft.AspNet.Mvc.Rendering foreach (var item in TriStateValues(value)) { - var encodedText = html.Encode(item.Text); + var encodedText = htmlHelper.Encode(item.Text); var option = DefaultHtmlGenerator.GenerateOption(item, encodedText); builder.Append(option); } @@ -89,9 +89,9 @@ namespace Microsoft.AspNet.Mvc.Rendering }; } - public static string CollectionTemplate(IHtmlHelper html) + public static string CollectionTemplate(IHtmlHelper htmlHelper) { - var model = html.ViewData.ModelMetadata.Model; + var model = htmlHelper.ViewData.ModelMetadata.Model; if (model == null) { return string.Empty; @@ -114,16 +114,16 @@ namespace Microsoft.AspNet.Mvc.Rendering var typeInCollectionIsNullableValueType = typeInCollection.IsNullableValueType(); - var oldPrefix = html.ViewData.TemplateInfo.HtmlFieldPrefix; + var oldPrefix = htmlHelper.ViewData.TemplateInfo.HtmlFieldPrefix; try { - html.ViewData.TemplateInfo.HtmlFieldPrefix = string.Empty; + htmlHelper.ViewData.TemplateInfo.HtmlFieldPrefix = string.Empty; var fieldNameBase = oldPrefix; var result = new StringBuilder(); - var serviceProvider = html.ViewContext.HttpContext.RequestServices; + var serviceProvider = htmlHelper.ViewContext.HttpContext.RequestServices; var metadataProvider = serviceProvider.GetRequiredService(); var viewEngine = serviceProvider.GetRequiredService(); @@ -141,8 +141,8 @@ namespace Microsoft.AspNet.Mvc.Rendering var templateBuilder = new TemplateBuilder( viewEngine, - html.ViewContext, - html.ViewData, + htmlHelper.ViewContext, + htmlHelper.ViewData, metadata, htmlFieldName: fieldName, templateName: null, @@ -157,51 +157,51 @@ namespace Microsoft.AspNet.Mvc.Rendering } finally { - html.ViewData.TemplateInfo.HtmlFieldPrefix = oldPrefix; + htmlHelper.ViewData.TemplateInfo.HtmlFieldPrefix = oldPrefix; } } - public static string DecimalTemplate(IHtmlHelper html) + public static string DecimalTemplate(IHtmlHelper htmlHelper) { - if (html.ViewData.TemplateInfo.FormattedModelValue == html.ViewData.ModelMetadata.Model) + if (htmlHelper.ViewData.TemplateInfo.FormattedModelValue == htmlHelper.ViewData.ModelMetadata.Model) { - html.ViewData.TemplateInfo.FormattedModelValue = - string.Format(CultureInfo.CurrentCulture, "{0:0.00}", html.ViewData.ModelMetadata.Model); + htmlHelper.ViewData.TemplateInfo.FormattedModelValue = + string.Format(CultureInfo.CurrentCulture, "{0:0.00}", htmlHelper.ViewData.ModelMetadata.Model); } - return StringTemplate(html); + return StringTemplate(htmlHelper); } - public static string EmailAddressTemplate(IHtmlHelper html) + public static string EmailAddressTemplate(IHtmlHelper htmlHelper) { - var uriString = "mailto:" + ((html.ViewData.Model == null) ? + var uriString = "mailto:" + ((htmlHelper.ViewData.Model == null) ? string.Empty : - html.ViewData.Model.ToString()); - var linkedText = (html.ViewData.TemplateInfo.FormattedModelValue == null) ? + htmlHelper.ViewData.Model.ToString()); + var linkedText = (htmlHelper.ViewData.TemplateInfo.FormattedModelValue == null) ? string.Empty : - html.ViewData.TemplateInfo.FormattedModelValue.ToString(); + htmlHelper.ViewData.TemplateInfo.FormattedModelValue.ToString(); return HyperlinkTemplate(uriString, linkedText); } - public static string HiddenInputTemplate(IHtmlHelper html) + public static string HiddenInputTemplate(IHtmlHelper htmlHelper) { - if (html.ViewData.ModelMetadata.HideSurroundingHtml) + if (htmlHelper.ViewData.ModelMetadata.HideSurroundingHtml) { return string.Empty; } - return StringTemplate(html); + return StringTemplate(htmlHelper); } - public static string HtmlTemplate(IHtmlHelper html) + public static string HtmlTemplate(IHtmlHelper htmlHelper) { - return html.ViewData.TemplateInfo.FormattedModelValue.ToString(); + return htmlHelper.ViewData.TemplateInfo.FormattedModelValue.ToString(); } - public static string ObjectTemplate(IHtmlHelper html) + public static string ObjectTemplate(IHtmlHelper htmlHelper) { - var viewData = html.ViewData; + var viewData = htmlHelper.ViewData; var templateInfo = viewData.TemplateInfo; var modelMetadata = viewData.ModelMetadata; var builder = new StringBuilder(); @@ -216,13 +216,13 @@ namespace Microsoft.AspNet.Mvc.Rendering var text = modelMetadata.SimpleDisplayText; if (modelMetadata.HtmlEncode) { - text = html.Encode(text); + text = htmlHelper.Encode(text); } return text; } - var serviceProvider = html.ViewContext.HttpContext.RequestServices; + var serviceProvider = htmlHelper.ViewContext.HttpContext.RequestServices; var viewEngine = serviceProvider.GetRequiredService(); foreach (var propertyMetadata in modelMetadata.Properties.Where(pm => ShouldShow(pm, templateInfo))) @@ -248,8 +248,8 @@ namespace Microsoft.AspNet.Mvc.Rendering var templateBuilder = new TemplateBuilder( viewEngine, - html.ViewContext, - html.ViewData, + htmlHelper.ViewContext, + htmlHelper.ViewData, propertyMetadata, htmlFieldName: propertyMetadata.PropertyName, templateName: null, @@ -275,17 +275,17 @@ namespace Microsoft.AspNet.Mvc.Rendering !templateInfo.Visited(metadata); } - public static string StringTemplate(IHtmlHelper html) + public static string StringTemplate(IHtmlHelper htmlHelper) { - return html.Encode(html.ViewData.TemplateInfo.FormattedModelValue); + return htmlHelper.Encode(htmlHelper.ViewData.TemplateInfo.FormattedModelValue); } - public static string UrlTemplate(IHtmlHelper html) + public static string UrlTemplate(IHtmlHelper htmlHelper) { - var uriString = (html.ViewData.Model == null) ? string.Empty : html.ViewData.Model.ToString(); - var linkedText = (html.ViewData.TemplateInfo.FormattedModelValue == null) ? + var uriString = (htmlHelper.ViewData.Model == null) ? string.Empty : htmlHelper.ViewData.Model.ToString(); + var linkedText = (htmlHelper.ViewData.TemplateInfo.FormattedModelValue == null) ? string.Empty : - html.ViewData.TemplateInfo.FormattedModelValue.ToString(); + htmlHelper.ViewData.TemplateInfo.FormattedModelValue.ToString(); return HyperlinkTemplate(uriString, linkedText); } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultEditorTemplates.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultEditorTemplates.cs index 742414c807..793e02823e 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultEditorTemplates.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultEditorTemplates.cs @@ -17,41 +17,41 @@ namespace Microsoft.AspNet.Mvc.Rendering { private const string HtmlAttributeKey = "htmlAttributes"; - public static string BooleanTemplate(IHtmlHelper html) + public static string BooleanTemplate(IHtmlHelper htmlHelper) { bool? value = null; - if (html.ViewData.Model != null) + if (htmlHelper.ViewData.Model != null) { - value = Convert.ToBoolean(html.ViewData.Model, CultureInfo.InvariantCulture); + value = Convert.ToBoolean(htmlHelper.ViewData.Model, CultureInfo.InvariantCulture); } - return html.ViewData.ModelMetadata.IsNullableValueType ? - BooleanTemplateDropDownList(html, value) : - BooleanTemplateCheckbox(html, value ?? false); + return htmlHelper.ViewData.ModelMetadata.IsNullableValueType ? + BooleanTemplateDropDownList(htmlHelper, value) : + BooleanTemplateCheckbox(htmlHelper, value ?? false); } - private static string BooleanTemplateCheckbox(IHtmlHelper html, bool value) + private static string BooleanTemplateCheckbox(IHtmlHelper htmlHelper, bool value) { - return html.CheckBox( - name: null, + return htmlHelper.CheckBox( + expression: null, isChecked: value, - htmlAttributes: CreateHtmlAttributes(html, "check-box")) + htmlAttributes: CreateHtmlAttributes(htmlHelper, "check-box")) .ToString(); } - private static string BooleanTemplateDropDownList(IHtmlHelper html, bool? value) + private static string BooleanTemplateDropDownList(IHtmlHelper htmlHelper, bool? value) { - return html.DropDownList( - name: null, + return htmlHelper.DropDownList( + expression: null, selectList: DefaultDisplayTemplates.TriStateValues(value), optionLabel: null, - htmlAttributes: CreateHtmlAttributes(html, "list-box tri-state")) + htmlAttributes: CreateHtmlAttributes(htmlHelper, "list-box tri-state")) .ToString(); } - public static string CollectionTemplate(IHtmlHelper html) + public static string CollectionTemplate(IHtmlHelper htmlHelper) { - var viewData = html.ViewData; + var viewData = htmlHelper.ViewData; var model = viewData.ModelMetadata.Model; if (model == null) { @@ -83,7 +83,7 @@ namespace Microsoft.AspNet.Mvc.Rendering var fieldNameBase = oldPrefix; var result = new StringBuilder(); - var serviceProvider = html.ViewContext.HttpContext.RequestServices; + var serviceProvider = htmlHelper.ViewContext.HttpContext.RequestServices; var metadataProvider = serviceProvider.GetRequiredService(); var viewEngine = serviceProvider.GetRequiredService(); @@ -101,8 +101,8 @@ namespace Microsoft.AspNet.Mvc.Rendering var templateBuilder = new TemplateBuilder( viewEngine, - html.ViewContext, - html.ViewData, + htmlHelper.ViewContext, + htmlHelper.ViewData, metadata, htmlFieldName: fieldName, templateName: null, @@ -121,20 +121,20 @@ namespace Microsoft.AspNet.Mvc.Rendering } } - public static string DecimalTemplate(IHtmlHelper html) + public static string DecimalTemplate(IHtmlHelper htmlHelper) { - if (html.ViewData.TemplateInfo.FormattedModelValue == html.ViewData.ModelMetadata.Model) + if (htmlHelper.ViewData.TemplateInfo.FormattedModelValue == htmlHelper.ViewData.ModelMetadata.Model) { - html.ViewData.TemplateInfo.FormattedModelValue = - string.Format(CultureInfo.CurrentCulture, "{0:0.00}", html.ViewData.ModelMetadata.Model); + htmlHelper.ViewData.TemplateInfo.FormattedModelValue = + string.Format(CultureInfo.CurrentCulture, "{0:0.00}", htmlHelper.ViewData.ModelMetadata.Model); } - return StringTemplate(html); + return StringTemplate(htmlHelper); } - public static string HiddenInputTemplate(IHtmlHelper html) + public static string HiddenInputTemplate(IHtmlHelper htmlHelper) { - var viewData = html.ViewData; + var viewData = htmlHelper.ViewData; var model = viewData.Model; string result; @@ -144,7 +144,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } else { - result = DefaultDisplayTemplates.StringTemplate(html); + result = DefaultDisplayTemplates.StringTemplate(htmlHelper); } // Special-case opaque values and arbitrary binary data. @@ -155,18 +155,18 @@ namespace Microsoft.AspNet.Mvc.Rendering } var htmlAttributesObject = viewData[HtmlAttributeKey]; - var hiddenResult = html.Hidden(name: null, value: model, htmlAttributes: htmlAttributesObject); + var hiddenResult = htmlHelper.Hidden(expression: null, value: model, htmlAttributes: htmlAttributesObject); result += hiddenResult.ToString(); return result; } private static IDictionary CreateHtmlAttributes( - IHtmlHelper html, + IHtmlHelper htmlHelper, string className, string inputType = null) { - var htmlAttributesObject = html.ViewData[HtmlAttributeKey]; + var htmlAttributesObject = htmlHelper.ViewData[HtmlAttributeKey]; if (htmlAttributesObject != null) { return MergeHtmlAttributes(htmlAttributesObject, className, inputType); @@ -212,20 +212,20 @@ namespace Microsoft.AspNet.Mvc.Rendering return htmlAttributes; } - public static string MultilineTemplate(IHtmlHelper html) + public static string MultilineTemplate(IHtmlHelper htmlHelper) { - var htmlString = html.TextArea( - name: string.Empty, - value: html.ViewContext.ViewData.TemplateInfo.FormattedModelValue.ToString(), + var htmlString = htmlHelper.TextArea( + expression: string.Empty, + value: htmlHelper.ViewContext.ViewData.TemplateInfo.FormattedModelValue.ToString(), rows: 0, columns: 0, - htmlAttributes: CreateHtmlAttributes(html, "text-box multi-line")); + htmlAttributes: CreateHtmlAttributes(htmlHelper, "text-box multi-line")); return htmlString.ToString(); } - public static string ObjectTemplate(IHtmlHelper html) + public static string ObjectTemplate(IHtmlHelper htmlHelper) { - var viewData = html.ViewData; + var viewData = htmlHelper.ViewData; var templateInfo = viewData.TemplateInfo; var modelMetadata = viewData.ModelMetadata; var builder = new StringBuilder(); @@ -240,13 +240,13 @@ namespace Microsoft.AspNet.Mvc.Rendering var text = modelMetadata.SimpleDisplayText; if (modelMetadata.HtmlEncode) { - text = html.Encode(text); + text = htmlHelper.Encode(text); } return text; } - var serviceProvider = html.ViewContext.HttpContext.RequestServices; + var serviceProvider = htmlHelper.ViewContext.HttpContext.RequestServices; var viewEngine = serviceProvider.GetRequiredService(); foreach (var propertyMetadata in modelMetadata.Properties.Where(pm => ShouldShow(pm, templateInfo))) @@ -255,7 +255,7 @@ namespace Microsoft.AspNet.Mvc.Rendering if (!propertyMetadata.HideSurroundingHtml) { - var label = html.Label( + var label = htmlHelper.Label( propertyMetadata.PropertyName, labelText: null, htmlAttributes: null) @@ -276,8 +276,8 @@ namespace Microsoft.AspNet.Mvc.Rendering var templateBuilder = new TemplateBuilder( viewEngine, - html.ViewContext, - html.ViewData, + htmlHelper.ViewContext, + htmlHelper.ViewData, propertyMetadata, htmlFieldName: propertyMetadata.PropertyName, templateName: null, @@ -289,7 +289,7 @@ namespace Microsoft.AspNet.Mvc.Rendering if (!propertyMetadata.HideSurroundingHtml) { builder.Append(" "); - builder.Append(html.ValidationMessage( + builder.Append(htmlHelper.ValidationMessage( propertyMetadata.PropertyName, message: null, htmlAttributes: null, @@ -302,12 +302,12 @@ namespace Microsoft.AspNet.Mvc.Rendering return builder.ToString(); } - public static string PasswordTemplate(IHtmlHelper html) + public static string PasswordTemplate(IHtmlHelper htmlHelper) { - return html.Password( - name: null, - value: html.ViewData.TemplateInfo.FormattedModelValue, - htmlAttributes: CreateHtmlAttributes(html, "text-box single-line password")) + return htmlHelper.Password( + expression: null, + value: htmlHelper.ViewData.TemplateInfo.FormattedModelValue, + htmlAttributes: CreateHtmlAttributes(htmlHelper, "text-box single-line password")) .ToString(); } @@ -319,88 +319,91 @@ namespace Microsoft.AspNet.Mvc.Rendering && !templateInfo.Visited(metadata); } - public static string StringTemplate(IHtmlHelper html) + public static string StringTemplate(IHtmlHelper htmlHelper) { - return GenerateTextBox(html); + return GenerateTextBox(htmlHelper); } - public static string PhoneNumberInputTemplate(IHtmlHelper html) + public static string PhoneNumberInputTemplate(IHtmlHelper htmlHelper) { - return GenerateTextBox(html, inputType: "tel"); + return GenerateTextBox(htmlHelper, inputType: "tel"); } - public static string UrlInputTemplate(IHtmlHelper html) + public static string UrlInputTemplate(IHtmlHelper htmlHelper) { - return GenerateTextBox(html, inputType: "url"); + return GenerateTextBox(htmlHelper, inputType: "url"); } - public static string EmailAddressInputTemplate(IHtmlHelper html) + public static string EmailAddressInputTemplate(IHtmlHelper htmlHelper) { - return GenerateTextBox(html, inputType: "email"); + return GenerateTextBox(htmlHelper, inputType: "email"); } - public static string DateTimeInputTemplate(IHtmlHelper html) + public static string DateTimeInputTemplate(IHtmlHelper htmlHelper) { - ApplyRfc3339DateFormattingIfNeeded(html, "{0:yyyy-MM-ddTHH:mm:ss.fffK}"); - return GenerateTextBox(html, inputType: "datetime"); + ApplyRfc3339DateFormattingIfNeeded(htmlHelper, "{0:yyyy-MM-ddTHH:mm:ss.fffK}"); + return GenerateTextBox(htmlHelper, inputType: "datetime"); } - public static string DateTimeLocalInputTemplate(IHtmlHelper html) + public static string DateTimeLocalInputTemplate(IHtmlHelper htmlHelper) { - ApplyRfc3339DateFormattingIfNeeded(html, "{0:yyyy-MM-ddTHH:mm:ss.fff}"); - return GenerateTextBox(html, inputType: "datetime-local"); + ApplyRfc3339DateFormattingIfNeeded(htmlHelper, "{0:yyyy-MM-ddTHH:mm:ss.fff}"); + return GenerateTextBox(htmlHelper, inputType: "datetime-local"); } - public static string DateInputTemplate(IHtmlHelper html) + public static string DateInputTemplate(IHtmlHelper htmlHelper) { - ApplyRfc3339DateFormattingIfNeeded(html, "{0:yyyy-MM-dd}"); - return GenerateTextBox(html, inputType: "date"); + ApplyRfc3339DateFormattingIfNeeded(htmlHelper, "{0:yyyy-MM-dd}"); + return GenerateTextBox(htmlHelper, inputType: "date"); } - public static string TimeInputTemplate(IHtmlHelper html) + public static string TimeInputTemplate(IHtmlHelper htmlHelper) { - ApplyRfc3339DateFormattingIfNeeded(html, "{0:HH:mm:ss.fff}"); - return GenerateTextBox(html, inputType: "time"); + ApplyRfc3339DateFormattingIfNeeded(htmlHelper, "{0:HH:mm:ss.fff}"); + return GenerateTextBox(htmlHelper, inputType: "time"); } - public static string NumberInputTemplate(IHtmlHelper html) + public static string NumberInputTemplate(IHtmlHelper htmlHelper) { - return GenerateTextBox(html, inputType: "number"); + return GenerateTextBox(htmlHelper, inputType: "number"); } - private static void ApplyRfc3339DateFormattingIfNeeded(IHtmlHelper html, string format) + private static void ApplyRfc3339DateFormattingIfNeeded(IHtmlHelper htmlHelper, string format) { - if (html.Html5DateRenderingMode != Html5DateRenderingMode.Rfc3339) + if (htmlHelper.Html5DateRenderingMode != Html5DateRenderingMode.Rfc3339) { return; } - var metadata = html.ViewData.ModelMetadata; + var metadata = htmlHelper.ViewData.ModelMetadata; var value = metadata.Model; - if (html.ViewData.TemplateInfo.FormattedModelValue != value && metadata.HasNonDefaultEditFormat) + if (htmlHelper.ViewData.TemplateInfo.FormattedModelValue != value && metadata.HasNonDefaultEditFormat) { return; } if (value is DateTime || value is DateTimeOffset) { - html.ViewData.TemplateInfo.FormattedModelValue = + htmlHelper.ViewData.TemplateInfo.FormattedModelValue = string.Format(CultureInfo.InvariantCulture, format, value); } } - private static string GenerateTextBox(IHtmlHelper html, string inputType = null) + private static string GenerateTextBox(IHtmlHelper htmlHelper, string inputType = null) { - return GenerateTextBox(html, inputType, html.ViewData.TemplateInfo.FormattedModelValue); + return GenerateTextBox(htmlHelper, inputType, htmlHelper.ViewData.TemplateInfo.FormattedModelValue); } - private static string GenerateTextBox(IHtmlHelper html, string inputType, object value) + private static string GenerateTextBox(IHtmlHelper htmlHelper, string inputType, object value) { - return html.TextBox( - name: null, + var htmlAttributes = + CreateHtmlAttributes(htmlHelper, className: "text-box single-line", inputType: inputType); + + return htmlHelper.TextBox( + current: null, value: value, format: null, - htmlAttributes: CreateHtmlAttributes(html, className: "text-box single-line", inputType: inputType)) + htmlAttributes: htmlAttributes) .ToString(); } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultHtmlGenerator.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultHtmlGenerator.cs index c77196895d..aafc08dc82 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultHtmlGenerator.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultHtmlGenerator.cs @@ -90,7 +90,7 @@ namespace Microsoft.AspNet.Mvc.Rendering public virtual TagBuilder GenerateCheckBox( [NotNull] ViewContext viewContext, ModelMetadata metadata, - string name, + string expression, bool? isChecked, object htmlAttributes) { @@ -121,7 +121,7 @@ namespace Microsoft.AspNet.Mvc.Rendering viewContext, InputType.CheckBox, metadata, - name, + expression, value: "true", useViewData: (metadata == null && !isChecked.HasValue), isChecked: isChecked ?? false, @@ -135,13 +135,13 @@ namespace Microsoft.AspNet.Mvc.Rendering public virtual TagBuilder GenerateHiddenForCheckbox( [NotNull] ViewContext viewContext, ModelMetadata metadata, - string name) + string expression) { var tagBuilder = new TagBuilder("input"); tagBuilder.MergeAttribute("type", GetInputTypeString(InputType.Hidden)); tagBuilder.MergeAttribute("value", "false"); - var fullName = GetFullHtmlFieldName(viewContext, name); + var fullName = GetFullHtmlFieldName(viewContext, expression); tagBuilder.MergeAttribute("name", fullName); return tagBuilder; @@ -202,7 +202,7 @@ namespace Microsoft.AspNet.Mvc.Rendering public virtual TagBuilder GenerateHidden( [NotNull] ViewContext viewContext, ModelMetadata metadata, - string name, + string expression, object value, bool useViewData, object htmlAttributes) @@ -219,7 +219,7 @@ namespace Microsoft.AspNet.Mvc.Rendering viewContext, InputType.Hidden, metadata, - name, + expression, value, useViewData, isChecked: false, @@ -233,7 +233,7 @@ namespace Microsoft.AspNet.Mvc.Rendering public virtual TagBuilder GenerateLabel( [NotNull] ViewContext viewContext, [NotNull] ModelMetadata metadata, - string name, + string expression, string labelText, object htmlAttributes) { @@ -241,7 +241,7 @@ namespace Microsoft.AspNet.Mvc.Rendering if (resolvedLabelText == null) { resolvedLabelText = - string.IsNullOrEmpty(name) ? string.Empty : name.Split('.').Last(); + string.IsNullOrEmpty(expression) ? string.Empty : expression.Split('.').Last(); } if (string.IsNullOrEmpty(resolvedLabelText)) @@ -251,7 +251,7 @@ namespace Microsoft.AspNet.Mvc.Rendering var tagBuilder = new TagBuilder("label"); var idString = - TagBuilder.CreateSanitizedId(GetFullHtmlFieldName(viewContext, name), IdAttributeDotReplacement); + TagBuilder.CreateSanitizedId(GetFullHtmlFieldName(viewContext, expression), IdAttributeDotReplacement); tagBuilder.Attributes.Add("for", idString); tagBuilder.SetInnerText(resolvedLabelText); tagBuilder.MergeAttributes(GetHtmlAttributeDictionaryOrNull(htmlAttributes), replaceExisting: true); @@ -263,7 +263,7 @@ namespace Microsoft.AspNet.Mvc.Rendering public virtual TagBuilder GeneratePassword( [NotNull] ViewContext viewContext, ModelMetadata metadata, - string name, + string expression, object value, object htmlAttributes) { @@ -272,7 +272,7 @@ namespace Microsoft.AspNet.Mvc.Rendering viewContext, InputType.Password, metadata, - name, + expression, value, useViewData: false, isChecked: false, @@ -286,7 +286,7 @@ namespace Microsoft.AspNet.Mvc.Rendering public virtual TagBuilder GenerateRadioButton( [NotNull] ViewContext viewContext, ModelMetadata metadata, - string name, + string expression, object value, bool? isChecked, object htmlAttributes) @@ -301,13 +301,16 @@ namespace Microsoft.AspNet.Mvc.Rendering // Note value may be null if isChecked is non-null. if (value == null) { - throw new ArgumentNullException("value"); + throw new ArgumentNullException(nameof(value)); } // isChecked not provided nor found in the given attributes; fall back to view data. var valueString = Convert.ToString(value, CultureInfo.CurrentCulture); - isChecked = !string.IsNullOrEmpty(name) && - string.Equals(EvalString(viewContext, name), valueString, StringComparison.OrdinalIgnoreCase); + isChecked = !string.IsNullOrEmpty(expression) && + string.Equals( + EvalString(viewContext, expression), + valueString, + StringComparison.OrdinalIgnoreCase); } } else @@ -334,7 +337,7 @@ namespace Microsoft.AspNet.Mvc.Rendering viewContext, InputType.Radio, metadata, - name, + expression, value, useViewData: false, isChecked: isChecked ?? false, @@ -363,7 +366,7 @@ namespace Microsoft.AspNet.Mvc.Rendering [NotNull] ViewContext viewContext, ModelMetadata metadata, string optionLabel, - string name, + string expression, IEnumerable selectList, bool allowMultiple, object htmlAttributes) @@ -373,7 +376,7 @@ namespace Microsoft.AspNet.Mvc.Rendering viewContext, metadata, optionLabel, - name, + expression, selectList, allowMultiple, htmlAttributes, @@ -385,31 +388,31 @@ namespace Microsoft.AspNet.Mvc.Rendering [NotNull] ViewContext viewContext, ModelMetadata metadata, string optionLabel, - string name, + string expression, IEnumerable selectList, bool allowMultiple, object htmlAttributes, out ICollection selectedValues) { - var fullName = GetFullHtmlFieldName(viewContext, name); + var fullName = GetFullHtmlFieldName(viewContext, expression); if (string.IsNullOrEmpty(fullName)) { - throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "name"); + throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(expression)); } // If we got a null selectList, try to use ViewData to get the list of items. var usedViewData = false; if (selectList == null) { - if (string.IsNullOrEmpty(name)) + if (string.IsNullOrEmpty(expression)) { // Avoid ViewData.Eval() throwing an ArgumentException with a different parameter name. Note this // is an extreme case since users must pass a non-null selectList to use CheckBox() or ListBox() // in a template, where a null or empty name has meaning. - throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "name"); + throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(expression)); } - selectList = GetSelectListItems(viewContext, name); + selectList = GetSelectListItems(viewContext, expression); usedViewData = true; } @@ -418,11 +421,11 @@ namespace Microsoft.AspNet.Mvc.Rendering // If we haven't already used ViewData to get the entire list of items then we need to // use the ViewData-supplied value before using the parameter-supplied value. - if (defaultValue == null && !string.IsNullOrEmpty(name)) + if (defaultValue == null && !string.IsNullOrEmpty(expression)) { if (!usedViewData) { - defaultValue = viewContext.ViewData.Eval(name); + defaultValue = viewContext.ViewData.Eval(expression); } else if (metadata != null) { @@ -465,7 +468,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } } - tagBuilder.MergeAttributes(GetValidationAttributes(viewContext, metadata, name)); + tagBuilder.MergeAttributes(GetValidationAttributes(viewContext, metadata, expression)); return tagBuilder; } @@ -474,25 +477,27 @@ namespace Microsoft.AspNet.Mvc.Rendering public virtual TagBuilder GenerateTextArea( [NotNull] ViewContext viewContext, ModelMetadata metadata, - string name, + string expression, int rows, int columns, object htmlAttributes) { if (rows < 0) { - throw new ArgumentOutOfRangeException("rows", Resources.HtmlHelper_TextAreaParameterOutOfRange); + throw new ArgumentOutOfRangeException(nameof(rows), Resources.HtmlHelper_TextAreaParameterOutOfRange); } if (columns < 0) { - throw new ArgumentOutOfRangeException("columns", Resources.HtmlHelper_TextAreaParameterOutOfRange); + throw new ArgumentOutOfRangeException( + nameof(columns), + Resources.HtmlHelper_TextAreaParameterOutOfRange); } - var fullName = GetFullHtmlFieldName(viewContext, name); + var fullName = GetFullHtmlFieldName(viewContext, expression); if (string.IsNullOrEmpty(fullName)) { - throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "name"); + throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(expression)); } ModelState modelState; @@ -522,7 +527,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } tagBuilder.MergeAttribute("name", fullName, true); - tagBuilder.MergeAttributes(GetValidationAttributes(viewContext, metadata, name)); + tagBuilder.MergeAttributes(GetValidationAttributes(viewContext, metadata, expression)); // If there are any errors for a named field, we add this CSS attribute. if (modelState != null && modelState.Errors.Count > 0) @@ -541,7 +546,7 @@ namespace Microsoft.AspNet.Mvc.Rendering public virtual TagBuilder GenerateTextBox( [NotNull] ViewContext viewContext, ModelMetadata metadata, - string name, + string expression, object value, string format, object htmlAttributes) @@ -551,7 +556,7 @@ namespace Microsoft.AspNet.Mvc.Rendering viewContext, InputType.Text, metadata, - name, + expression, value, useViewData: (metadata == null && value == null), isChecked: false, @@ -564,15 +569,15 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public virtual TagBuilder GenerateValidationMessage( [NotNull] ViewContext viewContext, - string name, + string expression, string message, string tag, object htmlAttributes) { - var fullName = GetFullHtmlFieldName(viewContext, name); + var fullName = GetFullHtmlFieldName(viewContext, expression); if (string.IsNullOrEmpty(fullName)) { - throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "expression"); + throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(expression)); } var formContext = viewContext.ClientValidationEnabled ? viewContext.FormContext : null; @@ -721,11 +726,11 @@ namespace Microsoft.AspNet.Mvc.Rendering public IEnumerable GetClientValidationRules( [NotNull] ViewContext viewContext, ModelMetadata metadata, - string name) + string expression) { var validatorProvider = _bindingContextAccessor.Value.ValidatorProvider; metadata = metadata ?? - ExpressionMetadataProvider.FromStringExpression(name, viewContext.ViewData, _metadataProvider); + ExpressionMetadataProvider.FromStringExpression(expression, viewContext.ViewData, _metadataProvider); var validationContext = new ClientModelValidationContext(metadata, _metadataProvider, viewContext.HttpContext.RequestServices); @@ -768,9 +773,9 @@ namespace Microsoft.AspNet.Mvc.Rendering return tagBuilder; } - internal static string GetFullHtmlFieldName(ViewContext viewContext, string name) + internal static string GetFullHtmlFieldName(ViewContext viewContext, string expression) { - var fullName = viewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(name); + var fullName = viewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(expression); return fullName; } @@ -827,7 +832,7 @@ namespace Microsoft.AspNet.Mvc.Rendering [NotNull] ViewContext viewContext, InputType inputType, ModelMetadata metadata, - string name, + string expression, object value, bool useViewData, bool isChecked, @@ -839,10 +844,10 @@ namespace Microsoft.AspNet.Mvc.Rendering // Not valid to use TextBoxForModel() and so on in a top-level view; would end up with an unnamed input // elements. But we support the *ForModel() methods in any lower-level template, once HtmlFieldPrefix is // non-empty. - var fullName = GetFullHtmlFieldName(viewContext, name); + var fullName = GetFullHtmlFieldName(viewContext, expression); if (string.IsNullOrEmpty(fullName)) { - throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, "name"); + throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(expression)); } var tagBuilder = new TagBuilder("input"); @@ -920,7 +925,7 @@ namespace Microsoft.AspNet.Mvc.Rendering tagBuilder.AddCssClass(HtmlHelper.ValidationInputCssClassName); } - tagBuilder.MergeAttributes(GetValidationAttributes(viewContext, metadata, name)); + tagBuilder.MergeAttributes(GetValidationAttributes(viewContext, metadata, expression)); return tagBuilder; } @@ -946,7 +951,7 @@ namespace Microsoft.AspNet.Mvc.Rendering protected virtual IDictionary GetValidationAttributes( ViewContext viewContext, ModelMetadata metadata, - string name) + string expression) { var formContext = viewContext.ClientValidationEnabled ? viewContext.FormContext : null; if (formContext == null) @@ -954,14 +959,14 @@ namespace Microsoft.AspNet.Mvc.Rendering return null; } - var fullName = GetFullHtmlFieldName(viewContext, name); + var fullName = GetFullHtmlFieldName(viewContext, expression); if (formContext.RenderedField(fullName)) { return null; } formContext.RenderedField(fullName, true); - var clientRules = GetClientValidationRules(viewContext, metadata, name); + var clientRules = GetClientValidationRules(viewContext, metadata, expression); return UnobtrusiveValidationAttributesGenerator.GetValidationAttributes(clientRules); } @@ -1011,20 +1016,22 @@ namespace Microsoft.AspNet.Mvc.Rendering } } - private static IEnumerable GetSelectListItems([NotNull] ViewContext viewContext, string name) + private static IEnumerable GetSelectListItems( + [NotNull] ViewContext viewContext, + string expression) { - var value = viewContext.ViewData.Eval(name); + var value = viewContext.ViewData.Eval(expression); if (value == null) { throw new InvalidOperationException(Resources.FormatHtmlHelper_MissingSelectData( - "IEnumerable", name)); + "IEnumerable", expression)); } var selectList = value as IEnumerable; if (selectList == null) { throw new InvalidOperationException(Resources.FormatHtmlHelper_WrongSelectDataType( - name, value.GetType().FullName, "IEnumerable")); + expression, value.GetType().FullName, "IEnumerable")); } return selectList; diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs index f305184861..cbda069aa7 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs @@ -113,18 +113,18 @@ namespace Microsoft.AspNet.Mvc.Rendering /// value to the dictionary. It will expose public properties from derived types as well. This is typically /// used with objects of an anonymous type. /// - /// If the object is already an instance, then it is - /// returned as-is. + /// If the is already an instance, then it + /// is returned as-is. /// /// new { data_name="value" } will translate to the entry { "data_name", "value" } /// in the resulting dictionary. /// /// - /// The object to be converted. + /// The to be converted. /// The created dictionary of property names and property values. - public static IDictionary ObjectToDictionary(object obj) + public static IDictionary ObjectToDictionary(object value) { - return TypeHelper.ObjectToDictionary(obj); + return TypeHelper.ObjectToDictionary(value); } /// @@ -231,9 +231,13 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public HtmlString CheckBox(string name, bool? isChecked, object htmlAttributes) + public HtmlString CheckBox(string expression, bool? isChecked, object htmlAttributes) { - return GenerateCheckBox(metadata: null, name: name, isChecked: isChecked, htmlAttributes: htmlAttributes); + return GenerateCheckBox( + metadata: null, + expression: expression, + isChecked: isChecked, + htmlAttributes: htmlAttributes); } /// @@ -255,9 +259,9 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public string GenerateIdFromName([NotNull] string name) + public string GenerateIdFromName([NotNull] string fullName) { - return TagBuilder.CreateSanitizedId(name, IdAttributeDotReplacement); + return TagBuilder.CreateSanitizedId(fullName, IdAttributeDotReplacement); } /// @@ -282,26 +286,32 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public string DisplayText(string name) + public string DisplayText(string expression) { - var metadata = ExpressionMetadataProvider.FromStringExpression(name, ViewData, MetadataProvider); + var metadata = ExpressionMetadataProvider.FromStringExpression(expression, ViewData, MetadataProvider); return GenerateDisplayText(metadata); } /// - public HtmlString DropDownList(string name, IEnumerable selectList, string optionLabel, + public HtmlString DropDownList( + string expression, + IEnumerable selectList, + string optionLabel, object htmlAttributes) { return GenerateDropDown( metadata: null, - expression: name, + expression: expression, selectList: selectList, optionLabel: optionLabel, htmlAttributes: htmlAttributes); } /// - public HtmlString Editor(string expression, string templateName, string htmlFieldName, + public HtmlString Editor( + string expression, + string templateName, + string htmlFieldName, object additionalViewData) { var metadata = ExpressionMetadataProvider.FromStringExpression(expression, ViewData, MetadataProvider); @@ -314,16 +324,20 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public HtmlString Hidden(string name, object value, object htmlAttributes) + public HtmlString Hidden(string expression, object value, object htmlAttributes) { - return GenerateHidden(metadata: null, name: name, value: value, useViewData: (value == null), + return GenerateHidden( + metadata: null, + expression: expression, + value: value, + useViewData: (value == null), htmlAttributes: htmlAttributes); } /// - public string Id(string name) + public string Id(string expression) { - return GenerateId(name); + return GenerateId(expression); } /// @@ -331,27 +345,33 @@ namespace Microsoft.AspNet.Mvc.Rendering { var metadata = ExpressionMetadataProvider.FromStringExpression(expression, ViewData, MetadataProvider); return GenerateLabel( - metadata, - expression, - labelText, - htmlAttributes); + metadata, + expression, + labelText, + htmlAttributes); } /// - public HtmlString ListBox(string name, IEnumerable selectList, object htmlAttributes) + public HtmlString ListBox(string expression, IEnumerable selectList, object htmlAttributes) { - return GenerateListBox(metadata: null, name: name, selectList: selectList, htmlAttributes: htmlAttributes); + return GenerateListBox( + metadata: null, + expression: expression, + selectList: selectList, + htmlAttributes: htmlAttributes); } /// - public string Name(string name) + public string Name(string expression) { - return GenerateName(name); + return GenerateName(expression); } /// - public async Task PartialAsync([NotNull] string partialViewName, object model, - ViewDataDictionary viewData) + public async Task PartialAsync( + [NotNull] string partialViewName, + object model, + ViewDataDictionary viewData) { using (var writer = new StringCollectionTextWriter(Encoding.UTF8)) { @@ -419,15 +439,23 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public HtmlString Password(string name, object value, object htmlAttributes) + public HtmlString Password(string expression, object value, object htmlAttributes) { - return GeneratePassword(metadata: null, name: name, value: value, htmlAttributes: htmlAttributes); + return GeneratePassword( + metadata: null, + expression: expression, + value: value, + htmlAttributes: htmlAttributes); } /// - public HtmlString RadioButton(string name, object value, bool? isChecked, object htmlAttributes) + public HtmlString RadioButton(string expression, object value, bool? isChecked, object htmlAttributes) { - return GenerateRadioButton(metadata: null, name: name, value: value, isChecked: isChecked, + return GenerateRadioButton( + metadata: null, + expression: expression, + value: value, + isChecked: isChecked, htmlAttributes: htmlAttributes); } @@ -504,28 +532,28 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public HtmlString TextArea(string name, string value, int rows, int columns, object htmlAttributes) + public HtmlString TextArea(string expression, string value, int rows, int columns, object htmlAttributes) { - var metadata = ExpressionMetadataProvider.FromStringExpression(name, ViewData, MetadataProvider); + var metadata = ExpressionMetadataProvider.FromStringExpression(expression, ViewData, MetadataProvider); if (value != null) { metadata.Model = value; } - return GenerateTextArea(metadata, name, rows, columns, htmlAttributes); + return GenerateTextArea(metadata, expression, rows, columns, htmlAttributes); } /// - public HtmlString TextBox(string name, object value, string format, object htmlAttributes) + public HtmlString TextBox(string expression, object value, string format, object htmlAttributes) { - return GenerateTextBox(metadata: null, name: name, value: value, format: format, + return GenerateTextBox(metadata: null, expression: expression, value: value, format: format, htmlAttributes: htmlAttributes); } /// - public string Value(string name, string format) + public string Value(string expression, string format) { - return GenerateValue(name, value: null, format: format, useViewData: true); + return GenerateValue(expression, value: null, format: format, useViewData: true); } /// @@ -538,16 +566,19 @@ namespace Microsoft.AspNet.Mvc.Rendering return new MvcForm(ViewContext); } - protected virtual HtmlString GenerateCheckBox(ModelMetadata metadata, string name, bool? isChecked, + protected virtual HtmlString GenerateCheckBox( + ModelMetadata metadata, + string expression, + bool? isChecked, object htmlAttributes) { var checkbox = _htmlGenerator.GenerateCheckBox( ViewContext, metadata, - name, + expression, isChecked, htmlAttributes); - var hidden = _htmlGenerator.GenerateHiddenForCheckbox(ViewContext, metadata, name); + var hidden = _htmlGenerator.GenerateHiddenForCheckbox(ViewContext, metadata, expression); if (checkbox == null || hidden == null) { return HtmlString.Empty; @@ -558,7 +589,7 @@ namespace Microsoft.AspNet.Mvc.Rendering return new HtmlString(elements); } - protected virtual string GenerateDisplayName([NotNull] ModelMetadata metadata, string htmlFieldName) + protected virtual string GenerateDisplayName([NotNull] ModelMetadata metadata, string expression) { // We don't call ModelMetadata.GetDisplayName here because // we want to fall back to the field name rather than the ModelType. @@ -567,7 +598,7 @@ namespace Microsoft.AspNet.Mvc.Rendering if (resolvedDisplayName == null) { resolvedDisplayName = - string.IsNullOrEmpty(htmlFieldName) ? string.Empty : htmlFieldName.Split('.').Last(); + string.IsNullOrEmpty(expression) ? string.Empty : expression.Split('.').Last(); } return resolvedDisplayName; @@ -578,14 +609,18 @@ namespace Microsoft.AspNet.Mvc.Rendering return metadata.SimpleDisplayText ?? string.Empty; } - protected HtmlString GenerateDropDown(ModelMetadata metadata, string expression, - IEnumerable selectList, string optionLabel, object htmlAttributes) + protected HtmlString GenerateDropDown( + ModelMetadata metadata, + string expression, + IEnumerable selectList, + string optionLabel, + object htmlAttributes) { var tagBuilder = _htmlGenerator.GenerateSelect( ViewContext, metadata, optionLabel, - name: expression, + expression: expression, selectList: selectList, allowMultiple: false, htmlAttributes: htmlAttributes); @@ -597,7 +632,10 @@ namespace Microsoft.AspNet.Mvc.Rendering return tagBuilder.ToHtmlString(TagRenderMode.Normal); } - protected virtual HtmlString GenerateEditor(ModelMetadata metadata, string htmlFieldName, string templateName, + protected virtual HtmlString GenerateEditor( + ModelMetadata metadata, + string htmlFieldName, + string templateName, object additionalViewData) { var templateBuilder = new TemplateBuilder( @@ -704,7 +742,7 @@ namespace Microsoft.AspNet.Mvc.Rendering protected virtual HtmlString GenerateHidden( ModelMetadata metadata, - string name, + string expression, object value, bool useViewData, object htmlAttributes) @@ -713,7 +751,7 @@ namespace Microsoft.AspNet.Mvc.Rendering _htmlGenerator.GenerateHidden( ViewContext, metadata, - name, + expression, value, useViewData, htmlAttributes); @@ -727,21 +765,22 @@ namespace Microsoft.AspNet.Mvc.Rendering protected virtual string GenerateId(string expression) { - var fullName = DefaultHtmlGenerator.GetFullHtmlFieldName(ViewContext, name: expression); + var fullName = DefaultHtmlGenerator.GetFullHtmlFieldName(ViewContext, expression: expression); var id = TagBuilder.CreateSanitizedId(fullName, IdAttributeDotReplacement); return id; } - protected virtual HtmlString GenerateLabel([NotNull] ModelMetadata metadata, - string htmlFieldName, - string labelText, - object htmlAttributes) + protected virtual HtmlString GenerateLabel( + [NotNull] ModelMetadata metadata, + string expression, + string labelText, + object htmlAttributes) { var tagBuilder = _htmlGenerator.GenerateLabel( ViewContext, metadata, - name: htmlFieldName, + expression: expression, labelText: labelText, htmlAttributes: htmlAttributes); if (tagBuilder == null) @@ -754,7 +793,7 @@ namespace Microsoft.AspNet.Mvc.Rendering protected HtmlString GenerateListBox( ModelMetadata metadata, - string name, + string expression, IEnumerable selectList, object htmlAttributes) { @@ -762,7 +801,7 @@ namespace Microsoft.AspNet.Mvc.Rendering ViewContext, metadata, optionLabel: null, - name: name, + expression: expression, selectList: selectList, allowMultiple: true, htmlAttributes: htmlAttributes); @@ -774,19 +813,22 @@ namespace Microsoft.AspNet.Mvc.Rendering return tagBuilder.ToHtmlString(TagRenderMode.Normal); } - protected virtual string GenerateName(string name) + protected virtual string GenerateName(string expression) { - var fullName = DefaultHtmlGenerator.GetFullHtmlFieldName(ViewContext, name); + var fullName = DefaultHtmlGenerator.GetFullHtmlFieldName(ViewContext, expression); return fullName; } - protected virtual HtmlString GeneratePassword(ModelMetadata metadata, string name, object value, + protected virtual HtmlString GeneratePassword( + ModelMetadata metadata, + string expression, + object value, object htmlAttributes) { var tagBuilder = _htmlGenerator.GeneratePassword( ViewContext, metadata, - name, + expression, value, htmlAttributes); if (tagBuilder == null) @@ -797,13 +839,17 @@ namespace Microsoft.AspNet.Mvc.Rendering return tagBuilder.ToHtmlString(TagRenderMode.SelfClosing); } - protected virtual HtmlString GenerateRadioButton(ModelMetadata metadata, string name, object value, - bool? isChecked, object htmlAttributes) + protected virtual HtmlString GenerateRadioButton( + ModelMetadata metadata, + string expression, + object value, + bool? isChecked, + object htmlAttributes) { var tagBuilder = _htmlGenerator.GenerateRadioButton( ViewContext, metadata, - name, + expression, value, isChecked, htmlAttributes); @@ -815,13 +861,17 @@ namespace Microsoft.AspNet.Mvc.Rendering return tagBuilder.ToHtmlString(TagRenderMode.SelfClosing); } - protected virtual HtmlString GenerateTextArea(ModelMetadata metadata, string name, - int rows, int columns, object htmlAttributes) + protected virtual HtmlString GenerateTextArea( + ModelMetadata metadata, + string expression, + int rows, + int columns, + object htmlAttributes) { var tagBuilder = _htmlGenerator.GenerateTextArea( ViewContext, metadata, - name, + expression, rows, columns, htmlAttributes); @@ -833,13 +883,17 @@ namespace Microsoft.AspNet.Mvc.Rendering return tagBuilder.ToHtmlString(TagRenderMode.Normal); } - protected virtual HtmlString GenerateTextBox(ModelMetadata metadata, string name, object value, string format, + protected virtual HtmlString GenerateTextBox( + ModelMetadata metadata, + string expression, + object value, + string format, object htmlAttributes) { var tagBuilder = _htmlGenerator.GenerateTextBox( ViewContext, metadata, - name, + expression, value, format, htmlAttributes); @@ -851,14 +905,15 @@ namespace Microsoft.AspNet.Mvc.Rendering return tagBuilder.ToHtmlString(TagRenderMode.SelfClosing); } - protected virtual HtmlString GenerateValidationMessage(string expression, + protected virtual HtmlString GenerateValidationMessage( + string expression, string message, object htmlAttributes, string tag) { var tagBuilder = _htmlGenerator.GenerateValidationMessage( ViewContext, - name: expression, + expression: expression, message: message, tag: tag, htmlAttributes: htmlAttributes); @@ -890,9 +945,9 @@ namespace Microsoft.AspNet.Mvc.Rendering return tagBuilder.ToHtmlString(TagRenderMode.Normal); } - protected virtual string GenerateValue(string name, object value, string format, bool useViewData) + protected virtual string GenerateValue(string expression, object value, string format, bool useViewData) { - var fullName = DefaultHtmlGenerator.GetFullHtmlFieldName(ViewContext, name); + var fullName = DefaultHtmlGenerator.GetFullHtmlFieldName(ViewContext, expression); var attemptedValue = (string)DefaultHtmlGenerator.GetModelStateValue(ViewContext, fullName, typeof(string)); @@ -904,7 +959,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } else if (useViewData) { - if (string.IsNullOrEmpty(name)) + if (string.IsNullOrEmpty(expression)) { // case 2(a): format the value from ModelMetadata for the current model var metadata = ViewData.ModelMetadata; @@ -913,7 +968,7 @@ namespace Microsoft.AspNet.Mvc.Rendering else { // case 2(b): format the value from ViewData - resolvedValue = DefaultHtmlGenerator.EvalString(ViewContext, name, format); + resolvedValue = DefaultHtmlGenerator.EvalString(ViewContext, expression, format); } } else @@ -928,9 +983,9 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public IEnumerable GetClientValidationRules( ModelMetadata metadata, - string name) + string expression) { - return _htmlGenerator.GetClientValidationRules(ViewContext, metadata, name); + return _htmlGenerator.GetClientValidationRules(ViewContext, metadata, expression); } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelperOfT.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelperOfT.cs index 3dc5a53e13..5b72c4fb98 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelperOfT.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelperOfT.cs @@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Mvc.Rendering throw new ArgumentException(Resources.FormatPropertyOfTypeCannotBeNull( "ViewData", typeof(ViewContext)), - "viewContext"); + nameof(viewContext)); } ViewData = viewContext.ViewData as ViewDataDictionary; @@ -44,14 +44,15 @@ namespace Microsoft.AspNet.Mvc.Rendering "ViewData", viewContext.ViewData.GetType().FullName, typeof(ViewDataDictionary).FullName), - "viewContext"); + nameof(viewContext)); } base.Contextualize(viewContext); } /// - public HtmlString CheckBoxFor([NotNull] Expression> expression, + public HtmlString CheckBoxFor( + [NotNull] Expression> expression, object htmlAttributes) { var metadata = GetModelMetadata(expression); @@ -60,8 +61,11 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public HtmlString DropDownListFor([NotNull] Expression> expression, - IEnumerable selectList, string optionLabel, object htmlAttributes) + public HtmlString DropDownListFor( + [NotNull] Expression> expression, + IEnumerable selectList, + string optionLabel, + object htmlAttributes) { var metadata = ExpressionMetadataProvider.FromLambdaExpression(expression, ViewData, MetadataProvider); @@ -70,10 +74,11 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public HtmlString DisplayFor([NotNull] Expression> expression, - string templateName, - string htmlFieldName, - object additionalViewData) + public HtmlString DisplayFor( + [NotNull] Expression> expression, + string templateName, + string htmlFieldName, + object additionalViewData) { var metadata = ExpressionMetadataProvider.FromLambdaExpression(expression, ViewData, @@ -86,17 +91,17 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public string DisplayNameFor([NotNull] Expression> expression) + public string DisplayNameFor([NotNull] Expression> expression) { var metadata = GetModelMetadata(expression); return GenerateDisplayName(metadata, ExpressionHelper.GetExpressionText(expression)); } /// - public string DisplayNameForInnerType( - [NotNull] Expression> expression) + public string DisplayNameForInnerType( + [NotNull] Expression> expression) { - var metadata = ExpressionMetadataProvider.FromLambdaExpression( + var metadata = ExpressionMetadataProvider.FromLambdaExpression( expression, new ViewDataDictionary(ViewData, model: null), MetadataProvider); @@ -111,14 +116,14 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public string DisplayTextFor([NotNull] Expression> expression) + public string DisplayTextFor([NotNull] Expression> expression) { return GenerateDisplayText(GetModelMetadata(expression)); } /// - public HtmlString EditorFor( - [NotNull] Expression> expression, + public HtmlString EditorFor( + [NotNull] Expression> expression, string templateName, string htmlFieldName, object additionalViewData) @@ -133,7 +138,8 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public HtmlString HiddenFor([NotNull] Expression> expression, + public HtmlString HiddenFor( + [NotNull] Expression> expression, object htmlAttributes) { var metadata = GetModelMetadata(expression); @@ -142,14 +148,14 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public string IdFor([NotNull] Expression> expression) + public string IdFor([NotNull] Expression> expression) { return GenerateId(GetExpressionName(expression)); } /// - public HtmlString LabelFor( - [NotNull] Expression> expression, + public HtmlString LabelFor( + [NotNull] Expression> expression, string labelText, object htmlAttributes) { @@ -158,8 +164,8 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public HtmlString ListBoxFor( - [NotNull] Expression> expression, + public HtmlString ListBoxFor( + [NotNull] Expression> expression, IEnumerable selectList, object htmlAttributes) { @@ -170,14 +176,15 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public string NameFor([NotNull] Expression> expression) + public string NameFor([NotNull] Expression> expression) { var expressionName = GetExpressionName(expression); return Name(expressionName); } /// - public HtmlString PasswordFor([NotNull] Expression> expression, + public HtmlString PasswordFor( + [NotNull] Expression> expression, object htmlAttributes) { var metadata = GetModelMetadata(expression); @@ -186,8 +193,8 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public HtmlString RadioButtonFor( - [NotNull] Expression> expression, + public HtmlString RadioButtonFor( + [NotNull] Expression> expression, [NotNull] object value, object htmlAttributes) { @@ -197,27 +204,32 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public HtmlString TextAreaFor([NotNull] Expression> expression, int rows, - int columns, object htmlAttributes) + public HtmlString TextAreaFor( + [NotNull] Expression> expression, + int rows, + int columns, + object htmlAttributes) { var metadata = GetModelMetadata(expression); return GenerateTextArea(metadata, GetExpressionName(expression), rows, columns, htmlAttributes); } /// - public HtmlString TextBoxFor([NotNull] Expression> expression, - string format, object htmlAttributes) + public HtmlString TextBoxFor( + [NotNull] Expression> expression, + string format, + object htmlAttributes) { var metadata = GetModelMetadata(expression); return GenerateTextBox(metadata, GetExpressionName(expression), metadata.Model, format, htmlAttributes); } - protected string GetExpressionName([NotNull] Expression> expression) + protected string GetExpressionName([NotNull] Expression> expression) { return ExpressionHelper.GetExpressionText(expression); } - protected ModelMetadata GetModelMetadata([NotNull] Expression> expression) + protected ModelMetadata GetModelMetadata([NotNull] Expression> expression) { var metadata = ExpressionMetadataProvider.FromLambdaExpression(expression, ViewData, MetadataProvider); if (metadata == null) @@ -230,7 +242,8 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public HtmlString ValidationMessageFor([NotNull] Expression> expression, + public HtmlString ValidationMessageFor( + [NotNull] Expression> expression, string message, object htmlAttributes, string tag) @@ -242,7 +255,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public string ValueFor([NotNull] Expression> expression, string format) + public string ValueFor([NotNull] Expression> expression, string format) { var metadata = GetModelMetadata(expression); return GenerateValue(ExpressionHelper.GetExpressionText(expression), metadata.Model, format, diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/IHtmlGenerator.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/IHtmlGenerator.cs index bbce6d96a0..d939218f35 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/IHtmlGenerator.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/IHtmlGenerator.cs @@ -34,7 +34,7 @@ namespace Microsoft.AspNet.Mvc.Rendering TagBuilder GenerateCheckBox( [NotNull] ViewContext viewContext, ModelMetadata metadata, - string name, + string expression, bool? isChecked, object htmlAttributes); @@ -46,7 +46,7 @@ namespace Microsoft.AspNet.Mvc.Rendering TagBuilder GenerateHiddenForCheckbox( [NotNull] ViewContext viewContext, ModelMetadata metadata, - string name); + string expression); /// /// Generate a <form> element. When the user submits the form, the action with name @@ -107,7 +107,7 @@ namespace Microsoft.AspNet.Mvc.Rendering TagBuilder GenerateHidden( [NotNull] ViewContext viewContext, ModelMetadata metadata, - string name, + string expression, object value, bool useViewData, object htmlAttributes); @@ -115,21 +115,21 @@ namespace Microsoft.AspNet.Mvc.Rendering TagBuilder GenerateLabel( [NotNull] ViewContext viewContext, [NotNull] ModelMetadata metadata, - string name, + string expression, string labelText, object htmlAttributes); TagBuilder GeneratePassword( [NotNull] ViewContext viewContext, ModelMetadata metadata, - string name, + string expression, object value, object htmlAttributes); TagBuilder GenerateRadioButton( [NotNull] ViewContext viewContext, ModelMetadata metadata, - string name, + string expression, object value, bool? isChecked, object htmlAttributes); @@ -147,7 +147,7 @@ namespace Microsoft.AspNet.Mvc.Rendering [NotNull] ViewContext viewContext, ModelMetadata metadata, string optionLabel, - string name, + string expression, IEnumerable selectList, bool allowMultiple, object htmlAttributes); @@ -156,7 +156,7 @@ namespace Microsoft.AspNet.Mvc.Rendering [NotNull] ViewContext viewContext, ModelMetadata metadata, string optionLabel, - string name, + string expression, IEnumerable selectList, bool allowMultiple, object htmlAttributes, @@ -165,7 +165,7 @@ namespace Microsoft.AspNet.Mvc.Rendering TagBuilder GenerateTextArea( [NotNull] ViewContext viewContext, ModelMetadata metadata, - string name, + string expression, int rows, int columns, object htmlAttributes); @@ -173,14 +173,14 @@ namespace Microsoft.AspNet.Mvc.Rendering TagBuilder GenerateTextBox( [NotNull] ViewContext viewContext, ModelMetadata metadata, - string name, + string expression, object value, string format, object htmlAttributes); TagBuilder GenerateValidationMessage( [NotNull] ViewContext viewContext, - string name, + string expression, string message, string tag, object htmlAttributes); @@ -193,11 +193,12 @@ namespace Microsoft.AspNet.Mvc.Rendering object htmlAttributes); /// - /// Not used directly in HtmlHelper. Exposed publicly for use in other IHtmlHelper implementations. + /// Not used directly in . Exposed publicly for use in other + /// implementations. /// IEnumerable GetClientValidationRules( [NotNull] ViewContext viewContext, ModelMetadata metadata, - string name); + string expression); } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs index ec65ba31d2..bd8b2b62b8 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Returns HTML markup for the , using a display template. The template is found /// using the 's . /// - /// The instance this method extends. + /// The instance this method extends. /// /// Expression name, relative to the current model. May identify a single property or an /// that contains the properties to display. @@ -35,9 +35,9 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString Display([NotNull] this IHtmlHelper html, string expression) + public static HtmlString Display([NotNull] this IHtmlHelper htmlHelper, string expression) { - return html.Display(expression, templateName: null, htmlFieldName: null, additionalViewData: null); + return htmlHelper.Display(expression, templateName: null, htmlFieldName: null, additionalViewData: null); } /// @@ -45,7 +45,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// additional view data. The template is found using the 's /// . /// - /// The instance this method extends. + /// The instance this method extends. /// /// Expression name, relative to the current model. May identify a single property or an /// that contains the properties to display. @@ -71,11 +71,14 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// public static HtmlString Display( - [NotNull] this IHtmlHelper html, + [NotNull] this IHtmlHelper htmlHelper, string expression, object additionalViewData) { - return html.Display(expression, templateName: null, htmlFieldName: null, + return htmlHelper.Display( + expression, + templateName: null, + htmlFieldName: null, additionalViewData: additionalViewData); } @@ -84,7 +87,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// using the or the 's /// . /// - /// The instance this method extends. + /// The instance this method extends. /// /// Expression name, relative to the current model. May identify a single property or an /// that contains the properties to display. @@ -106,11 +109,11 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// public static HtmlString Display( - [NotNull] this IHtmlHelper html, + [NotNull] this IHtmlHelper htmlHelper, string expression, string templateName) { - return html.Display(expression, templateName, htmlFieldName: null, additionalViewData: null); + return htmlHelper.Display(expression, templateName, htmlFieldName: null, additionalViewData: null); } /// @@ -118,7 +121,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// additional view data. The template is found using the or the /// 's . /// - /// The instance this method extends. + /// The instance this method extends. /// /// Expression name, relative to the current model. May identify a single property or an /// that contains the properties to display. @@ -145,12 +148,16 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// public static HtmlString Display( - [NotNull] this IHtmlHelper html, + [NotNull] this IHtmlHelper htmlHelper, string expression, string templateName, object additionalViewData) { - return html.Display(expression, templateName, htmlFieldName: null, additionalViewData: additionalViewData); + return htmlHelper.Display( + expression, + templateName, + htmlFieldName: null, + additionalViewData: additionalViewData); } /// @@ -158,7 +165,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// field name. The template is found using the or the /// 's. /// - /// The instance this method extends. + /// The instance this method extends. /// /// Expression name, relative to the current model. May identify a single property or an /// that contains the properties to display. @@ -184,22 +191,22 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// public static HtmlString Display( - [NotNull] this IHtmlHelper html, + [NotNull] this IHtmlHelper htmlHelper, string expression, string templateName, string htmlFieldName) { - return html.Display(expression, templateName, htmlFieldName, additionalViewData: null); + return htmlHelper.Display(expression, templateName, htmlFieldName, additionalViewData: null); } /// /// Returns HTML markup for the , using a display template. The template is found /// using the 's . /// - /// The instance this method extends. + /// The instance this method extends. /// An expression to be evaluated against the current model. /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the created HTML. /// /// @@ -211,10 +218,14 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString DisplayFor([NotNull] this IHtmlHelper html, - [NotNull] Expression> expression) + public static HtmlString DisplayFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression) { - return html.DisplayFor(expression, templateName: null, htmlFieldName: null, + return htmlHelper.DisplayFor( + expression, + templateName: null, + htmlFieldName: null, additionalViewData: null); } @@ -223,7 +234,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// additional view data. The template is found using the 's /// . /// - /// The instance this method extends. + /// The instance this method extends. /// An expression to be evaluated against the current model. /// /// An anonymous or @@ -231,7 +242,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// instance created for the template. /// /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the created HTML. /// /// @@ -243,11 +254,15 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString DisplayFor([NotNull] this IHtmlHelper html, - [NotNull] Expression> expression, - object additionalViewData) + public static HtmlString DisplayFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, + object additionalViewData) { - return html.DisplayFor(expression, templateName: null, htmlFieldName: null, + return htmlHelper.DisplayFor( + expression, + templateName: null, + htmlFieldName: null, additionalViewData: additionalViewData); } @@ -256,11 +271,11 @@ namespace Microsoft.AspNet.Mvc.Rendering /// using the or the 's /// . /// - /// The instance this method extends. + /// The instance this method extends. /// An expression to be evaluated against the current model. /// The name of the template used to create the HTML markup. /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the created HTML. /// /// @@ -272,11 +287,16 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString DisplayFor([NotNull] this IHtmlHelper html, - [NotNull] Expression> expression, - string templateName) + public static HtmlString DisplayFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, + string templateName) { - return html.DisplayFor(expression, templateName, htmlFieldName: null, additionalViewData: null); + return htmlHelper.DisplayFor( + expression, + templateName, + htmlFieldName: null, + additionalViewData: null); } /// @@ -284,7 +304,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// additional view data. The template is found using the or the /// 's . /// - /// The instance this method extends. + /// The instance this method extends. /// An expression to be evaluated against the current model. /// The name of the template used to create the HTML markup. /// @@ -293,7 +313,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// instance created for the template. /// /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the created HTML. /// /// @@ -305,12 +325,16 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString DisplayFor([NotNull] this IHtmlHelper html, - [NotNull] Expression> expression, - string templateName, - object additionalViewData) + public static HtmlString DisplayFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, + string templateName, + object additionalViewData) { - return html.DisplayFor(expression, templateName, htmlFieldName: null, + return htmlHelper.DisplayFor( + expression, + templateName, + htmlFieldName: null, additionalViewData: additionalViewData); } @@ -319,7 +343,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// field name. The template is found using the or the /// 's . /// - /// The instance this method extends. + /// The instance this method extends. /// An expression to be evaluated against the current model. /// The name of the template used to create the HTML markup. /// @@ -327,7 +351,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// that have the same name. /// /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the created HTML. /// /// @@ -339,12 +363,16 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString DisplayFor([NotNull] this IHtmlHelper html, - [NotNull] Expression> expression, - string templateName, - string htmlFieldName) + public static HtmlString DisplayFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, + string templateName, + string htmlFieldName) { - return html.DisplayFor(expression, templateName: templateName, htmlFieldName: htmlFieldName, + return htmlHelper.DisplayFor( + expression, + templateName: templateName, + htmlFieldName: htmlFieldName, additionalViewData: null); } @@ -352,7 +380,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Returns HTML markup for the current model, using a display template. The template is found using the /// model's . /// - /// The instance this method extends. + /// The instance this method extends. /// A new containing the created HTML. /// /// @@ -364,16 +392,20 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html) + public static HtmlString DisplayForModel([NotNull] this IHtmlHelper htmlHelper) { - return html.Display(expression: null, templateName: null, htmlFieldName: null, additionalViewData: null); + return htmlHelper.Display( + expression: null, + templateName: null, + htmlFieldName: null, + additionalViewData: null); } /// /// Returns HTML markup for the current model, using a display template and specified additional view data. The /// template is found using the model's . /// - /// The instance this method extends. + /// The instance this method extends. /// /// An anonymous or /// that can contain additional view data that will be merged into the @@ -390,9 +422,12 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html, object additionalViewData) + public static HtmlString DisplayForModel([NotNull] this IHtmlHelper htmlHelper, object additionalViewData) { - return html.Display(expression: null, templateName: null, htmlFieldName: null, + return htmlHelper.Display( + expression: null, + templateName: null, + htmlFieldName: null, additionalViewData: additionalViewData); } @@ -400,7 +435,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Returns HTML markup for the current model, using a display template. The template is found using the /// or the model's . /// - /// The instance this method extends. + /// The instance this method extends. /// The name of the template used to create the HTML markup. /// A new containing the created HTML. /// @@ -413,9 +448,12 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html, string templateName) + public static HtmlString DisplayForModel([NotNull] this IHtmlHelper htmlHelper, string templateName) { - return html.Display(expression: null, templateName: templateName, htmlFieldName: null, + return htmlHelper.Display( + expression: null, + templateName: templateName, + htmlFieldName: null, additionalViewData: null); } @@ -424,7 +462,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// template is found using the or the model's /// . /// - /// The instance this method extends. + /// The instance this method extends. /// The name of the template used to create the HTML markup. /// /// An anonymous or @@ -443,11 +481,14 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// public static HtmlString DisplayForModel( - [NotNull] this IHtmlHelper html, + [NotNull] this IHtmlHelper htmlHelper, string templateName, object additionalViewData) { - return html.Display(expression: null, templateName: templateName, htmlFieldName: null, + return htmlHelper.Display( + expression: null, + templateName: templateName, + htmlFieldName: null, additionalViewData: additionalViewData); } @@ -456,7 +497,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// template is found using the or the model's /// . /// - /// The instance this method extends. + /// The instance this method extends. /// The name of the template used to create the HTML markup. /// /// A used to disambiguate the names of HTML elements that are created for @@ -474,11 +515,14 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// public static HtmlString DisplayForModel( - [NotNull] this IHtmlHelper html, + [NotNull] this IHtmlHelper htmlHelper, string templateName, string htmlFieldName) { - return html.Display(expression: null, templateName: templateName, htmlFieldName: htmlFieldName, + return htmlHelper.Display( + expression: null, + templateName: templateName, + htmlFieldName: htmlFieldName, additionalViewData: null); } @@ -487,7 +531,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// additional view data. The template is found using the or the model's /// . /// - /// The instance this method extends. + /// The instance this method extends. /// The name of the template used to create the HTML markup. /// /// A used to disambiguate the names of HTML elements that are created for @@ -510,12 +554,15 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// public static HtmlString DisplayForModel( - [NotNull] this IHtmlHelper html, + [NotNull] this IHtmlHelper htmlHelper, string templateName, string htmlFieldName, object additionalViewData) { - return html.Display(expression: null, templateName: templateName, htmlFieldName: htmlFieldName, + return htmlHelper.Display( + expression: null, + templateName: templateName, + htmlFieldName: htmlFieldName, additionalViewData: additionalViewData); } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayNameExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayNameExtensions.cs index 201df16063..ab4508b63b 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayNameExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayNameExtensions.cs @@ -31,13 +31,13 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// An expression to be evaluated against an item in the current model. /// The type of items in the model collection. - /// The type of the result. + /// The type of the result. /// A containing the display name. - public static string DisplayNameFor( + public static string DisplayNameFor( [NotNull] this IHtmlHelper> htmlHelper, - [NotNull] Expression> expression) + [NotNull] Expression> expression) { - return htmlHelper.DisplayNameForInnerType(expression); + return htmlHelper.DisplayNameForInnerType(expression); } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperEditorExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperEditorExtensions.cs index f6f54fbc66..12e7d4e3bc 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperEditorExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperEditorExtensions.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Returns HTML markup for the , using an editor template. The template is found /// using the 's . /// - /// The instance this method extends. + /// The instance this method extends. /// /// Expression name, relative to the current model. May identify a single property or an /// that contains the properties to edit. @@ -35,9 +35,9 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression) + public static HtmlString Editor([NotNull] this IHtmlHelper htmlHelper, string expression) { - return html.Editor(expression, templateName: null, htmlFieldName: null, additionalViewData: null); + return htmlHelper.Editor(expression, templateName: null, htmlFieldName: null, additionalViewData: null); } /// @@ -45,7 +45,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// additional view data. The template is found using the 's /// . /// - /// The instance this method extends. + /// The instance this method extends. /// /// Expression name, relative to the current model. May identify a single property or an /// that contains the properties to edit. @@ -70,9 +70,15 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, object additionalViewData) + public static HtmlString Editor( + [NotNull] this IHtmlHelper htmlHelper, + string expression, + object additionalViewData) { - return html.Editor(expression, templateName: null, htmlFieldName: null, + return htmlHelper.Editor( + expression, + templateName: null, + htmlFieldName: null, additionalViewData: additionalViewData); } @@ -81,7 +87,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// using the or the 's /// . /// - /// The instance this method extends. + /// The instance this method extends. /// /// Expression name, relative to the current model. May identify a single property or an /// that contains the properties to edit. @@ -102,9 +108,9 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, string templateName) + public static HtmlString Editor([NotNull] this IHtmlHelper htmlHelper, string expression, string templateName) { - return html.Editor(expression, templateName, htmlFieldName: null, additionalViewData: null); + return htmlHelper.Editor(expression, templateName, htmlFieldName: null, additionalViewData: null); } /// @@ -112,7 +118,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// additional view data. The template is found using the or the /// 's . /// - /// The instance this method extends. + /// The instance this method extends. /// /// Expression name, relative to the current model. May identify a single property or an /// that contains the properties to edit. @@ -138,10 +144,17 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, string templateName, + public static HtmlString Editor( + [NotNull] this IHtmlHelper htmlHelper, + string expression, + string templateName, object additionalViewData) { - return html.Editor(expression, templateName, htmlFieldName: null, additionalViewData: additionalViewData); + return htmlHelper.Editor( + expression, + templateName, + htmlFieldName: null, + additionalViewData: additionalViewData); } /// @@ -149,7 +162,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// field name. The template is found using the or the /// 's . /// - /// The instance this method extends. + /// The instance this method extends. /// /// Expression name, relative to the current model. May identify a single property or an /// that contains the properties to edit. @@ -174,20 +187,23 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, string templateName, + public static HtmlString Editor( + [NotNull] this IHtmlHelper htmlHelper, + string expression, + string templateName, string htmlFieldName) { - return html.Editor(expression, templateName, htmlFieldName, additionalViewData: null); + return htmlHelper.Editor(expression, templateName, htmlFieldName, additionalViewData: null); } /// /// Returns HTML markup for the , using an editor template. The template is found /// using the 's . /// - /// The instance this method extends. + /// The instance this method extends. /// An expression to be evaluated against the current model. /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <input> element(s). /// /// @@ -199,10 +215,11 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString EditorFor([NotNull] this IHtmlHelper html, - [NotNull] Expression> expression) + public static HtmlString EditorFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression) { - return html.EditorFor(expression, templateName: null, htmlFieldName: null, additionalViewData: null); + return htmlHelper.EditorFor(expression, templateName: null, htmlFieldName: null, additionalViewData: null); } /// @@ -210,7 +227,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// additional view data. The template is found using the 's /// . /// - /// The instance this method extends. + /// The instance this method extends. /// An expression to be evaluated against the current model. /// /// An anonymous or @@ -218,7 +235,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// instance created for the template. /// /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <input> element(s). /// /// @@ -230,10 +247,15 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString EditorFor([NotNull] this IHtmlHelper html, - [NotNull] Expression> expression, object additionalViewData) + public static HtmlString EditorFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, + object additionalViewData) { - return html.EditorFor(expression, templateName: null, htmlFieldName: null, + return htmlHelper.EditorFor( + expression, + templateName: null, + htmlFieldName: null, additionalViewData: additionalViewData); } @@ -242,11 +264,11 @@ namespace Microsoft.AspNet.Mvc.Rendering /// using the or the 's /// . /// - /// The instance this method extends. + /// The instance this method extends. /// An expression to be evaluated against the current model. /// The name of the template that is used to create the HTML markup. /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <input> element(s). /// /// @@ -258,10 +280,12 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString EditorFor([NotNull] this IHtmlHelper html, - [NotNull] Expression> expression, string templateName) + public static HtmlString EditorFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, + string templateName) { - return html.EditorFor(expression, templateName, htmlFieldName: null, additionalViewData: null); + return htmlHelper.EditorFor(expression, templateName, htmlFieldName: null, additionalViewData: null); } /// @@ -269,7 +293,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// additional view data. The template is found using the or the /// 's . /// - /// The instance this method extends. + /// The instance this method extends. /// An expression to be evaluated against the current model. /// The name of the template that is used to create the HTML markup. /// @@ -278,7 +302,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// instance created for the template. /// /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <input> element(s). /// /// @@ -290,10 +314,16 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString EditorFor([NotNull] this IHtmlHelper html, - [NotNull] Expression> expression, string templateName, object additionalViewData) + public static HtmlString EditorFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, + string templateName, + object additionalViewData) { - return html.EditorFor(expression, templateName, htmlFieldName: null, + return htmlHelper.EditorFor( + expression, + templateName, + htmlFieldName: null, additionalViewData: additionalViewData); } @@ -302,7 +332,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// field name. The template is found using the or the /// 's . /// - /// The instance this method extends. + /// The instance this method extends. /// An expression to be evaluated against the current model. /// The name of the template that is used to create the HTML markup. /// @@ -310,7 +340,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// that have the same name. /// /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <input> element(s). /// /// @@ -322,17 +352,20 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString EditorFor([NotNull] this IHtmlHelper html, - [NotNull] Expression> expression, string templateName, string htmlFieldName) + public static HtmlString EditorFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, + string templateName, + string htmlFieldName) { - return html.EditorFor(expression, templateName, htmlFieldName, additionalViewData: null); + return htmlHelper.EditorFor(expression, templateName, htmlFieldName, additionalViewData: null); } /// /// Returns HTML markup for the current model, using an editor template. The template is found using the /// model's . /// - /// The instance this method extends. + /// The instance this method extends. /// A new containing the <input> element(s). /// /// @@ -344,16 +377,20 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString EditorForModel([NotNull] this IHtmlHelper html) + public static HtmlString EditorForModel([NotNull] this IHtmlHelper htmlHelper) { - return html.Editor(expression: null, templateName: null, htmlFieldName: null, additionalViewData: null); + return htmlHelper.Editor( + expression: null, + templateName: null, + htmlFieldName: null, + additionalViewData: null); } /// /// Returns HTML markup for the current model, using an editor template and specified additional view data. The /// template is found using the model's . /// - /// The instance this method extends. + /// The instance this method extends. /// /// An anonymous or /// that can contain additional view data that will be merged into the @@ -370,9 +407,12 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, object additionalViewData) + public static HtmlString EditorForModel([NotNull] this IHtmlHelper htmlHelper, object additionalViewData) { - return html.Editor(expression: null, templateName: null, htmlFieldName: null, + return htmlHelper.Editor( + expression: null, + templateName: null, + htmlFieldName: null, additionalViewData: additionalViewData); } @@ -380,7 +420,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Returns HTML markup for the current model, using an editor template. The template is found using the /// or the model's . /// - /// The instance this method extends. + /// The instance this method extends. /// The name of the template used to create the HTML markup. /// A new containing the <input> element(s). /// @@ -393,9 +433,12 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName) + public static HtmlString EditorForModel([NotNull] this IHtmlHelper htmlHelper, string templateName) { - return html.Editor(expression: null, templateName: templateName, htmlFieldName: null, + return htmlHelper.Editor( + expression: null, + templateName: templateName, + htmlFieldName: null, additionalViewData: null); } @@ -404,7 +447,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// template is found using the or the model's /// . /// - /// The instance this method extends. + /// The instance this method extends. /// The name of the template used to create the HTML markup. /// /// An anonymous or @@ -422,10 +465,15 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName, + public static HtmlString EditorForModel( + [NotNull] this IHtmlHelper htmlHelper, + string templateName, object additionalViewData) { - return html.Editor(expression: null, templateName: templateName, htmlFieldName: null, + return htmlHelper.Editor( + expression: null, + templateName: templateName, + htmlFieldName: null, additionalViewData: additionalViewData); } @@ -434,7 +482,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// template is found using the or the model's /// . /// - /// The instance this method extends. + /// The instance this method extends. /// The name of the template used to create the HTML markup. /// /// A used to disambiguate the names of HTML elements that are created for @@ -451,10 +499,15 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName, + public static HtmlString EditorForModel( + [NotNull] this IHtmlHelper htmlHelper, + string templateName, string htmlFieldName) { - return html.Editor(expression: null, templateName: templateName, htmlFieldName: htmlFieldName, + return htmlHelper.Editor( + expression: null, + templateName: templateName, + htmlFieldName: htmlFieldName, additionalViewData: null); } @@ -463,7 +516,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// additional view data. The template is found using the or the model's /// . /// - /// The instance this method extends. + /// The instance this method extends. /// The name of the template used to create the HTML markup. /// /// A used to disambiguate the names of HTML elements that are created for @@ -485,10 +538,16 @@ namespace Microsoft.AspNet.Mvc.Rendering /// case-sensitive file systems. /// /// - public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName, - string htmlFieldName, object additionalViewData) + public static HtmlString EditorForModel( + [NotNull] this IHtmlHelper htmlHelper, + string templateName, + string htmlFieldName, + object additionalViewData) { - return html.Editor(expression: null, templateName: templateName, htmlFieldName: htmlFieldName, + return htmlHelper.Editor( + expression: null, + templateName: templateName, + htmlFieldName: htmlFieldName, additionalViewData: additionalViewData); } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperInputExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperInputExtensions.cs index ce11c67d7d..74acc804b4 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperInputExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperInputExtensions.cs @@ -16,26 +16,27 @@ namespace Microsoft.AspNet.Mvc.Rendering /// "hidden" with value "false". /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// A new containing the <input> elements. /// /// - /// Combines and to set checkbox - /// element's "name" attribute. Sanitizes to set checkbox element's "id" attribute. + /// Combines and to set checkbox + /// element's "name" attribute. Sanitizes to set checkbox element's "id" + /// attribute. /// /// Determines checkbox element's "checked" attribute based on the following precedence: /// /// - /// entry for (converted to a + /// entry for (converted to a /// fully-qualified name) if entry exists and can be converted to a . /// /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// @@ -46,9 +47,9 @@ namespace Microsoft.AspNet.Mvc.Rendering /// value "checked" if the values is true; does not include the attribute otherwise. /// /// - public static HtmlString CheckBox([NotNull] this IHtmlHelper htmlHelper, string name) + public static HtmlString CheckBox([NotNull] this IHtmlHelper htmlHelper, string expression) { - return htmlHelper.CheckBox(name, isChecked: null, htmlAttributes: null); + return htmlHelper.CheckBox(expression, isChecked: null, htmlAttributes: null); } /// @@ -56,28 +57,29 @@ namespace Microsoft.AspNet.Mvc.Rendering /// "hidden" with value "false". /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// If true, checkbox is initially checked. /// A new containing the <input> elements. /// /// - /// Combines and to set checkbox - /// element's "name" attribute. Sanitizes to set checkbox element's "id" attribute. + /// Combines and to set checkbox + /// element's "name" attribute. Sanitizes to set checkbox element's "id" + /// attribute. /// /// Determines checkbox element's "checked" attribute based on the following precedence: /// /// - /// entry for (converted to a + /// entry for (converted to a /// fully-qualified name) if entry exists and can be converted to a . /// /// if non-null. /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// @@ -90,10 +92,10 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public static HtmlString CheckBox( [NotNull] this IHtmlHelper htmlHelper, - string name, + string expression, bool isChecked) { - return htmlHelper.CheckBox(name, isChecked, htmlAttributes: null); + return htmlHelper.CheckBox(expression, isChecked, htmlAttributes: null); } /// @@ -101,7 +103,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// "hidden" with value "false". /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// /// An that contains the HTML attributes for the checkbox element. Alternatively, an /// instance containing the HTML @@ -110,22 +112,23 @@ namespace Microsoft.AspNet.Mvc.Rendering /// A new containing the <input> elements. /// /// - /// Combines and to set checkbox - /// element's "name" attribute. Sanitizes to set checkbox element's "id" attribute. + /// Combines and to set checkbox + /// element's "name" attribute. Sanitizes to set checkbox element's "id" + /// attribute. /// /// Determines checkbox element's "checked" attribute based on the following precedence: /// /// - /// entry for (converted to a + /// entry for (converted to a /// fully-qualified name) if entry exists and can be converted to a . /// /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// @@ -139,10 +142,10 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public static HtmlString CheckBox( [NotNull] this IHtmlHelper htmlHelper, - string name, + string expression, object htmlAttributes) { - return htmlHelper.CheckBox(name, isChecked: null, htmlAttributes: htmlAttributes); + return htmlHelper.CheckBox(expression, isChecked: null, htmlAttributes: htmlAttributes); } /// @@ -175,75 +178,76 @@ namespace Microsoft.AspNet.Mvc.Rendering /// value "checked" if the values is true; does not include the attribute otherwise. /// /// - public static HtmlString CheckBoxFor([NotNull] this IHtmlHelper htmlHelper, + public static HtmlString CheckBoxFor( + [NotNull] this IHtmlHelper htmlHelper, [NotNull] Expression> expression) { return htmlHelper.CheckBoxFor(expression, htmlAttributes: null); } /// - /// Returns an <input> element of type "hidden" for the specified expression . + /// Returns an <input> element of type "hidden" for the specified . /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// A new containing the <input> element. /// /// - /// Combines and to set - /// <input> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <input> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// /// Determines <input> element's "value" attribute based on the following precedence: /// /// - /// entry for (converted to a + /// entry for (converted to a /// fully-qualified name) if entry exists and can be converted to a . /// /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// /// Otherwise, string.Empty. /// /// - public static HtmlString Hidden([NotNull] this IHtmlHelper htmlHelper, string name) + public static HtmlString Hidden([NotNull] this IHtmlHelper htmlHelper, string expression) { - return htmlHelper.Hidden(name, value: null, htmlAttributes: null); + return htmlHelper.Hidden(expression, value: null, htmlAttributes: null); } /// - /// Returns an <input> element of type "hidden" for the specified expression . + /// Returns an <input> element of type "hidden" for the specified . /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// If non-null, value to include in the element. /// A new containing the <input> element. /// /// - /// Combines and to set - /// <input> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <input> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// /// Determines <input> element's "value" attribute based on the following precedence: /// /// - /// entry for (converted to a + /// entry for (converted to a /// fully-qualified name) if entry exists and can be converted to a . /// /// if non-null. /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// @@ -252,10 +256,10 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public static HtmlString Hidden( [NotNull] this IHtmlHelper htmlHelper, - string name, + string expression, object value) { - return htmlHelper.Hidden(name, value, htmlAttributes: null); + return htmlHelper.Hidden(expression, value, htmlAttributes: null); } /// @@ -264,7 +268,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// The instance this method extends. /// An expression to be evaluated against the current model. /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <input> element. /// /// @@ -285,39 +289,40 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Otherwise, string.Empty. /// /// - public static HtmlString HiddenFor([NotNull] this IHtmlHelper htmlHelper, - [NotNull] Expression> expression) + public static HtmlString HiddenFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression) { return htmlHelper.HiddenFor(expression, htmlAttributes: null); } /// - /// Returns an <input> element of type "password" for the specified expression . + /// Returns an <input> element of type "password" for the specified . /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// A new containing the <input> element. /// - /// Combines and to set - /// <input> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <input> element's "name" attribute. Sanitizes to set element's "id" /// attribute. Sets <input> element's "value" attribute to string.Empty. /// - public static HtmlString Password([NotNull] this IHtmlHelper htmlHelper, string name) + public static HtmlString Password([NotNull] this IHtmlHelper htmlHelper, string expression) { - return htmlHelper.Password(name, value: null, htmlAttributes: null); + return htmlHelper.Password(expression, value: null, htmlAttributes: null); } /// - /// Returns an <input> element of type "password" for the specified expression . + /// Returns an <input> element of type "password" for the specified . /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// If non-null, value to include in the element. /// A new containing the <input> element. /// /// - /// Combines and to set - /// <input> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <input> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// /// Determines <input> element's "value" attribute based on the following precedence: @@ -328,10 +333,10 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public static HtmlString Password( [NotNull] this IHtmlHelper htmlHelper, - string name, + string expression, object value) { - return htmlHelper.Password(name, value, htmlAttributes: null); + return htmlHelper.Password(expression, value, htmlAttributes: null); } /// @@ -340,7 +345,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// The instance this method extends. /// An expression to be evaluated against the current model. /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <input> element. /// /// @@ -357,38 +362,39 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Otherwise, string.Empty. /// /// - public static HtmlString PasswordFor([NotNull] this IHtmlHelper htmlHelper, - [NotNull] Expression> expression) + public static HtmlString PasswordFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression) { return htmlHelper.PasswordFor(expression, htmlAttributes: null); } /// - /// Returns an <input> element of type "radio" for the specified expression . + /// Returns an <input> element of type "radio" for the specified . /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// Value to include in the element. Must not be null. /// A new containing the <input> element. /// /// - /// Combines and to set - /// <input> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <input> element's "name" attribute. Sanitizes to set element's "id" /// attribute. Sets <input> element's "value" attribute to . /// /// Determines <input> element's "checked" attribute based on the following precedence: /// /// - /// entry for (converted to a + /// entry for (converted to a /// fully-qualified name) if entry exists and can be converted to a . /// /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// @@ -403,17 +409,17 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public static HtmlString RadioButton( [NotNull] this IHtmlHelper htmlHelper, - string name, + string expression, object value) { - return htmlHelper.RadioButton(name, value, isChecked: null, htmlAttributes: null); + return htmlHelper.RadioButton(expression, value, isChecked: null, htmlAttributes: null); } /// - /// Returns an <input> element of type "radio" for the specified expression . + /// Returns an <input> element of type "radio" for the specified . /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// /// If non-null, value to include in the element. Must not be null if no "checked" entry exists /// in . @@ -426,8 +432,8 @@ namespace Microsoft.AspNet.Mvc.Rendering /// A new containing the <input> element. /// /// - /// Combines and to set - /// <input> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <input> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// /// Determines element's "value" attribute based on the following precedence: @@ -439,17 +445,17 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Determines <input> element's "checked" attribute based on the following precedence: /// /// - /// entry for (converted to a + /// entry for (converted to a /// fully-qualified name) if entry exists and can be converted to a . /// /// Existing "checked" entry in if any. /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// @@ -464,18 +470,18 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public static HtmlString RadioButton( [NotNull] this IHtmlHelper htmlHelper, - string name, + string expression, object value, object htmlAttributes) { - return htmlHelper.RadioButton(name, value, isChecked: null, htmlAttributes: htmlAttributes); + return htmlHelper.RadioButton(expression, value, isChecked: null, htmlAttributes: htmlAttributes); } /// - /// Returns an <input> element of type "radio" for the specified expression . + /// Returns an <input> element of type "radio" for the specified . /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// /// If non-null, value to include in the element. Must not be null if /// is also null. @@ -487,8 +493,8 @@ namespace Microsoft.AspNet.Mvc.Rendering /// A new containing the <input> element. /// /// - /// Combines and to set - /// <input> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <input> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// /// Determines element's "value" attribute based on the following precedence: @@ -499,18 +505,17 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Determines <input> element's "checked" attribute based on the following precedence: /// /// - /// entry for (converted to a + /// entry for (converted to a /// fully-qualified name) if entry exists and can be converted to a . /// /// if non-null. /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . - /// otherwise. + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// @@ -525,11 +530,11 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public static HtmlString RadioButton( [NotNull] this IHtmlHelper htmlHelper, - string name, + string expression, object value, bool isChecked) { - return htmlHelper.RadioButton(name, value, isChecked, htmlAttributes: null); + return htmlHelper.RadioButton(expression, value, isChecked, htmlAttributes: null); } /// @@ -539,7 +544,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// An expression to be evaluated against the current model. /// Value to include in the element. Must not be null. /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <input> element. /// /// @@ -565,79 +570,79 @@ namespace Microsoft.AspNet.Mvc.Rendering /// ; does not include the attribute otherwise. /// /// - public static HtmlString RadioButtonFor( + public static HtmlString RadioButtonFor( [NotNull] this IHtmlHelper htmlHelper, - [NotNull] Expression> expression, + [NotNull] Expression> expression, [NotNull] object value) { return htmlHelper.RadioButtonFor(expression, value, htmlAttributes: null); } /// - /// Returns an <input> element of type "text" for the specified expression . + /// Returns an <input> element of type "text" for the specified . /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// A new containing the <input> element. /// /// - /// Combines and to set - /// <input> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <input> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// /// Determines <input> element's "value" attribute based on the following precedence: /// /// - /// entry for (converted to a + /// entry for (converted to a /// fully-qualified name) if entry exists and can be converted to a . /// /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// /// Otherwise, string.Empty. /// /// - public static HtmlString TextBox([NotNull] this IHtmlHelper htmlHelper, string name) + public static HtmlString TextBox([NotNull] this IHtmlHelper htmlHelper, string expression) { - return htmlHelper.TextBox(name, value: null, format: null, htmlAttributes: null); + return htmlHelper.TextBox(expression, value: null, format: null, htmlAttributes: null); } /// - /// Returns an <input> element of type "text" for the specified expression . + /// Returns an <input> element of type "text" for the specified . /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// If non-null, value to include in the element. /// A new containing the <input> element. /// /// - /// Combines and to set - /// <input> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <input> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// /// Determines <input> element's "value" attribute based on the following precedence: /// /// - /// entry for (converted to a + /// entry for (converted to a /// fully-qualified name) if entry exists and can be converted to a . /// /// /// if non-null. /// /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// @@ -646,17 +651,17 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public static HtmlString TextBox( [NotNull] this IHtmlHelper htmlHelper, - string name, + string expression, object value) { - return htmlHelper.TextBox(name, value, format: null, htmlAttributes: null); + return htmlHelper.TextBox(expression, value, format: null, htmlAttributes: null); } /// - /// Returns an <input> element of type "text" for the specified expression . + /// Returns an <input> element of type "text" for the specified . /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// If non-null, value to include in the element. /// /// The composite format (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx). @@ -664,14 +669,14 @@ namespace Microsoft.AspNet.Mvc.Rendering /// A new containing the <input> element. /// /// - /// Combines and to set - /// <input> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <input> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// /// Determines <input> element's "value" attribute based on the following precedence: /// /// - /// entry for (converted to a + /// entry for (converted to a /// fully-qualified name) if entry exists and can be converted to a . /// /// @@ -680,13 +685,14 @@ namespace Microsoft.AspNet.Mvc.Rendering /// is null or empty. /// /// - /// entry for (converted to a fully-qualified name) if - /// entry exists and can be converted to a . Formats entry using - /// or converts entry to a directly if is null or empty. + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . Formats entry using + /// or converts entry to a directly if + /// is null or empty. /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. Formats result using or converts result to a /// directly if is null or empty. @@ -696,18 +702,18 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public static HtmlString TextBox( [NotNull] this IHtmlHelper htmlHelper, - string name, + string expression, object value, string format) { - return htmlHelper.TextBox(name, value, format, htmlAttributes: null); + return htmlHelper.TextBox(expression, value, format, htmlAttributes: null); } /// - /// Returns an <input> element of type "text" for the specified expression . + /// Returns an <input> element of type "text" for the specified . /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// If non-null, value to include in the element. /// /// An that contains the HTML attributes for the element. Alternatively, an @@ -717,26 +723,26 @@ namespace Microsoft.AspNet.Mvc.Rendering /// A new containing the <input> element. /// /// - /// Combines and to set - /// <input> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <input> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// /// Determines <input> element's "value" attribute based on the following precedence: /// /// - /// entry for (converted to a + /// entry for (converted to a /// fully-qualified name) if entry exists and can be converted to a . /// /// /// if non-null. /// /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// @@ -746,11 +752,11 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public static HtmlString TextBox( [NotNull] this IHtmlHelper htmlHelper, - string name, + string expression, object value, object htmlAttributes) { - return htmlHelper.TextBox(name, value, format: null, htmlAttributes: htmlAttributes); + return htmlHelper.TextBox(expression, value, format: null, htmlAttributes: htmlAttributes); } /// @@ -759,7 +765,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// The instance this method extends. /// An expression to be evaluated against the current model. /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <input> element. /// /// @@ -779,8 +785,9 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Otherwise, string.Empty. /// /// - public static HtmlString TextBoxFor([NotNull] this IHtmlHelper htmlHelper, - [NotNull] Expression> expression) + public static HtmlString TextBoxFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression) { return htmlHelper.TextBoxFor(expression, format: null, htmlAttributes: null); } @@ -794,7 +801,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// The composite format (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx). /// /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <input> element. /// /// @@ -816,8 +823,10 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Otherwise, string.Empty. /// /// - public static HtmlString TextBoxFor([NotNull] this IHtmlHelper htmlHelper, - [NotNull] Expression> expression, string format) + public static HtmlString TextBoxFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, + string format) { return htmlHelper.TextBoxFor(expression, format, htmlAttributes: null); } @@ -833,7 +842,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// attributes. /// /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <input> element. /// /// @@ -854,54 +863,57 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Otherwise, string.Empty. /// /// - public static HtmlString TextBoxFor([NotNull] this IHtmlHelper htmlHelper, - [NotNull] Expression> expression, object htmlAttributes) + public static HtmlString TextBoxFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, + object htmlAttributes) { return htmlHelper.TextBoxFor(expression, format: null, htmlAttributes: htmlAttributes); } /// - /// Returns a <textarea> element for the specified expression . + /// Returns a <textarea> element for the specified . /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// A new containing the <textarea> element. /// /// - /// Combines and to set - /// <textarea> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <textarea> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// /// Determines <textarea> element's content based on the following precedence: /// /// - /// entry for (converted to a + /// entry for (converted to a /// fully-qualified name) if entry exists and can be converted to a . /// /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// /// Otherwise, string.Empty. /// /// - public static HtmlString TextArea([NotNull] this IHtmlHelper htmlHelper, - string name) + public static HtmlString TextArea( + [NotNull] this IHtmlHelper htmlHelper, + string expression) { - return htmlHelper.TextArea(name, value: null, rows: 0, columns: 0, htmlAttributes: null); + return htmlHelper.TextArea(expression, value: null, rows: 0, columns: 0, htmlAttributes: null); } /// - /// Returns a <textarea> element for the specified expression . + /// Returns a <textarea> element for the specified . /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// /// An that contains the HTML attributes for the element. Alternatively, an /// instance containing the HTML @@ -910,79 +922,83 @@ namespace Microsoft.AspNet.Mvc.Rendering /// A new containing the <textarea> element. /// /// - /// Combines and to set - /// <textarea> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <textarea> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// /// Determines <textarea> element's content based on the following precedence: /// /// - /// entry for (converted to a + /// entry for (converted to a /// fully-qualified name) if entry exists and can be converted to a . /// /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// /// Otherwise, string.Empty. /// /// - public static HtmlString TextArea([NotNull] this IHtmlHelper htmlHelper, - string name, object htmlAttributes) + public static HtmlString TextArea( + [NotNull] this IHtmlHelper htmlHelper, + string expression, + object htmlAttributes) { - return htmlHelper.TextArea(name, value: null, rows: 0, columns: 0, htmlAttributes: htmlAttributes); + return htmlHelper.TextArea(expression, value: null, rows: 0, columns: 0, htmlAttributes: htmlAttributes); } /// - /// Returns a <textarea> element for the specified expression . + /// Returns a <textarea> element for the specified . /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// If non-null, value to include in the element. /// A new containing the <textarea> element. /// /// - /// Combines and to set - /// <textarea> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <textarea> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// /// Determines <textarea> element's content based on the following precedence: /// /// - /// entry for (converted to a + /// entry for (converted to a /// fully-qualified name) if entry exists and can be converted to a . /// /// if non-null. /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// /// Otherwise, string.Empty. /// /// - public static HtmlString TextArea([NotNull] this IHtmlHelper htmlHelper, - string name, string value) + public static HtmlString TextArea( + [NotNull] this IHtmlHelper htmlHelper, + string expression, + string value) { - return htmlHelper.TextArea(name, value, rows: 0, columns: 0, htmlAttributes: null); + return htmlHelper.TextArea(expression, value, rows: 0, columns: 0, htmlAttributes: null); } /// - /// Returns a <textarea> element for the specified expression . + /// Returns a <textarea> element for the specified . /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// If non-null, value to include in the element. /// /// An that contains the HTML attributes for the element. Alternatively, an @@ -992,34 +1008,37 @@ namespace Microsoft.AspNet.Mvc.Rendering /// A new containing the <textarea> element. /// /// - /// Combines and to set - /// <textarea> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <textarea> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// /// Determines <textarea> element's content based on the following precedence: /// /// - /// entry for (converted to a + /// entry for (converted to a /// fully-qualified name) if entry exists and can be converted to a . /// /// if non-null. /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// /// Otherwise, string.Empty. /// /// - public static HtmlString TextArea([NotNull] this IHtmlHelper htmlHelper, - string name, string value, object htmlAttributes) + public static HtmlString TextArea( + [NotNull] this IHtmlHelper htmlHelper, + string expression, + string value, + object htmlAttributes) { - return htmlHelper.TextArea(name, value, rows: 0, columns: 0, htmlAttributes: htmlAttributes); + return htmlHelper.TextArea(expression, value, rows: 0, columns: 0, htmlAttributes: htmlAttributes); } /// @@ -1028,7 +1047,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// The instance this method extends. /// An expression to be evaluated against the current model. /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <textarea> element. /// /// @@ -1048,8 +1067,9 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Otherwise, string.Empty. /// /// - public static HtmlString TextAreaFor([NotNull] this IHtmlHelper htmlHelper, - [NotNull] Expression> expression) + public static HtmlString TextAreaFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression) { return htmlHelper.TextAreaFor(expression, rows: 0, columns: 0, htmlAttributes: null); } @@ -1065,7 +1085,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// attributes. /// /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <textarea> element. /// /// @@ -1085,8 +1105,10 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Otherwise, string.Empty. /// /// - public static HtmlString TextAreaFor([NotNull] this IHtmlHelper htmlHelper, - [NotNull] Expression> expression, object htmlAttributes) + public static HtmlString TextAreaFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, + object htmlAttributes) { return htmlHelper.TextAreaFor(expression, rows: 0, columns: 0, htmlAttributes: htmlAttributes); } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLabelExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLabelExtensions.cs index d5c4ead307..789a1b07c1 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLabelExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLabelExtensions.cs @@ -12,64 +12,64 @@ namespace Microsoft.AspNet.Mvc.Rendering public static class HtmlHelperLabelExtensions { /// - /// Returns a <label> element for the specified expression . + /// Returns a <label> element for the specified . /// - /// The instance this method extends. + /// The instance this method extends. /// Expression name, relative to the current model. /// A new containing the <label> element. - public static HtmlString Label([NotNull] this IHtmlHelper html, string expression) + public static HtmlString Label([NotNull] this IHtmlHelper htmlHelper, string expression) { - return html.Label(expression, - labelText: null, - htmlAttributes: null); + return htmlHelper.Label(expression, labelText: null, htmlAttributes: null); } /// - /// Returns a <label> element for the specified expression . + /// Returns a <label> element for the specified . /// - /// The instance this method extends. + /// The instance this method extends. /// Expression name, relative to the current model. /// The inner text of the element. /// A new containing the <label> element. - public static HtmlString Label([NotNull] this IHtmlHelper html, string expression, string labelText) + public static HtmlString Label([NotNull] this IHtmlHelper htmlHelper, string expression, string labelText) { - return html.Label(expression, labelText, htmlAttributes: null); + return htmlHelper.Label(expression, labelText, htmlAttributes: null); } /// /// Returns a <label> element for the specified . /// - /// The instance this method extends. + /// The instance this method extends. /// An expression to be evaluated against the current model. /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <label> element. - public static HtmlString LabelFor([NotNull] this IHtmlHelper html, - [NotNull] Expression> expression) + public static HtmlString LabelFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression) { - return html.LabelFor(expression, labelText: null, htmlAttributes: null); + return htmlHelper.LabelFor(expression, labelText: null, htmlAttributes: null); } /// /// Returns a <label> element for the specified . /// - /// The instance this method extends. + /// The instance this method extends. /// An expression to be evaluated against the current model. /// The inner text of the element. /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <label> element. - public static HtmlString LabelFor([NotNull] this IHtmlHelper html, - [NotNull] Expression> expression, - string labelText) + public static HtmlString LabelFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, + string labelText) { - return html.LabelFor(expression, labelText, htmlAttributes: null); + return htmlHelper.LabelFor(expression, labelText, htmlAttributes: null); } /// /// Returns a <label> element for the specified . /// - /// The instance this method extends. + /// The instance this method extends. /// An expression to be evaluated against the current model. /// /// An that contains the HTML attributes for the element. Alternatively, an @@ -77,55 +77,56 @@ namespace Microsoft.AspNet.Mvc.Rendering /// attributes. /// /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <label> element. - public static HtmlString LabelFor([NotNull] this IHtmlHelper html, - [NotNull] Expression> expression, - object htmlAttributes) + public static HtmlString LabelFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, + object htmlAttributes) { - return html.LabelFor(expression, labelText: null, htmlAttributes: htmlAttributes); + return htmlHelper.LabelFor(expression, labelText: null, htmlAttributes: htmlAttributes); } /// /// Returns a <label> element for the current model. /// - /// The instance this method extends. + /// The instance this method extends. /// A new containing the <label> element. - public static HtmlString LabelForModel([NotNull] this IHtmlHelper html) + public static HtmlString LabelForModel([NotNull] this IHtmlHelper htmlHelper) { - return html.Label(expression: null, labelText: null, htmlAttributes: null); + return htmlHelper.Label(expression: null, labelText: null, htmlAttributes: null); } /// /// Returns a <label> element for the current model. /// - /// The instance this method extends. + /// The instance this method extends. /// The inner text of the element. /// A new containing the <label> element. - public static HtmlString LabelForModel([NotNull] this IHtmlHelper html, string labelText) + public static HtmlString LabelForModel([NotNull] this IHtmlHelper htmlHelper, string labelText) { - return html.Label(expression: null, labelText: labelText, htmlAttributes: null); + return htmlHelper.Label(expression: null, labelText: labelText, htmlAttributes: null); } /// /// Returns a <label> element for the current model. /// - /// The instance this method extends. + /// The instance this method extends. /// /// An that contains the HTML attributes for the element. Alternatively, an /// instance containing the HTML /// attributes. /// /// A new containing the <label> element. - public static HtmlString LabelForModel([NotNull] this IHtmlHelper html, object htmlAttributes) + public static HtmlString LabelForModel([NotNull] this IHtmlHelper htmlHelper, object htmlAttributes) { - return html.Label(expression: null, labelText: null, htmlAttributes: htmlAttributes); + return htmlHelper.Label(expression: null, labelText: null, htmlAttributes: htmlAttributes); } /// /// Returns a <label> element for the current model. /// - /// The instance this method extends. + /// The instance this method extends. /// The inner text of the element. /// /// An that contains the HTML attributes for the element. Alternatively, an @@ -134,11 +135,11 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// A new containing the <label> element. public static HtmlString LabelForModel( - [NotNull] this IHtmlHelper html, + [NotNull] this IHtmlHelper htmlHelper, string labelText, object htmlAttributes) { - return html.Label(expression: null, labelText: labelText, htmlAttributes: htmlAttributes); + return htmlHelper.Label(expression: null, labelText: labelText, htmlAttributes: htmlAttributes); } } } \ No newline at end of file diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperNameExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperNameExtensions.cs index 946cfe8022..274d4bf641 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperNameExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperNameExtensions.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// A containing the element name. public static string NameForModel([NotNull] this IHtmlHelper htmlHelper) { - return htmlHelper.Name(name: null); + return htmlHelper.Name(expression: null); } /// @@ -25,7 +25,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// A containing the element Id. public static string IdForModel([NotNull] this IHtmlHelper htmlHelper) { - return htmlHelper.Id(name: null); + return htmlHelper.Id(expression: null); } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperSelectExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperSelectExtensions.cs index 7eef96d5ee..7631f49633 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperSelectExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperSelectExtensions.cs @@ -13,71 +13,78 @@ namespace Microsoft.AspNet.Mvc.Rendering public static class HtmlHelperSelectExtensions { /// - /// Returns a single-selection HTML <select> element for the expression . + /// Returns a single-selection HTML <select> element for the . /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// A new containing the <select> element. /// - /// Combines and to set - /// <select> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <select> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// - public static HtmlString DropDownList([NotNull] this IHtmlHelper htmlHelper, string name) + public static HtmlString DropDownList([NotNull] this IHtmlHelper htmlHelper, string expression) { - return htmlHelper.DropDownList(name, selectList: null, optionLabel: null, htmlAttributes: null); + return htmlHelper.DropDownList(expression, selectList: null, optionLabel: null, htmlAttributes: null); } /// - /// Returns a single-selection HTML <select> element for the expression , - /// using the option label. + /// Returns a single-selection HTML <select> element for the , using the + /// option label. /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// /// The text for a default empty item. Does not include such an item if argument is null. /// /// A new containing the <select> element. /// - /// Combines and to set - /// <select> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <select> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// - public static HtmlString DropDownList([NotNull] this IHtmlHelper htmlHelper, string name, string optionLabel) + public static HtmlString DropDownList( + [NotNull] this IHtmlHelper htmlHelper, + string expression, + string optionLabel) { - return htmlHelper.DropDownList(name, selectList: null, optionLabel: optionLabel, htmlAttributes: null); + return htmlHelper.DropDownList( + expression, + selectList: null, + optionLabel: optionLabel, + htmlAttributes: null); } /// - /// Returns a single-selection HTML <select> element for the expression , - /// using the specified list items. + /// Returns a single-selection HTML <select> element for the , using the + /// specified list items. /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// /// A collection of objects used to populate the <select> element with /// <optgroup> and <option> elements. /// /// A new containing the <select> element. /// - /// Combines and to set - /// <select> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <select> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// public static HtmlString DropDownList( [NotNull] this IHtmlHelper htmlHelper, - string name, + string expression, IEnumerable selectList) { - return htmlHelper.DropDownList(name, selectList, optionLabel: null, htmlAttributes: null); + return htmlHelper.DropDownList(expression, selectList, optionLabel: null, htmlAttributes: null); } /// - /// Returns a single-selection HTML <select> element for the expression , - /// using the specified list items and HTML attributes. + /// Returns a single-selection HTML <select> element for the , using the + /// specified list items and HTML attributes. /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// /// A collection of objects used to populate the <select> element with /// <optgroup> and <option> elements. @@ -88,25 +95,25 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// A new containing the <select> element. /// - /// Combines and to set - /// <select> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <select> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// public static HtmlString DropDownList( [NotNull] this IHtmlHelper htmlHelper, - string name, + string expression, IEnumerable selectList, object htmlAttributes) { - return htmlHelper.DropDownList(name, selectList, optionLabel: null, htmlAttributes: htmlAttributes); + return htmlHelper.DropDownList(expression, selectList, optionLabel: null, htmlAttributes: htmlAttributes); } /// - /// Returns a single-selection HTML <select> element for the expression , - /// using the specified list items and option label. + /// Returns a single-selection HTML <select> element for the , using the + /// specified list items and option label. /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// /// A collection of objects used to populate the <select> element with /// <optgroup> and <option> elements. @@ -116,17 +123,17 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// A new containing the <select> element. /// - /// Combines and to set - /// <select> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <select> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// public static HtmlString DropDownList( [NotNull] this IHtmlHelper htmlHelper, - string name, + string expression, IEnumerable selectList, string optionLabel) { - return htmlHelper.DropDownList(name, selectList, optionLabel, htmlAttributes: null); + return htmlHelper.DropDownList(expression, selectList, optionLabel, htmlAttributes: null); } /// @@ -140,15 +147,17 @@ namespace Microsoft.AspNet.Mvc.Rendering /// <optgroup> and <option> elements. /// /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <select> element. /// /// Combines and the string representation of the /// to set <select> element's "name" attribute. Sanitizes the string /// representation of the to set element's "id" attribute. /// - public static HtmlString DropDownListFor([NotNull] this IHtmlHelper htmlHelper, - [NotNull] Expression> expression, IEnumerable selectList) + public static HtmlString DropDownListFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, + IEnumerable selectList) { return htmlHelper.DropDownListFor(expression, selectList, optionLabel: null, htmlAttributes: null); } @@ -168,18 +177,23 @@ namespace Microsoft.AspNet.Mvc.Rendering /// instance containing the HTML attributes. /// /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <select> element. /// /// Combines and the string representation of the /// to set <select> element's "name" attribute. Sanitizes the string /// representation of the to set element's "id" attribute. /// - public static HtmlString DropDownListFor([NotNull] this IHtmlHelper htmlHelper, - [NotNull] Expression> expression, IEnumerable selectList, + public static HtmlString DropDownListFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, + IEnumerable selectList, object htmlAttributes) { - return htmlHelper.DropDownListFor(expression, selectList, optionLabel: null, + return htmlHelper.DropDownListFor( + expression, + selectList, + optionLabel: null, htmlAttributes: htmlAttributes); } @@ -197,58 +211,60 @@ namespace Microsoft.AspNet.Mvc.Rendering /// The text for a default empty item. Does not include such an item if argument is null. /// /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <select> element. /// /// Combines and the string representation of the /// to set <select> element's "name" attribute. Sanitizes the string /// representation of the to set element's "id" attribute. /// - public static HtmlString DropDownListFor([NotNull] this IHtmlHelper htmlHelper, - [NotNull] Expression> expression, IEnumerable selectList, + public static HtmlString DropDownListFor([ + NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, + IEnumerable selectList, string optionLabel) { return htmlHelper.DropDownListFor(expression, selectList, optionLabel, htmlAttributes: null); } /// - /// Returns a multi-selection <select> element for the expression . + /// Returns a multi-selection <select> element for the . /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// A new containing the <select> element. /// - /// Combines and to set - /// <select> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <select> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// - public static HtmlString ListBox([NotNull] this IHtmlHelper htmlHelper, string name) + public static HtmlString ListBox([NotNull] this IHtmlHelper htmlHelper, string expression) { - return htmlHelper.ListBox(name, selectList: null, htmlAttributes: null); + return htmlHelper.ListBox(expression, selectList: null, htmlAttributes: null); } /// - /// Returns a multi-selection <select> element for the expression , using the + /// Returns a multi-selection <select> element for the , using the /// specified list items. /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// /// A collection of objects used to populate the <select> element with /// <optgroup> and <option> elements. /// /// A new containing the <select> element. /// - /// Combines and to set - /// <select> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <select> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// public static HtmlString ListBox( [NotNull] this IHtmlHelper htmlHelper, - string name, + string expression, IEnumerable selectList) { - return htmlHelper.ListBox(name, selectList, htmlAttributes: null); + return htmlHelper.ListBox(expression, selectList, htmlAttributes: null); } /// @@ -262,16 +278,16 @@ namespace Microsoft.AspNet.Mvc.Rendering /// <optgroup> and <option> elements. /// /// The type of the model. - /// The type of the result. + /// The type of the result. /// A new containing the <select> element. /// /// Combines and the string representation of the /// to set <select> element's "name" attribute. Sanitizes the string /// representation of the to set element's "id" attribute. /// - public static HtmlString ListBoxFor( + public static HtmlString ListBoxFor( [NotNull] this IHtmlHelper htmlHelper, - [NotNull] Expression> expression, + [NotNull] Expression> expression, IEnumerable selectList) { return htmlHelper.ListBoxFor(expression, selectList, htmlAttributes: null); diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValidationExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValidationExtensions.cs index 7982c600e4..8c0c6d2872 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValidationExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValidationExtensions.cs @@ -13,20 +13,20 @@ namespace Microsoft.AspNet.Mvc.Rendering { /// /// Returns the validation message if an error exists in the - /// object for the specified expression . + /// object for the specified . /// /// The instance this method extends. /// Expression name, relative to the current model. /// /// A new containing a element. - /// null if the expression is valid and client-side validation is - /// disabled. + /// null if the is valid and client-side validation is disabled. /// /// /// Method extracts an error string from the object. Message /// will always be visible but client-side validation may update the associated CSS class. /// - public static HtmlString ValidationMessage([NotNull] this IHtmlHelper htmlHelper, + public static HtmlString ValidationMessage( + [NotNull] this IHtmlHelper htmlHelper, string expression) { return htmlHelper.ValidationMessage(expression, message: null, htmlAttributes: null, tag: null); @@ -34,7 +34,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// Returns the validation message if an error exists in the - /// object for the specified expression . + /// object for the specified . /// /// The instance this method extends. /// Expression name, relative to the current model. @@ -45,10 +45,10 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// /// A new containing a element. - /// null if the expression is valid and client-side validation is - /// disabled. + /// null if the is valid and client-side validation is disabled. /// - public static HtmlString ValidationMessage([NotNull] this IHtmlHelper htmlHelper, + public static HtmlString ValidationMessage( + [NotNull] this IHtmlHelper htmlHelper, string expression, string message) { @@ -57,7 +57,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// Returns the validation message if an error exists in the - /// object for the specified expression . + /// object for the specified . /// /// The instance this method extends. /// Expression name, relative to the current model. @@ -69,14 +69,14 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// /// A new containing a element. - /// null if the expression is valid and client-side validation is - /// disabled. + /// null if the is valid and client-side validation is disabled. /// /// /// Method extracts an error string from the object. Message /// will always be visible but client-side validation may update the associated CSS class. /// - public static HtmlString ValidationMessage([NotNull] this IHtmlHelper htmlHelper, + public static HtmlString ValidationMessage( + [NotNull] this IHtmlHelper htmlHelper, string expression, object htmlAttributes) { @@ -85,7 +85,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// Returns the validation message if an error exists in the - /// object for the specified expression . + /// object for the specified . /// /// The instance this method extends. /// Expression name, relative to the current model. @@ -100,9 +100,10 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// /// A new containing a element. null if the - /// expression is valid and client-side validation is disabled. + /// is valid and client-side validation is disabled. /// - public static HtmlString ValidationMessage([NotNull] this IHtmlHelper htmlHelper, + public static HtmlString ValidationMessage( + [NotNull] this IHtmlHelper htmlHelper, string expression, string message, string tag) @@ -112,7 +113,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// Returns the validation message if an error exists in the - /// object for the specified expression . + /// object for the specified . /// /// The instance this method extends. /// Expression name, relative to the current model. @@ -129,10 +130,10 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// /// A new containing a element. - /// null if the expression is valid and client-side validation is - /// disabled. + /// null if the is valid and client-side validation is disabled. /// - public static HtmlString ValidationMessage([NotNull] this IHtmlHelper htmlHelper, + public static HtmlString ValidationMessage( + [NotNull] this IHtmlHelper htmlHelper, string expression, string message, object htmlAttributes) @@ -147,18 +148,18 @@ namespace Microsoft.AspNet.Mvc.Rendering /// The instance this method extends. /// An expression to be evaluated against the current model. /// The type of the model. - /// The type of the result. + /// The type of the result. /// /// A new containing a element. - /// null if the expression is valid and client-side validation is - /// disabled. + /// null if the is valid and client-side validation is disabled. /// /// /// Method extracts an error string from the object. Message /// will always be visible but client-side validation may update the associated CSS class. /// - public static HtmlString ValidationMessageFor([NotNull] this IHtmlHelper htmlHelper, - [NotNull] Expression> expression) + public static HtmlString ValidationMessageFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression) { return htmlHelper.ValidationMessageFor(expression, message: null, htmlAttributes: null, tag: null); } @@ -175,14 +176,14 @@ namespace Microsoft.AspNet.Mvc.Rendering /// validation may update the associated CSS class. /// /// The type of the model. - /// The type of the result. + /// The type of the result. /// /// A new containing a element. - /// null if the expression is valid and client-side validation is - /// disabled. + /// null if the is valid and client-side validation is disabled. /// - public static HtmlString ValidationMessageFor([NotNull] this IHtmlHelper htmlHelper, - [NotNull] Expression> expression, + public static HtmlString ValidationMessageFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, string message) { return htmlHelper.ValidationMessageFor(expression, message, htmlAttributes: null, tag: null); @@ -206,14 +207,14 @@ namespace Microsoft.AspNet.Mvc.Rendering /// attributes. /// /// The type of the model. - /// The type of the result. + /// The type of the result. /// /// A new containing a element. - /// null if the expression is valid and client-side validation is - /// disabled. + /// null if the is valid and client-side validation is disabled. /// - public static HtmlString ValidationMessageFor([NotNull] this IHtmlHelper htmlHelper, - [NotNull] Expression> expression, + public static HtmlString ValidationMessageFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, string message, object htmlAttributes) { @@ -236,13 +237,14 @@ namespace Microsoft.AspNet.Mvc.Rendering /// . /// /// The type of the model. - /// The type of the result. + /// The type of the result. /// /// A new containing the element. null if the /// is valid and client-side validation is disabled. /// - public static HtmlString ValidationMessageFor([NotNull] this IHtmlHelper htmlHelper, - [NotNull] Expression> expression, + public static HtmlString ValidationMessageFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, string message, string tag) { @@ -260,7 +262,8 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper) { - return htmlHelper.ValidationSummary(excludePropertyErrors: false, + return htmlHelper.ValidationSummary( + excludePropertyErrors: false, message: null, htmlAttributes: null, tag: null); @@ -280,7 +283,8 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, bool excludePropertyErrors) { - return htmlHelper.ValidationSummary(excludePropertyErrors, + return htmlHelper.ValidationSummary( + excludePropertyErrors, message: null, htmlAttributes: null, tag: null); @@ -300,7 +304,8 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, string message) { - return htmlHelper.ValidationSummary(excludePropertyErrors: false, + return htmlHelper.ValidationSummary( + excludePropertyErrors: false, message: message, htmlAttributes: null, tag: null); @@ -323,7 +328,8 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, string message, string tag) { - return htmlHelper.ValidationSummary(excludePropertyErrors: false, + return htmlHelper.ValidationSummary( + excludePropertyErrors: false, message: message, htmlAttributes: null, tag: tag); @@ -344,11 +350,13 @@ namespace Microsoft.AspNet.Mvc.Rendering /// ) and the <ul> element. if the current model /// is valid and client-side validation is disabled). /// - public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, + public static HtmlString ValidationSummary( + [NotNull] this IHtmlHelper htmlHelper, bool excludePropertyErrors, string message) { - return htmlHelper.ValidationSummary(excludePropertyErrors, + return htmlHelper.ValidationSummary( + excludePropertyErrors, message, htmlAttributes: null, tag: null); @@ -371,12 +379,16 @@ namespace Microsoft.AspNet.Mvc.Rendering /// ) and the <ul> element. if the current model /// is valid and client-side validation is disabled). /// - public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, + public static HtmlString ValidationSummary( + [NotNull] this IHtmlHelper htmlHelper, string message, object htmlAttributes) { return htmlHelper.ValidationSummary( - excludePropertyErrors: false, message: message, htmlAttributes: htmlAttributes, tag: null); + excludePropertyErrors: false, + message: message, + htmlAttributes: htmlAttributes, + tag: null); } /// @@ -399,13 +411,17 @@ namespace Microsoft.AspNet.Mvc.Rendering /// and the <ul> element. if the current model is valid and client-side /// validation is disabled). /// - public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, + public static HtmlString ValidationSummary( + [NotNull] this IHtmlHelper htmlHelper, string message, object htmlAttributes, string tag) { return htmlHelper.ValidationSummary( - excludePropertyErrors: false, message: message, htmlAttributes: htmlAttributes, tag: tag); + excludePropertyErrors: false, + message: message, + htmlAttributes: htmlAttributes, + tag: tag); } /// @@ -426,12 +442,14 @@ namespace Microsoft.AspNet.Mvc.Rendering /// and the <ul> element. if the current model is valid and client-side /// validation is disabled). /// - public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, + public static HtmlString ValidationSummary( + [NotNull] this IHtmlHelper htmlHelper, bool excludePropertyErrors, string message, string tag) { - return htmlHelper.ValidationSummary(excludePropertyErrors, + return htmlHelper.ValidationSummary( + excludePropertyErrors, message, htmlAttributes: null, tag: tag); @@ -457,7 +475,8 @@ namespace Microsoft.AspNet.Mvc.Rendering /// ) and the <ul> element. if the current model /// is valid and client-side validation is disabled). /// - public static HtmlString ValidationSummary([NotNull] this IHtmlHelper htmlHelper, + public static HtmlString ValidationSummary( + [NotNull] this IHtmlHelper htmlHelper, bool excludePropertyErrors, string message, object htmlAttributes) diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValueExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValueExtensions.cs index d79b23b25c..7daa28bb18 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValueExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValueExtensions.cs @@ -12,17 +12,17 @@ namespace Microsoft.AspNet.Mvc.Rendering public static class HtmlHelperValueExtensions { /// - /// Returns the formatted value for the specified expression . + /// Returns the formatted value for the specified . /// /// The instance this method extends. - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// A containing the formatted value. /// /// Converts the expression result to a directly. /// - public static string Value([NotNull] this IHtmlHelper htmlHelper, string name) + public static string Value([NotNull] this IHtmlHelper htmlHelper, string expression) { - return htmlHelper.Value(name, format: null); + return htmlHelper.Value(expression, format: null); } /// @@ -31,14 +31,14 @@ namespace Microsoft.AspNet.Mvc.Rendering /// The instance this method extends. /// An expression to be evaluated against the current model. /// The type of the model. - /// The type of the result. + /// The type of the result. /// A containing the formatted value. /// /// Converts the result to a directly. /// - public static string ValueFor( + public static string ValueFor( [NotNull] this IHtmlHelper htmlHelper, - [NotNull] Expression> expression) + [NotNull] Expression> expression) { return htmlHelper.ValueFor(expression, format: null); } @@ -53,7 +53,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public static string ValueForModel([NotNull] this IHtmlHelper htmlHelper) { - return htmlHelper.Value(name: null, format: null); + return htmlHelper.Value(expression: null, format: null); } /// @@ -70,7 +70,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public static string ValueForModel([NotNull] this IHtmlHelper htmlHelper, string format) { - return htmlHelper.Value(name: null, format: format); + return htmlHelper.Value(expression: null, format: format); } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs index e45b53f680..fbe0047b64 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs @@ -143,7 +143,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Returns an <input> element of type "checkbox" with value "true" and an <input> element of type /// "hidden" with value "false". /// - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// If true, checkbox is initially checked. /// /// An that contains the HTML attributes for the checkbox element. Alternatively, an @@ -152,23 +152,24 @@ namespace Microsoft.AspNet.Mvc.Rendering /// A new containing the <input> elements. /// /// - /// Combines and to set checkbox - /// element's "name" attribute. Sanitizes to set checkbox element's "id" attribute. + /// Combines and to set checkbox + /// element's "name" attribute. Sanitizes to set checkbox element's "id" + /// attribute. /// /// Determines checkbox element's "checked" attribute based on the following precedence: /// /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// if non-null. /// - /// entry for (converted to a fully-qualified name) + /// entry for (converted to a fully-qualified name) /// if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// @@ -180,7 +181,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// value "checked" if the values is true; does not include the attribute otherwise. /// /// - HtmlString CheckBox(string name, bool? isChecked, object htmlAttributes); + HtmlString CheckBox(string expression, bool? isChecked, object htmlAttributes); /// /// Returns HTML markup for the , using a display template, specified HTML field @@ -219,27 +220,27 @@ namespace Microsoft.AspNet.Mvc.Rendering object additionalViewData); /// - /// Returns the display name for the specified expression . + /// Returns the display name for the specified . /// /// Expression name, relative to the current model. /// A containing the display name. string DisplayName(string expression); /// - /// Returns the simple display text for the specified expression . + /// Returns the simple display text for the specified . /// - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// /// A containing the simple display text. /// If the expression result is null, returns . /// - string DisplayText(string name); + string DisplayText(string expression); /// - /// Returns a single-selection HTML <select> element for the expression , + /// Returns a single-selection HTML <select> element for the , /// using the specified list items, option label, and HTML attributes. /// - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// /// A collection of objects used to populate the <select> element with /// <optgroup> and <option> elements. @@ -253,12 +254,12 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// A new containing the <select> element. /// - /// Combines and to set - /// <select> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <select> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// HtmlString DropDownList( - string name, + string expression, IEnumerable selectList, string optionLabel, object htmlAttributes); @@ -332,30 +333,30 @@ namespace Microsoft.AspNet.Mvc.Rendering string FormatValue(object value, string format); /// - /// Returns an HTML element Id for the specified expression . + /// Returns an HTML element Id for the specified expression . /// - /// + /// /// Fully-qualified expression name, ignoring the current model. Must not be null. /// /// A containing the element Id. - string GenerateIdFromName([NotNull] string name); + string GenerateIdFromName([NotNull] string fullName); /// /// Returns information about about client validation rules for the specified or - /// . Intended for use in extension methods. + /// . Intended for use in extension methods. /// /// Metadata about the of interest. - /// + /// /// Expression name, relative to the current model. Used to determine when /// is null; ignored otherwise. /// /// An containing the relevant rules. - IEnumerable GetClientValidationRules(ModelMetadata metadata, string name); + IEnumerable GetClientValidationRules(ModelMetadata metadata, string expression); /// - /// Returns an <input> element of type "hidden" for the specified expression . + /// Returns an <input> element of type "hidden" for the specified . /// - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// If non-null, value to include in the element. /// /// An that contains the HTML attributes for the element. Alternatively, an @@ -364,24 +365,24 @@ namespace Microsoft.AspNet.Mvc.Rendering /// A new containing the <input> element. /// /// - /// Combines and to set - /// <input> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <input> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// /// Determines <input> element's "value" attribute based on the following precedence: /// /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// if non-null. /// - /// entry for (converted to a fully-qualified name) + /// entry for (converted to a fully-qualified name) /// if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// @@ -389,17 +390,17 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Otherwise, string.Empty. /// /// - HtmlString Hidden(string name, object value, object htmlAttributes); + HtmlString Hidden(string expression, object value, object htmlAttributes); /// - /// Returns the HTML element Id for the specified expression . + /// Returns the HTML element Id for the specified . /// - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// A containing the element Id. - string Id(string name); + string Id(string expression); /// - /// Returns a <label> element for the specified expression . + /// Returns a <label> element for the specified . /// /// Expression name, relative to the current model. /// The inner text of the element. @@ -411,10 +412,10 @@ namespace Microsoft.AspNet.Mvc.Rendering HtmlString Label(string expression, string labelText, object htmlAttributes); /// - /// Returns a multi-selection <select> element for the expression , using the + /// Returns a multi-selection <select> element for the , using the /// specified list items and HTML attributes. /// - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// /// A collection of objects used to populate the <select> element with /// <optgroup> and <option> elements. @@ -425,18 +426,18 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// A new containing the <select> element. /// - /// Combines and to set - /// <select> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <select> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// - HtmlString ListBox(string name, IEnumerable selectList, object htmlAttributes); + HtmlString ListBox(string expression, IEnumerable selectList, object htmlAttributes); /// - /// Returns the full HTML element name for the specified expression . + /// Returns the full HTML element name for the specified . /// - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// A containing the element name. - string Name(string name); + string Name(string expression); /// /// Returns HTML markup for the specified partial view. @@ -453,9 +454,9 @@ namespace Microsoft.AspNet.Mvc.Rendering Task PartialAsync([NotNull] string partialViewName, object model, ViewDataDictionary viewData); /// - /// Returns an <input> element of type "password" for the specified expression . + /// Returns an <input> element of type "password" for the specified . /// - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// If non-null, value to include in the element. /// /// An that contains the HTML attributes for the element. Alternatively, an @@ -464,8 +465,8 @@ namespace Microsoft.AspNet.Mvc.Rendering /// A new containing the <input> element. /// /// - /// Combines and to set - /// <input> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <input> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// /// Determines <input> element's "value" attribute based on the following precedence: @@ -475,12 +476,12 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Otherwise, string.Empty. /// /// - HtmlString Password(string name, object value, object htmlAttributes); + HtmlString Password(string expression, object value, object htmlAttributes); /// - /// Returns an <input> element of type "radio" for the specified expression . + /// Returns an <input> element of type "radio" for the specified . /// - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// /// If non-null, value to include in the element. Must not be null if /// is also null and no "checked" entry exists in @@ -498,8 +499,8 @@ namespace Microsoft.AspNet.Mvc.Rendering /// A new containing the <input> element. /// /// - /// Combines and to set - /// <input> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <input> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// /// Determines element's "value" attribute based on the following precedence: @@ -511,18 +512,18 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Determines <input> element's "checked" attribute based on the following precedence: /// /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// if non-null. /// Existing "checked" entry in if any. /// - /// entry for (converted to a fully-qualified name) + /// entry for (converted to a fully-qualified name) /// if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// @@ -535,7 +536,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// the attribute otherwise. /// /// - HtmlString RadioButton(string name, object value, bool? isChecked, object htmlAttributes); + HtmlString RadioButton(string expression, object value, bool? isChecked, object htmlAttributes); /// /// Wraps HTML markup in an , without HTML-encoding the specified @@ -596,9 +597,9 @@ namespace Microsoft.AspNet.Mvc.Rendering object htmlAttributes); /// - /// Returns a <textarea> element for the specified expression . + /// Returns a <textarea> element for the specified . /// - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// If non-null, value to include in the element. /// Number of rows in the textarea. /// Number of columns in the textarea. @@ -609,36 +610,36 @@ namespace Microsoft.AspNet.Mvc.Rendering /// A new containing the <textarea> element. /// /// - /// Combines and to set - /// <textarea> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <textarea> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// /// Determines <textarea> element's content based on the following precedence: /// /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// if non-null. /// - /// entry for (converted to a fully-qualified name) + /// entry for (converted to a fully-qualified name) /// if entry exists and can be converted to a . /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. /// /// Otherwise, string.Empty. /// /// - HtmlString TextArea(string name, string value, int rows, int columns, object htmlAttributes); + HtmlString TextArea(string expression, string value, int rows, int columns, object htmlAttributes); /// - /// Returns an <input> element of type "text" for the specified expression . + /// Returns an <input> element of type "text" for the specified . /// - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// If non-null, value to include in the element. /// /// The composite format (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx). @@ -650,15 +651,15 @@ namespace Microsoft.AspNet.Mvc.Rendering /// A new containing the <input> element. /// /// - /// Combines and to set - /// <input> element's "name" attribute. Sanitizes to set element's "id" + /// Combines and to set + /// <input> element's "name" attribute. Sanitizes to set element's "id" /// attribute. /// /// Determines <input> element's "value" attribute based on the following precedence: /// /// - /// entry for (converted to a fully-qualified name) - /// if entry exists and can be converted to a . + /// entry for (converted to a fully-qualified + /// name) if entry exists and can be converted to a . /// /// /// if non-null. Formats using @@ -666,13 +667,13 @@ namespace Microsoft.AspNet.Mvc.Rendering /// is null or empty. /// /// - /// entry for (converted to a fully-qualified name) if entry + /// entry for (converted to a fully-qualified name) if entry /// exists and can be converted to a . Formats entry using or /// converts entry to a directly if is null or empty. /// /// - /// Linq expression based on (converted to a fully-qualified name) run against current - /// model if result is non-null and can be converted to a . For example + /// Linq expression based on (converted to a fully-qualified name) run against + /// current model if result is non-null and can be converted to a . For example /// string.Empty identifies the current model and "prop" identifies the current model's "prop" /// property. Formats result using or converts result to a /// directly if is null or empty. @@ -681,13 +682,13 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Otherwise, string.Empty. /// /// - HtmlString TextBox(string name, object value, string format, object htmlAttributes); + HtmlString TextBox(string current, object value, string format, object htmlAttributes); /// /// Returns the validation message if an error exists in the object - /// for the specified expression . + /// for the specified . /// - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// /// The message to be displayed. If null or empty, method extracts an error string from the /// object. Message will always be visible but client-side validation may @@ -703,9 +704,9 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// /// A new containing a element. null if the - /// expression is valid and client-side validation is disabled. + /// is valid and client-side validation is disabled. /// - HtmlString ValidationMessage(string modelName, string message, object htmlAttributes, string tag); + HtmlString ValidationMessage(string expression, string message, object htmlAttributes, string tag); /// /// Returns an unordered list (<ul> element) of validation messages that are in the @@ -735,9 +736,9 @@ namespace Microsoft.AspNet.Mvc.Rendering string tag); /// - /// Returns the formatted value for the specified expression . + /// Returns the formatted value for the specified . /// - /// Expression name, relative to the current model. + /// Expression name, relative to the current model. /// /// The composite format (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx). /// @@ -746,6 +747,6 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Converts the expression result to a directly if /// is null or empty. /// - string Value(string name, string format); + string Value(string expression, string format); } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelperOfT.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelperOfT.cs index ef823912f5..6b5b65fbf1 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelperOfT.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelperOfT.cs @@ -70,24 +70,25 @@ namespace Microsoft.AspNet.Mvc.Rendering /// view data that will be merged into the instance created for the /// template. /// - /// The type of the result. + /// The type of the result. /// A new containing the created HTML. /// /// For example the default display template includes markup for each property in the /// result. /// - HtmlString DisplayFor([NotNull] Expression> expression, - string templateName, - string htmlFieldName, - object additionalViewData); + HtmlString DisplayFor( + [NotNull] Expression> expression, + string templateName, + string htmlFieldName, + object additionalViewData); /// /// Returns the display name for the specified . /// /// An expression to be evaluated against the current model. - /// The type of the result. + /// The type of the result. /// A containing the display name. - string DisplayNameFor([NotNull] Expression> expression); + string DisplayNameFor([NotNull] Expression> expression); /// /// Returns the display name for the specified @@ -95,22 +96,22 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// An expression to be evaluated against an item in the current model. /// The type of items in the model collection. - /// The type of the result. + /// The type of the result. /// A containing the display name. - string DisplayNameForInnerType( - [NotNull] Expression> expression); + string DisplayNameForInnerType( + [NotNull] Expression> expression); /// /// Returns the simple display text for the specified . /// /// An expression to be evaluated against the current model. - /// The type of the result. + /// The type of the result. /// /// A containing the simple display text. /// If the result is null, returns /// . /// - string DisplayTextFor([NotNull] Expression> expression); + string DisplayTextFor([NotNull] Expression> expression); /// /// Returns a single-selection HTML <select> element for the , using the @@ -128,15 +129,15 @@ namespace Microsoft.AspNet.Mvc.Rendering /// An that contains the HTML attributes for the <select> element. Alternatively, an /// instance containing the HTML attributes. /// - /// The type of the result. + /// The type of the result. /// A new containing the <select> element. /// /// Combines and the string representation of the /// to set <select> element's "name" attribute. Sanitizes the string /// representation of the to set element's "id" attribute. /// - HtmlString DropDownListFor( - [NotNull] Expression> expression, + HtmlString DropDownListFor( + [NotNull] Expression> expression, IEnumerable selectList, string optionLabel, object htmlAttributes); @@ -157,13 +158,14 @@ namespace Microsoft.AspNet.Mvc.Rendering /// view data that will be merged into the instance created for the /// template. /// - /// The type of the result. + /// The type of the result. /// A new containing the <input> element(s). /// /// For example the default editor template includes <label> and <input> /// elements for each property in the result. /// - HtmlString EditorFor([NotNull] Expression> expression, + HtmlString EditorFor( + [NotNull] Expression> expression, string templateName, string htmlFieldName, object additionalViewData); @@ -176,7 +178,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// An that contains the HTML attributes for the element. Alternatively, an /// instance containing the HTML attributes. /// - /// The type of the result. + /// The type of the result. /// A new containing the <input> element. /// /// @@ -198,16 +200,17 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Otherwise, string.Empty. /// /// - HtmlString HiddenFor([NotNull] Expression> expression, + HtmlString HiddenFor( + [NotNull] Expression> expression, object htmlAttributes); /// /// Returns the HTML element Id for the specified . /// /// An expression to be evaluated against the current model. - /// The type of the result. + /// The type of the result. /// A containing the element Id. - string IdFor([NotNull] Expression> expression); + string IdFor([NotNull] Expression> expression); /// /// Returns a <label> element for the specified . @@ -218,11 +221,12 @@ namespace Microsoft.AspNet.Mvc.Rendering /// An that contains the HTML attributes for the element. Alternatively, an /// instance containing the HTML attributes. /// - /// The type of the result. + /// The type of the result. /// A new containing the <label> element. - HtmlString LabelFor([NotNull] Expression> expression, - string labelText, - object htmlAttributes); + HtmlString LabelFor( + [NotNull] Expression> expression, + string labelText, + object htmlAttributes); /// /// Returns a multi-selection <select> element for the , using the @@ -237,15 +241,15 @@ namespace Microsoft.AspNet.Mvc.Rendering /// An that contains the HTML attributes for the <select> element. Alternatively, an /// instance containing the HTML attributes. /// - /// The type of the result. + /// The type of the result. /// A new containing the <select> element. /// /// Combines and the string representation of the /// to set <select> element's "name" attribute. Sanitizes the string /// representation of the to set element's "id" attribute. /// - HtmlString ListBoxFor( - [NotNull] Expression> expression, + HtmlString ListBoxFor( + [NotNull] Expression> expression, IEnumerable selectList, object htmlAttributes); @@ -253,9 +257,9 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Returns the full HTML element name for the specified . /// /// An expression to be evaluated against the current model. - /// The type of the result. + /// The type of the result. /// A containing the element name. - string NameFor([NotNull] Expression> expression); + string NameFor([NotNull] Expression> expression); /// /// Returns an <input> element of type "password" for the specified . @@ -265,7 +269,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// An that contains the HTML attributes for the element. Alternatively, an /// instance containing the HTML attributes. /// - /// The type of the result. + /// The type of the result. /// A new containing the <input> element. /// /// @@ -283,7 +287,8 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Otherwise, string.Empty. /// /// - HtmlString PasswordFor([NotNull] Expression> expression, + HtmlString PasswordFor( + [NotNull] Expression> expression, object htmlAttributes); /// @@ -295,7 +300,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// An that contains the HTML attributes for the element. Alternatively, an /// instance containing the HTML attributes. /// - /// The type of the result. + /// The type of the result. /// A new containing the <input> element. /// /// @@ -322,8 +327,8 @@ namespace Microsoft.AspNet.Mvc.Rendering /// ; does not include the attribute otherwise. /// /// - HtmlString RadioButtonFor( - [NotNull] Expression> expression, + HtmlString RadioButtonFor( + [NotNull] Expression> expression, [NotNull] object value, object htmlAttributes); @@ -337,7 +342,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// An that contains the HTML attributes for the element. Alternatively, an /// instance containing the HTML attributes. /// - /// The type of the result. + /// The type of the result. /// A new containing the <textarea> element. /// /// @@ -357,8 +362,11 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Otherwise, string.Empty. /// /// - HtmlString TextAreaFor([NotNull] Expression> expression, - int rows, int columns, object htmlAttributes); + HtmlString TextAreaFor( + [NotNull] Expression> expression, + int rows, + int columns, + object htmlAttributes); /// /// Returns an <input> element of type "text" for the specified . @@ -371,7 +379,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// An that contains the HTML attributes for the element. Alternatively, an /// instance containing the HTML attributes. /// - /// The type of the result. + /// The type of the result. /// A new containing the <input> element. /// /// @@ -394,7 +402,9 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Otherwise, string.Empty. /// /// - HtmlString TextBoxFor([NotNull] Expression> expression, string format, + HtmlString TextBoxFor( + [NotNull] Expression> expression, + string format, object htmlAttributes); /// @@ -415,12 +425,13 @@ namespace Microsoft.AspNet.Mvc.Rendering /// The tag to wrap the in the generated HTML. Its default value is /// . /// - /// The type of the result. + /// The type of the result. /// /// A new containing the element. null if the /// is valid and client-side validation is disabled. /// - HtmlString ValidationMessageFor([NotNull] Expression> expression, + HtmlString ValidationMessageFor( + [NotNull] Expression> expression, string message, object htmlAttributes, string tag); @@ -432,12 +443,14 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// The composite format (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx). /// - /// The type of the result. + /// The type of the result. /// A containing the formatted value. /// /// Converts the result to a directly if /// is null or empty. /// - string ValueFor([NotNull] Expression> expression, string format); + string ValueFor( + [NotNull] Expression> expression, + string format); } } diff --git a/src/Microsoft.AspNet.Mvc.TagHelpers/SelectTagHelper.cs b/src/Microsoft.AspNet.Mvc.TagHelpers/SelectTagHelper.cs index e28fb59aa1..790b00c42f 100644 --- a/src/Microsoft.AspNet.Mvc.TagHelpers/SelectTagHelper.cs +++ b/src/Microsoft.AspNet.Mvc.TagHelpers/SelectTagHelper.cs @@ -98,7 +98,7 @@ namespace Microsoft.AspNet.Mvc.TagHelpers ViewContext, For.Metadata, optionLabel: null, - name: For.Name, + expression: For.Name, selectList: items, allowMultiple: allowMultiple, htmlAttributes: null, diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperDisplayTextTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperDisplayTextTest.cs index 905b5cbd86..cf2d4824df 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperDisplayTextTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperDisplayTextTest.cs @@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Mvc.Rendering var helper = DefaultTemplatesUtilities.GetHtmlHelper(model: null); // Act - var result = helper.DisplayText(name: string.Empty); + var result = helper.DisplayText(expression: string.Empty); // Assert Assert.Empty(result); @@ -47,7 +47,7 @@ namespace Microsoft.AspNet.Mvc.Rendering helper.ViewData.ModelMetadata.NullDisplayText = "Null display Text"; // Act - var result = helper.DisplayText(name: string.Empty); + var result = helper.DisplayText(expression: string.Empty); // Assert Assert.Equal("Null display Text", result); @@ -75,8 +75,8 @@ namespace Microsoft.AspNet.Mvc.Rendering var helper = DefaultTemplatesUtilities.GetHtmlHelper(model); // Act - var result = helper.DisplayText(name: string.Empty); - var nullResult = helper.DisplayText(name: null); // null is another alias for current model + var result = helper.DisplayText(expression: string.Empty); + var nullResult = helper.DisplayText(expression: null); // null is another alias for current model // Assert Assert.Equal("Model value", result); @@ -120,7 +120,7 @@ namespace Microsoft.AspNet.Mvc.Rendering helper.ViewData.ModelMetadata.SimpleDisplayText = "Simple display text"; // Act - var result = helper.DisplayText(name: string.Empty); + var result = helper.DisplayText(expression: string.Empty); // Assert Assert.Equal("Simple display text", result); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperHiddenTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperHiddenTest.cs index 330e3b3e34..56e49c14dd 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperHiddenTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperHiddenTest.cs @@ -290,7 +290,7 @@ namespace Microsoft.AspNet.Mvc.Rendering // Act and Assert ExceptionAssert.ThrowsArgumentNullOrEmpty(() => helper.Hidden(string.Empty, string.Empty, attributes), - "name"); + "expression"); } [Fact] diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperNameExtensionsTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperNameExtensionsTest.cs index d0cec8393d..7a80dd34d9 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperNameExtensionsTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperNameExtensionsTest.cs @@ -21,12 +21,12 @@ namespace Microsoft.AspNet.Mvc.Core var helper = DefaultTemplatesUtilities.GetHtmlHelper(); // Act - var idResult = helper.Id(name: string.Empty); - var idNullResult = helper.Id(name: null); // null is another alias for current model + var idResult = helper.Id(expression: string.Empty); + var idNullResult = helper.Id(expression: null); // null is another alias for current model var idForResult = helper.IdFor(m => m); var idForModelResult = helper.IdForModel(); - var nameResult = helper.Name(name: string.Empty); - var nameNullResult = helper.Name(name: null); + var nameResult = helper.Name(expression: string.Empty); + var nameNullResult = helper.Name(expression: null); var nameForResult = helper.NameFor(m => m); var nameForModelResult = helper.NameForModel(); @@ -54,10 +54,10 @@ namespace Microsoft.AspNet.Mvc.Core helper.ViewData.TemplateInfo.HtmlFieldPrefix = prefix; // Act - var idResult = helper.Id(name: string.Empty); + var idResult = helper.Id(expression: string.Empty); var idForResult = helper.IdFor(m => m); var idForModelResult = helper.IdForModel(); - var nameResult = helper.Name(name: string.Empty); + var nameResult = helper.Name(expression: string.Empty); var nameForResult = helper.NameFor(m => m); var nameForModelResult = helper.NameForModel(); @@ -149,10 +149,10 @@ namespace Microsoft.AspNet.Mvc.Core var helper = DefaultTemplatesUtilities.GetHtmlHelper(provider.Object); // Act (do not throw) - var idResult = helper.Id(name: string.Empty); + var idResult = helper.Id(expression: string.Empty); var idForResult = helper.IdFor(m => m); var idForModelResult = helper.IdForModel(); - var nameResult = helper.Name(name: string.Empty); + var nameResult = helper.Name(expression: string.Empty); var nameForResult = helper.NameFor(m => m); var nameForModelResult = helper.NameForModel(); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperPasswordTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperPasswordTest.cs index 1d76883ec2..8a3c8e639b 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperPasswordTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperPasswordTest.cs @@ -130,7 +130,7 @@ namespace Microsoft.AspNet.Mvc.Rendering // Act and Assert ExceptionAssert.ThrowsArgumentNullOrEmpty(() => helper.Password(name, value, htmlAttributes: null), - "name"); + "expression"); } [Fact] diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperValueExtensionsTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperValueExtensionsTest.cs index 73028c093c..6f05c1afaf 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperValueExtensionsTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperValueExtensionsTest.cs @@ -91,8 +91,8 @@ namespace Microsoft.AspNet.Mvc.Core "{ StringProperty = ModelStringPropertyValue, ObjectProperty = 01/01/1900 00:00:00 }"; // Act & Assert - Assert.Equal(expectedModelValue, helper.Value(name: string.Empty)); - Assert.Equal(expectedModelValue, helper.Value(name: null)); // null is another alias for current model + Assert.Equal(expectedModelValue, helper.Value(expression: string.Empty)); + Assert.Equal(expectedModelValue, helper.Value(expression: null)); // null is another alias for current model Assert.Equal(expectedModelValue, helper.ValueFor(m => m)); Assert.Equal(expectedModelValue, helper.ValueForModel()); }