From 48e3edab0a7cf600d5564d3f597efda62819ac57 Mon Sep 17 00:00:00 2001 From: Mary Georgiou <89914005+mary-georgiou-sonarsource@users.noreply.github.com> Date: Fri, 16 Jun 2023 09:52:11 +0200 Subject: [PATCH] Modify S3966: Fix broken argument (#2210) --- rules/S3966/csharp/rule.adoc | 2 +- rules/S3966/vbnet/rule.adoc | 2 +- rules/S3966/why.adoc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rules/S3966/csharp/rule.adoc b/rules/S3966/csharp/rule.adoc index 30c533e3ac..ce611762d8 100644 --- a/rules/S3966/csharp/rule.adoc +++ b/rules/S3966/csharp/rule.adoc @@ -1,4 +1,4 @@ -:using_arg: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/using[`using`] keyword +:usingArg: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/using[using] keyword include::../why.adoc[] diff --git a/rules/S3966/vbnet/rule.adoc b/rules/S3966/vbnet/rule.adoc index 8ca8793495..5ba8028458 100644 --- a/rules/S3966/vbnet/rule.adoc +++ b/rules/S3966/vbnet/rule.adoc @@ -1,4 +1,4 @@ -:using_arg: https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/using-statement[`Using` statement] +:usingArg: https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/using-statement[Using statement] include::../why.adoc[] diff --git a/rules/S3966/why.adoc b/rules/S3966/why.adoc index af3c1bfbb8..84199bf3d3 100644 --- a/rules/S3966/why.adoc +++ b/rules/S3966/why.adoc @@ -1,5 +1,5 @@ == Why is this an issue? -Disposing an object twice in the same method, either with the {using} or by calling `Dispose` directly, is confusing and error-prone. For example, another developer might try to use an already-disposed object, or there can be runtime errors for specific paths in the code. +Disposing an object twice in the same method, either with the {usingArg} or by calling `Dispose` directly, is confusing and error-prone. For example, another developer might try to use an already-disposed object, or there can be runtime errors for specific paths in the code. In addition, even if the https://learn.microsoft.com/en-us/dotnet/api/system.idisposable.dispose#System_IDisposable_Dispose[documentation] explicitly states that calling the `Dispose` method multiple times should not throw an exception, some implementations still do it. Thus it is safer to not dispose of an object twice when possible.