• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

loresoft / KickStart / 17529667504

07 Sep 2025 02:14PM UTC coverage: 60.921%. Remained the same
17529667504

push

github

pwelter34
reformat code base

162 of 364 branches covered (44.51%)

Branch coverage included in aggregate %.

634 of 951 new or added lines in 72 files covered. (66.67%)

4 existing lines in 4 files now uncovered.

658 of 982 relevant lines covered (67.01%)

20.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/KickStart.DependencyInjection/ServiceCollectionExtensions.cs
1
using KickStart;
2

3
using Microsoft.Extensions.Logging;
4

5
// ReSharper disable once CheckNamespace
6
namespace Microsoft.Extensions.DependencyInjection;
7

8
/// <summary>
9
/// Extension methods for <see cref="IServiceCollection"/>
10
/// </summary>
11
public static class ServiceCollectionExtensions
12
{
13
    /// <summary>
14
    /// Configure and run the KickStart extensions.
15
    /// </summary>
16
    /// <param name="services"></param>
17
    /// <param name="configurator">The <see langword="delegate"/> to configure KickStart before execution of the extensions.</param>
18
    /// <example>Configure KickStart to use startup tasks.
19
    /// <code><![CDATA[
20
    /// services.KickStart(config => config
21
    ///     .IncludeAssemblyFor<Startup>()
22
    ///     .UseStartupTask()
23
    /// );]]></code>
24
    /// </example>
25
    public static IServiceCollection KickStart(this IServiceCollection services, Action<IConfigurationBuilder> configurator)
26
    {
NEW
27
        var logger = CreateLogger(services);
×
NEW
28
        var canWrite = logger?.IsEnabled(LogLevel.Debug) ?? false;
×
29

NEW
30
        Kick.Start(builder =>
×
31
        {
×
NEW
32
            builder
×
NEW
33
                .LogTo(m => { if (canWrite) logger?.LogDebug(m); })
×
NEW
34
                .UseDependencyInjection(d => d.Creator(() => services));
×
35

×
NEW
36
            configurator?.Invoke(builder);
×
NEW
37
        });
×
38

NEW
39
        return services;
×
40
    }
41

42
    private static ILogger CreateLogger(IServiceCollection services)
43
    {
44
        try
45
        {
NEW
46
            var serviceProvider = services.BuildServiceProvider();
×
NEW
47
            var loggerFactory = serviceProvider.GetService<ILoggerFactory>();
×
NEW
48
            var logger = loggerFactory?.CreateLogger(typeof(Kick));
×
NEW
49
            return logger;
×
50
        }
NEW
51
        catch (Exception)
×
52
        {
53
            // azure functions doesn't allow using services at startup.  
NEW
54
            return null;
×
55
        }
UNCOV
56
    }
×
57
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc