Skip to content

Commit b5e0f13

Browse files
authored
Add code example for CA1725 rule (#48960) (#48961)
1 parent f2a4706 commit b5e0f13

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ helpviewer_keywords:
1010
- ParameterNamesShouldMatchBaseDeclaration
1111
author: gewarren
1212
ms.author: gewarren
13+
dev_langs:
14+
- CSharp
1315
---
1416
# CA1725: Parameter names should match base declaration
1517

@@ -35,6 +37,10 @@ Consistent naming of parameters in an override hierarchy increases the usability
3537

3638
To fix a violation of this rule, rename the parameter to match the base declaration. The fix is a breaking change for callers who specify the parameter name.
3739

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

4046
Do not suppress a warning from this rule except for visible methods in libraries that have previously shipped.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
3+
namespace ca1725
4+
{
5+
//<snippet1>
6+
public interface IUserService
7+
{
8+
int GetAge(int id);
9+
}
10+
11+
public class UserService : IUserService
12+
{
13+
// Violates CA1725: Parameter name should match the base declaration ('id')
14+
// for consistency with IUserService
15+
public int GetAge(int userId)
16+
{
17+
throw new NotImplementedException();
18+
}
19+
}
20+
//</snippet1>
21+
}

0 commit comments

Comments
 (0)