The requested page is not available for the requested platform. You are viewing the content for Default platform.
All docs
V19.1
19.1
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

CRR0045 - Local variable can be replaced with discard

This analyzer detects unused or assigned variables which can be replaced with a discard.

public static class ReplaceWithDiscard {
    public static bool HasAssignment(this SimpleNameSyntax identifier) {
        SyntaxNode assignment;
        return identifier.HasAssignment(out assignment);
    }
}

To fix the issue, replace the local variable with discard:

public static class ReplaceWithDiscard {
    public static bool HasAssignment(this SimpleNameSyntax identifier) {
        return identifier.HasAssignment(out _);
    }
}

Call the Discard Variable refactoring to replace unused or assigned variables with a discard. To do it in different places at once, use the Code Cleanup feature with the Replace unused variables with discard code cleanup rule enabled.