< Summary

Information
Class: NexusLabs.Needlr.Generators.Models.GeneratedConstructorEmitContext
Assembly: NexusLabs.Needlr.Generators
File(s): /_work/nick-alienware-needlr-1-1784953859-3e8997/needlr/needlr/src/NexusLabs.Needlr.Generators/Models/Constructors/GeneratedConstructorEmitContext.cs
Line coverage
63%
Covered lines: 7
Uncovered lines: 4
Coverable lines: 11
Total lines: 57
Line coverage: 63.6%
Branch coverage
25%
Covered branches: 1
Total branches: 4
Branch coverage: 25%
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_AssemblyName()100%11100%
get_BreadcrumbLevel()100%11100%
Equals(...)50%22100%
Equals(...)0%620%
GetHashCode()100%210%
op_Equality(...)100%210%
op_Inequality(...)100%210%

File(s)

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

#LineLine coverage
 1using System;
 2
 3namespace NexusLabs.Needlr.Generators.Models;
 4
 5/// <summary>
 6/// The stable, scalar emission context shared by every generated-constructor model in
 7/// the compilation: the current assembly name and the configured breadcrumb verbosity.
 8/// </summary>
 9/// <remarks>
 10/// Deliberately holds only cheap, independently-cacheable scalar values rather than the
 11/// <see cref="Microsoft.CodeAnalysis.Compilation"/> or
 12/// <see cref="Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptionsProvider"/> objects
 13/// they were derived from. Combining a per-type model with the entire
 14/// <c>Compilation</c> would invalidate every generated constructor whenever anything in
 15/// the compilation changed (the exact bug this model exists to avoid); combining with
 16/// this instead lets the incremental pipeline reuse a cached emission context across
 17/// edits that don't touch the assembly name or breadcrumb MSBuild property.
 18/// </remarks>
 19internal readonly struct GeneratedConstructorEmitContext : IEquatable<GeneratedConstructorEmitContext>
 20{
 21    public GeneratedConstructorEmitContext(string assemblyName, BreadcrumbLevel breadcrumbLevel)
 22    {
 6723        AssemblyName = assemblyName;
 6724        BreadcrumbLevel = breadcrumbLevel;
 6725    }
 26
 27    /// <summary>
 28    /// The current compilation's assembly name, or <c>"Generated"</c> as a fallback.
 29    /// </summary>
 7630    public string AssemblyName { get; }
 31
 32    /// <summary>
 33    /// The configured breadcrumb verbosity, read from the
 34    /// <c>NeedlrBreadcrumbLevel</c> MSBuild property.
 35    /// </summary>
 7636    public BreadcrumbLevel BreadcrumbLevel { get; }
 37
 38    public bool Equals(GeneratedConstructorEmitContext other)
 39    {
 540        return string.Equals(AssemblyName, other.AssemblyName, StringComparison.Ordinal) &&
 541            BreadcrumbLevel == other.BreadcrumbLevel;
 42    }
 43
 044    public override bool Equals(object? obj) => obj is GeneratedConstructorEmitContext other && Equals(other);
 45
 46    public override int GetHashCode()
 47    {
 48        unchecked
 49        {
 050            return (AssemblyName.GetHashCode() * 397) ^ (int)BreadcrumbLevel;
 51        }
 52    }
 53
 054    public static bool operator ==(GeneratedConstructorEmitContext left, GeneratedConstructorEmitContext right) => left.
 55
 056    public static bool operator !=(GeneratedConstructorEmitContext left, GeneratedConstructorEmitContext right) => !left
 57}