-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ASP001 handle route on class #55
Comments
Maybe ASP002 [Test]
public void WhenRouteOnClass()
{
var code = @"
namespace AspBox
{
using Microsoft.AspNetCore.Mvc;
[Route(""api/values/{↓wrong}"")]
[ApiController]
public class OrdersController : Controller
{
[HttpGet]
public IActionResult GetValue(int id)
{
return this.Ok(id);
}
}
}";
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);
} |
And ASP007 [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()
{
return this.Ok();
}
}
}";
AnalyzerAssert.Diagnostics(Analyzer, ExpectedDiagnostic, code);
} |
I'm not sure if this issue is relevant . The problemThe warning below is emitted when building my project where route is defined on class. To ReproduceCreate new empty ASP Net Core Web Application using Microsoft.AspNetCore.Mvc;
namespace AnalyzerBugRepro
{
[ApiController]
[Route("api/")]
public class GrantStubController : ControllerBase
{
}
} Build the project |
Ah, that looks like a separate/new issue. Never hesitate to create issues, especially beautiful issues with repro code like you provided. Makes adding a test and then fixing fast and easy. Thanks for reporting! |
Done |
The text was updated successfully, but these errors were encountered: