Skip to content

Commit db72ea0

Browse files
Thiezpranavkm
authored andcommitted
Fix incorrect documentation, parameter check for HttpMethodAttribute (#11133)
The second constructor of the `HttpMethodAttribute` class claims that the `template` parameter may not be `null`, and no such claim is present about the `httpMethods` parameter. However, when `httpMethods` is `null`, an exception is thrown, while `template` *is* allowed to be null (as can be seen in the `HttpMethodAttribute(IEnumerable<string>)` constructor, which passes `null`. In addition, the `HttpMethodAttribute(IEnumerable<string>)` constructor contains a `null`-check for the `httpMethods` parameter, but since this check is *also* in the `HttpMethodAttribute(IEnumerable<string>, string)` constructor this check is dead code.
1 parent 6c806f9 commit db72ea0

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/Mvc/Mvc.Core/src/Routing/HttpMethodAttribute.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,19 @@ public abstract class HttpMethodAttribute : Attribute, IActionHttpMethodProvider
1717
/// <summary>
1818
/// Creates a new <see cref="HttpMethodAttribute"/> with the given
1919
/// set of HTTP methods.
20-
/// <param name="httpMethods">The set of supported HTTP methods.</param>
20+
/// <param name="httpMethods">The set of supported HTTP methods. May not be null.</param>
2121
/// </summary>
2222
public HttpMethodAttribute(IEnumerable<string> httpMethods)
2323
: this(httpMethods, null)
2424
{
25-
if (httpMethods == null)
26-
{
27-
throw new ArgumentNullException(nameof(httpMethods));
28-
}
2925
}
3026

3127
/// <summary>
3228
/// Creates a new <see cref="HttpMethodAttribute"/> with the given
3329
/// set of HTTP methods an the given route template.
3430
/// </summary>
35-
/// <param name="httpMethods">The set of supported methods.</param>
36-
/// <param name="template">The route template. May not be null.</param>
31+
/// <param name="httpMethods">The set of supported methods. May not be null.</param>
32+
/// <param name="template">The route template.</param>
3733
public HttpMethodAttribute(IEnumerable<string> httpMethods, string template)
3834
{
3935
if (httpMethods == null)
@@ -69,4 +65,4 @@ public int Order
6965
/// <inheritdoc />
7066
public string Name { get; set; }
7167
}
72-
}
68+
}

0 commit comments

Comments
 (0)