-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
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.
Metadata
Metadata
Assignees
Labels
No labels