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

Fix S3253 FP: Conflicts with CS8983 - A 'struct' with field initializers must include an explicitly declared constructor. #8087

Closed
rjgotten opened this issue Sep 27, 2023 · 1 comment · Fixed by #8223
Assignees
Labels
Area: C# C# rules related issues. Sprint: Hardening Fix FPs/FNs/improvements Type: False Positive Rule IS triggered when it shouldn't be.
Milestone

Comments

@rjgotten
Copy link

Description

S3253 is raised on empty constructors that must be added to readonly structs containing field initializers, as per CS8983.

Repro steps

public readonly struct Example
{
  public Example() { }
  
  public bool Foo { get; init; } = true;
}

Expected behavior

S3253 is not raised, because the constructor is actually required.

Actual behavior

S3253 is raised.

Known workarounds

None. Suppress the rule.

Related information

  • C#/VB.NET Plugins version : C# 9.8.0.76515 (SonarLint 7.3.0.77872)
  • Visual Studio version: 17.7.4
  • MSBuild / dotnet version: dotnet 7.0.401
  • Operating System: Windows 11
@cristian-ambrosini-sonarsource
Copy link
Contributor

Hi @rjgotten! I confirm this to be an FP indeed, your issue has been added to our backlog and we will try to tackle it in a future sprint.
Thanks for reporting this!

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. Sprint: Hardening Fix FPs/FNs/improvements Type: False Positive Rule IS triggered when it shouldn't be.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants