From 147b4416b518b2e38ad5120c7c503f4a6c974a78 Mon Sep 17 00:00:00 2001 From: dougbu Date: Thu, 7 Aug 2014 10:59:09 -0700 Subject: [PATCH] Correct gaps in PR #934 - correct XML comment typo introduced in `HtmlHelper` in 56d66c090eaedc33e4838437e7611ba2b9ca8929 (bad merge) - fix missed `null` requirement for `@Html.RadioButtonFor()` and remove buried `null` check - add back `Environment.Newline` to `@Html.TextArea()` (was dropped though comment wasn't) --- .../Rendering/Html/HtmlHelper.cs | 12 +++++------- .../Rendering/Html/HtmlHelperOfT.cs | 6 ++++-- .../Rendering/HtmlHelperInputExtensions.cs | 6 ++++-- .../Rendering/IHtmlHelperOfT.cs | 7 ++++--- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelper.cs index 48fddceffb..b10421fb8f 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 . + /// Default implementation of . /// public class HtmlHelper : IHtmlHelper, ICanHasViewContext { @@ -814,11 +814,9 @@ namespace Microsoft.AspNet.Mvc.Rendering { // RadioButtonFor() case. That API does not support passing isChecked directly. Contract.Assert(!isChecked.HasValue); - if (value == null) - { - // Need a value to determine isChecked. - throw new ArgumentNullException("value"); - } + + // Need a value to determine isChecked. + Contract.Assert(value != null); var model = metadata.Model; var valueString = Convert.ToString(value, CultureInfo.CurrentCulture); @@ -981,7 +979,7 @@ namespace Microsoft.AspNet.Mvc.Rendering // The first newline is always trimmed when a TextArea is rendered, so we add an extra one // in case the value being rendered is something like "\r\nHello". - tagBuilder.InnerHtml = WebUtility.HtmlEncode(value); + tagBuilder.InnerHtml = Environment.NewLine + WebUtility.HtmlEncode(value); return tagBuilder.ToHtmlString(TagRenderMode.Normal); } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelperOfT.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelperOfT.cs index 814f2cc879..499e6b4dbe 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelperOfT.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/Html/HtmlHelperOfT.cs @@ -188,8 +188,10 @@ namespace Microsoft.AspNet.Mvc.Rendering } /// - public HtmlString RadioButtonFor([NotNull] Expression> expression, - object value, object htmlAttributes) + public HtmlString RadioButtonFor( + [NotNull] Expression> expression, + [NotNull] object value, + object htmlAttributes) { var metadata = GetModelMetadata(expression); return GenerateRadioButton(metadata, GetExpressionName(expression), value, isChecked: null, diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperInputExtensions.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperInputExtensions.cs index 05ea4e1825..4167966776 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperInputExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/HtmlHelperInputExtensions.cs @@ -99,8 +99,10 @@ namespace Microsoft.AspNet.Mvc.Rendering return htmlHelper.RadioButton(name, value, isChecked, htmlAttributes: null); } - public static HtmlString RadioButtonFor([NotNull] this IHtmlHelper htmlHelper, - [NotNull] Expression> expression, object value) + public static HtmlString RadioButtonFor( + [NotNull] this IHtmlHelper htmlHelper, + [NotNull] Expression> expression, + [NotNull] object value) { return htmlHelper.RadioButtonFor(expression, value, htmlAttributes: null); } diff --git a/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelperOfT.cs b/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelperOfT.cs index 70ae46687a..5e9eb055ff 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelperOfT.cs +++ b/src/Microsoft.AspNet.Mvc.Core/Rendering/IHtmlHelperOfT.cs @@ -212,14 +212,15 @@ namespace Microsoft.AspNet.Mvc.Rendering /// An expression that identifies the object that contains the properties to render. /// /// - /// If non-null, value to compare with current expression value to determine whether radio button is - /// checked. + /// Value to compare with current expression value to determine whether radio button is checked. /// /// An object that contains the HTML attributes to set for the element. /// Alternatively, an instance containing the HTML attributes. /// /// New containing the rendered HTML. - HtmlString RadioButtonFor([NotNull] Expression> expression, object value, + HtmlString RadioButtonFor( + [NotNull] Expression> expression, + [NotNull] object value, object htmlAttributes); ///