< Summary

Line coverage
100%
Covered lines: 35
Uncovered lines: 0
Coverable lines: 35
Total lines: 113
Line coverage: 100%
Branch coverage
83%
Covered branches: 10
Total branches: 12
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
File 1: .cctor()100%11100%
File 1: LogConfiguringHubs(...)100%22100%
File 1: LogRegisteringHub(...)100%22100%
File 1: LogHubsConfigured(...)100%22100%
File 2: Map(...)66.66%66100%

File(s)

/_/src/NexusLabs.Needlr.SignalR/obj/Release/net10.0/Microsoft.Extensions.Logging.Generators/Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator/LoggerMessage.g.cs

File '/_/src/NexusLabs.Needlr.SignalR/obj/Release/net10.0/Microsoft.Extensions.Logging.Generators/Microsoft.Extensions.Logging.Generators.LoggerMessageGenerator/LoggerMessage.g.cs' does not exist (any more).

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.SignalR/SignalRHubReflectionMapper.cs

#LineLine coverage
 1using System.Diagnostics.CodeAnalysis;
 2using System.Reflection;
 3
 4using Microsoft.AspNetCore.Builder;
 5using Microsoft.AspNetCore.SignalR;
 6using Microsoft.Extensions.Logging;
 7
 8using NexusLabs.Needlr.AspNet;
 9
 10namespace NexusLabs.Needlr.SignalR;
 11
 12/// <summary>
 13/// Maps explicitly requested SignalR hubs through reflection without participating
 14/// in Needlr plugin discovery.
 15/// </summary>
 16[DoNotAutoRegister]
 17internal sealed partial class SignalRHubReflectionMapper
 18{
 19    [RequiresUnreferencedCode("SignalR hub registration uses reflection to invoke MapHub<T>(). For AOT scenarios, use ap
 20    [RequiresDynamicCode("SignalR hub registration uses MakeGenericMethod() which requires dynamic code generation.")]
 21    internal void Map(
 22        WebApplication app,
 23        IReadOnlyList<Assembly> assemblies,
 24        IPluginFactory pluginFactory)
 25    {
 426        ArgumentNullException.ThrowIfNull(app);
 427        ArgumentNullException.ThrowIfNull(assemblies);
 428        ArgumentNullException.ThrowIfNull(pluginFactory);
 29
 430        LogConfiguringHubs(app.Logger);
 31
 432        var mapHubMethod = typeof(HubEndpointRouteBuilderExtensions)
 433            .GetMethods()
 434            .First(method =>
 835                method.Name == "MapHub" &&
 836                method.IsGenericMethodDefinition &&
 837                method.GetParameters().Length == 2);
 38
 1639        foreach (var plugin in
 440            pluginFactory.CreatePluginsFromAssemblies<IHubRegistrationPlugin>(
 441                assemblies))
 42        {
 643            LogRegisteringHub(app.Logger, plugin.GetType().Name);
 644            var genericMapHub = mapHubMethod.MakeGenericMethod(plugin.HubType);
 645            genericMapHub.Invoke(
 646                null,
 647                [app, plugin.HubPath]);
 48        }
 49
 450        LogHubsConfigured(app.Logger);
 451    }
 52
 53    [LoggerMessage(
 54        Level = LogLevel.Information,
 55        Message = "Configuring SignalR hubs...")]
 56    private static partial void LogConfiguringHubs(ILogger logger);
 57
 58    [LoggerMessage(
 59        Level = LogLevel.Information,
 60        Message = "Registering SignalR hub '{HubName}'...")]
 61    private static partial void LogRegisteringHub(
 62        ILogger logger,
 63        string hubName);
 64
 65    [LoggerMessage(
 66        Level = LogLevel.Information,
 67        Message = "SignalR hubs configured successfully.")]
 68    private static partial void LogHubsConfigured(ILogger logger);
 69}