Skip to content

Commit

Permalink
[Group 6] Enable nullable annotations for Microsoft.Extensions.Loggin…
Browse files Browse the repository at this point in the history
…g.Configuration (#67174)
  • Loading branch information
maxkoshevoi authored Apr 1, 2022
1 parent 779de9b commit fc7da6e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ private void LoadDefaultConfigValues(LoggerFilterOptions options)
bool GetCaptureScopesValue(LoggerFilterOptions options) => _configuration.GetValue(nameof(options.CaptureScopes), options.CaptureScopes);
}

private static void LoadRules(LoggerFilterOptions options, IConfigurationSection configurationSection, string logger)
private static void LoadRules(LoggerFilterOptions options, IConfigurationSection configurationSection, string? logger)
{
foreach (System.Collections.Generic.KeyValuePair<string, string> section in configurationSection.AsEnumerable(true))
foreach (System.Collections.Generic.KeyValuePair<string, string?> section in configurationSection.AsEnumerable(true))
{
if (TryGetSwitch(section.Value, out LogLevel level))
{
string category = section.Key;
string? category = section.Key;
if (category.Equals(DefaultCategory, StringComparison.OrdinalIgnoreCase))
{
category = null;
Expand All @@ -74,7 +74,7 @@ private static void LoadRules(LoggerFilterOptions options, IConfigurationSection
}
}

private static bool TryGetSwitch(string value, out LogLevel level)
private static bool TryGetSwitch(string? value, out LogLevel level)
{
if (string.IsNullOrEmpty(value))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,10 @@ public LoggerProviderConfigurationFactory(IEnumerable<LoggingConfiguration> conf
_configurations = configurations;
}

public IConfiguration GetConfiguration(Type providerType)
public IConfiguration GetConfiguration(Type providerType!!)
{
if (providerType == null)
{
throw new ArgumentNullException(nameof(providerType));
}

string fullName = providerType.FullName;
string alias = ProviderAliasUtilities.GetAlias(providerType);
string fullName = providerType.FullName!;
string? alias = ProviderAliasUtilities.GetAlias(providerType);
var configurationBuilder = new ConfigurationBuilder();
foreach (LoggingConfiguration configuration in _configurations)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
<Nullable>enable</Nullable>
<EnableDefaultItems>true</EnableDefaultItems>
<!-- Use targeting pack references instead of granular ones in the project file. -->
<DisableImplicitAssemblyReferences>false</DisableImplicitAssemblyReferences>
Expand Down

0 comments on commit fc7da6e

Please sign in to comment.