Skip to content

Commit 58c4e27

Browse files
authored
Add code example for CA1707 rule (#48934) (#48935)
* Add code example for CA1707 rule (#48934) * Delete useless blank (#48934) * Add comment for violation code (#48934)
1 parent bc6f309 commit 58c4e27

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

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

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

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

3638
Remove all underscore characters from the name.
3739

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

4046
Do not suppress warnings for production code. However, it's safe to suppress this warning for test code.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
3+
// <Snippet1>
4+
// This code violates the rule.
5+
namespace ca_1707
6+
{
7+
public interface IUser_Service
8+
{
9+
void Add_User(User_Model user_Model);
10+
}
11+
12+
public class User_Service : IUser_Service
13+
{
14+
public const string Admin_Name = "admin";
15+
public event EventHandler? User_Added;
16+
17+
public void Add_User(User_Model user_Model)
18+
{
19+
// ...
20+
}
21+
}
22+
23+
public struct User_Model
24+
{
25+
public int User_Id { get; set; }
26+
}
27+
28+
public enum User_Type
29+
{
30+
Client_User = 0,
31+
Manager_Admin = 1,
32+
Syper_Admin = 3,
33+
}
34+
}
35+
// </Snippet1>

0 commit comments

Comments
 (0)