-
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 #31 from HavenDV/readable-generated-code
feat: generated code is now more readable.
- Loading branch information
Showing
38 changed files
with
1,767 additions
and
1,186 deletions.
There are no files selected for viewing
117 changes: 68 additions & 49 deletions
117
Generator.Equals.SnapshotTests/Classes/CustomEquality.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 |
---|---|---|
@@ -1,54 +1,73 @@ | ||
//HintName: Generator.Equals.Tests.Classes.CustomEquality.Sample.Generator.Equals.g.cs | ||
namespace Generator.Equals.Tests.Classes { | ||
partial class CustomEquality { | ||
partial class Sample : global::System.IEquatable<Sample> { | ||
|
||
#nullable enable | ||
#pragma warning disable CS0612,CS0618 | ||
/// <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.CustomEquality.Sample? left, global::Generator.Equals.Tests.Classes.CustomEquality.Sample? right) => global::System.Collections.Generic.EqualityComparer<global::Generator.Equals.Tests.Classes.CustomEquality.Sample?>.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.CustomEquality.Sample? left, global::Generator.Equals.Tests.Classes.CustomEquality.Sample? right) => !(left == right); | ||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public override bool Equals(object? obj) => Equals(obj as global::Generator.Equals.Tests.Classes.CustomEquality.Sample); | ||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public bool Equals(global::Generator.Equals.Tests.Classes.CustomEquality.Sample? other) { | ||
return !ReferenceEquals(other, null) && this.GetType() == other.GetType() | ||
&& global::Generator.Equals.Tests.Classes.CustomEquality.Comparer1.Default.Equals(Name1!, other.Name1!) | ||
&& global::Generator.Equals.Tests.Classes.CustomEquality.Comparer2.Instance.Equals(Name2!, other.Name2!) | ||
&& new global::Generator.Equals.Tests.Classes.CustomEquality.LengthEqualityComparer().Equals(Name3!, other.Name3!) | ||
; | ||
} | ||
/// <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.Name1!, global::Generator.Equals.Tests.Classes.CustomEquality.Comparer1.Default | ||
); | ||
hashCode.Add(this.Name2!, global::Generator.Equals.Tests.Classes.CustomEquality.Comparer2.Instance | ||
); | ||
hashCode.Add(this.Name3!, new global::Generator.Equals.Tests.Classes.CustomEquality.LengthEqualityComparer() | ||
); | ||
return hashCode.ToHashCode(); | ||
} | ||
#pragma warning restore CS0612,CS0618 | ||
#nullable restore | ||
} | ||
|
||
} | ||
namespace Generator.Equals.Tests.Classes | ||
{ | ||
partial class CustomEquality | ||
{ | ||
partial class Sample : global::System.IEquatable<Sample> | ||
{ | ||
/// <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.CustomEquality.Sample? left, | ||
global::Generator.Equals.Tests.Classes.CustomEquality.Sample? right) => | ||
global::System.Collections.Generic.EqualityComparer<global::Generator.Equals.Tests.Classes.CustomEquality.Sample?>.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.CustomEquality.Sample? left, global::Generator.Equals.Tests.Classes.CustomEquality.Sample? right) => | ||
!(left == right); | ||
|
||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public override bool Equals(object? obj) => | ||
Equals(obj as global::Generator.Equals.Tests.Classes.CustomEquality.Sample); | ||
|
||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public bool Equals(global::Generator.Equals.Tests.Classes.CustomEquality.Sample? other) | ||
{ | ||
return | ||
!ReferenceEquals(other, null) && this.GetType() == other.GetType() | ||
&& global::Generator.Equals.Tests.Classes.CustomEquality.Comparer1.Default.Equals(Name1!, other.Name1!) | ||
&& global::Generator.Equals.Tests.Classes.CustomEquality.Comparer2.Instance.Equals(Name2!, other.Name2!) | ||
&& new global::Generator.Equals.Tests.Classes.CustomEquality.LengthEqualityComparer().Equals(Name3!, other.Name3!) | ||
; | ||
} | ||
|
||
/// <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.Name1!, | ||
global::Generator.Equals.Tests.Classes.CustomEquality.Comparer1.Default); | ||
hashCode.Add( | ||
this.Name2!, | ||
global::Generator.Equals.Tests.Classes.CustomEquality.Comparer2.Instance); | ||
hashCode.Add( | ||
this.Name3!, | ||
new global::Generator.Equals.Tests.Classes.CustomEquality.LengthEqualityComparer()); | ||
|
||
return hashCode.ToHashCode(); | ||
} | ||
} | ||
} | ||
} |
102 changes: 60 additions & 42 deletions
102
Generator.Equals.SnapshotTests/Classes/DictionaryEquality.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 |
---|---|---|
@@ -1,47 +1,65 @@ | ||
//HintName: Generator.Equals.Tests.Classes.DictionaryEquality.Sample.Generator.Equals.g.cs | ||
namespace Generator.Equals.Tests.Classes { | ||
partial class DictionaryEquality { | ||
partial class Sample : global::System.IEquatable<Sample> { | ||
|
||
#nullable enable | ||
#pragma warning disable CS0612,CS0618 | ||
/// <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.DictionaryEquality.Sample? left, global::Generator.Equals.Tests.Classes.DictionaryEquality.Sample? right) => global::System.Collections.Generic.EqualityComparer<global::Generator.Equals.Tests.Classes.DictionaryEquality.Sample?>.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.DictionaryEquality.Sample? left, global::Generator.Equals.Tests.Classes.DictionaryEquality.Sample? right) => !(left == right); | ||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public override bool Equals(object? obj) => Equals(obj as global::Generator.Equals.Tests.Classes.DictionaryEquality.Sample); | ||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public bool Equals(global::Generator.Equals.Tests.Classes.DictionaryEquality.Sample? other) { | ||
return !ReferenceEquals(other, null) && this.GetType() == other.GetType() | ||
&& global::Generator.Equals.DictionaryEqualityComparer<string, int>.Default.Equals(Properties!, other.Properties!) | ||
; | ||
} | ||
/// <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.Properties!, global::Generator.Equals.DictionaryEqualityComparer<string, int>.Default); | ||
return hashCode.ToHashCode(); | ||
} | ||
#pragma warning restore CS0612,CS0618 | ||
#nullable restore | ||
} | ||
|
||
} | ||
namespace Generator.Equals.Tests.Classes | ||
{ | ||
partial class DictionaryEquality | ||
{ | ||
partial class Sample : global::System.IEquatable<Sample> | ||
{ | ||
/// <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.DictionaryEquality.Sample? left, | ||
global::Generator.Equals.Tests.Classes.DictionaryEquality.Sample? right) => | ||
global::System.Collections.Generic.EqualityComparer<global::Generator.Equals.Tests.Classes.DictionaryEquality.Sample?>.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.DictionaryEquality.Sample? left, global::Generator.Equals.Tests.Classes.DictionaryEquality.Sample? right) => | ||
!(left == right); | ||
|
||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public override bool Equals(object? obj) => | ||
Equals(obj as global::Generator.Equals.Tests.Classes.DictionaryEquality.Sample); | ||
|
||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public bool Equals(global::Generator.Equals.Tests.Classes.DictionaryEquality.Sample? other) | ||
{ | ||
return | ||
!ReferenceEquals(other, null) && this.GetType() == other.GetType() | ||
&& global::Generator.Equals.DictionaryEqualityComparer<string, int>.Default.Equals(Properties!, other.Properties!) | ||
; | ||
} | ||
|
||
/// <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.Properties!, | ||
global::Generator.Equals.DictionaryEqualityComparer<string, int>.Default); | ||
|
||
return hashCode.ToHashCode(); | ||
} | ||
} | ||
} | ||
} |
102 changes: 60 additions & 42 deletions
102
Generator.Equals.SnapshotTests/Classes/ExplicitMode.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 |
---|---|---|
@@ -1,47 +1,65 @@ | ||
//HintName: Generator.Equals.Tests.Classes.ExplicitMode.Sample.Generator.Equals.g.cs | ||
namespace Generator.Equals.Tests.Classes { | ||
partial class ExplicitMode { | ||
partial class Sample : global::System.IEquatable<Sample> { | ||
|
||
#nullable enable | ||
#pragma warning disable CS0612,CS0618 | ||
/// <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.ExplicitMode.Sample? left, global::Generator.Equals.Tests.Classes.ExplicitMode.Sample? right) => global::System.Collections.Generic.EqualityComparer<global::Generator.Equals.Tests.Classes.ExplicitMode.Sample?>.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.ExplicitMode.Sample? left, global::Generator.Equals.Tests.Classes.ExplicitMode.Sample? right) => !(left == right); | ||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public override bool Equals(object? obj) => Equals(obj as global::Generator.Equals.Tests.Classes.ExplicitMode.Sample); | ||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public bool Equals(global::Generator.Equals.Tests.Classes.ExplicitMode.Sample? other) { | ||
return !ReferenceEquals(other, null) && this.GetType() == other.GetType() | ||
&& global::System.Collections.Generic.EqualityComparer<global::System.Int32>.Default.Equals(Age!, other.Age!) | ||
; | ||
} | ||
/// <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::System.Collections.Generic.EqualityComparer<global::System.Int32>.Default); | ||
return hashCode.ToHashCode(); | ||
} | ||
#pragma warning restore CS0612,CS0618 | ||
#nullable restore | ||
} | ||
|
||
} | ||
namespace Generator.Equals.Tests.Classes | ||
{ | ||
partial class ExplicitMode | ||
{ | ||
partial class Sample : global::System.IEquatable<Sample> | ||
{ | ||
/// <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.ExplicitMode.Sample? left, | ||
global::Generator.Equals.Tests.Classes.ExplicitMode.Sample? right) => | ||
global::System.Collections.Generic.EqualityComparer<global::Generator.Equals.Tests.Classes.ExplicitMode.Sample?>.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.ExplicitMode.Sample? left, global::Generator.Equals.Tests.Classes.ExplicitMode.Sample? right) => | ||
!(left == right); | ||
|
||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public override bool Equals(object? obj) => | ||
Equals(obj as global::Generator.Equals.Tests.Classes.ExplicitMode.Sample); | ||
|
||
/// <inheritdoc/> | ||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Generator.Equals", "1.0.0.0")] | ||
public bool Equals(global::Generator.Equals.Tests.Classes.ExplicitMode.Sample? other) | ||
{ | ||
return | ||
!ReferenceEquals(other, null) && this.GetType() == other.GetType() | ||
&& global::System.Collections.Generic.EqualityComparer<global::System.Int32>.Default.Equals(Age!, other.Age!) | ||
; | ||
} | ||
|
||
/// <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::System.Collections.Generic.EqualityComparer<global::System.Int32>.Default); | ||
|
||
return hashCode.ToHashCode(); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.