| | | 1 | | using System; |
| | | 2 | | using System.Linq; |
| | | 3 | | |
| | | 4 | | namespace NexusLabs.Needlr.Generators.Models; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// A marked record property added to a generated forwarding constructor. |
| | | 8 | | /// </summary> |
| | | 9 | | internal readonly struct RecordConstructorPropertyParameter : |
| | | 10 | | IEquatable<RecordConstructorPropertyParameter> |
| | | 11 | | { |
| | | 12 | | public RecordConstructorPropertyParameter( |
| | | 13 | | string propertyName, |
| | | 14 | | string escapedPropertyName, |
| | | 15 | | string typeName, |
| | | 16 | | string documentation, |
| | | 17 | | ConstructorGuardModel[] effectiveGuards) |
| | | 18 | | { |
| | 24 | 19 | | PropertyName = propertyName; |
| | 24 | 20 | | EscapedPropertyName = escapedPropertyName; |
| | 24 | 21 | | TypeName = typeName; |
| | 24 | 22 | | Documentation = documentation; |
| | 24 | 23 | | EffectiveGuards = effectiveGuards; |
| | 24 | 24 | | } |
| | | 25 | | |
| | 50 | 26 | | public string PropertyName { get; } |
| | | 27 | | |
| | 77 | 28 | | public string EscapedPropertyName { get; } |
| | | 29 | | |
| | 30 | 30 | | public string TypeName { get; } |
| | | 31 | | |
| | 24 | 32 | | public string Documentation { get; } |
| | | 33 | | |
| | 44 | 34 | | public ConstructorGuardModel[] EffectiveGuards { get; } |
| | | 35 | | |
| | | 36 | | public bool Equals(RecordConstructorPropertyParameter other) |
| | | 37 | | { |
| | 5 | 38 | | return string.Equals( |
| | 5 | 39 | | PropertyName, |
| | 5 | 40 | | other.PropertyName, |
| | 5 | 41 | | StringComparison.Ordinal) && |
| | 5 | 42 | | string.Equals( |
| | 5 | 43 | | EscapedPropertyName, |
| | 5 | 44 | | other.EscapedPropertyName, |
| | 5 | 45 | | StringComparison.Ordinal) && |
| | 5 | 46 | | string.Equals(TypeName, other.TypeName, StringComparison.Ordinal) && |
| | 5 | 47 | | string.Equals( |
| | 5 | 48 | | Documentation, |
| | 5 | 49 | | other.Documentation, |
| | 5 | 50 | | StringComparison.Ordinal) && |
| | 5 | 51 | | EffectiveGuards.SequenceEqual(other.EffectiveGuards); |
| | | 52 | | } |
| | | 53 | | |
| | | 54 | | public override bool Equals(object? obj) |
| | | 55 | | { |
| | 0 | 56 | | return obj is RecordConstructorPropertyParameter other && Equals(other); |
| | | 57 | | } |
| | | 58 | | |
| | | 59 | | public override int GetHashCode() |
| | | 60 | | { |
| | | 61 | | unchecked |
| | | 62 | | { |
| | 0 | 63 | | var hash = PropertyName.GetHashCode(); |
| | 0 | 64 | | hash = (hash * 397) ^ EscapedPropertyName.GetHashCode(); |
| | 0 | 65 | | hash = (hash * 397) ^ TypeName.GetHashCode(); |
| | 0 | 66 | | hash = (hash * 397) ^ Documentation.GetHashCode(); |
| | | 67 | | |
| | 0 | 68 | | foreach (var guard in EffectiveGuards) |
| | | 69 | | { |
| | 0 | 70 | | hash = (hash * 397) ^ guard.GetHashCode(); |
| | | 71 | | } |
| | | 72 | | |
| | 0 | 73 | | return hash; |
| | | 74 | | } |
| | | 75 | | } |
| | | 76 | | |
| | | 77 | | public static bool operator ==( |
| | | 78 | | RecordConstructorPropertyParameter left, |
| | | 79 | | RecordConstructorPropertyParameter right) |
| | | 80 | | { |
| | 0 | 81 | | return left.Equals(right); |
| | | 82 | | } |
| | | 83 | | |
| | | 84 | | public static bool operator !=( |
| | | 85 | | RecordConstructorPropertyParameter left, |
| | | 86 | | RecordConstructorPropertyParameter right) |
| | | 87 | | { |
| | 0 | 88 | | return !left.Equals(right); |
| | | 89 | | } |
| | | 90 | | } |