Skip to content

NET-2219 Fix S1128 FP: Deconstruct method C# #9747

@relrafie

Description

@relrafie

Description

'S1128' Remove this unnecessary 'using'' is raised when ref. is needed for a deconstructed method.

Reproducer

using CSharpFunctionalExtensions;

    private void SomeMethod()
    {
        var (_, _, _) = GetResult();
    }

    private CSharpFunctionalExtensions.Result GetResult()
    {
        return CSharpFunctionalExtensions.Result.Success();
    }

Removing the using statement will result in an error, adding it will result in a sonar smell.

Expected behavior
S1128 shouldn't be detected as there is no error there

Actual behavior
A code smell is detected

Product and Version

SonarQube Server: 2025.1.1.104738; csharpenterprise: "10.4.1 (build 110446)"

Metadata

Metadata

Assignees

No one assigned

    Labels

    False PositiveRule IS triggered when it shouldn't be.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions