Skip to content

Commit

Permalink
Merge pull request #351 from 0xced/drop-net451
Browse files Browse the repository at this point in the history
Drop support for .NET Framework 4.5.1
  • Loading branch information
nblumhardt authored Mar 9, 2023
2 parents ab87641 + beefbfe commit 1b5feb2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
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

0 comments on commit 1b5feb2

Please sign in to comment.