< Summary

Information
Class: NexusLabs.Needlr.Generators.Models.RecordConstructorOverloadModel
Assembly: NexusLabs.Needlr.Generators
File(s): /_work/nick-alienware-needlr-1-1784953859-3e8997/needlr/needlr/src/NexusLabs.Needlr.Generators/Models/RecordConstructorOverloads/RecordConstructorOverloadModel.cs
Line coverage
74%
Covered lines: 40
Uncovered lines: 14
Coverable lines: 54
Total lines: 119
Line coverage: 74%
Branch coverage
31%
Covered branches: 7
Total branches: 22
Branch coverage: 31.8%
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_ContainingNamespace()100%11100%
get_ContainingTypeName()100%11100%
get_EscapedContainingTypeName()100%11100%
get_TypeParameterList()100%11100%
get_Arity()100%11100%
get_PrimaryParameters()100%11100%
get_PropertyParameters()100%11100%
get_SourceFilePath()100%11100%
Equals(...)50%1414100%
Equals(...)0%620%
GetHashCode()0%4260%
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/RecordConstructorOverloadModel.cs

#LineLine coverage
 1using System;
 2using System.Linq;
 3
 4namespace NexusLabs.Needlr.Generators.Models;
 5
 6/// <summary>
 7/// The complete equatable model for one generated positional-record constructor
 8/// overload.
 9/// </summary>
 10internal 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    {
 1823        ContainingNamespace = containingNamespace;
 1824        ContainingTypeName = containingTypeName;
 1825        EscapedContainingTypeName = escapedContainingTypeName;
 1826        TypeParameterList = typeParameterList;
 1827        Arity = arity;
 1828        PrimaryParameters = primaryParameters;
 1829        PropertyParameters = propertyParameters;
 1830        SourceFilePath = sourceFilePath;
 1831    }
 32
 9033    public string ContainingNamespace { get; }
 34
 5835    public string ContainingTypeName { get; }
 36
 7437    public string EscapedContainingTypeName { get; }
 38
 7439    public string TypeParameterList { get; }
 40
 4241    public int Arity { get; }
 42
 7443    public RecordConstructorPrimaryParameter[] PrimaryParameters { get; }
 44
 13845    public RecordConstructorPropertyParameter[] PropertyParameters { get; }
 46
 2647    public string? SourceFilePath { get; }
 48
 49    public bool Equals(RecordConstructorOverloadModel other)
 50    {
 1351        return string.Equals(
 1352                ContainingNamespace,
 1353                other.ContainingNamespace,
 1354                StringComparison.Ordinal) &&
 1355            string.Equals(
 1356                ContainingTypeName,
 1357                other.ContainingTypeName,
 1358                StringComparison.Ordinal) &&
 1359            string.Equals(
 1360                EscapedContainingTypeName,
 1361                other.EscapedContainingTypeName,
 1362                StringComparison.Ordinal) &&
 1363            string.Equals(
 1364                TypeParameterList,
 1365                other.TypeParameterList,
 1366                StringComparison.Ordinal) &&
 1367            Arity == other.Arity &&
 1368            string.Equals(
 1369                SourceFilePath,
 1370                other.SourceFilePath,
 1371                StringComparison.Ordinal) &&
 1372            PrimaryParameters.SequenceEqual(other.PrimaryParameters) &&
 1373            PropertyParameters.SequenceEqual(other.PropertyParameters);
 74    }
 75
 76    public override bool Equals(object? obj)
 77    {
 078        return obj is RecordConstructorOverloadModel other && Equals(other);
 79    }
 80
 81    public override int GetHashCode()
 82    {
 83        unchecked
 84        {
 085            var hash = ContainingNamespace.GetHashCode();
 086            hash = (hash * 397) ^ ContainingTypeName.GetHashCode();
 087            hash = (hash * 397) ^ EscapedContainingTypeName.GetHashCode();
 088            hash = (hash * 397) ^ TypeParameterList.GetHashCode();
 089            hash = (hash * 397) ^ Arity;
 090            hash = (hash * 397) ^ (SourceFilePath?.GetHashCode() ?? 0);
 91
 092            foreach (var parameter in PrimaryParameters)
 93            {
 094                hash = (hash * 397) ^ parameter.GetHashCode();
 95            }
 96
 097            foreach (var parameter in PropertyParameters)
 98            {
 099                hash = (hash * 397) ^ parameter.GetHashCode();
 100            }
 101
 0102            return hash;
 103        }
 104    }
 105
 106    public static bool operator ==(
 107        RecordConstructorOverloadModel left,
 108        RecordConstructorOverloadModel right)
 109    {
 0110        return left.Equals(right);
 111    }
 112
 113    public static bool operator !=(
 114        RecordConstructorOverloadModel left,
 115        RecordConstructorOverloadModel right)
 116    {
 0117        return !left.Equals(right);
 118    }
 119}