NET-1534 Rule Idea: `void` method implementations should not be `async`
interface IInterface
{
void InterfaceMethod();
}
class Base
{
protected virtual void BaseMethod() {}
}
class Sample : Base, IInterface
{
public async void InterfaceMethod() {} // Noncompliant
protected override async void BaseMethod() {} // Noncompliant
protected virtual async void VirtualMethod() {} // Noncompliant
async void OtherMethod() {} // Compliant: covered by S3168
}
This rule complements S3168, which ignores methods that implement an interface, override a base method, or are virtual. Having this functionality as a separate rule allows users to tailor their analysis to their needs.
The implementation should be a straightforward adaption of S3168.
This looks good to me!
Some questions regarding the exceptions raised in https://github.com/SonarSource/rspec/pull/4547:
Would this capture all these scenarios?
- Methods implementing an interface
- Methods overriding a base class method
- Virtual methods
From the wording here it should capture all 3 cases, correct?
I clarified it. Thanks for pointing it out!
Internal ticket NET-1534
Similar to AsyncFixer03