Modify S3966: Fix broken argument (#2210)

This commit is contained in:
Mary Georgiou 2023-06-16 09:52:11 +02:00 committed by GitHub
parent 0bbdb53a0c
commit 48e3edab0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -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[]

View File

@ -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[]

View File

@ -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.