Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Huge Breaking Issue in Net7 with MemberInfo equality #78218

Closed
jogibear9988 opened this issue Nov 11, 2022 · 21 comments · Fixed by #78249
Closed

Huge Breaking Issue in Net7 with MemberInfo equality #78218

jogibear9988 opened this issue Nov 11, 2022 · 21 comments · Fixed by #78249
Assignees
Milestone

Comments

@jogibear9988
Copy link

jogibear9988 commented Nov 11, 2022

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: linq2db/linq2db#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

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Nov 11, 2022
@jogibear9988
Copy link
Author

jogibear9988 commented Nov 11, 2022

And if you do:

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

this will return false... So memberinfos with different properties are handled as equal

@jogibear9988
Copy link
Author

jogibear9988 commented Nov 11, 2022

@stephentoub
Copy link
Member

cc: @buyaa-n, @jkotas

@jogibear9988
Copy link
Author

jogibear9988 commented Nov 11, 2022

With Fields it's also an issue. With Methods it works.

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

    var i3 = typeof(a).GetMethod("aa");
    var i4 = typeof(b).GetMethod("aa");
    Console.WriteLine(i3 == i4);

    var i5 = typeof(a).GetField("d");
    var i6 = typeof(b).GetField("d");
    Console.WriteLine(i5 == i6);
    Console.WriteLine(i5.ReflectedType == i6.ReflectedType);

    Console.ReadLine();

    class a
    {
        public string c { get; set; }
        public void aa() { }
        public string d;
    }

    class b : a
    { }

@jogibear9988
Copy link
Author

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

@jogibear9988
Copy link
Author

And a question, will there be an Hotfix?

@jkotas
Copy link
Member

jkotas commented Nov 11, 2022

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.

@marek-safar
Copy link
Contributor

/cc @lambdageek

@jogibear9988
Copy link
Author

I've the issue also in VS when I disable Hotreload

@jogibear9988
Copy link
Author

And also in release Mode.

@jogibear9988
Copy link
Author

It don't appear to happen if you don't start from Visual Studio

@jogibear9988
Copy link
Author

Now I understand why I don't saw this issue in my logfiles. I was looking why our App does not work in Net7 and thought this is the issue. But so it's not. It's only an issue while debugging. Now I need to look what's wrong without debugger...

@buyaa-n buyaa-n added this to the 8.0.0 milestone Nov 11, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Nov 11, 2022
@jogibear9988
Copy link
Author

really? milestone 8.0.0?

@steveharter
Copy link
Member

really? milestone 8.0.0?

We always start with current (8.0 here) then backport.

@jogibear9988
Copy link
Author

Can someone tell me, how I could disable hot reload? So I could still debug.

image

the upper two switches don't seem to help, I still got the error.

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Nov 11, 2022
@buyaa-n
Copy link
Contributor

buyaa-n commented Nov 11, 2022

We always start with current (8.0 here) then backport.

Tag @ericstj @jeffhandley for porting the fix to 7.0

@ericstj
Copy link
Member

ericstj commented Nov 12, 2022

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.

@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Nov 12, 2022
@jogibear9988
Copy link
Author

@jkotas

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

can you tell me how to disable it when I start the app from within visual studio?

@jkotas
Copy link
Member

jkotas commented Nov 14, 2022

I just checked - it is not possible to completely disable hot-reload when running under debugger. Parts of it are automatically enabled when debugger is attached. I am sorry that the workaround that I have suggested does not work.

@jogibear9988
Copy link
Author

@jkotas
maybe it should also be thought of? a way to disable hot reload?

@jkotas
Copy link
Member

jkotas commented Nov 18, 2022

Yes, I agree: #78540

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants