| | | 1 | | using System; |
| | | 2 | | using System.Linq; |
| | | 3 | | |
| | | 4 | | namespace NexusLabs.Needlr.Generators.Models; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// The complete equatable model for one generated positional-record constructor |
| | | 8 | | /// overload. |
| | | 9 | | /// </summary> |
| | | 10 | | internal readonly struct RecordConstructorOverloadModel : |
| | | 11 | | IEquatable<RecordConstructorOverloadModel> |
| | | 12 | | { |
| | | 13 | | public RecordConstructorOverloadModel( |
| | | 14 | | string containingNamespace, |
| | | 15 | | string containingTypeName, |
| | | 16 | | string escapedContainingTypeName, |
| | | 17 | | string typeParameterList, |
| | | 18 | | int arity, |
| | | 19 | | RecordConstructorPrimaryParameter[] primaryParameters, |
| | | 20 | | RecordConstructorPropertyParameter[] propertyParameters, |
| | | 21 | | string? sourceFilePath) |
| | | 22 | | { |
| | 18 | 23 | | ContainingNamespace = containingNamespace; |
| | 18 | 24 | | ContainingTypeName = containingTypeName; |
| | 18 | 25 | | EscapedContainingTypeName = escapedContainingTypeName; |
| | 18 | 26 | | TypeParameterList = typeParameterList; |
| | 18 | 27 | | Arity = arity; |
| | 18 | 28 | | PrimaryParameters = primaryParameters; |
| | 18 | 29 | | PropertyParameters = propertyParameters; |
| | 18 | 30 | | SourceFilePath = sourceFilePath; |
| | 18 | 31 | | } |
| | | 32 | | |
| | 90 | 33 | | public string ContainingNamespace { get; } |
| | | 34 | | |
| | 58 | 35 | | public string ContainingTypeName { get; } |
| | | 36 | | |
| | 74 | 37 | | public string EscapedContainingTypeName { get; } |
| | | 38 | | |
| | 74 | 39 | | public string TypeParameterList { get; } |
| | | 40 | | |
| | 42 | 41 | | public int Arity { get; } |
| | | 42 | | |
| | 74 | 43 | | public RecordConstructorPrimaryParameter[] PrimaryParameters { get; } |
| | | 44 | | |
| | 138 | 45 | | public RecordConstructorPropertyParameter[] PropertyParameters { get; } |
| | | 46 | | |
| | 26 | 47 | | public string? SourceFilePath { get; } |
| | | 48 | | |
| | | 49 | | public bool Equals(RecordConstructorOverloadModel other) |
| | | 50 | | { |
| | 13 | 51 | | return string.Equals( |
| | 13 | 52 | | ContainingNamespace, |
| | 13 | 53 | | other.ContainingNamespace, |
| | 13 | 54 | | StringComparison.Ordinal) && |
| | 13 | 55 | | string.Equals( |
| | 13 | 56 | | ContainingTypeName, |
| | 13 | 57 | | other.ContainingTypeName, |
| | 13 | 58 | | StringComparison.Ordinal) && |
| | 13 | 59 | | string.Equals( |
| | 13 | 60 | | EscapedContainingTypeName, |
| | 13 | 61 | | other.EscapedContainingTypeName, |
| | 13 | 62 | | StringComparison.Ordinal) && |
| | 13 | 63 | | string.Equals( |
| | 13 | 64 | | TypeParameterList, |
| | 13 | 65 | | other.TypeParameterList, |
| | 13 | 66 | | StringComparison.Ordinal) && |
| | 13 | 67 | | Arity == other.Arity && |
| | 13 | 68 | | string.Equals( |
| | 13 | 69 | | SourceFilePath, |
| | 13 | 70 | | other.SourceFilePath, |
| | 13 | 71 | | StringComparison.Ordinal) && |
| | 13 | 72 | | PrimaryParameters.SequenceEqual(other.PrimaryParameters) && |
| | 13 | 73 | | PropertyParameters.SequenceEqual(other.PropertyParameters); |
| | | 74 | | } |
| | | 75 | | |
| | | 76 | | public override bool Equals(object? obj) |
| | | 77 | | { |
| | 0 | 78 | | return obj is RecordConstructorOverloadModel other && Equals(other); |
| | | 79 | | } |
| | | 80 | | |
| | | 81 | | public override int GetHashCode() |
| | | 82 | | { |
| | | 83 | | unchecked |
| | | 84 | | { |
| | 0 | 85 | | var hash = ContainingNamespace.GetHashCode(); |
| | 0 | 86 | | hash = (hash * 397) ^ ContainingTypeName.GetHashCode(); |
| | 0 | 87 | | hash = (hash * 397) ^ EscapedContainingTypeName.GetHashCode(); |
| | 0 | 88 | | hash = (hash * 397) ^ TypeParameterList.GetHashCode(); |
| | 0 | 89 | | hash = (hash * 397) ^ Arity; |
| | 0 | 90 | | hash = (hash * 397) ^ (SourceFilePath?.GetHashCode() ?? 0); |
| | | 91 | | |
| | 0 | 92 | | foreach (var parameter in PrimaryParameters) |
| | | 93 | | { |
| | 0 | 94 | | hash = (hash * 397) ^ parameter.GetHashCode(); |
| | | 95 | | } |
| | | 96 | | |
| | 0 | 97 | | foreach (var parameter in PropertyParameters) |
| | | 98 | | { |
| | 0 | 99 | | hash = (hash * 397) ^ parameter.GetHashCode(); |
| | | 100 | | } |
| | | 101 | | |
| | 0 | 102 | | return hash; |
| | | 103 | | } |
| | | 104 | | } |
| | | 105 | | |
| | | 106 | | public static bool operator ==( |
| | | 107 | | RecordConstructorOverloadModel left, |
| | | 108 | | RecordConstructorOverloadModel right) |
| | | 109 | | { |
| | 0 | 110 | | return left.Equals(right); |
| | | 111 | | } |
| | | 112 | | |
| | | 113 | | public static bool operator !=( |
| | | 114 | | RecordConstructorOverloadModel left, |
| | | 115 | | RecordConstructorOverloadModel right) |
| | | 116 | | { |
| | 0 | 117 | | return !left.Equals(right); |
| | | 118 | | } |
| | | 119 | | } |