From 9a77f9954a65edfc83762828557e2532f8ca20e1 Mon Sep 17 00:00:00 2001 From: kurnakovv Date: Wed, 8 Oct 2025 12:43:27 +0900 Subject: [PATCH] Add code example for CA1713 rule (#48953) --- .../code-analysis/quality-rules/ca1713.md | 6 ++++++ .../snippets/csharp/all-rules/ca1713.cs | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1713.cs diff --git a/docs/fundamentals/code-analysis/quality-rules/ca1713.md b/docs/fundamentals/code-analysis/quality-rules/ca1713.md index 2f3bd9dd2fc01..618c2b3d29354 100644 --- a/docs/fundamentals/code-analysis/quality-rules/ca1713.md +++ b/docs/fundamentals/code-analysis/quality-rules/ca1713.md @@ -10,6 +10,8 @@ helpviewer_keywords: - EventsShouldNotHaveBeforeOrAfterPrefix author: gewarren ms.author: gewarren +dev_langs: +- CSharp --- # CA1713: Events should not have before or after prefix @@ -35,6 +37,10 @@ Naming conventions provide a common look for libraries that target the common la Remove the prefix from the event name, and consider changing the name to use the present or past tense of a verb. +## Example + +:::code language="csharp" source="snippets/csharp/all-rules/ca1713.cs" id="snippet1"::: + ## When to suppress warnings Do not suppress a warning from this rule. diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1713.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1713.cs new file mode 100644 index 0000000000000..4e38230511f8b --- /dev/null +++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1713.cs @@ -0,0 +1,17 @@ +using System; + +namespace ca1713 +{ + // + public class Session + { + // This code violates the rule. + public event EventHandler? BeforeClose; + public event EventHandler? AfterClose; + + // This code satisfies the rule. + public event EventHandler? Closing; + public event EventHandler? Closed; + } + // +}