From 5aec4087d4b799d120b50e87797692a3dd5484c3 Mon Sep 17 00:00:00 2001 From: Rolf Kristensen Date: Fri, 29 Dec 2023 12:22:50 +0100 Subject: [PATCH] Fixed IncludeActivityIdsWithBeginScope for NET8 --- .../Logging/ActivityExtensions.cs | 2 +- .../Logging/NLogBeginScopeParser.cs | 12 ++++++------ .../Logging/NLogProviderOptions.cs | 2 +- .../Extensions/ConfigureExtensionsTests.cs | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/NLog.Extensions.Logging/Logging/ActivityExtensions.cs b/src/NLog.Extensions.Logging/Logging/ActivityExtensions.cs index f6351290..8d0ca00c 100644 --- a/src/NLog.Extensions.Logging/Logging/ActivityExtensions.cs +++ b/src/NLog.Extensions.Logging/Logging/ActivityExtensions.cs @@ -1,4 +1,4 @@ -#if NET6_0 +#if NET5_0_OR_GREATER using System.Diagnostics; diff --git a/src/NLog.Extensions.Logging/Logging/NLogBeginScopeParser.cs b/src/NLog.Extensions.Logging/Logging/NLogBeginScopeParser.cs index 551c744e..fd8b873b 100644 --- a/src/NLog.Extensions.Logging/Logging/NLogBeginScopeParser.cs +++ b/src/NLog.Extensions.Logging/Logging/NLogBeginScopeParser.cs @@ -94,12 +94,7 @@ private IReadOnlyList> ParseScopeProperties(IReadOn } } -#if !NET6_0 - private static IReadOnlyList> IncludeActivityIdsProperties(IReadOnlyList> scopePropertyList) - { - return scopePropertyList; // Not supported - } -#else +#if NET5_0_OR_GREATER private IReadOnlyList> IncludeActivityIdsProperties(IReadOnlyList> scopePropertyList) { if (_options.IncludeActivityIdsWithBeginScope && "RequestId".Equals(scopePropertyList[0].Key)) @@ -162,6 +157,11 @@ IEnumerator IEnumerable.GetEnumerator() return ((IEnumerable)_originalPropertyList).GetEnumerator(); } } +#else + private static IReadOnlyList> IncludeActivityIdsProperties(IReadOnlyList> scopePropertyList) + { + return scopePropertyList; // Not supported + } #endif public static IDisposable CaptureScopeProperties(IEnumerable scopePropertyCollection, ExtractorDictionary stateExtractor) diff --git a/src/NLog.Extensions.Logging/Logging/NLogProviderOptions.cs b/src/NLog.Extensions.Logging/Logging/NLogProviderOptions.cs index eb826384..ea64cc5d 100644 --- a/src/NLog.Extensions.Logging/Logging/NLogProviderOptions.cs +++ b/src/NLog.Extensions.Logging/Logging/NLogProviderOptions.cs @@ -60,7 +60,7 @@ public class NLogProviderOptions /// public bool AutoShutdown { get; set; } -#if NET6_0 +#if NET5_0_OR_GREATER /// /// Automatically include , and /// diff --git a/test/NLog.Extensions.Logging.Tests/Extensions/ConfigureExtensionsTests.cs b/test/NLog.Extensions.Logging.Tests/Extensions/ConfigureExtensionsTests.cs index bf7cc787..20a167b7 100644 --- a/test/NLog.Extensions.Logging.Tests/Extensions/ConfigureExtensionsTests.cs +++ b/test/NLog.Extensions.Logging.Tests/Extensions/ConfigureExtensionsTests.cs @@ -57,7 +57,7 @@ public void AddNLog_LoggerFactory_LogInfoWithEventId_ShouldLogToNLogWithEventId( AssertSingleMessage(memoryTarget, $"{expectedEventInLog} - test message with 1 arg"); } -#if NET6_0 +#if NET5_0_OR_GREATER [Fact] public void AddNLog_LoggerFactory_IncludeActivityIdsWithBeginScope() {