< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.Scheduling.RoslynJobFactory
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Scheduling/RoslynJobFactory.cs
Tag: Kestrun/Kestrun@5f1d2b981c9d7292c11fd448428c6ab6c811c5de
Line coverage
100%
Covered lines: 39
Uncovered lines: 0
Coverable lines: 39
Total lines: 79
Line coverage: 100%
Branch coverage
72%
Covered branches: 13
Total branches: 18
Branch coverage: 72.2%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 11/19/2025 - 17:40:50 Line coverage: 100% (37/37) Branch coverage: 72.2% (13/18) Total lines: 81 Tag: Kestrun/Kestrun@fcf33342333cef0516fe0d0912a86709874fd02603/28/2026 - 19:32:00 Line coverage: 100% (39/39) Branch coverage: 72.2% (13/18) Total lines: 79 Tag: Kestrun/Kestrun@84d0d2071c053497504fc6f8a83b92eb3b0e4e21 11/19/2025 - 17:40:50 Line coverage: 100% (37/37) Branch coverage: 72.2% (13/18) Total lines: 81 Tag: Kestrun/Kestrun@fcf33342333cef0516fe0d0912a86709874fd02603/28/2026 - 19:32:00 Line coverage: 100% (39/39) Branch coverage: 72.2% (13/18) Total lines: 79 Tag: Kestrun/Kestrun@84d0d2071c053497504fc6f8a83b92eb3b0e4e21

Coverage delta

Coverage delta 1 -1

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Build(...)80%1010100%
Build(...)62.5%88100%

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/Scheduling/RoslynJobFactory.cs

#LineLine coverage
 1using Kestrun.Hosting;
 2using Kestrun.Languages;
 3using Microsoft.CodeAnalysis.CSharp;
 4using Serilog.Events;
 5using System.Reflection;
 6
 7namespace Kestrun.Scheduling;
 8
 9internal static class RoslynJobFactory
 10{
 11    public static Func<CancellationToken, Task> Build(
 12        KestrunHost host,
 13        string code,
 14        string[]? extraImports,
 15        Assembly[]? extraRefs,
 16        IReadOnlyDictionary<string, object?>? locals,
 17        LanguageVersion languageVersion = LanguageVersion.CSharp12)
 18    {
 519        var log = host.Logger;
 520        if (log.IsEnabled(LogEventLevel.Debug))
 21        {
 522            log.Debug("Building C# job, code length={Length}, imports={ImportsCount}, refs={RefsCount}, lang={Lang}",
 523                code?.Length, extraImports?.Length ?? 0, extraRefs?.Length ?? 0, languageVersion);
 24        }
 25
 526        var script = CSharpDelegateBuilder.Compile(host: host, code: code, extraImports: extraImports, extraRefs: extraR
 427        var runner = script.CreateDelegate();   // returns ScriptRunner<object?>
 428        if (log.IsEnabled(LogEventLevel.Debug))
 29        {
 430            log.Debug("C# job runner created, type={Type}", runner.GetType());
 31        }
 32        /* 5️⃣  Returned delegate = *execute only* */
 433        return async ct =>
 434        {
 435            if (log.IsEnabled(LogEventLevel.Debug))
 436            {
 437                log.Debug("Executing C# job at {Now:O}", DateTimeOffset.UtcNow);
 438            }
 439
 440            var globals = locals is { Count: > 0 }
 441                ? new CsGlobals(globals: host.SharedState.Snapshot(), locals: locals)
 442                : new CsGlobals(globals: host.SharedState.Snapshot());
 443            _ = await runner(globals, ct).ConfigureAwait(false);
 844        };
 45    }
 46
 47    public static Func<CancellationToken, Task> Build(
 48        KestrunHost host,
 49       string code,
 50       string[]? extraImports,
 51       Assembly[]? extraRefs,
 52       IReadOnlyDictionary<string, object?>? locals,
 53       Microsoft.CodeAnalysis.VisualBasic.LanguageVersion languageVersion = Microsoft.CodeAnalysis.VisualBasic.LanguageV
 54    {
 255        var log = host.Logger;
 256        if (log.IsEnabled(LogEventLevel.Debug))
 57        {
 258            log.Debug("Building VB.NET job, code length={Length}, imports={ImportsCount}, refs={RefsCount}, lang={Lang}"
 259                code?.Length, extraImports?.Length ?? 0, extraRefs?.Length ?? 0, languageVersion);
 60        }
 61
 262        var script = VBNetDelegateBuilder.Compile<object>(host: host, code: code,
 263            extraImports: extraImports, extraRefs: extraRefs,
 264            locals: locals, languageVersion: languageVersion);
 65
 266        return async ct =>
 267        {
 268            if (log.IsEnabled(LogEventLevel.Debug))
 269            {
 270                log.Debug("Executing VB.NET job at {Now:O}", DateTimeOffset.UtcNow);
 271            }
 272
 273            var globals = locals is { Count: > 0 }
 274                ? new CsGlobals(globals: host.SharedState.Snapshot(), locals: locals)
 275                : new CsGlobals(globals: host.SharedState.Snapshot());
 276            _ = await script(globals).ConfigureAwait(false);
 477        };
 78    }
 79}