From 3cef53d971d4a0759fc6001b008943b725a01784 Mon Sep 17 00:00:00 2001 From: kurnakovv Date: Wed, 8 Oct 2025 14:30:03 +0900 Subject: [PATCH 1/3] Add code example for CA1720 rule (#48958) --- .../code-analysis/quality-rules/ca1720.md | 6 ++++++ .../snippets/csharp/all-rules/ca1720.cs | 13 +++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1720.cs diff --git a/docs/fundamentals/code-analysis/quality-rules/ca1720.md b/docs/fundamentals/code-analysis/quality-rules/ca1720.md index 93e737b5c6e8f..0378767cb9528 100644 --- a/docs/fundamentals/code-analysis/quality-rules/ca1720.md +++ b/docs/fundamentals/code-analysis/quality-rules/ca1720.md @@ -10,6 +10,8 @@ helpviewer_keywords: - CA1720 author: gewarren ms.author: gewarren +dev_langs: +- CSharp --- # CA1720: Identifiers should not contain type names @@ -91,6 +93,10 @@ Replace the data type identifier in the name of the parameter with either a term Replace the language-specific data type identifier in the name of the member with a term that better describes its meaning, a language-independent equivalent, or a more generic term, such as 'value'. +## Example + +:::code language="csharp" source="snippets/csharp/all-rules/ca1720.cs" id="snippet1"::: + ## When to suppress warnings Occasional use of type-based parameter and member names might be appropriate. However, for new development, no known scenarios occur where you should suppress a warning from this rule. For libraries that have previously shipped, you might have to suppress a warning from this rule. diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1720.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1720.cs new file mode 100644 index 0000000000000..00b37183fd426 --- /dev/null +++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1720.cs @@ -0,0 +1,13 @@ +namespace ca1715 +{ + // + // This code violates the rule. + public class Short + { + public int Int32 { get; set; } + public Guid Guid { get; set; } + + public void Float(int int32) { } + } + // +} From ad05c2f8ff8b36e44d6987eabde4b59169c5cb41 Mon Sep 17 00:00:00 2001 From: kurnakovv Date: Wed, 8 Oct 2025 14:31:25 +0900 Subject: [PATCH 2/3] Add using System (#48958) --- .../quality-rules/snippets/csharp/all-rules/ca1720.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1720.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1720.cs index 00b37183fd426..fef7de097c9cc 100644 --- a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1720.cs +++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1720.cs @@ -1,3 +1,5 @@ +using System; + namespace ca1715 { // From b9067db6173ae547e65cbb63fbd8b63de41bb612 Mon Sep 17 00:00:00 2001 From: kurnakovv Date: Wed, 8 Oct 2025 14:54:23 +0900 Subject: [PATCH 3/3] Fix namespace name (#48958) --- .../quality-rules/snippets/csharp/all-rules/ca1720.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1720.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1720.cs index fef7de097c9cc..249a6ba73c6ea 100644 --- a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1720.cs +++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1720.cs @@ -1,6 +1,6 @@ using System; -namespace ca1715 +namespace ca1720 { // // This code violates the rule.