Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Should().BeEquivalentTo() throws "Sequence contains more than one matching element" when comparing classes that have a field that uses the "new" keyword to hide a field with the same name. #1982

Copy link
Copy link

Description

@ERGeorgiev
Issue body actions

I have class A that inherits class ABase. ABase contains field Id of type string. A has its own Id string field declared as new to hide the Id member coming from ABase.

Scenario:
Calling A.Should().BeEquivalentTo(A)

Expected:
The two fields are compared correctly for equivalency and the proper result is returned.

Actual:
Throws "Sequence contains more than one matching element", thrown on line 144 (return list. SingleOrDefault()) in method TypeExtensions.FindProperty() in my decompiled code.

Note:
Does not happen if you compare the same class instance to itself.

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

Morty Proxy This is a proxified and sanitized view of the page, visit original site.