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
{
/// <summary>
/// Default implementation of <see cref="IHtmlHelper">.
/// Default implementation of <see cref="IHtmlHelper"/>.
/// </summary>
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);
}

View File

@ -188,8 +188,10 @@ namespace Microsoft.AspNet.Mvc.Rendering
}
/// <inheritdoc />
public HtmlString RadioButtonFor<TProperty>([NotNull] Expression<Func<TModel, TProperty>> expression,
object value, object htmlAttributes)
public HtmlString RadioButtonFor<TProperty>(
[NotNull] Expression<Func<TModel, TProperty>> expression,
[NotNull] object value,
object htmlAttributes)
{
var metadata = GetModelMetadata(expression);
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);
}
public static HtmlString RadioButtonFor<TModel, TProperty>([NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TProperty>> expression, object value)
public static HtmlString RadioButtonFor<TModel, TProperty>(
[NotNull] this IHtmlHelper<TModel> htmlHelper,
[NotNull] Expression<Func<TModel, TProperty>> expression,
[NotNull] object value)
{
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.
/// </param>
/// <param name="value">
/// If non-<c>null</c>, 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.
/// </param>
/// <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.
/// </param>
/// <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);
/// <summary>