Incorrect Code coverage reporting for C# Object Initializers
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Tranquilla
- Stack tecnologico
- csharp
- Ambito
- testing-qa
Direzione di ricerca
Inizia riproducendo il modello di inizializzatore di oggetti e raccolte segnalato e il suo equivalente con assegnazioni esplicite usando vstest.console 17.14.0-release-25203-01 e 18.0.1-release-25520-05. Confronta i report di coverage risultanti; il lavoro è completato quando le istruzioni di inizializzazione risultano coperte se il percorso del codice viene eseguito completamente, oppure quando la limitazione e il workaround sono documentati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
We are running into an issue where code coverage reports incorrect or partial coverage for certain C# object/collection initializer patterns, even though the code path is fully executed.
Specifically, the following initializer-style pattern is not fully recognized by the coverage tool:
var thing = new Example
{
name = "object one",
[1] = '1',
[2] = '4',
[3] = '9',
Size = Math.PI,
['C', 4] = "Middle C"
};
To investigate, I ran the impacted tests locally using two versions of vstest.console:
17.14.0-release-25203-01
18.0.1-release-25520-05
In both cases, the coverage results remained unchanged, which suggests this is not resolved by upgrading the test runner.
What we’ve observed is that rewriting the same logic using explicit assignments (instead of initializer-style patterns) results in correct coverage being reported. For example, the following pattern is correctly recognized by the coverage tool:
var thing = new Example();
thing.name = "object one";
thing[1] = '1';
thing[2] = '4';
thing[3] = '9';
thing.Size = Math.PI;
thing['C', 4] = "Middle C";
Based on this, it appears to be a limitation or bug in how the underlying coverage engine handles certain object/collection initializer patterns, rather than an issue with our pipeline or configuration.
If this is a known limitation, or if there is a recommended workaround or escalation path, guidance would be appreciated.
Thanks!
- Lingua principale
- C#
- Stelle
- 125
- Fork
- 17
- Merge medio
- 1h 17m
- PR unite (30g)
- 2
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/codecoverage
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
microsoft/codecoverage#246 · 6 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
microsoft/codecoverage#237 · 1 commento ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
microsoft/codecoverage#234 · 1 commento · 2 reazioni ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
microsoft/codecoverage#233 · 2 reazioni ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 28/100
microsoft/codecoverage#232 · 6 commenti ·
Tutte le issue di microsoft/codecoverage
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
sillsdev/languageforge-lexbox#2665 ·
-
bug documentation frontend
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
azurenoops/spin_agent#975 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
SubtitleEdit/subtitleedit#15108 · 1 commento ·