Skip to content

Commit

Permalink
S1144: Add FP repro for #9416 (#9417)
Browse files Browse the repository at this point in the history
  • Loading branch information
mary-georgiou-sonarsource authored Jun 7, 2024
1 parent 1413694 commit 2508462
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ private void SomeMethod(bool condition) { } // Compliant
protected override void Up(MigrationBuilder migrationBuilder) { }
}
}
""").AddReferences(EntityFrameworkCoreReferences("7.0.14")).VerifyNoIssues();
""")
.AddReferences(EntityFrameworkCoreReferences("7.0.14"))
.VerifyNoIssues();

[DataTestMethod]
[DataRow(ProjectType.Product)]
Expand Down Expand Up @@ -203,6 +205,30 @@ public void UnusedPrivateMember_FromCSharp12() =>
.WithOptions(ParseOptionsHelper.FromCSharp12)
.VerifyNoIssues();

[TestMethod]
public void UnusedPrivateMemeber_EntityFramework_DontRaiseOnUnusedEntityPropertiesPrivateSetters() =>
builder.AddSnippet("""
// Repro https://github.com/SonarSource/sonar-dotnet/issues/9416
using Microsoft.EntityFrameworkCore;

internal class MyContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
}

public class Blog
{
public Blog(int id, string name)
{
Name = name;
}

public int Id { get; private set; } // Noncompliant FP
public string Name { get; private set; }
}
""")
.AddReferences(NuGetMetadataReference.MicrosoftEntityFrameworkCore("8.0.6"))
.Verify();
#endif

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ internal static partial class NuGetMetadataFactory
"netstandard2.0",
"net7.0",
"net6.0",
"net8.0",
"net47",
"net461",
"netstandard1.6",
Expand Down

0 comments on commit 2508462

Please sign in to comment.