Correct gaps in PR #934

- correct XML comment typo introduced in `HtmlHelper` in 56d66c090e (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)
This commit is contained in:
dougbu 2014-08-07 10:59:09 -07:00
parent cd3e1da219
commit 147b4416b5
4 changed files with 17 additions and 14 deletions

View File

@ -18,7 +18,7 @@ using Microsoft.AspNet.Mvc.Rendering.Expressions;
namespace Microsoft.AspNet.Mvc.Rendering namespace Microsoft.AspNet.Mvc.Rendering
{ {
/// <summary> /// <summary>
/// Default implementation of <see cref="IHtmlHelper">. /// Default implementation of <see cref="IHtmlHelper"/>.
/// </summary> /// </summary>
public class HtmlHelper : IHtmlHelper, ICanHasViewContext public class HtmlHelper : IHtmlHelper, ICanHasViewContext
{ {
@ -814,11 +814,9 @@ namespace Microsoft.AspNet.Mvc.Rendering
{ {
// RadioButtonFor() case. That API does not support passing isChecked directly. // RadioButtonFor() case. That API does not support passing isChecked directly.
Contract.Assert(!isChecked.HasValue); Contract.Assert(!isChecked.HasValue);
if (value == null)
{ // Need a value to determine isChecked.
// Need a value to determine isChecked. Contract.Assert(value != null);
throw new ArgumentNullException("value");
}
var model = metadata.Model; var model = metadata.Model;
var valueString = Convert.ToString(value, CultureInfo.CurrentCulture); 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 // 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". // 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); return tagBuilder.ToHtmlString(TagRenderMode.Normal);
} }

View File

@ -188,8 +188,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
} }
/// <inheritdoc /> /// <inheritdoc />
public HtmlString RadioButtonFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression, public HtmlString RadioButtonFor<TProperty>(
object value, object htmlAttributes) [NotNull] Expression<Func<TModel, TProperty>> expression,
[NotNull] object value,
object htmlAttributes)
{ {
var metadata = GetModelMetadata(expression); var metadata = GetModelMetadata(expression);
return GenerateRadioButton(metadata, GetExpressionName(expression), value, isChecked: null, return GenerateRadioButton(metadata, GetExpressionName(expression), value, isChecked: null,

View File

@ -99,8 +99,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
return htmlHelper.RadioButton(name, value, isChecked, htmlAttributes: null); return htmlHelper.RadioButton(name, value, isChecked, htmlAttributes: null);
} }
public static HtmlString RadioButtonFor<TModel, TProperty>([NotNull] this IHtmlHelper<TModel> htmlHelper, public static HtmlString RadioButtonFor<TModel, TProperty>(
[NotNull] Expression<Func<TModel, TProperty>> expression, object value) [NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TProperty>> expression,
[NotNull] object value)
{ {
return htmlHelper.RadioButtonFor(expression, value, htmlAttributes: null); return htmlHelper.RadioButtonFor(expression, value, htmlAttributes: null);
} }

View File

@ -212,14 +212,15 @@ namespace Microsoft.AspNet.Mvc.Rendering
/// An expression that identifies the object that contains the properties to render. /// An expression that identifies the object that contains the properties to render.
/// </param> /// </param>
/// <param name="value"> /// <param name="value">
/// If non-<c>null</c>, value to compare with current expression value to determine whether radio button is /// Value to compare with current expression value to determine whether radio button is checked.
/// checked.
/// </param> /// </param>
/// <param name="htmlAttributes">An object that contains the HTML attributes to set for the element. /// <param name="htmlAttributes">An object that contains the HTML attributes to set for the element.
/// Alternatively, an <see cref="IDictionary{string, object}"/> instance containing the HTML attributes. /// Alternatively, an <see cref="IDictionary{string, object}"/> instance containing the HTML attributes.
/// </param> /// </param>
/// <returns>New <see cref="HtmlString"/> containing the rendered HTML.</returns> /// <returns>New <see cref="HtmlString"/> containing the rendered HTML.</returns>
HtmlString RadioButtonFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression, object value, HtmlString RadioButtonFor<TProperty>(
[NotNull] Expression<Func<TModel, TProperty>> expression,
[NotNull] object value,
object htmlAttributes); object htmlAttributes);
/// <summary> /// <summary>