Fix to work with 7.0.4

This commit is contained in:
Mark J Price 2023-06-29 15:28:27 +01:00
parent c1c4286dee
commit 130d784319
6 changed files with 10 additions and 22 deletions

View file

@ -8,8 +8,7 @@
</PropertyGroup>
<ItemGroup>
<!--Do NOT use version 7.0.3 or 7.0.4 because they have a bug that causes an exception.-->
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<!--The following packages are included anyway due to dependencies-->

View file

@ -1,13 +1,6 @@
using System.Diagnostics;
using System.Reflection;
using Microsoft.Extensions.Configuration;
Console.WriteLine("Warning! Versions 7.0.3xx and 7.0.4xx have bugs that cause an exception:");
Console.WriteLine("Microsoft.Extensions.Configuration.Binder version: {0}",
typeof(ConfigurationBinder).Assembly.GetCustomAttribute
<AssemblyFileVersionAttribute>()?.Version);
Console.WriteLine();
string logPath = Path.Combine(Environment.GetFolderPath(
Environment.SpecialFolder.DesktopDirectory), "log.txt");
@ -52,6 +45,7 @@ configuration.GetSection("PacktSwitch").Bind(ts);
// Output the trace switch level from appsettings.json.
Console.WriteLine($"Trace switch level: {ts.Level}");
Console.WriteLine($"Trace switch value: {ts.Value}");
Trace.WriteLineIf(ts.TraceError, "Trace error");
Trace.WriteLineIf(ts.TraceWarning, "Trace warning");

View file

@ -1,5 +1,6 @@
{
"PacktSwitch": {
"Level": "Info"
"Value": "Info", // Must be set to work with 7.0.3 or later.
"Level": "Info" // To work with 7.0.2 or earlier including .NET 6.
}
}

View file

@ -8,8 +8,7 @@
</PropertyGroup>
<ItemGroup>
<!--Do NOT use version 7.0.3 or 7.0.4 because they have a bug that causes an exception.-->
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<!--The following packages are included anyway due to dependencies-->

View file

@ -1,13 +1,6 @@
using System.Diagnostics;
using System.Reflection;
using Microsoft.Extensions.Configuration;
Console.WriteLine("Warning! Versions 7.0.3xx and 7.0.4xx have bugs that cause an exception:");
Console.WriteLine("Microsoft.Extensions.Configuration.Binder version: {0}",
typeof(ConfigurationBinder).Assembly.GetCustomAttribute
<AssemblyFileVersionAttribute>()?.Version);
Console.WriteLine();
string logPath = Path.Combine(Environment.GetFolderPath(
Environment.SpecialFolder.DesktopDirectory), "log.txt");
@ -52,6 +45,7 @@ configuration.GetSection("PacktSwitch").Bind(ts);
// Output the trace switch level from appsettings.json.
Console.WriteLine($"Trace switch level: {ts.Level}");
Console.WriteLine($"Trace switch value: {ts.Value}");
Trace.WriteLineIf(ts.TraceError, "Trace error");
Trace.WriteLineIf(ts.TraceWarning, "Trace warning");

View file

@ -1,5 +1,6 @@
{
"PacktSwitch": {
"Level": "Info"
"Value": "Info", // Must be set to work with 7.0.3 or later.
"Level": "Info" // To work with 7.0.2 or earlier including .NET 6.
}
}