File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
docs/fundamentals/code-analysis/quality-rules
snippets/csharp/all-rules Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ helpviewer_keywords:
99- DynamicInterfaceCastableImplementationAnalyzer
1010- CA2256
1111author : Youssef1313
12+ dev_langs :
13+ - CSharp
1214---
1315# CA2256: All members declared in parent interfaces must have an implementation in a DynamicInterfaceCastableImplementation-attributed interface
1416
@@ -32,10 +34,15 @@ Types attributed with <xref:System.Runtime.InteropServices.DynamicInterfaceCasta
3234
3335Implement the missing interface members.
3436
37+ ## Example
38+
39+ :::code language="csharp" source="snippets/csharp/all-rules/ca2256.cs" id="snippet1" highlight="30":::
40+
3541## When to suppress errors
3642
3743Do not suppress a warning from this rule.
3844
3945## See also
4046
4147- [ Usage warnings] ( usage-warnings.md )
48+ - [ CA2257: Members defined on an interface with the 'DynamicInterfaceCastableImplementationAttribute' should be 'static'] ( ca2257.md )
Original file line number Diff line number Diff line change 1+ using System . Runtime . InteropServices ;
2+
3+ namespace ca2256
4+ {
5+ //<snippet1>
6+ interface IParent
7+ {
8+ void ParentMethod ( ) ;
9+ }
10+
11+ // This interface violates the rule.
12+ [ DynamicInterfaceCastableImplementation ]
13+ interface IBadChild : IParent
14+ {
15+ static void ChildMethod ( )
16+ {
17+ // ...
18+ }
19+ }
20+
21+ // This interface satisfies the rule.
22+ [ DynamicInterfaceCastableImplementation ]
23+ interface IGoodChild : IParent
24+ {
25+ static void ChildMethod ( )
26+ {
27+ // ...
28+ }
29+
30+ void IParent . ParentMethod ( )
31+ {
32+ // ...
33+ }
34+ }
35+ //</snippet1>
36+ }
You can’t perform that action at this time.
0 commit comments