C#

C#

By DeepSource

Missing implementation of members wrapped in an interface attributed with DynamicInterfaceCastableImplementation CS-W1066

Bug risk

Interfaces attributed with the DynamicInterfaceCastableImplementation attribute must contain methods that are marked static and have an implementation. Failing to do so violates the DynamicInterfaceCastableImplementation contract and may lead to runtime exceptions.

Examples

Bad Practice

[DynamicInterfaceCastableImplementation]
interface IFoo
{
    public void Bar()
    {
        // ...
    }
}

Recommended

[DynamicInterfaceCastableImplementation]
interface IFoo
{
    public static void Bar()
    {
        // ...
    }
}

Reference