public partial class DummyModel : IEqutable<DummyModel>
{
//Your properties
}
using System;
namespace EquatableSourceGenerator.Sample.Models
{
partial class DummyModel
{
public bool Equals(DummyModel? other)
{
return other is not null
/*&& All your properties*/;
}
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
return obj.GetType() == this.GetType()
|| obj is DummyModel self && Equals(self);
}
public override int GetHashCode()
{
HashCode hashCode = new();
/*&& hashCode will add all your properties*/;
return hashCode.ToHashCode();
}
public static bool operator == (DummyModel? self, DummyModel? other)
{
return other?.Equals(self) ?? self is null;
}
public static bool operator != (DummyModel? self, DummyModel? other)
{
return !(self == other);
}
}
}