diff --git a/appveyor.yml b/appveyor.yml
index a359ed21..8e25f204 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -23,11 +23,11 @@ artifacts:
test_script:
- nuget.exe install OpenCover -ExcludeVersion -DependencyVersion Ignore
- OpenCover\tools\OpenCover.Console.exe -register:user -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net462 -c debug NLog.Extensions.Logging.Tests" -filter:"+[NLog.Extensions.Logging]* +[NLog.Extensions.Hosting]* -[NLog.Extensions.Logging.Tests]* -[NLog.Extensions.Hosting.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- - OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f netcoreapp3.1 -c debug NLog.Extensions.Logging.Tests" -filter:"+[NLog.Extensions.Logging]* -[NLog.Extensions.Logging.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net6.0 -c debug NLog.Extensions.Logging.Tests" -filter:"+[NLog.Extensions.Logging]* -[NLog.Extensions.Logging.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
+ - OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net8.0 -c debug NLog.Extensions.Logging.Tests" -filter:"+[NLog.Extensions.Logging]* -[NLog.Extensions.Logging.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net462 -c debug NLog.Extensions.Hosting.Tests" -filter:"+[NLog.Extensions.Logging]* +[NLog.Extensions.Hosting]* -[NLog.Extensions.Logging.Tests]* -[NLog.Extensions.Hosting.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- - OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f netcoreapp3.1 -c debug NLog.Extensions.Hosting.Tests" -filter:"+[NLog.Extensions.Logging]* +[NLog.Extensions.Hosting]* -[NLog.Extensions.Logging.Tests]* -[NLog.Extensions.Hosting.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net6.0 -c debug NLog.Extensions.Hosting.Tests" -filter:"+[NLog.Extensions.Logging]* +[NLog.Extensions.Hosting]* -[NLog.Extensions.Logging.Tests]* -[NLog.Extensions.Hosting.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
+ - OpenCover\tools\OpenCover.Console.exe -register:user -mergeoutput -target:"C:/Program Files/dotnet/dotnet.exe" -targetargs:"test -f net8.0 -c debug NLog.Extensions.Hosting.Tests" -filter:"+[NLog.Extensions.Logging]* +[NLog.Extensions.Hosting]* -[NLog.Extensions.Logging.Tests]* -[NLog.Extensions.Hosting.Tests]*" -output:"coverage.xml" -oldstyle -targetdir:"test"
- pip install codecov
- codecov -f "coverage.xml"
- set PATH=%JAVA_HOME%\bin;%PATH%
diff --git a/examples/NetCore2/ConsoleExample/ConsoleExample.csproj b/examples/NetCore2/ConsoleExample/ConsoleExample.csproj
index 73f85b86..7ec32385 100644
--- a/examples/NetCore2/ConsoleExample/ConsoleExample.csproj
+++ b/examples/NetCore2/ConsoleExample/ConsoleExample.csproj
@@ -2,14 +2,14 @@
Exe
- net6.0
+ net8.0
latest
false
-
-
+
+
diff --git a/examples/NetCore2/ConsoleExampleJsonConfig/ConsoleExampleJsonConfig.csproj b/examples/NetCore2/ConsoleExampleJsonConfig/ConsoleExampleJsonConfig.csproj
index 8472a4a9..ce1719f2 100644
--- a/examples/NetCore2/ConsoleExampleJsonConfig/ConsoleExampleJsonConfig.csproj
+++ b/examples/NetCore2/ConsoleExampleJsonConfig/ConsoleExampleJsonConfig.csproj
@@ -2,14 +2,14 @@
Exe
- net6.0
+ net8.0
latest
false
-
-
+
+
diff --git a/examples/NetCore2/HostingExample/HostingExample.csproj b/examples/NetCore2/HostingExample/HostingExample.csproj
index 09fb5d08..47d7f3a8 100644
--- a/examples/NetCore2/HostingExample/HostingExample.csproj
+++ b/examples/NetCore2/HostingExample/HostingExample.csproj
@@ -15,7 +15,7 @@
-
+
diff --git a/src/NLog.Extensions.Logging/Logging/NLogBeginScopeParser.cs b/src/NLog.Extensions.Logging/Logging/NLogBeginScopeParser.cs
index fd8b873b..f784d4fd 100644
--- a/src/NLog.Extensions.Logging/Logging/NLogBeginScopeParser.cs
+++ b/src/NLog.Extensions.Logging/Logging/NLogBeginScopeParser.cs
@@ -45,6 +45,12 @@ public IDisposable ParseBeginScope(T state)
else
return ScopeContext.PushNestedStateProperties(scopeProperties, scopeProperties);
}
+#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER || NET471_OR_GREATER
+ else if (state is System.Runtime.CompilerServices.ITuple tuple && tuple.Length == 2 && tuple[0] is string)
+ {
+ return ScopeContext.PushProperty(tuple[0].ToString(), tuple[1]);
+ }
+#endif
if (!(state is string))
{
diff --git a/test/NLog.Extensions.Hosting.Tests/NLog.Extensions.Hosting.Tests.csproj b/test/NLog.Extensions.Hosting.Tests/NLog.Extensions.Hosting.Tests.csproj
index 8fdc520b..c1b89093 100644
--- a/test/NLog.Extensions.Hosting.Tests/NLog.Extensions.Hosting.Tests.csproj
+++ b/test/NLog.Extensions.Hosting.Tests/NLog.Extensions.Hosting.Tests.csproj
@@ -1,6 +1,6 @@
- net462;net6.0
+ net462;net8.0
Library
false
full
@@ -21,7 +21,7 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
diff --git a/test/NLog.Extensions.Logging.Tests/NLog.Extensions.Logging.Tests.csproj b/test/NLog.Extensions.Logging.Tests/NLog.Extensions.Logging.Tests.csproj
index 9a504d1b..8f5bfdb3 100644
--- a/test/NLog.Extensions.Logging.Tests/NLog.Extensions.Logging.Tests.csproj
+++ b/test/NLog.Extensions.Logging.Tests/NLog.Extensions.Logging.Tests.csproj
@@ -1,7 +1,7 @@
- net462;net6.0
+ net462;net8.0
Library
false
Full
@@ -15,7 +15,7 @@
-
+
@@ -26,14 +26,9 @@
-
+
-
-
-
-
-
diff --git a/test/NLog.Extensions.Logging.Tests/NLogLoggingConfigurationTests.cs b/test/NLog.Extensions.Logging.Tests/NLogLoggingConfigurationTests.cs
index dcbae6a0..0ab3881b 100644
--- a/test/NLog.Extensions.Logging.Tests/NLogLoggingConfigurationTests.cs
+++ b/test/NLog.Extensions.Logging.Tests/NLogLoggingConfigurationTests.cs
@@ -33,8 +33,8 @@ public void LoadSimpleConfig()
Assert.Single(logConfig.LoggingRules);
Assert.Equal(2, logConfig.LoggingRules[0].Targets.Count);
Assert.Equal(2, logConfig.AllTargets.Count);
- Assert.Single(logConfig.AllTargets.Where(t => t is FileTarget));
- Assert.Single(logConfig.AllTargets.Where(t => t is ConsoleTarget));
+ Assert.Single(logConfig.AllTargets, (t) => t is FileTarget);
+ Assert.Single(logConfig.AllTargets, (t) => t is ConsoleTarget);
Assert.Equal("hello.txt", (logConfig.FindTargetByName("file") as FileTarget)?.FileName.Render(LogEventInfo.CreateNullEvent()));
}
@@ -100,8 +100,8 @@ public void LoadSimpleConfigWithCustomKey()
Assert.Single(logConfig.LoggingRules);
Assert.Equal(2, logConfig.LoggingRules[0].Targets.Count);
Assert.Equal(2, logConfig.AllTargets.Count);
- Assert.Single(logConfig.AllTargets.Where(t => t is FileTarget));
- Assert.Single(logConfig.AllTargets.Where(t => t is ConsoleTarget));
+ Assert.Single(logConfig.AllTargets, (t) => t is FileTarget);
+ Assert.Single(logConfig.AllTargets, (t) => t is ConsoleTarget);
Assert.Equal("hello.txt", (logConfig.FindTargetByName("file") as FileTarget)?.FileName.Render(LogEventInfo.CreateNullEvent()));
}
@@ -117,8 +117,8 @@ public void LoadSimpleConfigAndTrimSpace()
Assert.Single(logConfig.LoggingRules);
Assert.Equal(2, logConfig.LoggingRules[0].Targets.Count);
Assert.Equal(2, logConfig.AllTargets.Count);
- Assert.Single(logConfig.AllTargets.Where(t => t is FileTarget));
- Assert.Single(logConfig.AllTargets.Where(t => t is ConsoleTarget));
+ Assert.Single(logConfig.AllTargets, (t) => t is FileTarget);
+ Assert.Single(logConfig.AllTargets, (t) => t is ConsoleTarget);
Assert.Equal("hello.txt", (logConfig.FindTargetByName("file") as FileTarget)?.FileName.Render(LogEventInfo.CreateNullEvent()));
}
@@ -135,9 +135,9 @@ public void LoadWrapperConfig()
Assert.Single(logConfig.LoggingRules);
Assert.Equal(2, logConfig.LoggingRules[0].Targets.Count);
Assert.Equal(3, logConfig.AllTargets.Count);
- Assert.Single(logConfig.AllTargets.Where(t => t is AsyncTargetWrapper));
- Assert.Single(logConfig.AllTargets.Where(t => t is FileTarget));
- Assert.Single(logConfig.AllTargets.Where(t => t is ConsoleTarget));
+ Assert.Single(logConfig.AllTargets, (t) => t is AsyncTargetWrapper);
+ Assert.Single(logConfig.AllTargets, (t) => t is FileTarget);
+ Assert.Single(logConfig.AllTargets, (t) => t is ConsoleTarget);
Assert.Equal("hello.txt", (logConfig.FindTargetByName("wrappedFile") as FileTarget)?.FileName.Render(LogEventInfo.CreateNullEvent()));
}
@@ -154,9 +154,9 @@ public void LoadWrapperConfigExplicitName()
Assert.Single(logConfig.LoggingRules);
Assert.Equal(2, logConfig.LoggingRules[0].Targets.Count);
Assert.Equal(3, logConfig.AllTargets.Count);
- Assert.Single(logConfig.AllTargets.Where(t => t is AsyncTargetWrapper));
- Assert.Single(logConfig.AllTargets.Where(t => t is MemoryTarget));
- Assert.Single(logConfig.AllTargets.Where(t => t is ConsoleTarget));
+ Assert.Single(logConfig.AllTargets, (t) => t is AsyncTargetWrapper);
+ Assert.Single(logConfig.AllTargets, (t) => t is MemoryTarget);
+ Assert.Single(logConfig.AllTargets, (t) => t is ConsoleTarget);
Assert.NotNull(logConfig.FindTargetByName("wrappedMem") as MemoryTarget);
}
@@ -171,8 +171,8 @@ public void LoadWrapperConfigWithoutName()
Assert.Single(logConfig.LoggingRules);
Assert.Equal(2, logConfig.LoggingRules[0].Targets.Count);
- Assert.Single(logConfig.AllTargets.Where(t => t is ConsoleTarget));
- Assert.Single(logConfig.AllTargets.Where(t => t is AsyncTargetWrapper));
+ Assert.Single(logConfig.AllTargets, (t) => t is ConsoleTarget);
+ Assert.Single(logConfig.AllTargets, (t) => t is AsyncTargetWrapper);
Assert.True(logConfig.FindTargetByName("file")?.WrappedTarget is MemoryTarget);
}
@@ -189,8 +189,8 @@ public void LoadVariablesConfig()
Assert.Single(logConfig.LoggingRules);
Assert.Equal(2, logConfig.LoggingRules[0].Targets.Count);
Assert.Equal(2, logConfig.AllTargets.Count);
- Assert.Single(logConfig.AllTargets.Where(t => t is FileTarget));
- Assert.Single(logConfig.AllTargets.Where(t => t is ConsoleTarget));
+ Assert.Single(logConfig.AllTargets, (t) => t is FileTarget);
+ Assert.Single(logConfig.AllTargets, (t) => t is ConsoleTarget);
Assert.Equal("hello.txt", (logConfig.FindTargetByName("file") as FileTarget)?.FileName.Render(LogEventInfo.CreateNullEvent()));
}
@@ -209,8 +209,8 @@ public void LoadVariablesDependentConfig()
Assert.Single(logConfig.LoggingRules);
Assert.Equal(2, logConfig.LoggingRules[0].Targets.Count);
Assert.Equal(2, logConfig.AllTargets.Count);
- Assert.Single(logConfig.AllTargets.Where(t => t is FileTarget));
- Assert.Single(logConfig.AllTargets.Where(t => t is ConsoleTarget));
+ Assert.Single(logConfig.AllTargets, (t) => t is FileTarget);
+ Assert.Single(logConfig.AllTargets, (t) => t is ConsoleTarget);
Assert.Equal("hello/world.txt", (logConfig.FindTargetByName("file") as FileTarget)?.FileName.Render(LogEventInfo.CreateNullEvent()));
}
@@ -234,8 +234,8 @@ public void LoadVariableJsonLayoutConfig()
Assert.Single(logConfig.Variables);
Assert.Equal(2, logConfig.LoggingRules[0].Targets.Count);
Assert.Equal(2, logConfig.AllTargets.Count);
- Assert.Single(logConfig.AllTargets.Where(t => t is FileTarget));
- Assert.Single(logConfig.AllTargets.Where(t => t is ConsoleTarget));
+ Assert.Single(logConfig.AllTargets, (t) => t is FileTarget);
+ Assert.Single(logConfig.AllTargets, (t) => t is ConsoleTarget);
Assert.Equal(2, logConfig.AllTargets.Count(t => (t as TargetWithLayout)?.Layout is NLog.Layouts.JsonLayout));
}
@@ -259,8 +259,8 @@ public void LoadVariableDependentJsonLayoutConfig()
Assert.Equal(3, logConfig.Variables.Count);
Assert.Equal(2, logConfig.LoggingRules[0].Targets.Count);
Assert.Equal(2, logConfig.AllTargets.Count);
- Assert.Single(logConfig.AllTargets.Where(t => t is FileTarget));
- Assert.Single(logConfig.AllTargets.Where(t => t is ConsoleTarget));
+ Assert.Single(logConfig.AllTargets, (t) => t is FileTarget);
+ Assert.Single(logConfig.AllTargets, (t) => t is ConsoleTarget);
Assert.Equal(2, logConfig.AllTargets.Count(t => (t as TargetWithLayout)?.Layout is NLog.Layouts.JsonLayout));
}
@@ -278,8 +278,8 @@ public void LoadDefaultWrapperConfig()
Assert.Single(logConfig.LoggingRules);
Assert.Equal(2, logConfig.LoggingRules[0].Targets.Count);
Assert.Equal(2, (logConfig.AllTargets.Count(t => t is AsyncTargetWrapper asyncTarget && asyncTarget.BatchSize == 1)));
- Assert.Single(logConfig.AllTargets.Where(t => t is AsyncTargetWrapper asyncTarget && asyncTarget.WrappedTarget is FileTarget));
- Assert.Single(logConfig.AllTargets.Where(t => t is AsyncTargetWrapper asyncTarget && asyncTarget.WrappedTarget is ConsoleTarget));
+ Assert.Single(logConfig.AllTargets, (t) => t is AsyncTargetWrapper asyncTarget && asyncTarget.WrappedTarget is FileTarget);
+ Assert.Single(logConfig.AllTargets, (t) => t is AsyncTargetWrapper asyncTarget && asyncTarget.WrappedTarget is ConsoleTarget);
Assert.Equal("hello.txt", ((logConfig.FindTargetByName("file") as AsyncTargetWrapper)?.WrappedTarget as FileTarget)?.FileName.Render(LogEventInfo.CreateNullEvent()));
}
@@ -297,8 +297,8 @@ public void LoadTargetDefaultWrapperConfig()
Assert.Single(logConfig.LoggingRules);
Assert.Equal(2, logConfig.LoggingRules[0].Targets.Count);
Assert.Equal(2, (logConfig.AllTargets.Count(t => t is AsyncTargetWrapper asyncTarget && asyncTarget.BatchSize == 1)));
- Assert.Single(logConfig.AllTargets.Where(t => t is AsyncTargetWrapper asyncTarget && asyncTarget.WrappedTarget is FileTarget));
- Assert.Single(logConfig.AllTargets.Where(t => t is AsyncTargetWrapper asyncTarget && asyncTarget.WrappedTarget is ConsoleTarget));
+ Assert.Single(logConfig.AllTargets, (t) => t is AsyncTargetWrapper asyncTarget && asyncTarget.WrappedTarget is FileTarget);
+ Assert.Single(logConfig.AllTargets, (t) => t is AsyncTargetWrapper asyncTarget && asyncTarget.WrappedTarget is ConsoleTarget);
Assert.Equal("hello.txt", ((logConfig.FindTargetByName("file") as AsyncTargetWrapper)?.WrappedTarget as FileTarget)?.FileName.Render(LogEventInfo.CreateNullEvent()));
}
@@ -315,8 +315,8 @@ public void LoadDefaultTargetParametersConfig()
Assert.Single(logConfig.LoggingRules);
Assert.Equal(2, logConfig.LoggingRules[0].Targets.Count);
Assert.Equal(2, logConfig.AllTargets.Count);
- Assert.Single(logConfig.AllTargets.Where(t => t is FileTarget));
- Assert.Single(logConfig.AllTargets.Where(t => t is ConsoleTarget));
+ Assert.Single(logConfig.AllTargets, (t) => t is FileTarget);
+ Assert.Single(logConfig.AllTargets, (t) => t is ConsoleTarget);
Assert.Equal("hello.txt", (logConfig.FindTargetByName("file") as FileTarget)?.FileName?.Render(LogEventInfo.CreateNullEvent()));
Assert.True((logConfig.FindTargetByName("console") as ConsoleTarget)?.StdErr);
}
@@ -334,8 +334,8 @@ public void LoadTargetDefaultParametersConfig()
Assert.Single(logConfig.LoggingRules);
Assert.Equal(2, logConfig.LoggingRules[0].Targets.Count);
Assert.Equal(2, logConfig.AllTargets.Count);
- Assert.Single(logConfig.AllTargets.Where(t => t is FileTarget));
- Assert.Single(logConfig.AllTargets.Where(t => t is ConsoleTarget));
+ Assert.Single(logConfig.AllTargets, (t) => t is FileTarget);
+ Assert.Single(logConfig.AllTargets, (t) => t is ConsoleTarget);
Assert.Equal("hello.txt", (logConfig.FindTargetByName("file") as FileTarget)?.FileName?.Render(LogEventInfo.CreateNullEvent()));
Assert.True((logConfig.FindTargetByName("console") as ConsoleTarget)?.StdErr);
}
@@ -359,8 +359,8 @@ public void LoadDefaultTargetParametersJsonLayoutConfig()
Assert.Single(logConfig.LoggingRules);
Assert.Equal(2, logConfig.LoggingRules[0].Targets.Count);
Assert.Equal(2, logConfig.AllTargets.Count);
- Assert.Single(logConfig.AllTargets.Where(t => t is FileTarget));
- Assert.Single(logConfig.AllTargets.Where(t => t is ConsoleTarget));
+ Assert.Single(logConfig.AllTargets, (t) => t is FileTarget);
+ Assert.Single(logConfig.AllTargets, (t) => t is ConsoleTarget);
Assert.Equal("hello.txt", (logConfig.FindTargetByName("file") as FileTarget)?.FileName.Render(LogEventInfo.CreateNullEvent()));
Assert.Equal(3, ((logConfig.FindTargetByName("file") as FileTarget)?.Layout as NLog.Layouts.JsonLayout)?.Attributes?.Count);
}