Implement a Dispose method has contradictory example to documentation about thread synchronization

オープン
#56,633 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Manish-1kumar がすでに取り組んでいます。

2026年11月1日 から。

  • #56648 @Manish-1kumar による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
57/100
issue の種類
ドキュメント
明瞭さ
おおむね明確
活発さ
活発
技術スタック
csharp
領域
documentation

調査の方向性

Read docs/standard/garbage-collection/implementing-dispose.md, especially the custom safe handle section and its note about SafeHandle.ReleaseHandle. Compare that note with the example's Interlocked.CompareExchange use, then verify the accurate explanation with the relevant .NET disposal guidance. Update the example or note so they agree and the synchronization behavior is clear.

索引モデルが issue の本文から書いたものです。

説明

dotnet-fundamentals/svc
Type of issue

Missing information

Description

On the page Implement a Dispose method, the section Implement the dispose pattern using a custom safe handle has a NOTE section that says:

[!NOTE]

  • ....
  • There is no need for synchronization to guarantee thread safety. Even though there is a race condition in the Dispose implementation of DisposableBaseWithSafeHandle, SafeHandle guarantees that SafeHandle.ReleaseHandle is called only once.

However, the example under that specific section, "Implement the dispose pattern using a custom safe handle", still includes thread synchronization using Interlocked.CompareExchange. This is contradictory and confusing. Should the thread synchronization be remove that that specific example - or is the statement about not needing thread synchronization incorrect?

Page URL

https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/implementing-dispose#implement-the-dispose-pattern-using-a-custom-safe-handle

Content source URL

https://github.com/dotnet/docs/blob/main/docs/standard/garbage-collection/implementing-dispose.md

Document Version Independent Id

9c754da1-c234-fb12-580b-0fcf9ffe2c20

Platform Id

de77d8c7-6af8-0b64-9357-30e46ab49cbd

Article author

@gewarren

Metadata
  • ID: 572ef6c6-5066-4a14-76a0-c3fb4b62e604
  • PlatformId: de77d8c7-6af8-0b64-9357-30e46ab49cbd
  • Service: dotnet-fundamentals

Related Issues

主要言語
言語のデータがありません
スター
4.8k
フォーク
6.1k
平均マージ
1日 7時間
マージ済み PR(30日)
259

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

dotnet/docs のほかの issue

dotnet/docs の issue をすべて見る

似ている issue

Documentation の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。