From 83cdb3012a122ae0a8a0c11ea59d1affdc4cf0b6 Mon Sep 17 00:00:00 2001 From: kurnakovv Date: Wed, 8 Oct 2025 14:51:22 +0900 Subject: [PATCH] Add code example for CA1725 rule (#48960) --- .../code-analysis/quality-rules/ca1725.md | 6 ++++++ .../snippets/csharp/all-rules/ca1725.cs | 21 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1725.cs diff --git a/docs/fundamentals/code-analysis/quality-rules/ca1725.md b/docs/fundamentals/code-analysis/quality-rules/ca1725.md index 20ef67d724b9e..3ef7976b6528a 100644 --- a/docs/fundamentals/code-analysis/quality-rules/ca1725.md +++ b/docs/fundamentals/code-analysis/quality-rules/ca1725.md @@ -10,6 +10,8 @@ helpviewer_keywords: - ParameterNamesShouldMatchBaseDeclaration author: gewarren ms.author: gewarren +dev_langs: +- CSharp --- # CA1725: Parameter names should match base declaration @@ -35,6 +37,10 @@ Consistent naming of parameters in an override hierarchy increases the usability 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. +## Example + +:::code language="csharp" source="snippets/csharp/all-rules/ca1725.cs" id="snippet1"::: + ## When to suppress warnings Do not suppress a warning from this rule except for visible methods in libraries that have previously shipped. diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1725.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1725.cs new file mode 100644 index 0000000000000..14b35389a530a --- /dev/null +++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1725.cs @@ -0,0 +1,21 @@ +using System; + +namespace ca1725 +{ + // + public interface IUserService + { + int GetAge(int id); + } + + public class UserService : IUserService + { + // Violates CA1725: Parameter name should match the base declaration ('id') + // for consistency with IUserService + public int GetAge(int userId) + { + throw new NotImplementedException(); + } + } + // +}