This doesn't apply to all asynchronous methods, but I think it might be a useful rule to have in the toolbox (rulebox?) provided it is disabled by default.
I write a lot of methods like this:
public Task<Response> GetResponse(
string href,
CancellationToken cancellationToken = default(CancellationToken))
{
//...
}
...which is a pattern modeled after the TAP guidelines and Mongo's excellent C# driver.
It's easy to forget the CancellationToken parameter, though, so in my own project I have a short unit test that uses reflection to make sure I haven't forgotten something. That made me think that an analyzer rule might be a better tool for the job! 😄
This doesn't apply to all asynchronous methods, but I think it might be a useful rule to have in the toolbox (rulebox?) provided it is disabled by default.
I write a lot of methods like this:
...which is a pattern modeled after the TAP guidelines and Mongo's excellent C# driver.
It's easy to forget the
CancellationTokenparameter, though, so in my own project I have a short unit test that uses reflection to make sure I haven't forgotten something. That made me think that an analyzer rule might be a better tool for the job! 😄