Skip to content

Commit 9bb2589

Browse files
authored
Add code example for CA1713 rule (#48953) (#48954)
1 parent 6e361e3 commit 9bb2589

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

docs/fundamentals/code-analysis/quality-rules/ca1713.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ helpviewer_keywords:
1010
- EventsShouldNotHaveBeforeOrAfterPrefix
1111
author: gewarren
1212
ms.author: gewarren
13+
dev_langs:
14+
- CSharp
1315
---
1416
# CA1713: Events should not have before or after prefix
1517

@@ -35,6 +37,10 @@ Naming conventions provide a common look for libraries that target the common la
3537

3638
Remove the prefix from the event name, and consider changing the name to use the present or past tense of a verb.
3739

40+
## Example
41+
42+
:::code language="csharp" source="snippets/csharp/all-rules/ca1713.cs" id="snippet1":::
43+
3844
## When to suppress warnings
3945

4046
Do not suppress a warning from this rule.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
3+
namespace ca1713
4+
{
5+
//<snippet1>
6+
public class Session
7+
{
8+
// This code violates the rule.
9+
public event EventHandler? BeforeClose;
10+
public event EventHandler? AfterClose;
11+
12+
// This code satisfies the rule.
13+
public event EventHandler? Closing;
14+
public event EventHandler? Closed;
15+
}
16+
//</snippet1>
17+
}

0 commit comments

Comments
 (0)