< Summary

Information
Class: NexusLabs.Needlr.SemanticKernel.PluginScanners.GeneratedSemanticKernelPluginScanner
Assembly: NexusLabs.Needlr.SemanticKernel
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.SemanticKernel/PluginScanners/GeneratedSemanticKernelPluginScanner.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 44
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
.ctor(...)100%11100%
ScanForPluginTypes()100%11100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.SemanticKernel/PluginScanners/GeneratedSemanticKernelPluginScanner.cs

#LineLine coverage
 1namespace NexusLabs.Needlr.SemanticKernel.PluginScanners;
 2
 3/// <summary>
 4/// Source-generation-friendly SemanticKernel plugin scanner that uses compile-time generated plugin type lists.
 5/// </summary>
 6/// <remarks>
 7/// When using source generation, the generator emits a
 8/// <c>NexusLabs.Needlr.Generated.SemanticKernelPlugins</c> class containing:
 9/// - <c>StaticPluginTypes</c>: Types with static [KernelFunction] methods
 10/// - <c>InstancePluginTypes</c>: Types with instance [KernelFunction] methods
 11/// - <c>AllPluginTypes</c>: Combined list of all plugin types
 12///
 13/// This scanner provides a reflection-free way to access these generated lists.
 14/// For AOT/trimmed applications, use this scanner instead of
 15/// <see cref="AssemblySemanticKernelPluginScanner"/> or
 16/// <see cref="ServiceProviderSemanticKernelPluginScanner"/> which use reflection.
 17///
 18/// Usage:
 19/// <code>
 20/// // The generated types are available in NexusLabs.Needlr.Generated namespace
 21/// var pluginTypes = NexusLabs.Needlr.Generated.SemanticKernelPlugins.AllPluginTypes;
 22///
 23/// // Or use this scanner wrapper
 24/// var scanner = new GeneratedSemanticKernelPluginScanner();
 25/// var types = scanner.ScanForPluginTypes();
 26/// </code>
 27/// </remarks>
 28public sealed class GeneratedSemanticKernelPluginScanner : ISemanticKernelPluginScanner
 29{
 30    private readonly IReadOnlyList<Type> _pluginTypes;
 31
 32    /// <summary>
 33    /// Creates a new instance using the specified plugin types.
 34    /// </summary>
 35    /// <param name="pluginTypes">The pre-discovered plugin types (typically from generated code).</param>
 536    public GeneratedSemanticKernelPluginScanner(IReadOnlyList<Type> pluginTypes)
 37    {
 538        ArgumentNullException.ThrowIfNull(pluginTypes);
 439        _pluginTypes = pluginTypes;
 440    }
 41
 42    /// <inheritdoc />
 443    public IReadOnlyList<Type> ScanForPluginTypes() => _pluginTypes;
 44}