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

Apply Object member rules even when the methods are overridden #1777

Closed
thomaslevesque opened this issue Jun 5, 2020 · 1 comment · Fixed by #1778
Closed

Apply Object member rules even when the methods are overridden #1777

thomaslevesque opened this issue Jun 5, 2020 · 1 comment · Fixed by #1778
Assignees
Milestone

Comments

@thomaslevesque
Copy link
Member

Prompted by #1774, after internal discussion.

Currently, special fake rules are applied for members of System.Object:

  • Equals(object): returns true if the argument is the same instance as the fake
  • GetHashCode(): returns the hash code of the fake manager
  • ToString(): returns a default string representation of the form Faked <faked object type>

However, when the faked type overrides those methods, these rules are not applied, so a default value is returned instead (unless the methods are explicitly configured). This leads to surprising results:

  • Equals always returns false, so the fake isn't even considered equal to itself
  • GetHashCode always returns 0
  • ToString always returns an empty string

Although this behavior makes sense from a technical point of view, there doesn't seem to be any scenario where it's desirable.

The special rules should still be applied even if the fake type overrides System.Object members.

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

Successfully merging a pull request may close this issue.

2 participants