Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/fundamentals/code-analysis/quality-rules/ca2257.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ helpviewer_keywords:
- DynamicInterfaceCastableImplementationAnalyzer
- CA2257
author: Youssef1313
dev_langs:
- CSharp
---
# CA2257: Members defined on an interface with the 'DynamicInterfaceCastableImplementationAttribute' should be 'static'

Expand All @@ -32,10 +34,15 @@ Since a type that implements `IDynamicInterfaceCastable` may not implement a dyn

Mark the interface member `static`.

## Example

:::code language="csharp" source="snippets/csharp/all-rules/ca2257.cs" id="snippet1":::

## When to suppress errors

Do not suppress a warning from this rule.

## See also

- [Usage warnings](usage-warnings.md)
- [CA2256: All members declared in parent interfaces must have an implementation in a DynamicInterfaceCastableImplementation-attributed interface](ca2256.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Runtime.InteropServices;

namespace ca2257
{
//<snippet1>
[DynamicInterfaceCastableImplementation]
interface IExample
{
// This method violates the rule.
void BadMethod();

// This method satisfies the rule.
static void GoodMethod()
{
// ...
}
}
//</snippet1>
}