runtime: Huge Breaking Issue in Net7 with MemberInfo equality

Description

If you compare 2 Memberinfos in Net7 from a Class and a Base they are equal in 7 but not in Previous Versions. Cause of this my Database Mapping Framework did not work any more. see issue: https://github.com/linq2db/linq2db/issues/3823

Reproduction Steps

Try this code in Net6 it returns false, in 7 it returns true

    var i1 = typeof(a).GetProperty("c");
    var i2 = typeof(b).GetProperty("c");

    Console.WriteLine(i1 == i2);
    Console.ReadLine();

    class a
    {
        public string c { get; set; }
    }

    class b : a
    { }

Expected behavior

Code should return false

Actual behavior

returns tre

Regression?

Yes

Known Workarounds

None

Configuration

No response

Other information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (8 by maintainers)

Most upvoted comments

Seems reasonable to backport. Regression from last release in a common scenario with non-trivial workaround. Proceed with fix in main then open the backport pr and add template when ready.

Note that this reproduces only under debugger with hot-reload enabled. You can work around this by disabling hot-reload.

Maybe a ReflectedType comparison is missing here: https://github.com/dotnet/runtime/blob/main/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimePropertyInfo.cs#L59

ReflectedType comparison is missing in the Equals method. The CacheEquals method is fine.

really? milestone 8.0.0?

Could be a huge problem with linq2db and fluent mapping. It depends on the correct behavior.