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

DemoBytom / DemoEngine / 11962340992

21 Nov 2024 09:57PM UTC coverage: 26.816%. Remained the same
11962340992

push

coveralls.net

web-flow
Merge pull request #399 from DemoBytom/feature/update_dotnet_9

Updating to .net 9.0

96 of 358 relevant lines covered (26.82%)

161836.61 hits per line

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

0.0
/src/Demo.Engine.Core/Extensions/CoreHostExtensions.cs
1
// Copyright © Michał Dembski and contributors.
2
// Distributed under MIT license. See LICENSE file in the root for more information.
3

4
using System.Reflection;
5
using Microsoft.Extensions.Configuration;
6
using Microsoft.Extensions.DependencyInjection;
7
using Microsoft.Extensions.Hosting;
8

9
namespace Demo.Engine.Core.Extensions;
10

11
public static class CoreHostExtensions
12
{
13
    /// <summary>
14
    /// Creates a default (yet different than <see cref="Host.CreateDefaultBuilder(string[])"/>)
15
    /// host builder
16
    /// </summary>
17
    /// <param name="hostBuilder"></param>
18
    /// <param name="args">command line arguments</param>
19
    /// <param name="appsettingsFile">appsettings filename, default is "appsettings.json"</param>
20
    /// <returns>Preconfigured <see cref="IHostBuilder"/></returns>
21
    public static IHostBuilder CreateDefault(
22
        this IHostBuilder hostBuilder,
23
        string[] args,
24
        string appsettingsFile = "appsettings.json") =>
25
    hostBuilder
×
26
        .UseContentRoot(Directory.GetCurrentDirectory())
×
27
        .ConfigureHostConfiguration((configHost) =>
×
28
        {
×
29
            _ = configHost
×
30
                .SetBasePath(Directory.GetCurrentDirectory())
×
31
                .AddEnvironmentVariables("DEMOENGINE_");
×
32

×
33
            if (args is not null)
×
34
            {
×
35
                _ = configHost.AddCommandLine(args);
×
36
            }
×
37
        })
×
38
        .ConfigureAppConfiguration((hostingContext, configApp) =>
×
39
        {
×
40
            var env = hostingContext.HostingEnvironment;
×
41
            _ = configApp
×
42
                .AddJsonFile(appsettingsFile, optional: false, reloadOnChange: true);
×
43

×
44
            if (env.IsDevelopment())
×
45
            {
×
46
                var appAssembly = Assembly.Load(new AssemblyName(env.ApplicationName));
×
47
                if (appAssembly is not null)
×
48
                {
×
49
                    _ = configApp.AddUserSecrets(appAssembly, optional: true);
×
50
                }
×
51
            }
×
52

×
53
            if (args is not null)
×
54
            {
×
55
                _ = configApp.AddCommandLine(args);
×
56
            }
×
57
        })
×
58
        .ConfigureServices(services =>
×
59
            //supresses the default "Application started. Press Ctrl+C to shut down." etc. log messages, that ConsoleLifetime produces
×
60
            services.Configure<ConsoleLifetimeOptions>(options => options.SuppressStatusMessages = true))
×
61
        .UseDefaultServiceProvider((context, options) =>
×
62
        {
×
63
            var isDev = context.HostingEnvironment.IsDevelopment();
×
64
            options.ValidateOnBuild = isDev;
×
65
            options.ValidateScopes = isDev;
×
66
        });
×
67
}
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

© 2025 Coveralls, Inc