Skip to content

Fix S3253 FP: Don't raise for primary constructor in type declarations without parameters when they inherit from types with parameters #8436

Description

@thomasfroehle

Description

S3253 is reported when a record with a parameterless constructor inherits another record that has parameters and passes them inline (instead of having an explicit base()-call).

Repro steps

public abstract record Base(string Value);

public record Foo() : Base("SomeValue");

Expected behavior

No S3253 is raised because the Foo()-constructor is not redundant.

Actual behavior

S3253 is raised.

Known workarounds

public abstract record Base(string Value);

public record Foo : Base
{
    public Foo() : base("SomeValue")
    {

    }
}

Related information

SonarAnalyzer.CSharp: 9.14.0.81108

Activity

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

Metadata

Metadata

Assignees

Labels

False PositiveRule IS triggered when it shouldn't be.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions