Skip to content

Incorrect trimming of static properties when DIM is involved #2865

@dakersnar

Description

@dakersnar

I'm attempting to add a static virtual DIM (AllBitsSet) to an interface (IBinaryNumber), and then override it in a child (BigInteger). However, the test is failing because the DIM is being called instead of the child's implementation of it.

Here is the commit for reproduction purposes:
dakersnar/runtime@4af1fa8

Reproduction steps:

  • clone the above branch
  • ./build.cmd clr+libs -rc Release
  • cd .\src\libraries\System.Runtime.Numerics\tests
  • dotnet build /t:Test /p:XunitMethodName=System.Numerics.Tests.BigIntegerTests_GenericMath.AllBitsSetTest

Result:

System.Numerics.Tests.BigIntegerTests_GenericMath.AllBitsSetTest [FAIL]
Assert.Equal() Failure
Expected: -1 (this is what BigInteger.AllBitsSet should return
Actual: 1 (this is what the IBinaryNumber DIM returns)

More info

if you observe .\artifacts\obj\System.Runtime.Numerics\Release\net7.0\System.Runtime.Numerics.dll
vs .\artifacts\obj\System.Runtime.Numerics\Release\net7.0\PreTrim\System.Runtime.Numerics.dll
in a tool like ildasm, you'll see that the former has AllBitsSet and the latter is missing it. I suspect this is a trimmer bug.

It seems like similar issues have been looked at already (#2058) (#2711). Given that properties seem to still be buggy, @tannergooding recommends testing properties, events, and other member types explicitly.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions