TrackingDictionary.Remove(KeyValuePair) removes entries without notifying subscribers

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

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

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
csharp

調査の方向性

sources/core/Stride.Core.Tests/Stride.Core.Tests.csproj の TrackingDictionaryTests のケースから始め、issue に記載された対象を絞った dotnet test コマンドを実行します。ICollection<KeyValuePair<TKey, TValue>> の削除と Remove(TKey) を比較します。完了条件は、一致するペアが変更前に通知し、存在しないペアまたは一致しないペアは変更されず、通知も行わず、21 個すべてのテストに合格することです。

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

説明

area-Core bug

Release Type: GitHub

Version: master, commit eb9c619e16e589c588f0dccc9ba062223ecf52cd

Platform(s): Reproduced with source-linked collection tests on macOS arm64 / .NET SDK 9.0.112. This is managed collection code; other platforms and the full engine build have not been tested locally.

Describe the bug

TrackingDictionary<TKey, TValue>.Remove(KeyValuePair<TKey, TValue>) successfully removes a matching entry without raising CollectionChanged. Removing the same entry through Remove(TKey) raises a removal notification before the entry is removed.

This means subscribers can miss removals performed through ICollection<KeyValuePair<TKey, TValue>>.

To Reproduce

var dictionary = new TrackingDictionary<string, int> { { "key", 42 } };
var notifications = 0;
dictionary.CollectionChanged += (_, _) => notifications++;

ICollection<KeyValuePair<string, int>> collection = dictionary;
var removed = collection.Remove(new KeyValuePair<string, int>("key", 42));

// Actual: removed == true, dictionary.Count == 0, notifications == 0.
// Expected: notifications == 1, with the same pre-removal timing as Remove(TKey).

Expected behavior

A matching pair raises one removal notification before mutation, preserving the existing keyed-removal contract. Missing keys and mismatched values return false, leave the dictionary intact, and raise no event.

Screenshots

Not applicable to this managed collection behavior.

Log and callstacks

With the new regression tests and the original implementation, the source-linked test run has 20 passing cases and one failure:

Remove_KeyValuePair_NotifiesBeforeRemovingMatchingEntry
Assert.Single() Failure: The collection was empty

The focused fix changes the matching-pair branch from innerDictionary.Remove(item.Key) to Remove(item.Key). All 21 dictionary test cases then pass, including six added regression cases. Serialization metadata types are stubbed in the standalone harness; collection/event code and the test file are linked directly from the checkout. This does not represent a full Stride build or editor test. Stride's current project targets .NET 10, while the installed local SDK used for this isolated reproduction is .NET 9.

Additional context

Related: #3171 and the closed #3209 by @marko1olo. The missing pair-removal notification was already identified in that earlier PR. This proposal isolates it while preserving the pre-mutation timing discussed by @Kryptos-FR. It does not attempt to resolve #3171's broader event-timing/API question.

@stride3d/stride-contributors Would you approve a US$20 bounty for this focused fix and regression coverage under the published contribution bounty program? A patch is prepared locally. If approved and reserved, I can submit it as a pull request and address review feedback. Please reply here; payment/contact details can be provided privately through the official payout process.

This patch and its tests were prepared with AI assistance.

Additional validation — actual Stride test project

The 21 TrackingDictionaryTests cases also pass in the actual Stride.Core.Tests.csproj on macOS arm64 with .NET SDK 10.0.400. The real Stride collections and serialization dependencies were compiled, and Stride's assembly processor ran for the test assembly. No serialization stubs are used in this run. The full engine test suite and editor have not been run.

The focused run used dotnet test sources/core/Stride.Core.Tests/Stride.Core.Tests.csproj --filter FullyQualifiedName~TrackingDictionaryTests with StridePlatforms=macOS, StrideTestRuntimeIdentifier=osx-arm64, and scratch-directory build/cache settings.

主要言語
C#
スター
8k
フォーク
1.2k
平均マージ
1日 1時間
マージ済み PR(30日)
321

環境構築

はじめの一歩

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

stride3d/stride のほかの issue

stride3d/stride の issue をすべて見る

似ている issue

C# の issue をもっと見る

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

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