Skip to content

Fix S2857 FN: No issue is raised if SQL related namespaces are imported through global using directives #5956

Open
@mary-georgiou-sonarsource

Description

Description

No issue is raised if SQL related namespaces are imported through global using directives

Repro steps

// global using System.Data.SqlClient is declared in another file.
class Foo
{
    private string field = "SELECT *" + // FN
        "FROM TABLE" +
        "WHERE X = 1;";
}

Expected behavior

Issue is raised.

Actual behavior

No issue is raised.

Related information

  • C#/VB.NET Plugins version: 8.42.0.51121

How?

Global using retrieval will be available from MSBuild version 17.3 onwards through this API, exposed via semanticModel.GetImportScopes.

Since the semantic model will be called, we have to consider the potential performance regression but running tests.

Activity

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

Metadata

Assignees

No one assigned

    Labels

    Area: C#C# rules related issues.Type: False NegativeRule is NOT triggered when it should be.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions