DotNetAnalyzers / AspNetCoreAnalyzers

MIT License
62 stars 4 forks source link

Checks when multiple [Route] #59

Open JohanLarsson opened 5 years ago

JohanLarsson commented 5 years ago
    [Route("api/values/{id}")]
    [Route("api/values")]
    [ApiController]
    public class FoosController : ControllerBase

Check that

JohanLarsson commented 5 years ago
        [Test]
        public void WhenMultipleRouteAttributesMissingAction()
        {
            var code = @"
namespace AspBox
{
    using Microsoft.AspNetCore.Mvc;

    [Route(↓""api/values"")]
    [Route(""api/values/{id}"")]
    [ApiController]
    public class ValuesController : Controller
    {
        [HttpGet]
        public IActionResult Get(int id)
        {
            return this.Ok(id);
        }
    }
}";

            AnalyzerAssert.Diagnostics(Analyzer, ExpectedDiagnostic, code);
        }

Maybe this should be a new id?