question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incomplete GetHashCode() method generated for an entity that does not define any properties

See original GitHub issue

When trying to code gen an entity without any properties (only has operations), GetHashCode() is not generated fully and causes compile error. Missing a return and closing }. It comes out as:

public override int GetHashCode()
        {
            var hash = new HashCode();
        #region ICopyFrom

If a property is added to the entity and re-gen’d, the method is generated correctly, e.g.

public override int GetHashCode()
        {
            var hash = new HashCode();
            hash.Add(TestProp);
            return base.GetHashCode() ^ hash.ToHashCode();
        }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
edjo23commented, Nov 12, 2020

Hi @chullybun, sorry for the late reply (I took some time off and went away for a week). I haven’t had a chance to check it out yet. Will try and test it out soon.

1reaction
chullybuncommented, Oct 29, 2020

Hi @Simke11, issue is fixed. Published NuGet package Beef.CodeGen.Core version 4.1.7. Cheers…

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the best way to implement GetHashCode() for class ...
1. Note: The hash code will change if any public property changes value. · Note: if two class instances have the same number...
Read more >
How do you implement GetHashCode() on a class that has ...
It is an easy to misunderstand what you should do with GetHashCode in a mutable class, and it gladly generates improper data into...
Read more >
Generate C# Equals and GetHashCode Method Overrides
Override the GetHashCode method to allow a type to work correctly in a hash table. Read more guidance on equality operators.
Read more >
Object.GetHashCode Method (System)
One of the simplest ways to compute a hash code for a numeric value that has the same or a smaller range than...
Read more >
Non-readonly type member referenced in 'GetHashCode()'
Specifically, it says: The GetHashCode method for an object must consistently return the same hash code as long as there is no modification...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found