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.
This commit is contained in:
Thiez 2019-06-12 18:33:52 +02:00 committed by Pranav K
parent 6c806f91b1
commit db72ea04a2
1 changed files with 4 additions and 8 deletions

View File

@ -17,23 +17,19 @@ namespace Microsoft.AspNetCore.Mvc.Routing
/// <summary> /// <summary>
/// Creates a new <see cref="HttpMethodAttribute"/> with the given /// Creates a new <see cref="HttpMethodAttribute"/> with the given
/// set of HTTP methods. /// set of HTTP methods.
/// <param name="httpMethods">The set of supported HTTP methods.</param> /// <param name="httpMethods">The set of supported HTTP methods. May not be null.</param>
/// </summary> /// </summary>
public HttpMethodAttribute(IEnumerable<string> httpMethods) public HttpMethodAttribute(IEnumerable<string> httpMethods)
: this(httpMethods, null) : this(httpMethods, null)
{ {
if (httpMethods == null)
{
throw new ArgumentNullException(nameof(httpMethods));
}
} }
/// <summary> /// <summary>
/// Creates a new <see cref="HttpMethodAttribute"/> with the given /// Creates a new <see cref="HttpMethodAttribute"/> with the given
/// set of HTTP methods an the given route template. /// set of HTTP methods an the given route template.
/// </summary> /// </summary>
/// <param name="httpMethods">The set of supported methods.</param> /// <param name="httpMethods">The set of supported methods. May not be null.</param>
/// <param name="template">The route template. May not be null.</param> /// <param name="template">The route template.</param>
public HttpMethodAttribute(IEnumerable<string> httpMethods, string template) public HttpMethodAttribute(IEnumerable<string> httpMethods, string template)
{ {
if (httpMethods == null) if (httpMethods == null)
@ -69,4 +65,4 @@ namespace Microsoft.AspNetCore.Mvc.Routing
/// <inheritdoc /> /// <inheritdoc />
public string Name { get; set; } public string Name { get; set; }
} }
} }