< Summary

Information
Class: NexusLabs.Needlr.Generators.Models.RecordConstructorPropertyParameter
Assembly: NexusLabs.Needlr.Generators
File(s): /_work/nick-alienware-needlr-1-1784953859-3e8997/needlr/needlr/src/NexusLabs.Needlr.Generators/Models/RecordConstructorOverloads/RecordConstructorPropertyParameter.cs
Line coverage
71%
Covered lines: 25
Uncovered lines: 10
Coverable lines: 35
Total lines: 90
Line coverage: 71.4%
Branch coverage
66%
Covered branches: 8
Total branches: 12
Branch coverage: 66.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_PropertyName()100%11100%
get_EscapedPropertyName()100%11100%
get_TypeName()100%11100%
get_Documentation()100%11100%
get_EffectiveGuards()100%11100%
Equals(...)100%88100%
Equals(...)0%620%
GetHashCode()0%620%
op_Equality(...)100%210%
op_Inequality(...)100%210%

File(s)

/_work/nick-alienware-needlr-1-1784953859-3e8997/needlr/needlr/src/NexusLabs.Needlr.Generators/Models/RecordConstructorOverloads/RecordConstructorPropertyParameter.cs

#LineLine coverage
 1using System;
 2using System.Linq;
 3
 4namespace NexusLabs.Needlr.Generators.Models;
 5
 6/// <summary>
 7/// A marked record property added to a generated forwarding constructor.
 8/// </summary>
 9internal 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    {
 2419        PropertyName = propertyName;
 2420        EscapedPropertyName = escapedPropertyName;
 2421        TypeName = typeName;
 2422        Documentation = documentation;
 2423        EffectiveGuards = effectiveGuards;
 2424    }
 25
 5026    public string PropertyName { get; }
 27
 7728    public string EscapedPropertyName { get; }
 29
 3030    public string TypeName { get; }
 31
 2432    public string Documentation { get; }
 33
 4434    public ConstructorGuardModel[] EffectiveGuards { get; }
 35
 36    public bool Equals(RecordConstructorPropertyParameter other)
 37    {
 538        return string.Equals(
 539                PropertyName,
 540                other.PropertyName,
 541                StringComparison.Ordinal) &&
 542            string.Equals(
 543                EscapedPropertyName,
 544                other.EscapedPropertyName,
 545                StringComparison.Ordinal) &&
 546            string.Equals(TypeName, other.TypeName, StringComparison.Ordinal) &&
 547            string.Equals(
 548                Documentation,
 549                other.Documentation,
 550                StringComparison.Ordinal) &&
 551            EffectiveGuards.SequenceEqual(other.EffectiveGuards);
 52    }
 53
 54    public override bool Equals(object? obj)
 55    {
 056        return obj is RecordConstructorPropertyParameter other && Equals(other);
 57    }
 58
 59    public override int GetHashCode()
 60    {
 61        unchecked
 62        {
 063            var hash = PropertyName.GetHashCode();
 064            hash = (hash * 397) ^ EscapedPropertyName.GetHashCode();
 065            hash = (hash * 397) ^ TypeName.GetHashCode();
 066            hash = (hash * 397) ^ Documentation.GetHashCode();
 67
 068            foreach (var guard in EffectiveGuards)
 69            {
 070                hash = (hash * 397) ^ guard.GetHashCode();
 71            }
 72
 073            return hash;
 74        }
 75    }
 76
 77    public static bool operator ==(
 78        RecordConstructorPropertyParameter left,
 79        RecordConstructorPropertyParameter right)
 80    {
 081        return left.Equals(right);
 82    }
 83
 84    public static bool operator !=(
 85        RecordConstructorPropertyParameter left,
 86        RecordConstructorPropertyParameter right)
 87    {
 088        return !left.Equals(right);
 89    }
 90}