Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/fundamentals/code-analysis/quality-rules/ca1707.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ helpviewer_keywords:
- IdentifiersShouldNotContainUnderscores
author: gewarren
ms.author: gewarren
dev_langs:
- CSharp
---
# CA1707: Identifiers should not contain underscores

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

Remove all underscore characters from the name.

## Example

:::code language="csharp" source="snippets/csharp/all-rules/ca1707.cs" id="snippet1":::

## When to suppress warnings

Do not suppress warnings for production code. However, it's safe to suppress this warning for test code.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;

// <Snippet1>
// This code violates the rule.
namespace ca_1707
{
public interface IUser_Service
{
void Add_User(User_Model user_Model);
}

public class User_Service : IUser_Service
{
public const string Admin_Name = "admin";
public event EventHandler? User_Added;

public void Add_User(User_Model user_Model)
{
// ...
}
}

public struct User_Model
{
public int User_Id { get; set; }
}

public enum User_Type
{
Client_User = 0,
Manager_Admin = 1,
Syper_Admin = 3,
}
}
// </Snippet1>