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

JaCraig / Gestalt / 19320957261

13 Nov 2025 04:53AM UTC coverage: 81.565% (-1.2%) from 82.759%
19320957261

push

github

JaCraig
feat(deps): update package dependencies

Upgrade multiple package dependencies across projects to ensure compatibility, address bug fixes, and introduce new features. Changes are applied consistently to maintain uniformity.

- Upgrade `Microsoft.NET.Test.Sdk` to `18.0.1` in test projects.
- Upgrade `Microsoft.CodeAnalysis.NetAnalyzers` to `10.0.100`.
- Upgrade `Microsoft.Extensions.Hosting` to `10.0.0` in console projects.
- Upgrade `Microsoft.Extensions.Configuration.Abstractions`, `Microsoft.Extensions.Hosting.Abstractions`, `Microsoft.Extensions.Logging`, and `Microsoft.Extensions.Logging.Console` to `10.0.0` in `Gestalt.Core.csproj`.
- Upgrade `BigBook` to `6.1.0` in `Gestalt.Core.csproj`.
- Upgrade `BenchmarkDotNet` to `0.15.7` in `Gestalt.SpeedTests.csproj`.
- Upgrade `Mecha.xUnit` to `3.2.0` in `Gestalt.Tests.Helpers.csproj`.

233 of 328 branches covered (71.04%)

Branch coverage included in aggregate %.

382 of 426 relevant lines covered (89.67%)

6939.16 hits per line

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

73.71
/Gestalt.Core/BaseClasses/ApplicationBaseClass.cs
1
using BigBook;
2
using Gestalt.Core.ExtensionMethods;
3
using Gestalt.Core.Interfaces;
4
using Microsoft.Extensions.Configuration;
5
using Microsoft.Extensions.DependencyInjection;
6
using Microsoft.Extensions.Hosting;
7
using Microsoft.Extensions.Logging;
8
using System.Diagnostics.CodeAnalysis;
9
using System.Reflection;
10

11
namespace Gestalt.Core.BaseClasses
12
{
13
    /// <summary>
14
    /// Application info holder.
15
    /// </summary>
16
    /// <seealso cref="IApplication"/>
17
    public abstract class ApplicationBaseClass : IApplication
18
    {
19
        /// <summary>
20
        /// Initializes a new instance of the <see cref="ApplicationBaseClass"/> class.
21
        /// </summary>
22
        /// <param name="configuration">The configuration.</param>
23
        /// <param name="env">The host environment</param>
24
        /// <param name="assemblies">
25
        /// The assemblies to search for modules, if empty the base application directory is searched.
26
        /// </param>
27
        protected ApplicationBaseClass(IConfiguration? configuration, IHostEnvironment? env, params Assembly?[]? assemblies)
41✔
28
        {
29
            configuration ??= new ConfigurationBuilder().Build();
41!
30
            IConfigurationSection? LoggingConfiguration = configuration.GetSection("Logging");
41✔
31
            try
32
            {
33
                InternalLogger = LoggerFactory.Create(builder =>
41✔
34
                {
41✔
35
                    try
41✔
36
                    {
41✔
37
                        if (LoggingConfiguration is not null)
41✔
38
                            builder = builder.AddConfiguration(LoggingConfiguration);
41✔
39
                    }
41✔
40
                    catch { }
×
41
                    _ = builder.AddConsole();
41✔
42
                }).CreateLogger("Gestalt");
82✔
43
            }
41✔
44
            catch { }
×
45
            var EntryAssembly = Assembly.GetEntryAssembly();
41✔
46
            if (assemblies is null || assemblies.Length == 0)
41✔
47
                assemblies = EntryAssembly.FindAssemblies();
6✔
48

49
            InternalLogger?.LogInformation("Starting application {entryAssemblyName}", EntryAssembly?.GetName().Name);
41!
50
            InternalLogger?.LogInformation("Assembly Count: {assemblyCount}", assemblies.Length);
41!
51
            if (assemblies.Length > 0)
41✔
52
                InternalLogger?.LogInformation("Searching assemblies {assemblies}", assemblies.ToString(x => x?.GetName().Name ?? "", ", "));
744!
53

54
            Configuration = configuration;
41✔
55
            Environment = env;
41✔
56
            Modules = assemblies.FindModules();
41✔
57

58
            InternalLogger?.LogInformation("Module Count: {moduleCount}", Modules.Length);
41!
59
            if (Modules.Length > 0)
41✔
60
                InternalLogger?.LogInformation("Using modules {modules}", Modules.ToString(x => x?.Name ?? "", ", "));
12!
61

62
            Frameworks = assemblies.FindFrameworks();
41✔
63

64
            InternalLogger?.LogInformation("Framework Count: {frameworkCount}", Frameworks.Length);
41!
65
            if (Frameworks.Length > 0)
41!
66
                InternalLogger?.LogInformation("Using frameworks {frameworks}", Frameworks.ToString(x => x?.Name ?? "", ", "));
×
67

68
            Name = EntryAssembly?.GetName().Name ?? "";
41!
69
        }
41✔
70

71
        /// <summary>
72
        /// Gets the name.
73
        /// </summary>
74
        /// <value>The name.</value>
75
        public string Name { get; }
2✔
76

77
        /// <summary>
78
        /// Gets the configuration.
79
        /// </summary>
80
        /// <value>The configuration.</value>
81
        protected IConfiguration? Configuration { get; }
39✔
82

83
        /// <summary>
84
        /// Gets the environment.
85
        /// </summary>
86
        /// <value>The environment.</value>
87
        protected IHostEnvironment? Environment { get; }
45✔
88

89
        /// <summary>
90
        /// Gets the frameworks.
91
        /// </summary>
92
        /// <value>The frameworks.</value>
93
        protected IApplicationFramework[] Frameworks { get; }
88✔
94

95
        /// <summary>
96
        /// Gets the internal logger.
97
        /// </summary>
98
        protected ILogger? InternalLogger { get; }
270✔
99

100
        /// <summary>
101
        /// Gets the modules.
102
        /// </summary>
103
        /// <value>The modules.</value>
104
        protected IApplicationModule[] Modules { get; }
215✔
105

106
        /// <summary>
107
        /// Configures the configuration settings.
108
        /// </summary>
109
        /// <param name="configuration">The configuration.</param>
110
        /// <param name="args">The command line arguments</param>
111
        /// <returns>The configuration builder.</returns>
112
        [return: NotNullIfNotNull(nameof(configuration))]
113
        public IConfigurationBuilder? ConfigureConfigurationSettings(IConfigurationBuilder? configuration, string?[]? args)
114
        {
115
            if (configuration is null)
13!
116
                return configuration;
×
117

118
            args ??= [];
13✔
119

120
            InternalLogger?.LogInformation("Configuring configuration settings");
13!
121

122
            for (int I = 0, ModulesLength = Modules.Length; I < ModulesLength; I++)
51✔
123
            {
124
                IApplicationModule Module = Modules[I];
6✔
125
                configuration = Module.ConfigureConfigurationSettings(configuration, Environment, args) ?? configuration;
6!
126
            }
127
            return configuration;
13✔
128
        }
129

130
        /// <summary>
131
        /// Configures the framework specific services.
132
        /// </summary>
133
        /// <param name="services">The services.</param>
134
        /// <returns>The services.</returns>
135
        [return: NotNullIfNotNull(nameof(services))]
136
        public IServiceCollection? ConfigureFrameworks(IServiceCollection? services)
137
        {
138
            if (services is null)
7✔
139
                return services;
1✔
140

141
            InternalLogger?.LogInformation("Configuring framework specific services");
6!
142

143
            for (int I = 0, FrameworksLength = Frameworks.Length; I < FrameworksLength; I++)
18!
144
            {
145
                IApplicationFramework Framework = Frameworks[I];
×
146
                services = Framework.Configure(Modules, services, Configuration, Environment) ?? services;
×
147
            }
148
            return services;
6✔
149
        }
150

151
        /// <summary>
152
        /// Configures the host settings.
153
        /// </summary>
154
        /// <param name="host">The host.</param>
155
        /// <returns>Host builder</returns>
156
        [return: NotNullIfNotNull(nameof(host))]
157
        public IHostBuilder? ConfigureHostSettings(IHostBuilder? host)
158
        {
159
            if (host is null)
7✔
160
                return host;
1✔
161

162
            InternalLogger?.LogInformation("Configuring host settings");
6!
163

164
            for (int I = 0, ModulesLength = Modules.Length; I < ModulesLength; I++)
22✔
165
            {
166
                IApplicationModule Module = Modules[I];
2✔
167
                host = Module.ConfigureHostSettings(host, Configuration, Environment) ?? host;
2!
168
            }
169
            return host;
6✔
170
        }
171

172
        /// <summary>
173
        /// Configures the logging settings.
174
        /// </summary>
175
        /// <param name="logging">The logging.</param>
176
        /// <returns>Logging builder</returns>
177
        [return: NotNullIfNotNull(nameof(logging))]
178
        public ILoggingBuilder? ConfigureLoggingSettings(ILoggingBuilder? logging)
179
        {
180
            if (logging is null)
13✔
181
                return logging;
1✔
182

183
            InternalLogger?.LogInformation("Configuring logging settings");
12!
184

185
            for (int I = 0, ModulesLength = Modules.Length; I < ModulesLength; I++)
48✔
186
            {
187
                IApplicationModule Module = Modules[I];
6✔
188
                logging = Module.ConfigureLoggingSettings(logging, Configuration, Environment) ?? logging;
6!
189
            }
190
            return logging;
12✔
191
        }
192

193
        /// <summary>
194
        /// Configures the services for MVC.
195
        /// </summary>
196
        /// <param name="services">The services collection.</param>
197
        /// <returns>The service collection</returns>
198
        [return: NotNullIfNotNull(nameof(services))]
199
        public IServiceCollection? ConfigureServices(IServiceCollection? services)
200
        {
201
            if (Configuration is null || Environment is null || services?.IsReadOnly != false)
13✔
202
                return services;
1✔
203

204
            InternalLogger?.LogInformation("Configuring services");
12!
205

206
            // Set up advanced configuration abilities.
207
            services = services?.AddCanisterModules();
12!
208

209
            // Add application
210
            services = services?.AddSingleton<IApplication>(this);
12!
211

212
            // Add options
213
            services = services?.AddOptions();
12!
214

215
            //Add modules
216
            for (int I = 0, ModulesLength = Modules.Length; I < ModulesLength; I++)
48✔
217
            {
218
                IApplicationModule Module = Modules[I];
6✔
219
                services = services?.AddSingleton(Module);
6!
220
            }
221
            for (int I = 0, ModulesLength = Modules.Length; I < ModulesLength; I++)
48✔
222
            {
223
                IApplicationModule Module = Modules[I];
6✔
224
                services = Module.ConfigureServices(services, Configuration, Environment) ?? services;
6!
225
            }
226
            return services;
12✔
227
        }
228

229
        /// <summary>
230
        /// Called when [started].
231
        /// </summary>
232
        public void OnStarted()
233
        {
234
            InternalLogger?.LogInformation("Application started");
1!
235
            for (int I = 0, ModulesLength = Modules.Length; I < ModulesLength; I++)
3!
236
            {
237
                IApplicationModule Module = Modules[I];
×
238
                Module.OnStarted();
×
239
            }
240
        }
1✔
241

242
        /// <summary>
243
        /// Called when [stopped].
244
        /// </summary>
245
        public void OnStopped()
246
        {
247
            InternalLogger?.LogInformation("Application stopped");
1!
248
            for (int I = 0, ModulesLength = Modules.Length; I < ModulesLength; I++)
3!
249
            {
250
                IApplicationModule Module = Modules[I];
×
251
                Module.OnStopped();
×
252
            }
253
        }
1✔
254

255
        /// <summary>
256
        /// Called when [shutdown].
257
        /// </summary>
258
        public void OnStopping()
259
        {
260
            InternalLogger?.LogInformation("Application stopping");
1!
261
            for (int I = 0, ModulesLength = Modules.Length; I < ModulesLength; I++)
3!
262
            {
263
                IApplicationModule Module = Modules[I];
×
264
                Module.OnStopping();
×
265
            }
266
        }
1✔
267
    }
268
}
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