-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from diegofrata/deep-equality
Fix the IEquatable<T> implementation so it works when comparing using base types
- Loading branch information
Showing
43 changed files
with
698 additions
and
164 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
...lity.00Generator.Equals.Tests.Classes.BaseEquality.Manager.Generator.Equals.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//HintName: Generator.Equals.Tests.Classes.BaseEquality.Manager.Generator.Equals.g.cs | ||
|
||
#nullable enable | ||
#pragma warning disable CS0612,CS0618 | ||
|
||
namespace Generator.Equals.Tests.Classes | ||
{ | ||
partial class BaseEquality | ||
{ | ||
partial class Manager : global::System.IEquatable<Manager> | ||
{ | ||
/// <summary> | ||
/// Indicates whether the object on the left is equal to the object on the right. | ||
/// </summary> | ||
/// <param name="left">The left object</param> | ||
/// <param name="right">The right object</param> | ||
/// <returns>true if the objects are equal; otherwise, false.</returns> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public static bool operator ==( | ||
global::Generator.Equals.Tests.Classes.BaseEquality.Manager? left, | ||
global::Generator.Equals.Tests.Classes.BaseEquality.Manager? right) => | ||
global::Generator.Equals.DefaultEqualityComparer<global::Generator.Equals.Tests.Classes.BaseEquality.Manager?>.Default | ||
.Equals(left, right); | ||
|
||
/// <summary> | ||
/// Indicates whether the object on the left is not equal to the object on the right. | ||
/// </summary> | ||
/// <param name="left">The left object</param> | ||
/// <param name="right">The right object</param> | ||
/// <returns>true if the objects are not equal; otherwise, false.</returns> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public static bool operator !=(global::Generator.Equals.Tests.Classes.BaseEquality.Manager? left, global::Generator.Equals.Tests.Classes.BaseEquality.Manager? right) => | ||
!(left == right); | ||
|
||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public override bool Equals(object? obj) | ||
{ | ||
var other = obj as global::Generator.Equals.Tests.Classes.BaseEquality.Manager; | ||
return | ||
!ReferenceEquals(other, null) && base.Equals(obj) | ||
&& global::Generator.Equals.DefaultEqualityComparer<global::System.String>.Default.Equals(this.Department!, other.Department!) | ||
; | ||
} | ||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public bool Equals(global::Generator.Equals.Tests.Classes.BaseEquality.Manager? other) => | ||
Equals((object?) other); | ||
|
||
|
||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public override int GetHashCode() | ||
{ | ||
var hashCode = new global::System.HashCode(); | ||
|
||
hashCode.Add(base.GetHashCode()); | ||
hashCode.Add( | ||
this.Department!, | ||
global::Generator.Equals.DefaultEqualityComparer<global::System.String>.Default); | ||
|
||
return hashCode.ToHashCode(); | ||
} | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...ality.01Generator.Equals.Tests.Classes.BaseEquality.Person.Generator.Equals.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//HintName: Generator.Equals.Tests.Classes.BaseEquality.Person.Generator.Equals.g.cs | ||
|
||
#nullable enable | ||
#pragma warning disable CS0612,CS0618 | ||
|
||
namespace Generator.Equals.Tests.Classes | ||
{ | ||
partial class BaseEquality | ||
{ | ||
partial class Person : global::System.IEquatable<Person> | ||
{ | ||
/// <summary> | ||
/// Indicates whether the object on the left is equal to the object on the right. | ||
/// </summary> | ||
/// <param name="left">The left object</param> | ||
/// <param name="right">The right object</param> | ||
/// <returns>true if the objects are equal; otherwise, false.</returns> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public static bool operator ==( | ||
global::Generator.Equals.Tests.Classes.BaseEquality.Person? left, | ||
global::Generator.Equals.Tests.Classes.BaseEquality.Person? right) => | ||
global::Generator.Equals.DefaultEqualityComparer<global::Generator.Equals.Tests.Classes.BaseEquality.Person?>.Default | ||
.Equals(left, right); | ||
|
||
/// <summary> | ||
/// Indicates whether the object on the left is not equal to the object on the right. | ||
/// </summary> | ||
/// <param name="left">The left object</param> | ||
/// <param name="right">The right object</param> | ||
/// <returns>true if the objects are not equal; otherwise, false.</returns> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public static bool operator !=(global::Generator.Equals.Tests.Classes.BaseEquality.Person? left, global::Generator.Equals.Tests.Classes.BaseEquality.Person? right) => | ||
!(left == right); | ||
|
||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public override bool Equals(object? obj) | ||
{ | ||
var other = obj as global::Generator.Equals.Tests.Classes.BaseEquality.Person; | ||
return | ||
!ReferenceEquals(other, null) && this.GetType() == other.GetType() | ||
&& global::Generator.Equals.DefaultEqualityComparer<global::System.Int32>.Default.Equals(this.Age!, other.Age!) | ||
; | ||
} | ||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public bool Equals(global::Generator.Equals.Tests.Classes.BaseEquality.Person? other) => | ||
Equals((object?) other); | ||
|
||
|
||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public override int GetHashCode() | ||
{ | ||
var hashCode = new global::System.HashCode(); | ||
|
||
hashCode.Add(this.GetType()); | ||
hashCode.Add( | ||
this.Age!, | ||
global::Generator.Equals.DefaultEqualityComparer<global::System.Int32>.Default); | ||
|
||
return hashCode.ToHashCode(); | ||
} | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
Generator.Equals.SnapshotTests/Classes/BaseEquality.Diagnostics.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
66 changes: 66 additions & 0 deletions
66
...t6_0.00Generator.Equals.Tests.Classes.BaseEquality.Manager.Generator.Equals.g.received.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//HintName: Generator.Equals.Tests.Classes.BaseEquality.Manager.Generator.Equals.g.cs | ||
|
||
#nullable enable | ||
#pragma warning disable CS0612,CS0618 | ||
|
||
namespace Generator.Equals.Tests.Classes | ||
{ | ||
partial class BaseEquality | ||
{ | ||
partial class Manager : global::System.IEquatable<Manager> | ||
{ | ||
/// <summary> | ||
/// Indicates whether the object on the left is equal to the object on the right. | ||
/// </summary> | ||
/// <param name="left">The left object</param> | ||
/// <param name="right">The right object</param> | ||
/// <returns>true if the objects are equal; otherwise, false.</returns> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public static bool operator ==( | ||
global::Generator.Equals.Tests.Classes.BaseEquality.Manager? left, | ||
global::Generator.Equals.Tests.Classes.BaseEquality.Manager? right) => | ||
global::Generator.Equals.DefaultEqualityComparer<global::Generator.Equals.Tests.Classes.BaseEquality.Manager?>.Default | ||
.Equals(left, right); | ||
|
||
/// <summary> | ||
/// Indicates whether the object on the left is not equal to the object on the right. | ||
/// </summary> | ||
/// <param name="left">The left object</param> | ||
/// <param name="right">The right object</param> | ||
/// <returns>true if the objects are not equal; otherwise, false.</returns> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public static bool operator !=(global::Generator.Equals.Tests.Classes.BaseEquality.Manager? left, global::Generator.Equals.Tests.Classes.BaseEquality.Manager? right) => | ||
!(left == right); | ||
|
||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public override bool Equals(object? obj) | ||
{ | ||
var other = obj as global::Generator.Equals.Tests.Classes.BaseEquality.Manager; | ||
return | ||
!ReferenceEquals(other, null) && base.Equals(obj) | ||
&& global::Generator.Equals.DefaultEqualityComparer<global::System.String>.Default.Equals(this.Department!, other.Department!) | ||
; | ||
} | ||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public bool Equals(global::Generator.Equals.Tests.Classes.BaseEquality.Manager? other) => | ||
Equals((object?) other); | ||
|
||
|
||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public override int GetHashCode() | ||
{ | ||
var hashCode = new global::System.HashCode(); | ||
|
||
hashCode.Add(base.GetHashCode()); | ||
hashCode.Add( | ||
this.Department!, | ||
global::Generator.Equals.DefaultEqualityComparer<global::System.String>.Default); | ||
|
||
return hashCode.ToHashCode(); | ||
} | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...et6_0.01Generator.Equals.Tests.Classes.BaseEquality.Person.Generator.Equals.g.received.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//HintName: Generator.Equals.Tests.Classes.BaseEquality.Person.Generator.Equals.g.cs | ||
|
||
#nullable enable | ||
#pragma warning disable CS0612,CS0618 | ||
|
||
namespace Generator.Equals.Tests.Classes | ||
{ | ||
partial class BaseEquality | ||
{ | ||
partial class Person : global::System.IEquatable<Person> | ||
{ | ||
/// <summary> | ||
/// Indicates whether the object on the left is equal to the object on the right. | ||
/// </summary> | ||
/// <param name="left">The left object</param> | ||
/// <param name="right">The right object</param> | ||
/// <returns>true if the objects are equal; otherwise, false.</returns> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public static bool operator ==( | ||
global::Generator.Equals.Tests.Classes.BaseEquality.Person? left, | ||
global::Generator.Equals.Tests.Classes.BaseEquality.Person? right) => | ||
global::Generator.Equals.DefaultEqualityComparer<global::Generator.Equals.Tests.Classes.BaseEquality.Person?>.Default | ||
.Equals(left, right); | ||
|
||
/// <summary> | ||
/// Indicates whether the object on the left is not equal to the object on the right. | ||
/// </summary> | ||
/// <param name="left">The left object</param> | ||
/// <param name="right">The right object</param> | ||
/// <returns>true if the objects are not equal; otherwise, false.</returns> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public static bool operator !=(global::Generator.Equals.Tests.Classes.BaseEquality.Person? left, global::Generator.Equals.Tests.Classes.BaseEquality.Person? right) => | ||
!(left == right); | ||
|
||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public override bool Equals(object? obj) | ||
{ | ||
var other = obj as global::Generator.Equals.Tests.Classes.BaseEquality.Person; | ||
return | ||
!ReferenceEquals(other, null) && this.GetType() == other.GetType() | ||
&& global::Generator.Equals.DefaultEqualityComparer<global::System.Int32>.Default.Equals(this.Age!, other.Age!) | ||
; | ||
} | ||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public bool Equals(global::Generator.Equals.Tests.Classes.BaseEquality.Person? other) => | ||
Equals((object?) other); | ||
|
||
|
||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public override int GetHashCode() | ||
{ | ||
var hashCode = new global::System.HashCode(); | ||
|
||
hashCode.Add(this.GetType()); | ||
hashCode.Add( | ||
this.Age!, | ||
global::Generator.Equals.DefaultEqualityComparer<global::System.Int32>.Default); | ||
|
||
return hashCode.ToHashCode(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.