Skip to content

Commit f2a4706

Browse files
authored
Add code example for CA1720 rule (#48958) (#48959)
1 parent 34a2b60 commit f2a4706

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ helpviewer_keywords:
1010
- CA1720
1111
author: gewarren
1212
ms.author: gewarren
13+
dev_langs:
14+
- CSharp
1315
---
1416
# CA1720: Identifiers should not contain type names
1517

@@ -91,6 +93,10 @@ Replace the data type identifier in the name of the parameter with either a term
9193

9294
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'.
9395

96+
## Example
97+
98+
:::code language="csharp" source="snippets/csharp/all-rules/ca1720.cs" id="snippet1":::
99+
94100
## When to suppress warnings
95101

96102
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.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
namespace ca1720
4+
{
5+
//<snippet1>
6+
// This code violates the rule.
7+
public class Short
8+
{
9+
public int Int32 { get; set; }
10+
public Guid Guid { get; set; }
11+
12+
public void Float(int int32) { }
13+
}
14+
//</snippet1>
15+
}

0 commit comments

Comments
 (0)