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

Drop support for .NET Framework 4.5.1 #351

Merged
merged 1 commit into from
Mar 9, 2023
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
Expand Up @@ -4,7 +4,7 @@
<Description>Microsoft.Extensions.Configuration (appsettings.json) support for Serilog.</Description>
<VersionPrefix>3.5.0</VersionPrefix>
<Authors>Serilog Contributors</Authors>
<TargetFrameworks>netstandard2.0;net451;net461</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Serilog.Settings.Configuration</AssemblyName>
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
Expand All @@ -20,18 +20,16 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>

<ItemGroup>
<Using Remove="System.Net.Http" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="6.0.0" />
<PackageReference Include="Serilog" Version="2.10.0" />
<None Include="..\..\assets\icon.png" Pack="true" PackagePath="" Visible="false" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework) == 'net451'">
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="1.1.2" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework) != 'net451'">
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.0.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,14 @@ class ConfigurationReader : IConfigurationReader
readonly IConfigurationSection _section;
readonly IReadOnlyCollection<Assembly> _configurationAssemblies;
readonly ResolutionContext _resolutionContext;
#if NETSTANDARD || NET461
readonly IConfigurationRoot _configurationRoot;
#endif

public ConfigurationReader(IConfigurationSection configSection, AssemblyFinder assemblyFinder, IConfiguration configuration = null)
{
_section = configSection ?? throw new ArgumentNullException(nameof(configSection));
_configurationAssemblies = LoadConfigurationAssemblies(_section, assemblyFinder);
_resolutionContext = new ResolutionContext(configuration);
#if NETSTANDARD || NET461
_configurationRoot = configuration as IConfigurationRoot;
#endif
}

// Used internally for processing nested configuration sections -- see GetMethodCalls below.
Expand All @@ -40,9 +36,7 @@ internal ConfigurationReader(IConfigurationSection configSection, IReadOnlyColle
_section = configSection ?? throw new ArgumentNullException(nameof(configSection));
_configurationAssemblies = configurationAssemblies ?? throw new ArgumentNullException(nameof(configurationAssemblies));
_resolutionContext = resolutionContext ?? throw new ArgumentNullException(nameof(resolutionContext));
#if NETSTANDARD || NET461
_configurationRoot = resolutionContext.HasAppConfiguration ? resolutionContext.AppConfiguration as IConfigurationRoot : null;
#endif
}

public void Configure(LoggerConfiguration loggerConfiguration)
Expand Down Expand Up @@ -192,8 +186,6 @@ void ApplyMinimumLevelConfiguration(IConfigurationSection directive, Action<Logg

IConfigurationSection GetDefaultMinLevelDirective()
{
#if NETSTANDARD || NET461

var defaultLevelDirective = minimumLevelDirective.GetSection("Default");
if (_configurationRoot != null && minimumLevelDirective.Value != null && defaultLevelDirective.Value != null)
{
Expand All @@ -213,8 +205,6 @@ IConfigurationSection GetDefaultMinLevelDirective()
return null;
}

#endif //NET451 or fallback

return minimumLevelDirective.Value != null ? minimumLevelDirective : minimumLevelDirective.GetSection("Default");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ public void ObjectMinimumLevelCorrectOneIsEnabledOnLogger(IConfigurationRoot roo
AssertLogEventLevels(loggerConfig, expectedMinimumLevel);
}

#if !(NET452)

// currently only works in the .NET 4.6.1 and .NET Standard builds of Serilog.Settings.Configuration
public static IEnumerable<object[]> MixedMinimumLevel => new List<object[]>
{
Expand Down Expand Up @@ -266,8 +264,6 @@ public void MixedMinimumLevelCorrectOneIsEnabledOnLogger(IConfigurationRoot root
AssertLogEventLevels(loggerConfig, expectedMinimumLevel);
}

#endif

[Fact]
public void NoConfigurationRootUsedStillValid()
{
Expand Down