From db72ea04a2e12fa98ab4638c6c4ba05ac418fbd6 Mon Sep 17 00:00:00 2001 From: Thiez Date: Wed, 12 Jun 2019 18:33:52 +0200 Subject: [PATCH] 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)` constructor, which passes `null`. In addition, the `HttpMethodAttribute(IEnumerable)` constructor contains a `null`-check for the `httpMethods` parameter, but since this check is *also* in the `HttpMethodAttribute(IEnumerable, string)` constructor this check is dead code. --- src/Mvc/Mvc.Core/src/Routing/HttpMethodAttribute.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Mvc/Mvc.Core/src/Routing/HttpMethodAttribute.cs b/src/Mvc/Mvc.Core/src/Routing/HttpMethodAttribute.cs index cdf2138204..eb7af924bd 100644 --- a/src/Mvc/Mvc.Core/src/Routing/HttpMethodAttribute.cs +++ b/src/Mvc/Mvc.Core/src/Routing/HttpMethodAttribute.cs @@ -17,23 +17,19 @@ namespace Microsoft.AspNetCore.Mvc.Routing /// /// Creates a new with the given /// set of HTTP methods. - /// The set of supported HTTP methods. + /// The set of supported HTTP methods. May not be null. /// public HttpMethodAttribute(IEnumerable httpMethods) : this(httpMethods, null) { - if (httpMethods == null) - { - throw new ArgumentNullException(nameof(httpMethods)); - } } /// /// Creates a new with the given /// set of HTTP methods an the given route template. /// - /// The set of supported methods. - /// The route template. May not be null. + /// The set of supported methods. May not be null. + /// The route template. public HttpMethodAttribute(IEnumerable httpMethods, string template) { if (httpMethods == null) @@ -69,4 +65,4 @@ namespace Microsoft.AspNetCore.Mvc.Routing /// public string Name { get; set; } } -} \ No newline at end of file +}