diff --git a/docs/fundamentals/code-analysis/quality-rules/ca2016.md b/docs/fundamentals/code-analysis/quality-rules/ca2016.md index 6e16a8dea2ee2..dc6b6b18c36c4 100644 --- a/docs/fundamentals/code-analysis/quality-rules/ca2016.md +++ b/docs/fundamentals/code-analysis/quality-rules/ca2016.md @@ -49,7 +49,7 @@ The rule can detect a variety of violations. The following examples show cases t ### Example 1 -The rule will suggest forwarding the `c` parameter from `MyMethod` to the `MyMethodWithDefault` invocation, because the method defines an optional token parameter: +The rule will suggest forwarding the `ct` parameter from `MyMethod` to the `MyMethodWithDefault` invocation, because the method defines an optional token parameter: ```csharp using System.Threading; @@ -62,7 +62,7 @@ namespace ConsoleApp { } - public static void MyMethod(CancellationToken c) + public static void MyMethod(CancellationToken ct) { MyMethodWithDefault(); } @@ -72,13 +72,13 @@ namespace ConsoleApp Fix: -Forward the `c` parameter: +Forward the `ct` parameter: ```csharp - public static void MyMethod(CancellationToken c) - { - MyMethodWithDefault(c); - } +public static void MyMethod(CancellationToken ct) +{ + MyMethodWithDefault(ct); +} ``` If you are not concerned about forwarding cancellation notifications to lower invocations, you can either: @@ -86,24 +86,24 @@ If you are not concerned about forwarding cancellation notifications to lower in Explicitly pass `default`: ```csharp - public static void MyMethod(CancellationToken c) - { - MyMethodWithDefault(default); - } +public static void MyMethod(CancellationToken ct) +{ + MyMethodWithDefault(default); +} ``` Or explicitly pass `CancellationToken.None`: ```csharp - public static void MyMethod(CancellationToken c) - { - MyMethodWithDefault(CancellationToken.None); - } +public static void MyMethod(CancellationToken ct) +{ + MyMethodWithDefault(CancellationToken.None); +} ``` ### Example 2 -The rule will suggest forwarding the `c` parameter from `MyMethod` to the `MyMethodWithOverload` invocation, because the method has an overload that takes a `CancellationToken` parameter: +The rule will suggest forwarding the `ct` parameter from `MyMethod` to the `MyMethodWithOverload` invocation, because the method has an overload that takes a `CancellationToken` parameter: ```csharp using System.Threading; @@ -120,7 +120,7 @@ namespace ConsoleApp { } - public static void MyMethod(CancellationToken c) + public static void MyMethod(CancellationToken ct) { MyMethodWithOverload(); } @@ -130,13 +130,13 @@ namespace ConsoleApp Fix: -Forward the `c` parameter: +Forward the `ct` parameter: ```csharp - public static void MyMethod(CancellationToken c) - { - MyMethodWithOverload(c); - } +public static void MyMethod(CancellationToken ct) +{ + MyMethodWithOverload(ct); +} ``` If you are not concerned about forwarding cancellation notifications to lower invocations, you can either: @@ -144,19 +144,19 @@ If you are not concerned about forwarding cancellation notifications to lower in Explicitly pass `default`: ```csharp - public static void MyMethod(CancellationToken c) - { - MyMethodWithOverload(default); - } +public static void MyMethod(CancellationToken ct) +{ + MyMethodWithOverload(default); +} ``` Or explicitly pass `CancellationToken.None`: ```csharp - public static void MyMethod(CancellationToken c) - { - MyMethodWithOverload(CancellationToken.None); - } +public static void MyMethod(CancellationToken ct) +{ + MyMethodWithOverload(CancellationToken.None); +} ``` ## Non-violation examples @@ -174,7 +174,7 @@ namespace ConsoleApp { } - public static void MyMethod(CancellationToken c, int lastParameter) + public static void MyMethod(CancellationToken ct, int lastParameter) { MyMethodWithDefault(); } @@ -195,7 +195,7 @@ namespace ConsoleApp { } - public static void MyMethod(CancellationToken c) + public static void MyMethod(CancellationToken ct) { MyMethodWithDefault(); } @@ -219,7 +219,7 @@ namespace ConsoleApp { } - public static void MyMethod(CancellationToken c) + public static void MyMethod(CancellationToken ct) { MyMethodWithOverload(); } @@ -240,7 +240,7 @@ namespace ConsoleApp { } - public static void MyMethod(CancellationToken c1, CancellationToken c2) + public static void MyMethod(CancellationToken ct1, CancellationToken ct2) { MyMethodWithDefault(); } @@ -257,11 +257,11 @@ namespace ConsoleApp { public static class MyTestClass { - public static void MyMethodWithDefault(CancellationToken c1 = default, CancellationToken c2 = default) + public static void MyMethodWithDefault(CancellationToken ct1 = default, CancellationToken ct2 = default) { } - public static void MyMethod(CancellationToken c) + public static void MyMethod(CancellationToken ct) { MyMethodWithDefault(); } @@ -278,7 +278,7 @@ namespace ConsoleApp { public static class MyTestClass { - public static void MyMethodWithOverload(CancellationToken c1, CancellationToken c2) + public static void MyMethodWithOverload(CancellationToken ct1, CancellationToken ct2) { } @@ -286,7 +286,7 @@ namespace ConsoleApp { } - public static void MyMethod(CancellationToken c) + public static void MyMethod(CancellationToken ct) { MyMethodWithOverload(); } diff --git a/docs/fundamentals/code-analysis/quality-rules/media/ca2016-diagnose.png b/docs/fundamentals/code-analysis/quality-rules/media/ca2016-diagnose.png index d47f999d9cc92..029c3d6bd0f13 100644 Binary files a/docs/fundamentals/code-analysis/quality-rules/media/ca2016-diagnose.png and b/docs/fundamentals/code-analysis/quality-rules/media/ca2016-diagnose.png differ