<commit_before>using Ritter.Domain.Seedwork.Validation;
using System;

namespace Ritter.Domain.Seedwork
{
    public abstract class Entity : IEntity
    {
        private int? requestedHashCode;

        public virtual int Id { get; protected set; }

        public virtual Guid Uid { get; protected set; } = Guid.NewGuid();

        protected Entity() : base() { }

        public bool IsTransient()
        {
            return Id == default(int);
        }

        public override bool Equals(object obj)
        {
            if (obj is null || !(obj is Entity))
                return false;

            if (ReferenceEquals(this, obj))
                return true;

            Entity item = obj as Entity;

            if (item.IsTransient() || this.IsTransient())
                return false;

            return item.Id == this.Id;
        }

        public override int GetHashCode()
        {
            if (!IsTransient())
            {
                if (!requestedHashCode.HasValue)
                    requestedHashCode = this.Id.GetHashCode() ^ 31;

                return requestedHashCode.Value;
            }

            return base.GetHashCode();
        }

        public static bool operator ==(Entity left, Entity right)
        {
            if (Equals(left, null))
                return (Equals(right, null)) ? true : false;

            return left.Equals(right);
        }

        public static bool operator !=(Entity left, Entity right)
        {
            return !(left == right);
        }
    }
}<commit_msg>refact(entity): fix gethashcode<commit_after>using Ritter.Domain.Seedwork.Validation;
using System;

namespace Ritter.Domain.Seedwork
{
    public abstract class Entity : IEntity
    {
        public virtual int Id { get; protected set; }

        public virtual Guid Uid { get; protected set; } = Guid.NewGuid();

        protected Entity() : base() { }

        public bool IsTransient()
        {
            return Id == default(int);
        }

        public override bool Equals(object obj)
        {
            if (obj is null || !(obj is Entity))
                return false;

            if (ReferenceEquals(this, obj))
                return true;

            Entity item = obj as Entity;

            if (item.IsTransient() || this.IsTransient())
                return false;

            return item.Id == this.Id;
        }

        public override int GetHashCode()
        {
            if (!IsTransient())
                return this.Id.GetHashCode() ^ 31;

            return base.GetHashCode();
        }

        public static bool operator ==(Entity left, Entity right)
        {
            if (Equals(left, null))
                return (Equals(right, null)) ? true : false;

            return left.Equals(right);
        }

        public static bool operator !=(Entity left, Entity right)
        {
            return !(left == right);
        }
    }
}
{'fraction_non_alphanumeric': 0.09754433833560709, 'fraction_numerical': 0.001364256480218281, 'mean_word_length': 1.5437987857762359, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7461136', 'n_tokens_mistral': 778, 'n_tokens_neox': 734, 'n_words': 223}