Skip to content
This repository was archived by the owner on Nov 12, 2026. It is now read-only.
This repository was archived by the owner on Nov 12, 2026. It is now read-only.

CA2257 should not be reported on nested types #7106

Closed

Description

@jkoritzinsky

Analyzer

Diagnostic ID: CA2257: Members defined on an interface with the 'DynamicInterfaceCastableImplementationAttribute' should be 'static'

Analyzer source

SDK: Built-in CA analyzers in .NET 8 SDK or later

Version: SDK 8.0.100

Describe the bug

The analyzer reports that nested types in a type with [DynamicInterfaceCastableImplementation] should be static, but the rationale for that rule does not apply to nested types.

Steps To Reproduce

interface Foo
{
   void Bar();
}

[DynamicInterfaceCastableImplementation]
interface FooImpl
{
     void Foo.Bar() {}

     private class C {}
}

Expected behavior

No diagnostic

Actual behavior

A diagnostic on the class declaration

Additional context

Activity

  1. added
    BugThe product is not behaving according to its current intended design
    False_PositiveA diagnostic is reported for non-problematic case
    on Dec 19, 2023
  2. added a commit that references this issue on Jan 23, 2024
    4949055
  3. added a commit that references this issue on Feb 15, 2024
    781d2ac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThe product is not behaving according to its current intended designFalse_PositiveA diagnostic is reported for non-problematic case

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions