Skip to content

CA1814 is reported in generated code, for a call to a method I don't control #3487

Open

Description

Analyzer package

Microsoft.CodeAnalysis.FxCopAnalyzers

Package Version

v2.9.8

Diagnostic ID

CA1814

Repro steps

  1. In EF Core model configuration, define seed data for an entity using builder.Entity<MyEntity>().HasData(new MyEntity { ... }, new MyEntity { ... } ... )
  2. Generate a new migration (dotnet ef migrations add)

Expected behavior

No warning

Actual behavior

Warning CA1814 on the argument for values:

            migrationBuilder.InsertData(
                table: "MyEntity",
                columns: new[] { "Id", "Name" },
                values: new object[,]
                {
                    { 1, "Foo" },
                    { 2, "Bar" }
                });

InsertData is a method from EF Core, I don't control it. I can't do anything about its signature, so the warning is useless in this case ; the only way to "fix" it would be to not call this method...

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions