< Summary - SonghayCore

Information
Class: Songhay.Extensions.TraceSourcesExtensions
Assembly: SonghayCore
File(s): /home/rasx/sourceRoot/SonghayCore/SonghayCore/Extensions/TraceSourcesExtensions.cs
Line coverage
88%
Covered lines: 8
Uncovered lines: 1
Coverable lines: 9
Total lines: 68
Line coverage: 88.8%
Branch coverage
66%
Covered branches: 4
Total branches: 6
Branch coverage: 66.6%
Method coverage

Method coverage is only available for sponsors.

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
GetConfiguredTraceSource(...)100%1100%
GetConfiguredTraceSource(...)100%10%
GetConfiguredTraceSource(...)66.66%6100%

File(s)

/home/rasx/sourceRoot/SonghayCore/SonghayCore/Extensions/TraceSourcesExtensions.cs

#LineLine coverage
 1namespace Songhay.Extensions;
 2
 3/// <summary>
 4/// Extensions of <see cref="TraceSources"/>
 5/// </summary>
 6public static class TraceSourcesExtensions
 7{
 8    /// <summary>
 9    /// Gets the configured trace source.
 10    /// </summary>
 11    /// <param name="instance">The instance.</param>
 12    /// <remarks>
 13    /// For .NET Standard, this member makes sense after lines like these:
 14    /// <code>
 15    ///     var configuration = builder.Build();
 16    ///     TraceSources.ConfiguredTraceSourceName = configuration[DeploymentEnvironment.DefaultTraceSourceNameConfigura
 17    /// </code>
 18    ///
 19    /// This member makes the <c>GetConfiguredTraceSource</c> pattern cross platform.
 20    /// </remarks>
 21    public static TraceSource? GetConfiguredTraceSource(this TraceSources? instance) =>
 822        instance.GetConfiguredTraceSource(configuration: null, key: null);
 23
 24    /// <summary>
 25    /// Gets the configured trace source.
 26    /// </summary>
 27    /// <param name="instance">The instance.</param>
 28    /// <param name="configuration">The configuration.</param>
 29    /// <remarks>
 30    /// For .NET Standard, this member makes sense after lines like these:
 31    /// <code>
 32    ///     var configuration = builder.Build();
 33    ///     TraceSources.ConfiguredTraceSourceName = configuration[DeploymentEnvironment.DefaultTraceSourceNameConfigura
 34    /// </code>
 35    ///
 36    /// This member makes the <c>GetConfiguredTraceSource</c> pattern cross platform.
 37    /// </remarks>
 38    public static TraceSource? GetConfiguredTraceSource(this TraceSources? instance, IConfiguration? configuration) =>
 039        instance.GetConfiguredTraceSource(configuration, key: null);
 40
 41    /// <summary>
 42    /// Gets the configured trace source.
 43    /// </summary>
 44    /// <param name="instance">The instance.</param>
 45    /// <param name="configuration">The configuration.</param>
 46    /// <param name="key">The key.</param>
 47    /// <remarks>
 48    /// For .NET Standard, this member makes sense after lines like these:
 49    /// <code>
 50    ///     var configuration = builder.Build();
 51    ///     TraceSources.ConfiguredTraceSourceName = configuration[DeploymentEnvironment.DefaultTraceSourceNameConfigura
 52    /// </code>
 53    ///
 54    /// This member makes the <c>GetConfiguredTraceSource</c> pattern cross platform.
 55    /// </remarks>
 56    public static TraceSource? GetConfiguredTraceSource(this TraceSources? instance, IConfiguration? configuration,
 57        string? key)
 1058    {
 1059        if (instance == null) return null;
 60
 1861        if (configuration == null) return instance.GetTraceSourceFromConfiguredName();
 62
 263        if (string.IsNullOrWhiteSpace(key)) key = DeploymentEnvironment.DefaultTraceSourceNameConfigurationKey;
 264        TraceSources.ConfiguredTraceSourceName = configuration[key];
 65
 266        return instance.GetTraceSourceFromConfiguredName();
 1067    }
 68}