-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Make HTML helper null
handling consistent
#934
Conversation
Rebased and made a small addition to the commit description. Otherwise unchanged. |
@@ -231,7 +231,7 @@ public interface IHtmlHelper | |||
/// </summary> | |||
/// <param name="name">The name of the HTML element.</param> | |||
/// <returns>The ID of the HTML element.</returns> | |||
string GenerateIdFromName(string name); | |||
string GenerateIdFromName([NotNull] string name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going back to #765, this might not make sense. The presence of [NotNull]
on an interface doesn't guarantee the implementation would have a NotNull.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👎 We're not fixing #765 right now and the rest of this interface uses [NotNull]
. We should be consistent.
In any case those uses aren't really about guaranteeing an implementation has the same attribute (though a compiler extension or analysis tool that did that would be nice as well). More about complaints an analysis tool might make if it notices a potentially-null
string
passed to this method.
- #874 lines 3, 4, and 6 - correct `Value()` to treat a `null` expression name the same as `string.Empty` - add missing `[NotNull]` attributes in `EditorExtensions` and for `GenerateIdFromName()` - consistently pass `null` for default expression names to the helpers - for example, from extension methods - add test cases using `null` for expression name nits: - correct summary XML comment for `HtmlHelper` class - use named parameters and prefer interface (not extension) methods in changed calls - use `string.Empty` instead of `""` in a few tests
- correct XML comment typo introduced in `HtmlHelper` in 56d66c0 (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)
- correct XML comment typo introduced in `HtmlHelper` in 56d66c0 (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)
- correct XML comment typo introduced in `HtmlHelper` in 56d66c0 (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)
IHtmlHelper
,HtmlHelper
, et cetera public API; correct inconsistencies #874 lines 3, 4, and 6Value()
to treat anull
expression name the same asstring.Empty
[NotNull]
attributes inEditorExtensions
and forGenerateIdFromName()
null
for default expression names to the helpersnull
for expression namenits:
HtmlHelper
class