MemoizingEnumerable.Count returns only the buffered prefix after partial enumeration
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
Línea de trabajo
Empieza con Common/Util/MemoizingEnumerable.cs y sigue cómo Count, Empty y la enumeración parcial usan el búfer y registran el agotamiento de la fuente. Añade cobertura para llamar a Count inmediatamente, después de Empty y después de una enumeración parcial, incluido el caso Take(1).Single(). Se considera terminado cuando cada orden de acceso devuelve el recuento completo sin perder elementos almacenados en el búfer ni volver a evaluar la fuente.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C#
- Estrellas
- 22.5k
- Forks
- 5.4k
- Merge medio
- 13 h 11 min
- PR fusionados (30 d)
- 104
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de QuantConnect/Lean
-
priority:p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
QuantConnect/Lean#10191 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
priority:p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
QuantConnect/Lean#10189 ·
Los mantenedores suelen responder en 1 día
-
priority:p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
QuantConnect/Lean#10187 ·
Los mantenedores suelen responder en 1 día
-
priority:p2
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
QuantConnect/Lean#10147 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
PDF report generation can overwrite HTML when the destination extension is not lowercase .htmlAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
QuantConnect/Lean#10082 ·
Los mantenedores suelen responder en 1 día
Todos los issues de QuantConnect/Lean
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 1 día
-
area-ai untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
dotnet/extensions#7956 ·
Los mantenedores suelen responder en 1 día
-
bug needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
microsoft/microsoft-ui-reactor#1567 ·
Los mantenedores suelen responder en 1 día
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
openclaw/openclaw-windows-node#2287 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
AI Generated CI/CD ⚒️ Flaky-tests 🐦 go 🏃
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
valkey-io/valkey-glide#7772 ·
Los mantenedores suelen responder en 1 día