diff --git a/samples/MvcSample.Web/Views/Shared/EditorTemplates/Decimal.cshtml b/samples/MvcSample.Web/Views/Shared/EditorTemplates/Decimal.cshtml index 5b580266a2..ee875197ef 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: string.Empty, + name: 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/Html/DefaultEditorTemplates.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultEditorTemplates.cs index c0c58f9694..78f23cece9 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultEditorTemplates.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/DefaultEditorTemplates.cs @@ -32,15 +32,20 @@ namespace Microsoft.AspNet.Mvc.Rendering private static string BooleanTemplateCheckbox(IHtmlHelper html, bool value) { - return html.CheckBox(string.Empty, value, CreateHtmlAttributes(html, "check-box")).ToString(); + return html.CheckBox( + name: null, + isChecked: value, + htmlAttributes: CreateHtmlAttributes(html, "check-box")) + .ToString(); } private static string BooleanTemplateDropDownList(IHtmlHelper html, bool? value) { return html.DropDownList( - string.Empty, - DefaultDisplayTemplates.TriStateValues(value), - CreateHtmlAttributes(html, "list-box tri-state")) + name: null, + selectList: DefaultDisplayTemplates.TriStateValues(value), + optionLabel: null, + htmlAttributes: CreateHtmlAttributes(html, "list-box tri-state")) .ToString(); } @@ -144,7 +149,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } var htmlAttributesObject = viewData[HtmlAttributeKey]; - var hiddenResult = html.Hidden(string.Empty, model, htmlAttributesObject); + var hiddenResult = html.Hidden(name: null, value: model, htmlAttributes: htmlAttributesObject); result += hiddenResult.ToString(); return result; @@ -262,9 +267,10 @@ namespace Microsoft.AspNet.Mvc.Rendering public static string PasswordTemplate(IHtmlHelper html) { - return html.Password(string.Empty, - html.ViewData.TemplateInfo.FormattedModelValue, - CreateHtmlAttributes(html, "text-box single-line password")) + return html.Password( + name: null, + value: html.ViewData.TemplateInfo.FormattedModelValue, + htmlAttributes: CreateHtmlAttributes(html, "text-box single-line password")) .ToString(); } @@ -356,8 +362,9 @@ namespace Microsoft.AspNet.Mvc.Rendering private static string GenerateTextBox(IHtmlHelper html, string inputType, object value) { return html.TextBox( - name: string.Empty, + name: null, value: value, + format: null, htmlAttributes: CreateHtmlAttributes(html, className: "text-box single-line", inputType: inputType)) .ToString(); } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs index 3d63d93ba8..48fddceffb 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs @@ -18,7 +18,7 @@ using Microsoft.AspNet.Mvc.Rendering.Expressions; namespace Microsoft.AspNet.Mvc.Rendering { /// - /// Default implementation of non-generic portions of . + /// Default implementation of . /// public class HtmlHelper : IHtmlHelper, ICanHasViewContext { @@ -482,7 +482,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public string Value([NotNull] string name, string format) + public string Value(string name, string format) { return GenerateValue(name, value: null, format: format, useViewData: true); } @@ -1275,7 +1275,7 @@ namespace Microsoft.AspNet.Mvc.Rendering } else if (useViewData) { - if (name.Length == 0) + if (string.IsNullOrEmpty(name)) { // case 2(a): format the value from ModelMetadata for the current model var metadata = ViewData.ModelMetadata; diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs index 281ab758cc..c1a8055b19 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayExtensions.cs @@ -90,19 +90,18 @@ namespace Microsoft.AspNet.Mvc.Rendering public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html) { - return html.Display(expression: string.Empty, templateName: null, htmlFieldName: null, - additionalViewData: null); + return html.Display(expression: null, templateName: null, htmlFieldName: null, additionalViewData: null); } public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html, object additionalViewData) { - return html.Display(expression: string.Empty, templateName: null, htmlFieldName: null, + return html.Display(expression: null, templateName: null, htmlFieldName: null, additionalViewData: additionalViewData); } public static HtmlString DisplayForModel([NotNull] this IHtmlHelper html, string templateName) { - return html.Display(expression: string.Empty, templateName: templateName, htmlFieldName: null, + return html.Display(expression: null, templateName: templateName, htmlFieldName: null, additionalViewData: null); } @@ -111,7 +110,7 @@ namespace Microsoft.AspNet.Mvc.Rendering string templateName, object additionalViewData) { - return html.Display(expression: string.Empty, templateName: templateName, htmlFieldName: null, + return html.Display(expression: null, templateName: templateName, htmlFieldName: null, additionalViewData: additionalViewData); } @@ -120,7 +119,7 @@ namespace Microsoft.AspNet.Mvc.Rendering string templateName, string htmlFieldName) { - return html.Display(expression: string.Empty, templateName: templateName, htmlFieldName: htmlFieldName, + return html.Display(expression: null, templateName: templateName, htmlFieldName: htmlFieldName, additionalViewData: null); } @@ -130,7 +129,7 @@ namespace Microsoft.AspNet.Mvc.Rendering string htmlFieldName, object additionalViewData) { - return html.Display(expression: string.Empty, templateName: templateName, htmlFieldName: htmlFieldName, + return html.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 71c1903e2d..27aba0b848 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayNameExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperDisplayNameExtensions.cs @@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// A containing the display name. public static string DisplayNameForModel([NotNull] this IHtmlHelper htmlHelper) { - return htmlHelper.DisplayName(string.Empty); + return htmlHelper.DisplayName(expression: null); } /// diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperEditorExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperEditorExtensions.cs index 6dbc2c6755..2fe3a53783 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperEditorExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperEditorExtensions.cs @@ -8,100 +8,101 @@ namespace Microsoft.AspNet.Mvc.Rendering { public static class EditorExtensions { - public static HtmlString Editor(this IHtmlHelper html, string expression) + public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression) { return html.Editor(expression, templateName: null, htmlFieldName: null, additionalViewData: null); } - public static HtmlString Editor(this IHtmlHelper html, string expression, object additionalViewData) + public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, object additionalViewData) { return html.Editor(expression, templateName: null, htmlFieldName: null, additionalViewData: additionalViewData); } - public static HtmlString Editor(this IHtmlHelper html, string expression, string templateName) + public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, string templateName) { return html.Editor(expression, templateName, htmlFieldName: null, additionalViewData: null); } - public static HtmlString Editor(this IHtmlHelper html, string expression, string templateName, + public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, string templateName, object additionalViewData) { return html.Editor(expression, templateName, htmlFieldName: null, additionalViewData: additionalViewData); } - public static HtmlString Editor(this IHtmlHelper html, string expression, string templateName, + public static HtmlString Editor([NotNull] this IHtmlHelper html, string expression, string templateName, string htmlFieldName) { return html.Editor(expression, templateName, htmlFieldName, additionalViewData: null); } - public static HtmlString EditorFor(this IHtmlHelper html, - Expression> expression) + public static HtmlString EditorFor([NotNull] this IHtmlHelper html, + [NotNull] Expression> expression) { return html.EditorFor(expression, templateName: null, htmlFieldName: null, additionalViewData: null); } - public static HtmlString EditorFor(this IHtmlHelper html, - Expression> expression, object additionalViewData) + public static HtmlString EditorFor([NotNull] this IHtmlHelper html, + [NotNull] Expression> expression, object additionalViewData) { return html.EditorFor(expression, templateName: null, htmlFieldName: null, additionalViewData: additionalViewData); } - public static HtmlString EditorFor(this IHtmlHelper html, - Expression> expression, string templateName) + public static HtmlString EditorFor([NotNull] this IHtmlHelper html, + [NotNull] Expression> expression, string templateName) { return html.EditorFor(expression, templateName, htmlFieldName: null, additionalViewData: null); } - public static HtmlString EditorFor(this IHtmlHelper html, - Expression> expression, string templateName, object additionalViewData) + public static HtmlString EditorFor([NotNull] this IHtmlHelper html, + [NotNull] Expression> expression, string templateName, object additionalViewData) { return html.EditorFor(expression, templateName, htmlFieldName: null, additionalViewData: additionalViewData); } - public static HtmlString EditorFor(this IHtmlHelper html, - Expression> expression, string templateName, string htmlFieldName) + public static HtmlString EditorFor([NotNull] this IHtmlHelper html, + [NotNull] Expression> expression, string templateName, string htmlFieldName) { return html.EditorFor(expression, templateName, htmlFieldName, additionalViewData: null); } - public static HtmlString EditorForModel(this IHtmlHelper html) + public static HtmlString EditorForModel([NotNull] this IHtmlHelper html) { - return html.Editor(expression: string.Empty, templateName: null, htmlFieldName: null, - additionalViewData: null); + return html.Editor(expression: null, templateName: null, htmlFieldName: null, additionalViewData: null); } - public static HtmlString EditorForModel(this IHtmlHelper html, object additionalViewData) + public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, object additionalViewData) { - return html.Editor(expression: string.Empty, templateName: null, htmlFieldName: null, + return html.Editor(expression: null, templateName: null, htmlFieldName: null, additionalViewData: additionalViewData); } - public static HtmlString EditorForModel(this IHtmlHelper html, string templateName) + public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName) { - return html.Editor(expression: string.Empty, templateName: templateName, htmlFieldName: null, + return html.Editor(expression: null, templateName: templateName, htmlFieldName: null, additionalViewData: null); } - public static HtmlString EditorForModel(this IHtmlHelper html, string templateName, object additionalViewData) - { - return html.Editor(expression: string.Empty, templateName: templateName, htmlFieldName: null, - additionalViewData: additionalViewData); - } - - public static HtmlString EditorForModel(this IHtmlHelper html, string templateName, string htmlFieldName) - { - return html.Editor(expression: string.Empty, templateName: templateName, htmlFieldName: htmlFieldName, - additionalViewData: null); - } - - public static HtmlString EditorForModel(this IHtmlHelper html, string templateName, string htmlFieldName, + public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName, object additionalViewData) { - return html.Editor(expression: string.Empty, templateName: templateName, htmlFieldName: htmlFieldName, + return html.Editor(expression: null, templateName: templateName, htmlFieldName: null, + additionalViewData: additionalViewData); + } + + public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName, + string htmlFieldName) + { + return html.Editor(expression: null, templateName: templateName, htmlFieldName: htmlFieldName, + additionalViewData: null); + } + + public static HtmlString EditorForModel([NotNull] this IHtmlHelper html, string templateName, + string htmlFieldName, object additionalViewData) + { + return html.Editor(expression: null, templateName: templateName, htmlFieldName: htmlFieldName, additionalViewData: additionalViewData); } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLabelExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLabelExtensions.cs index c6b4c316ab..a54cf52511 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLabelExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperLabelExtensions.cs @@ -47,12 +47,12 @@ namespace Microsoft.AspNet.Mvc.Rendering public static HtmlString LabelForModel([NotNull] this IHtmlHelper html, string labelText) { - return html.Label(expression: string.Empty, labelText: labelText, htmlAttributes: null); + return html.Label(expression: null, labelText: labelText, htmlAttributes: null); } public static HtmlString LabelForModel([NotNull] this IHtmlHelper html, object htmlAttributes) { - return html.Label(expression: string.Empty, labelText: null, htmlAttributes: htmlAttributes); + return html.Label(expression: null, labelText: null, htmlAttributes: htmlAttributes); } public static HtmlString LabelForModel( @@ -60,7 +60,7 @@ namespace Microsoft.AspNet.Mvc.Rendering string labelText, object htmlAttributes) { - return html.Label(expression: string.Empty, labelText: labelText, htmlAttributes: htmlAttributes); + return html.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 569597ed98..1765112a06 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(string.Empty); + return htmlHelper.Name(name: 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(string.Empty); + return htmlHelper.Id(name: null); } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValueExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValueExtensions.cs index 4056d8af81..24d7e02767 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValueExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperValueExtensions.cs @@ -53,7 +53,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// public static string ValueForModel([NotNull] this IHtmlHelper htmlHelper) { - return htmlHelper.Value(name: string.Empty, format: null); + return htmlHelper.Value(name: 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: string.Empty, format: format); + return htmlHelper.Value(name: null, format: format); } } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs index 534be8083a..af73a3005a 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelper.cs @@ -236,7 +236,7 @@ namespace Microsoft.AspNet.Mvc.Rendering /// /// The name of the HTML element. /// The ID of the HTML element. - string GenerateIdFromName(string name); + string GenerateIdFromName([NotNull] string name); /// /// Returns information about about client validation rules for the given or @@ -491,6 +491,6 @@ namespace Microsoft.AspNet.Mvc.Rendering /// Converts the expression result to a directly if /// is null or empty. /// - string Value([NotNull] string name, string format); + string Value(string name, string format); } } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperDisplayNameExtensionsTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperDisplayNameExtensionsTest.cs index 551899f7f5..a8d6ce154b 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperDisplayNameExtensionsTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperDisplayNameExtensionsTest.cs @@ -24,7 +24,7 @@ namespace Microsoft.AspNet.Mvc.Core DefaultTemplatesUtilities.GetHtmlHelper>(null); // Act - var displayNameResult = helper.DisplayName(""); + var displayNameResult = helper.DisplayName(expression: string.Empty); var displayNameNullResult = helper.DisplayName(expression: null); // null is another alias for current model var displayNameForResult = helper.DisplayNameFor(m => m); var displayNameForEnumerableModelResult = enumerableHelper.DisplayNameFor(m => m); @@ -96,7 +96,7 @@ namespace Microsoft.AspNet.Mvc.Core enumerableHelper.ViewData.ModelMetadata = metadata; // Act - var displayNameResult = helper.DisplayName(""); + var displayNameResult = helper.DisplayName(expression: string.Empty); var displayNameForResult = helper.DisplayNameFor(m => m); var displayNameForEnumerableResult = enumerableHelper.DisplayNameFor(m => m); var displayNameForModelResult = helper.DisplayNameForModel(); @@ -153,7 +153,7 @@ namespace Microsoft.AspNet.Mvc.Core enumerableHelper.ViewData.ModelMetadata.DisplayName = displayName; // Act - var displayNameResult = helper.DisplayName(""); + var displayNameResult = helper.DisplayName(expression: string.Empty); var displayNameForResult = helper.DisplayNameFor(m => m); var displayNameForEnumerableResult = enumerableHelper.DisplayNameFor(m => m); var displayNameForModelResult = helper.DisplayNameForModel(); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperDisplayTextTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperDisplayTextTest.cs index 232a6a0dec..011df639d8 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.Core var helper = DefaultTemplatesUtilities.GetHtmlHelper(model: null); // Act - var result = helper.DisplayText(""); + var result = helper.DisplayText(name: string.Empty); // Assert Assert.Empty(result); @@ -47,7 +47,7 @@ namespace Microsoft.AspNet.Mvc.Core helper.ViewData.ModelMetadata.NullDisplayText = "Null display Text"; // Act - var result = helper.DisplayText(""); + var result = helper.DisplayText(name: string.Empty); // Assert Assert.Equal("Null display Text", result); @@ -75,10 +75,12 @@ namespace Microsoft.AspNet.Mvc.Core var helper = DefaultTemplatesUtilities.GetHtmlHelper(model); // Act - var result = helper.DisplayText(""); + var result = helper.DisplayText(name: string.Empty); + var nullResult = helper.DisplayText(name: null); // null is another alias for current model // Assert Assert.Equal("Model value", result); + Assert.Equal("Model value", nullResult); } [Fact] @@ -118,7 +120,7 @@ namespace Microsoft.AspNet.Mvc.Core helper.ViewData.ModelMetadata.SimpleDisplayText = "Simple display text"; // Act - var result = helper.DisplayText(""); + var result = helper.DisplayText(name: string.Empty); // Assert Assert.Equal("Simple display text", result); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperLabelExtensionsTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperLabelExtensionsTest.cs index 1113e3770a..342379932c 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperLabelExtensionsTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperLabelExtensionsTest.cs @@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Mvc.Core var helper = DefaultTemplatesUtilities.GetHtmlHelper(); // Act - var labelResult = helper.Label(""); + var labelResult = helper.Label(expression: string.Empty); var labelNullResult = helper.Label(expression: null); // null is another alias for current model var labelForResult = helper.LabelFor(m => m); var labelForModelResult = helper.LabelForModel(); @@ -79,7 +79,7 @@ namespace Microsoft.AspNet.Mvc.Core helper.ViewData.ModelMetadata = metadata; // Act - var labelResult = helper.Label(""); + var labelResult = helper.Label(expression: string.Empty); var labelNullResult = helper.Label(expression: null); // null is another alias for current model var labelForResult = helper.LabelFor(m => m); var labelForModelResult = helper.LabelForModel(); @@ -108,7 +108,7 @@ namespace Microsoft.AspNet.Mvc.Core helper.ViewData.ModelMetadata = metadata; // Act - var labelResult = helper.Label(""); + var labelResult = helper.Label(expression: string.Empty); var labelForResult = helper.LabelFor(m => m); var labelForModelResult = helper.LabelForModel(); @@ -152,7 +152,7 @@ namespace Microsoft.AspNet.Mvc.Core helper.ViewData.ModelMetadata.DisplayName = string.Empty; // Act - var labelResult = helper.Label(""); + var labelResult = helper.Label(expression: string.Empty); var labelNullResult = helper.Label(expression: null); // null is another alias for current model var labelForResult = helper.LabelFor(m => m); var labelForModelResult = helper.LabelForModel(); @@ -174,7 +174,7 @@ namespace Microsoft.AspNet.Mvc.Core helper.ViewData.ModelMetadata.DisplayName = displayName; // Act - var labelResult = helper.Label(""); + var labelResult = helper.Label(expression: string.Empty); var labelForResult = helper.LabelFor(m => m); var labelForModelResult = helper.LabelForModel(); @@ -195,7 +195,7 @@ namespace Microsoft.AspNet.Mvc.Core var helper = DefaultTemplatesUtilities.GetHtmlHelper(metadataHelper.MetadataProvider.Object); // Act - var labelResult = helper.Label(""); + var labelResult = helper.Label(expression: string.Empty); var labelNullResult = helper.Label(expression: null); // null is another alias for current model var labelForResult = helper.LabelFor(m => m); var labelForModelResult = helper.LabelForModel(); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperNameExtensionsTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperNameExtensionsTest.cs index 2c775bae2a..5944e8ae66 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperNameExtensionsTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperNameExtensionsTest.cs @@ -25,11 +25,11 @@ namespace Microsoft.AspNet.Mvc.Core var helper = DefaultTemplatesUtilities.GetHtmlHelper(); // Act - var idResult = helper.Id(""); + var idResult = helper.Id(name: string.Empty); var idNullResult = helper.Id(name: null); // null is another alias for current model var idForResult = helper.IdFor(m => m); var idForModelResult = helper.IdForModel(); - var nameResult = helper.Name(""); + var nameResult = helper.Name(name: string.Empty); var nameNullResult = helper.Name(name: null); var nameForResult = helper.NameFor(m => m); var nameForModelResult = helper.NameForModel(); @@ -58,10 +58,10 @@ namespace Microsoft.AspNet.Mvc.Core helper.ViewData.TemplateInfo.HtmlFieldPrefix = prefix; // Act - var idResult = helper.Id(""); + var idResult = helper.Id(name: string.Empty); var idForResult = helper.IdFor(m => m); var idForModelResult = helper.IdForModel(); - var nameResult = helper.Name(""); + var nameResult = helper.Name(name: string.Empty); var nameForResult = helper.NameFor(m => m); var nameForModelResult = helper.NameForModel(); @@ -152,10 +152,10 @@ namespace Microsoft.AspNet.Mvc.Core var helper = DefaultTemplatesUtilities.GetHtmlHelper(provider.Object); // Act (do not throw) - var idResult = helper.Id(""); + var idResult = helper.Id(name: string.Empty); var idForResult = helper.IdFor(m => m); var idForModelResult = helper.IdForModel(); - var nameResult = helper.Name(""); + var nameResult = helper.Name(name: string.Empty); var nameForResult = helper.NameFor(m => m); var nameForModelResult = helper.NameForModel(); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperValueExtensionsTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperValueExtensionsTest.cs index e8dbdfd082..209aee8b12 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperValueExtensionsTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Rendering/HtmlHelperValueExtensionsTest.cs @@ -94,6 +94,7 @@ namespace Microsoft.AspNet.Mvc.Core // 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.ValueFor(m => m)); Assert.Equal(expectedModelValue, helper.ValueForModel()); }