< Summary

Information
Class: NexusLabs.Needlr.Generators.Models.RecordConstructorOverloadModel
Assembly: NexusLabs.Needlr.Generators
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.Generators/Models/RecordConstructorOverloads/RecordConstructorOverloadModel.cs
Line coverage
100%
Covered lines: 54
Uncovered lines: 0
Coverable lines: 54
Total lines: 119
Line coverage: 100%
Branch coverage
90%
Covered branches: 20
Total branches: 22
Branch coverage: 90.9%
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(...)100%1414100%
Equals(...)50%22100%
GetHashCode()83.33%66100%
op_Equality(...)100%11100%
op_Inequality(...)100%11100%

File(s)

/home/runner/work/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    {
 8223        ContainingNamespace = containingNamespace;
 8224        ContainingTypeName = containingTypeName;
 8225        EscapedContainingTypeName = escapedContainingTypeName;
 8226        TypeParameterList = typeParameterList;
 8227        Arity = arity;
 8228        PrimaryParameters = primaryParameters;
 8229        PropertyParameters = propertyParameters;
 8230        SourceFilePath = sourceFilePath;
 8231    }
 32
 36033    public string ContainingNamespace { get; }
 34
 25435    public string ContainingTypeName { get; }
 36
 30437    public string EscapedContainingTypeName { get; }
 38
 30239    public string TypeParameterList { get; }
 40
 19641    public int Arity { get; }
 42
 29643    public RecordConstructorPrimaryParameter[] PrimaryParameters { get; }
 44
 47245    public RecordConstructorPropertyParameter[] PropertyParameters { get; }
 46
 14247    public string? SourceFilePath { get; }
 48
 49    public bool Equals(RecordConstructorOverloadModel other)
 50    {
 7451        return string.Equals(
 7452                ContainingNamespace,
 7453                other.ContainingNamespace,
 7454                StringComparison.Ordinal) &&
 7455            string.Equals(
 7456                ContainingTypeName,
 7457                other.ContainingTypeName,
 7458                StringComparison.Ordinal) &&
 7459            string.Equals(
 7460                EscapedContainingTypeName,
 7461                other.EscapedContainingTypeName,
 7462                StringComparison.Ordinal) &&
 7463            string.Equals(
 7464                TypeParameterList,
 7465                other.TypeParameterList,
 7466                StringComparison.Ordinal) &&
 7467            Arity == other.Arity &&
 7468            string.Equals(
 7469                SourceFilePath,
 7470                other.SourceFilePath,
 7471                StringComparison.Ordinal) &&
 7472            PrimaryParameters.SequenceEqual(other.PrimaryParameters) &&
 7473            PropertyParameters.SequenceEqual(other.PropertyParameters);
 74    }
 75
 76    public override bool Equals(object? obj)
 77    {
 278        return obj is RecordConstructorOverloadModel other && Equals(other);
 79    }
 80
 81    public override int GetHashCode()
 82    {
 83        unchecked
 84        {
 485            var hash = ContainingNamespace.GetHashCode();
 486            hash = (hash * 397) ^ ContainingTypeName.GetHashCode();
 487            hash = (hash * 397) ^ EscapedContainingTypeName.GetHashCode();
 488            hash = (hash * 397) ^ TypeParameterList.GetHashCode();
 489            hash = (hash * 397) ^ Arity;
 490            hash = (hash * 397) ^ (SourceFilePath?.GetHashCode() ?? 0);
 91
 1692            foreach (var parameter in PrimaryParameters)
 93            {
 494                hash = (hash * 397) ^ parameter.GetHashCode();
 95            }
 96
 1697            foreach (var parameter in PropertyParameters)
 98            {
 499                hash = (hash * 397) ^ parameter.GetHashCode();
 100            }
 101
 4102            return hash;
 103        }
 104    }
 105
 106    public static bool operator ==(
 107        RecordConstructorOverloadModel left,
 108        RecordConstructorOverloadModel right)
 109    {
 1110        return left.Equals(right);
 111    }
 112
 113    public static bool operator !=(
 114        RecordConstructorOverloadModel left,
 115        RecordConstructorOverloadModel right)
 116    {
 1117        return !left.Equals(right);
 118    }
 119}