Microsoft.CodeCoverage.MSBuild introduces new trim warnings in otherwise trim-safe project
@fhnaseer ci sta già lavorando.
Dal 5/1/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Describe the bug
Adding static code coverage instrumentation to a NativeAOT test binary introduces trim warnings where there were none before.
My guess is whatever IL rewriting is going on for static code analysis, it isn't applying appropriate attributes to the modified code to preserve trim safety.
Steps To Reproduce
git clone -b tunit-code-coverage git@github.com:AArnott/Nerdbank.MessagePack.git
cd Nerdbank.MessagePack
./init.ps1
dotnet publish -f net10.0 .\test\Nerdbank.MessagePack.TUnit\
Expected behavior
No trim warnings.
Actual behavior
Nerdbank.MessagePack.TUnit net10.0 win-x64 succeeded with 3 warning(s) (26.3s) → bin\Nerdbank.MessagePack.TUnit\Debug\net10.0\win-x64\publish\
E:\src\nerdbank.messagepack\src\Nerdbank.MessagePack\ConverterTypeCollection.cs(116): Trim analysis warning IL2078: Nerdbank.MessagePack.ConverterTypeCollection.ConverterType.Type.get: 'Nerdbank.MessagePack.ConverterTypeCollection.ConverterType.Type.get' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors' requirements. The field 'Nerdbank.MessagePack.ConverterTypeCollection.ConverterType.<Type>k__BackingField' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
E:\src\nerdbank.messagepack\src\Nerdbank.MessagePack\UseComparerAttribute.cs(56): Trim analysis warning IL2078: Nerdbank.MessagePack.UseComparerAttribute.ComparerType.get: 'Nerdbank.MessagePack.UseComparerAttribute.ComparerType.get' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor', 'DynamicallyAccessedMemberTypes.PublicProperties' requirements. The field 'Nerdbank.MessagePack.UseComparerAttribute.<ComparerType>k__BackingField' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
E:\src\nerdbank.messagepack\src\Nerdbank.MessagePack\MessagePackConverterAttribute.cs(32): Trim analysis warning IL2078: Nerdbank.MessagePack.MessagePackConverterAttribute.ConverterType.get: 'Nerdbank.MessagePack.MessagePackConverterAttribute.ConverterType.get' method return value does not satisfy 'DynamicallyAccessedMemberTypes.PublicParameterlessConstructor' requirements. The field 'Nerdbank.MessagePack.MessagePackConverterAttribute.<ConverterType>k__BackingField' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
Additional context
If you run git checkout HEAD~1 and then repeat the publish command, you can see how the trim warnings disappear.
The only difference is you've removed the last commit, which is what added the Microsoft.CodeCoverage.MSBuild package dependency and AotMsCodeCoverageInstrumentation property.
- 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
-
type/automation type/tech-debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
t/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
ci-failure-cause test-failure
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
area:auth FE mvp P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
klasolsson81/jobbliggaren#1788 ·