未验证 提交 fc7da6e5 编写于 作者: M Maksym Koshovyi 提交者: GitHub

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

上级 779de9bf
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
......
......@@ -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;
......@@ -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))
{
......
......@@ -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)
{
......
......@@ -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>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册