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

new ContentWrapperAttribute(null).GetHashCode() throws NRE #212

Closed
hughbe opened this issue Dec 26, 2018 · 0 comments · Fixed by #215
Closed

new ContentWrapperAttribute(null).GetHashCode() throws NRE #212

hughbe opened this issue Dec 26, 2018 · 0 comments · Fixed by #215
Labels
Bug Product bug (most likely) 🚧 work in progress

Comments

@hughbe
Copy link
Contributor

hughbe commented Dec 26, 2018

[Fact]
public void GetHashCode_NullContentWrapper_ThrowsNullReferenceException()
{
    var attribute = new ContentWrapperAttribute(null);
    Assert.Throws<NullReferenceException>(() => attribute.GetHashCode());
}

From https://blogs.msdn.microsoft.com/ericlippert/2011/02/28/guidelines-and-rules-for-gethashcode/:

Rule: GetHashCode must never throw an exception, and must return

Getting a hash code simply calculates an integer; there's no reason why it should ever fail. An implementation of GetHashCode should be able to handle any legal configuration of the object.

@stevenbrix stevenbrix added this to the 3.0 milestone Apr 4, 2019
@stevenbrix stevenbrix added the Bug Product bug (most likely) label Apr 4, 2019
@rladuca rladuca modified the milestones: 3.0, Future May 20, 2019
@ghost ghost removed this from the Future milestone Apr 28, 2023
@ghost ghost locked as resolved and limited conversation to collaborators May 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Product bug (most likely) 🚧 work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants