Skip to content

Commit

Permalink
Breaking API change to support base type comparison. Equals made prot…
Browse files Browse the repository at this point in the history
…ected and and IEquatable<T> made explicit for classes.
  • Loading branch information
diegofrata committed Jan 3, 2023
1 parent c5e8fd8 commit 575c486
Show file tree
Hide file tree
Showing 35 changed files with 317 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ public override bool Equals(object? obj) =>

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
public bool Equals(global::Generator.Equals.Tests.Classes.BaseEquality.Manager? other)
bool global::System.IEquatable<global::Generator.Equals.Tests.Classes.BaseEquality.Manager>.Equals(global::Generator.Equals.Tests.Classes.BaseEquality.Manager? obj) => Equals((object?) obj);

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
protected bool Equals(global::Generator.Equals.Tests.Classes.BaseEquality.Manager? other)
{
return
base.Equals(other as global::Generator.Equals.Tests.Classes.BaseEquality.Person)
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;

return base.Equals(other as global::Generator.Equals.Tests.Classes.BaseEquality.Person)
&& global::Generator.Equals.DefaultEqualityComparer<global::System.String>.Default.Equals(this.Department!, other.Department!)
;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ public override bool Equals(object? obj) =>

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
public bool Equals(global::Generator.Equals.Tests.Classes.BaseEquality.Person? other)
bool global::System.IEquatable<global::Generator.Equals.Tests.Classes.BaseEquality.Person>.Equals(global::Generator.Equals.Tests.Classes.BaseEquality.Person? obj) => Equals((object?) obj);

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
protected bool Equals(global::Generator.Equals.Tests.Classes.BaseEquality.Person? other)
{
return
!ReferenceEquals(other, null) && this.GetType() == other.GetType()
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;

return other.GetType() == this.GetType()
&& global::Generator.Equals.DefaultEqualityComparer<global::System.Int32>.Default.Equals(this.Age!, other.Age!)
;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ public override bool Equals(object? obj) =>

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
public bool Equals(global::Generator.Equals.Tests.Classes.BaseEquality.Manager? other)
bool global::System.IEquatable<global::Generator.Equals.Tests.Classes.BaseEquality.Manager>.Equals(global::Generator.Equals.Tests.Classes.BaseEquality.Manager? obj) => Equals((object?) obj);

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
protected bool Equals(global::Generator.Equals.Tests.Classes.BaseEquality.Manager? other)
{
return
base.Equals(other as global::Generator.Equals.Tests.Classes.BaseEquality.Person)
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;

return base.Equals(other as global::Generator.Equals.Tests.Classes.BaseEquality.Person)
&& global::Generator.Equals.DefaultEqualityComparer<global::System.String>.Default.Equals(this.Department!, other.Department!)
;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ public override bool Equals(object? obj) =>

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
public bool Equals(global::Generator.Equals.Tests.Classes.BaseEquality.Person? other)
bool global::System.IEquatable<global::Generator.Equals.Tests.Classes.BaseEquality.Person>.Equals(global::Generator.Equals.Tests.Classes.BaseEquality.Person? obj) => Equals((object?) obj);

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
protected bool Equals(global::Generator.Equals.Tests.Classes.BaseEquality.Person? other)
{
return
!ReferenceEquals(other, null) && this.GetType() == other.GetType()
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;

return other.GetType() == this.GetType()
&& global::Generator.Equals.DefaultEqualityComparer<global::System.Int32>.Default.Equals(this.Age!, other.Age!)
;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ public override bool Equals(object? obj) =>

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
public bool Equals(global::Generator.Equals.Tests.Classes.CustomEquality.Sample? other)
bool global::System.IEquatable<global::Generator.Equals.Tests.Classes.CustomEquality.Sample>.Equals(global::Generator.Equals.Tests.Classes.CustomEquality.Sample? obj) => Equals((object?) obj);

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
protected bool Equals(global::Generator.Equals.Tests.Classes.CustomEquality.Sample? other)
{
return
!ReferenceEquals(other, null) && this.GetType() == other.GetType()
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;

return other.GetType() == this.GetType()
&& global::Generator.Equals.Tests.Classes.CustomEquality.Comparer1.Default.Equals(this.Name1!, other.Name1!)
&& global::Generator.Equals.Tests.Classes.CustomEquality.Comparer2.Instance.Equals(this.Name2!, other.Name2!)
&& new global::Generator.Equals.Tests.Classes.CustomEquality.LengthEqualityComparer().Equals(this.Name3!, other.Name3!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ public override bool Equals(object? obj) =>

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
public bool Equals(global::Generator.Equals.Tests.Classes.DeepEquality.Manager? other)
bool global::System.IEquatable<global::Generator.Equals.Tests.Classes.DeepEquality.Manager>.Equals(global::Generator.Equals.Tests.Classes.DeepEquality.Manager? obj) => Equals((object?) obj);

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
protected bool Equals(global::Generator.Equals.Tests.Classes.DeepEquality.Manager? other)
{
return
base.Equals(other as global::Generator.Equals.Tests.Classes.DeepEquality.Person)
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;

return base.Equals(other as global::Generator.Equals.Tests.Classes.DeepEquality.Person)
&& global::Generator.Equals.DefaultEqualityComparer<global::System.String>.Default.Equals(this.Department!, other.Department!)
;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ public override bool Equals(object? obj) =>

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
public bool Equals(global::Generator.Equals.Tests.Classes.DeepEquality.Person? other)
bool global::System.IEquatable<global::Generator.Equals.Tests.Classes.DeepEquality.Person>.Equals(global::Generator.Equals.Tests.Classes.DeepEquality.Person? obj) => Equals((object?) obj);

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
protected bool Equals(global::Generator.Equals.Tests.Classes.DeepEquality.Person? other)
{
return
!ReferenceEquals(other, null) && this.GetType() == other.GetType()
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;

return other.GetType() == this.GetType()
&& global::Generator.Equals.DefaultEqualityComparer<global::System.Int32>.Default.Equals(this.Age!, other.Age!)
;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ public override bool Equals(object? obj) =>

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
public bool Equals(global::Generator.Equals.Tests.Classes.DeepEquality.Sample? other)
bool global::System.IEquatable<global::Generator.Equals.Tests.Classes.DeepEquality.Sample>.Equals(global::Generator.Equals.Tests.Classes.DeepEquality.Sample? obj) => Equals((object?) obj);

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
protected bool Equals(global::Generator.Equals.Tests.Classes.DeepEquality.Sample? other)
{
return
!ReferenceEquals(other, null) && this.GetType() == other.GetType()
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;

return other.GetType() == this.GetType()
&& global::Generator.Equals.DefaultEqualityComparer<global::Generator.Equals.Tests.Classes.DeepEquality.Person>.Default.Equals(this.Person!, other.Person!)
;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ public override bool Equals(object? obj) =>

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
public bool Equals(global::Generator.Equals.Tests.Classes.DeepEquality.Manager? other)
bool global::System.IEquatable<global::Generator.Equals.Tests.Classes.DeepEquality.Manager>.Equals(global::Generator.Equals.Tests.Classes.DeepEquality.Manager? obj) => Equals((object?) obj);

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
protected bool Equals(global::Generator.Equals.Tests.Classes.DeepEquality.Manager? other)
{
return
base.Equals(other as global::Generator.Equals.Tests.Classes.DeepEquality.Person)
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;

return base.Equals(other as global::Generator.Equals.Tests.Classes.DeepEquality.Person)
&& global::Generator.Equals.DefaultEqualityComparer<global::System.String>.Default.Equals(this.Department!, other.Department!)
;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ public override bool Equals(object? obj) =>

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
public bool Equals(global::Generator.Equals.Tests.Classes.DeepEquality.Person? other)
bool global::System.IEquatable<global::Generator.Equals.Tests.Classes.DeepEquality.Person>.Equals(global::Generator.Equals.Tests.Classes.DeepEquality.Person? obj) => Equals((object?) obj);

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
protected bool Equals(global::Generator.Equals.Tests.Classes.DeepEquality.Person? other)
{
return
!ReferenceEquals(other, null) && this.GetType() == other.GetType()
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;

return other.GetType() == this.GetType()
&& global::Generator.Equals.DefaultEqualityComparer<global::System.Int32>.Default.Equals(this.Age!, other.Age!)
;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ public override bool Equals(object? obj) =>

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
public bool Equals(global::Generator.Equals.Tests.Classes.DeepEquality.Sample? other)
bool global::System.IEquatable<global::Generator.Equals.Tests.Classes.DeepEquality.Sample>.Equals(global::Generator.Equals.Tests.Classes.DeepEquality.Sample? obj) => Equals((object?) obj);

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
protected bool Equals(global::Generator.Equals.Tests.Classes.DeepEquality.Sample? other)
{
return
!ReferenceEquals(other, null) && this.GetType() == other.GetType()
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;

return other.GetType() == this.GetType()
&& global::Generator.Equals.DefaultEqualityComparer<global::Generator.Equals.Tests.Classes.DeepEquality.Person>.Default.Equals(this.Person!, other.Person!)
;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ public override bool Equals(object? obj) =>

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
public bool Equals(global::Generator.Equals.Tests.Classes.DictionaryEquality.Sample? other)
bool global::System.IEquatable<global::Generator.Equals.Tests.Classes.DictionaryEquality.Sample>.Equals(global::Generator.Equals.Tests.Classes.DictionaryEquality.Sample? obj) => Equals((object?) obj);

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
protected bool Equals(global::Generator.Equals.Tests.Classes.DictionaryEquality.Sample? other)
{
return
!ReferenceEquals(other, null) && this.GetType() == other.GetType()
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;

return other.GetType() == this.GetType()
&& global::Generator.Equals.DictionaryEqualityComparer<string, int>.Default.Equals(this.Properties!, other.Properties!)
;
}
Expand Down
12 changes: 9 additions & 3 deletions Generator.Equals.SnapshotTests/Classes/ExplicitMode.verified.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ public override bool Equals(object? obj) =>

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
public bool Equals(global::Generator.Equals.Tests.Classes.ExplicitMode.Sample? other)
bool global::System.IEquatable<global::Generator.Equals.Tests.Classes.ExplicitMode.Sample>.Equals(global::Generator.Equals.Tests.Classes.ExplicitMode.Sample? obj) => Equals((object?) obj);

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
protected bool Equals(global::Generator.Equals.Tests.Classes.ExplicitMode.Sample? other)
{
return
!ReferenceEquals(other, null) && this.GetType() == other.GetType()
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;

return other.GetType() == this.GetType()
&& global::Generator.Equals.DefaultEqualityComparer<global::System.Int32>.Default.Equals(this.Age!, other.Age!)
;
}
Expand Down
12 changes: 9 additions & 3 deletions Generator.Equals.SnapshotTests/Classes/FieldEquality.verified.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ public override bool Equals(object? obj) =>

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
public bool Equals(global::Generator.Equals.Tests.Classes.FieldEquality.Sample? other)
bool global::System.IEquatable<global::Generator.Equals.Tests.Classes.FieldEquality.Sample>.Equals(global::Generator.Equals.Tests.Classes.FieldEquality.Sample? obj) => Equals((object?) obj);

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
protected bool Equals(global::Generator.Equals.Tests.Classes.FieldEquality.Sample? other)
{
return
!ReferenceEquals(other, null) && this.GetType() == other.GetType()
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;

return other.GetType() == this.GetType()
&& global::Generator.Equals.OrderedEqualityComparer<string>.Default.Equals(this._addresses!, other._addresses!)
;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ public override bool Equals(object? obj) =>

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
public bool Equals(global::Generator.Equals.Tests.Classes.GenericParameterEquality.Sample<TName, TAge>? other)
bool global::System.IEquatable<global::Generator.Equals.Tests.Classes.GenericParameterEquality.Sample<TName, TAge>>.Equals(global::Generator.Equals.Tests.Classes.GenericParameterEquality.Sample<TName, TAge>? obj) => Equals((object?) obj);

/// <inheritdoc/>
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")]
protected bool Equals(global::Generator.Equals.Tests.Classes.GenericParameterEquality.Sample<TName, TAge>? other)
{
return
!ReferenceEquals(other, null) && this.GetType() == other.GetType()
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;

return other.GetType() == this.GetType()
&& global::Generator.Equals.DefaultEqualityComparer<TName>.Default.Equals(this.Name!, other.Name!)
&& global::Generator.Equals.DefaultEqualityComparer<TAge>.Default.Equals(this.Age!, other.Age!)
;
Expand Down
Loading

0 comments on commit 575c486

Please sign in to comment.