Skip to content
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

Detect ReturnsForAnyArgs/ReceivedWithAnyArgs simplification with "default(!)" #175

Open
rklec opened this issue Oct 28, 2021 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@rklec
Copy link

rklec commented Oct 28, 2021

Could you detect and suggest the simplification of ...Any calls with default for modern C# versions, as you describe here?

public interface ITest
{
    void DoSomething(string? thing);
}

public class Test
{
    [Test]
    public void TestSth()
    {

        var test = Substitute.For<ITest>();

        test.DoSomething("this");

        test.ReceivedWithAnyArgs().DoSomething(Arg.Any<string>()); // too complicated
        test.ReceivedWithAnyArgs().DoSomething(default!); // could be simplified as this
    }
}

...the same for setting return args with ReturnsForAnyArgs etc.

@rklec rklec changed the title Detect ReceivedWithAnyArgs simplification with "default(!)" Detect ReturnsForAnyArgs/ReceivedWithAnyArgs simplification with "default(!)" Oct 28, 2021
@tpodolak tpodolak added the enhancement New feature or request label Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants