Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Incorrect trimming of static properties when DIM is involved #2865

Closed

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.

Activity

  1. tannergooding commented on Jun 24, 2022

    @tannergooding
    Member
  2. agocke commented on Jun 25, 2022

    @agocke
    Member
  3. self-assigned this
    on Jul 26, 2022
  4. added this to the .NET 7.0 milestone on Jul 26, 2022
  5. agocke commented on Jul 27, 2022

    @agocke
    Member

    I believe this is fixed.

  6. added a commit that references this issue on Aug 3, 2022
    118bdca
  7. added a commit that references this issue on Nov 16, 2022
    c4c3a35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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