Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Group 6] Enable nullable annotations for Microsoft.Extensions.Logging.Configuration #67174

Merged
merged 3 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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