MemoizingEnumerable.Count returns only the buffered prefix after partial enumeration
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Common/Util/MemoizingEnumerable.csから始め、Count、Empty、部分列挙がバッファをどのように使い、ソースの終端をどのように追跡するかをたどってください。Countをすぐに呼び出す場合、Emptyの後に呼び出す場合、部分列挙の後に呼び出す場合を含むテストを追加し、Take(1).Single()のケースも含めてください。各アクセス順序で、バッファされた要素を失ったりソースを再評価したりせずに、完全な件数が返されれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Problem
MemoizingEnumerable<T>.Count returns the buffered prefix's length after partial enumeration, rather than the total number of elements promised by its documentation.
Reproduction
var items = new MemoizingEnumerable<int>(Enumerable.Range(1, 100));
Console.WriteLine(items.Empty); // False
Console.WriteLine(items.Count); // 1 -- expected 100
Console.WriteLine(items.ToArray().Length); // 100
Console.WriteLine(items.Count); // 100
Likewise, items.Take(1).Single() before Count produces 1 instead of 100. I ran both cases against the current implementation; both reproduced. The same implementation is present on master.
Cause and expected result
In Common/Util/MemoizingEnumerable.cs, Count completes enumeration only when _buffer == null. Empty and partial enumeration allocate and populate that buffer without exhausting the source, so the count silently depends on how the enumerable has previously been accessed.
A fix must make Count return the full source count whether called immediately, after Empty, or after partial enumeration, without losing the buffered elements or repeating source evaluation. Add coverage for these access orders. A suggested approach is to use source-exhaustion state, rather than buffer allocation, to determine whether enumeration remains necessary.
This is limited to callers accessing the count before completing enumeration; fully enumerating first is a workaround.
- 主要言語
- C#
- スター
- 22.5k
- フォーク
- 5.4k
- 平均マージ
- 13時間 11分
- マージ済み PR(30日)
- 104
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
QuantConnect/Lean のほかの issue
-
priority:p2
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
QuantConnect/Lean#10191 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
priority:p2
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
QuantConnect/Lean#10189 ·
メンテナーはふだん 1 日以内に返信
-
priority:p2
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
QuantConnect/Lean#10187 ·
メンテナーはふだん 1 日以内に返信
-
priority:p2
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
QuantConnect/Lean#10147 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
QuantConnect/Lean#10082 ·
メンテナーはふだん 1 日以内に返信
QuantConnect/Lean の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
area-ai untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
dotnet/extensions#7956 ·
メンテナーはふだん 1 日以内に返信
-
bug needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
microsoft/microsoft-ui-reactor#1567 ·
メンテナーはふだん 1 日以内に返信
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P2
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
openclaw/openclaw-windows-node#2287 · コメント 2 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
AI Generated CI/CD ⚒️ Flaky-tests 🐦 go 🏃
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
valkey-io/valkey-glide#7772 ·
メンテナーはふだん 1 日以内に返信