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

Bug: Use ?.Invoke operator and method to fire 'configuration' event, though configuration can't be null #536

Closed
TsengSR opened this issue Oct 4, 2015 · 1 comment

Comments

@TsengSR
Copy link

TsengSR commented Oct 4, 2015

When validating parameters and enforcing the this methods invariants, Code-Cracker keeps giving this message, even though it's guaranteed that configuration can't be null.

public static class ActionInvokeExample
{
    public void ActionExample(this IApplicationBuilder app, Action<IApplicationBuilder> configuration)
    {
        if (configuration == null)
        {
            throw new ArgumentNullException(nameof(configuration));
        }

        var builder = app.New();

        // Use ?.Invoke operator and method to fire 'configuration' event, though configuration
        configuration(builder);
}

Please remove this warning, if the it was assured that configuration can't be null or change the suggestion to "configuration.Invoke(builder)" without the null check. We add this kind of check so we don't have to explicity do null-checks again

@giggio
Copy link
Member

giggio commented Oct 4, 2015

I agree this needs improvement. I have had this problem myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants