Skip to content

Conversation

@dennisdoomen
Copy link
Member

@dennisdoomen dennisdoomen commented Jul 30, 2021

Excluding() or Including() covariant properties in a BeEquivalentTo call didn't work. To reproduce this, I had to include .NET 5 to the frameworks the unit test project targets. Also, covariant properties behave completely different from normal properties. In fact, from a Reflection point of view, it looks like a covariant property is a completely different property, a bit like new properties. See also this SO thread.

Then while looking at #1363, I discovered another problem. Simply calling GetProperties on a hierarchy that includes covariant or "new" properties will also include the hidden properties, causing weird side-effects later on. The new implementation traverses the class hierarchy and will only return the fields and properties that are really visible from a certain type.

Fixes #1562 and #1363

@dennisdoomen dennisdoomen force-pushed the Fix/1562 branch 3 times, most recently from 1bbce09 to 26a0b8f Compare August 1, 2021 12:36
@dennisdoomen dennisdoomen marked this pull request as ready for review August 1, 2021 12:38
@dennisdoomen dennisdoomen requested a review from jnyrup August 1, 2021 12:38
This also broke a test that was relying on some internal behavior in earlier versions of the framework.
@dennisdoomen dennisdoomen removed the request for review from jnyrup August 3, 2021 17:56
@dennisdoomen dennisdoomen marked this pull request as draft August 3, 2021 17:56
Simply calling GetProperties on a hierarchy that includes covariant or "new" properties will also include the hidden properties. The new implementation traverses the class hierarchy and will only return the fields and properties that are really visible from a certain type.
@dennisdoomen dennisdoomen changed the title Support covariant property exclusion and inclusion in BeEquivalentTo Support covariant and inherited property exclusion and inclusion in BeEquivalentTo Aug 4, 2021
@dennisdoomen dennisdoomen marked this pull request as ready for review August 4, 2021 19:27
@dennisdoomen dennisdoomen requested a review from jnyrup August 4, 2021 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants