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

net-daemon / netdaemon / 5747992183

pending completion
5747992183

push

github

web-flow
Cleaned some extensions (#898)

- Support for User Secrets by not overriding it.

789 of 1112 branches covered (70.95%)

Branch coverage included in aggregate %.

24 of 24 new or added lines in 2 files covered. (100.0%)

3671 of 4326 relevant lines covered (84.86%)

48.26 hits per line

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

67.31
/src/AppModel/NetDaemon.AppModel/Common/Extensions/IConfigurationBuilderExtensions.cs
1
using Microsoft.Extensions.Configuration;
2
using Microsoft.Extensions.FileProviders;
3
using NetDaemon.AppModel.Internal.Config;
4

5
namespace NetDaemon.AppModel;
6

7
/// <summary>
8
///     Extensions for IConfigurationBuilder
9
/// </summary>
10
public static class ConfigurationBuilderExtensions
11
{
12
    /// <summary>
13
    ///     Adds json configurations for apps given the path
14
    /// </summary>
15
    /// <param name="builder">Builder</param>
16
    /// <param name="appConfigPath">Path to the folder containing configurations</param>
17
    public static IConfigurationBuilder AddJsonAppConfig(this IConfigurationBuilder builder, string appConfigPath)
18
    {
2✔
19
        Directory.EnumerateFiles(appConfigPath, "*.json", SearchOption.AllDirectories)
2✔
20
            .ToList()
2✔
21
            .ForEach(x => builder.AddJsonFile(x, false, false));
6✔
22
        return builder;
2✔
23
    }
2✔
24

25
    /// <summary>
26
    ///     Adds yaml configurations for apps given the path
27
    /// </summary>
28
    /// <param name="builder">Builder</param>
29
    /// <param name="appConfigPath">Path to the folder containing configurations</param>
30
    public static IConfigurationBuilder AddYamlAppConfig(this IConfigurationBuilder builder, string appConfigPath)
31
    {
31✔
32
        Directory.EnumerateFiles(appConfigPath, "*.y*", SearchOption.AllDirectories)
31✔
33
            .ToList()
31✔
34
            .ForEach(x => builder.AddYamlFile(x, false, false));
100✔
35
        return builder;
31✔
36
    }
31✔
37

38
    /// <summary>
39
    /// Adds yaml configurations for apps given the path in the configuration
40
    /// </summary>
41
    /// <param name="builder">Builder</param>
42
    /// <param name="configuration">Configuration</param>
43
    /// <remarks>Should be called from `hostBuilder.ConfigureAppConfiguration`</remarks>
44
    /// <example>
45
    /// hostBuilder.ConfigureAppConfiguration((context, config) =>
46
    /// {
47
    ///     config.AddYamlAppConfigs(context.Configuration);
48
    /// });
49
    /// </example>
50
    public static IConfigurationBuilder AddYamlAppConfigs(this IConfigurationBuilder builder, IConfiguration configuration)
51
    {
×
52
        AppConfigurationLocationSetting? appConfigurationLocationSetting = configuration.GetSection("NetDaemon")?.Get<AppConfigurationLocationSetting>();
×
53
        if (appConfigurationLocationSetting?.ApplicationConfigurationFolder != null)
×
54
        {
×
55
            string fullPath = Path.GetFullPath(appConfigurationLocationSetting.ApplicationConfigurationFolder);
×
56
            builder.AddYamlAppConfig(fullPath);
×
57
        }
×
58

59
        return builder;
×
60
    }
×
61

62
    internal static IConfigurationBuilder AddYamlFile(this IConfigurationBuilder builder, string filePath, bool optional,
63
        bool reloadOnChange)
64
    {
70✔
65
        return AddYamlFile(builder, null, filePath, optional, reloadOnChange);
70✔
66
    }
70✔
67

68
    internal static IConfigurationBuilder AddYamlFile(this IConfigurationBuilder builder, IFileProvider? provider,
69
        string filePath, bool optional, bool reloadOnChange)
70
    {
70✔
71
        if (provider == null && Path.IsPathRooted(filePath))
70!
72
        {
70✔
73
            provider = new PhysicalFileProvider(Path.GetDirectoryName(filePath)??"");
70!
74
            filePath = Path.GetFileName(filePath);
70✔
75
        }
70✔
76

77
        var source = new YamlConfigurationSource
70✔
78
        {
70✔
79
            FileProvider = provider,
70✔
80
            Path = filePath,
70✔
81
            Optional = optional,
70✔
82
            ReloadOnChange = reloadOnChange
70✔
83
        };
70✔
84
        builder.Add(source);
70✔
85
        return builder;
70✔
86
    }
70✔
87
}
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