async
should have their names suffixed with Async
CS-R1073Task
does not follow the naming convention60 }
61
62 [HttpDelete("{id}")]
63 public async Task<ActionResult<List<Customer>>> Delete(int id)64 {
65 var dbCustomer = await _context.Customers.FindAsync(id);
66 if (dbCustomer == null)
Task
does not follow the naming convention40 }
41
42 [HttpPut]
43 public async Task<ActionResult<List<Customer>>> Update(Customer request)44 {
45 var dbCustomer = await _context.Customers.FindAsync(request.Id);
46 if (dbCustomer == null)
Task
does not follow the naming convention31
32
33 [HttpPost]
34 public async Task<ActionResult<List<Customer>>> AddHero(Customer customer)35 {
36 _context.Customers.Add(customer);
37 await _context.SaveChangesAsync();
Task
does not follow the naming convention21 }
22
23 [HttpGet("{id}")]
24 public async Task<ActionResult<List<Customer>>> Get(int id)25 {
26 var customer = await _context.Customers.FindAsync(id);
27 if (customer == null)
Task
does not follow the naming convention15 }
16
17 [HttpGet]
18 public async Task<ActionResult<Customer>> Get()19 {
20 return Ok(await _context.Customers.ToListAsync());
21 }
The consensus in .NET is to have names of methods dealing with async
hronous operations suffixed with Async
. One such example is Stream.ReadAsync
from System.IO
. Doing so improves readability and provides crucial information at a glance.
public virtual System.Threading.Tasks.ValueTask<int> Read (Memory<byte> buffer, System.Threading.CancellationToken cancellationToken = default);
public virtual System.Threading.Tasks.ValueTask<int> ReadAsync (Memory<byte> buffer, System.Threading.CancellationToken cancellationToken = default);