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

S927 FP : FP when generic type arguments are changed to reflect the actual type they represent. #4370

Closed
dmitry-golovinov-sonarsource opened this issue May 4, 2021 · 0 comments · Fixed by #5241
Assignees
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: False Positive Rule IS triggered when it shouldn't be.
Milestone

Comments

@dmitry-golovinov-sonarsource
Copy link
Contributor

dmitry-golovinov-sonarsource commented May 4, 2021

Description

False positive for S927. When the type of the argument is generic interface it will be more useful to provide name based on the actual substituted type, since it can better express what the code is about

Repro steps

    public interface SomeInterface<A> { }

    public interface BaseInterface<A>
    {
        void Apply(SomeInterface<A> param);
    }

    public class BasicImplementation : BaseInterface<int>
    {
        public void Apply(SomeInterface<int> intValue) { }   //Noncompliant FP
    }

Expected behavior

Do not raise the rule.

Actual behavior

In the previous example issue is being raised, since type kind of parameter param in Apply method of BaseInterface
does not have the kind of TypeParameter.

Related information

  • SonarC# Version: 8.22
  • Visual Studio 16.9.4
@dmitry-golovinov-sonarsource dmitry-golovinov-sonarsource added Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: False Positive Rule IS triggered when it shouldn't be. labels May 4, 2021
@csaba-sagi-sonarsource csaba-sagi-sonarsource added this to the 8.34 milestone Jan 5, 2022
@csaba-sagi-sonarsource csaba-sagi-sonarsource self-assigned this Jan 5, 2022
@mary-georgiou-sonarsource mary-georgiou-sonarsource modified the milestone: 8.34 Jan 17, 2022
@mary-georgiou-sonarsource mary-georgiou-sonarsource changed the title S927 FP S927 FP : FP when generic type arguments are changed to reflect the actual type they represent. Jan 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: False Positive Rule IS triggered when it shouldn't be.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants