< Summary

Information
Class: MultiProjectApp.Features.CrossGenSimulation.CrossGenSimulationRegistrations
Assembly: MultiProjectApp.Features.CrossGenSimulation
File(s): /home/runner/work/needlr/needlr/src/Examples/MultiProjectApp/MultiProjectApp.Features.CrossGenSimulation/CrossGenSimulation.cs
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 43
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Initialize()100%11100%

File(s)

/home/runner/work/needlr/needlr/src/Examples/MultiProjectApp/MultiProjectApp.Features.CrossGenSimulation/CrossGenSimulation.cs

#LineLine coverage
 1using System.Runtime.CompilerServices;
 2
 3using NexusLabs.Needlr.Generators;
 4
 5namespace MultiProjectApp.Features.CrossGenSimulation;
 6
 7/// <summary>
 8/// Represents a type that was emitted by a second source generator.
 9/// TypeRegistryGenerator cannot see this type because NeedlrAutoGenerate is disabled for this
 10/// assembly, simulating what happens when another generator produces types at compile time —
 11/// those types are invisible to TypeRegistryGenerator because it operates on the original
 12/// compilation snapshot, before any other generator has emitted code.
 13/// </summary>
 14public interface ICrossGeneratedPlugin { }
 15
 16/// <summary>
 17/// A plugin type that exists only because a hypothetical second generator emitted it.
 18/// TypeRegistryGenerator has no knowledge of this type. It reaches the Needlr registry
 19/// exclusively through <see cref="CrossGenSimulationRegistrations"/>.
 20/// </summary>
 21public sealed record SimulatedGeneratorPlugin : ICrossGeneratedPlugin { }
 22
 23/// <summary>
 24/// Simulates the module initializer that a second source generator would emit to register its
 25/// types with Needlr at runtime, bypassing the Roslyn generator isolation boundary.
 26/// </summary>
 27internal static class CrossGenSimulationRegistrations
 28{
 29#pragma warning disable CA2255
 30    [ModuleInitializer]
 31    internal static void Initialize()
 32#pragma warning restore CA2255
 133    {
 134        NeedlrSourceGenBootstrap.RegisterPlugins(static () =>
 1135        [
 1136            new PluginTypeInfo(
 1137                typeof(SimulatedGeneratorPlugin),
 1138                [typeof(ICrossGeneratedPlugin)],
 239                static () => new SimulatedGeneratorPlugin(),
 1140                [])
 1141        ]);
 142    }
 43}

Methods/Properties

Initialize()