Skip to content

ASP001 handle route on class #55

Open
@JohanLarsson

Description

@JohanLarsson
        [Test]
        public void WhenRouteOnClass()
        {
            var code = @"
namespace AspBox
{
    using Microsoft.AspNetCore.Mvc;

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

            var fixedCode = @"
namespace AspBox
{
    using Microsoft.AspNetCore.Mvc;

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

            AnalyzerAssert.CodeFix(Analyzer, Fix, ExpectedDiagnostic, code, fixedCode);
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions