diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..36f9632c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +; Top-most EditorConfig file +root = true + +; Unix-style newlines +[*] +end_of_line = crlf + +; 4-column space indentation +[*.cs] +indent_style = space +indent_size = 4 +insert_final_newline = true +trim_trailing_whitespace = true + +# .NET formatting rules +[*.{cs,vb}] +dotnet_sort_system_directives_first = true \ No newline at end of file diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 75b8a611..ebfd7f3c 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -2,6 +2,10 @@ Date format: (year/month/day) +### Version 6.0.4 (2025/09/11) + +- [#808](https://github.com/NLog/NLog.Extensions.Logging/pull/808) Updated to NLog v6.0.4 (@snakefoot) + ### Version 6.0.3 (2025/08/10) - [#806](https://github.com/NLog/NLog.Extensions.Logging/pull/806) Updated to NLog v6.0.3 (@snakefoot) diff --git a/build.ps1 b/build.ps1 index 555cbe96..7899d23f 100644 --- a/build.ps1 +++ b/build.ps1 @@ -2,7 +2,7 @@ # creates NuGet package at \artifacts dotnet --version -$versionPrefix = "6.0.3" +$versionPrefix = "6.0.4" $versionSuffix = "" $versionFile = $versionPrefix + "." + ${env:APPVEYOR_BUILD_NUMBER} $versionProduct = $versionPrefix; diff --git a/examples/NetCore2/HostingExample/Program.cs b/examples/NetCore2/HostingExample/Program.cs index 68e4af16..37d20eba 100644 --- a/examples/NetCore2/HostingExample/Program.cs +++ b/examples/NetCore2/HostingExample/Program.cs @@ -4,7 +4,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using NLog; using NLog.Extensions.Hosting; namespace HostingExample diff --git a/src/NLog.Extensions.Hosting/LayoutRenderers/HostAppNameLayoutRenderer.cs b/src/NLog.Extensions.Hosting/LayoutRenderers/HostAppNameLayoutRenderer.cs index 5a517bc6..399c5c5b 100644 --- a/src/NLog.Extensions.Hosting/LayoutRenderers/HostAppNameLayoutRenderer.cs +++ b/src/NLog.Extensions.Hosting/LayoutRenderers/HostAppNameLayoutRenderer.cs @@ -1,5 +1,4 @@ -using System; -using System.Text; +using System.Text; using Microsoft.Extensions.Hosting; using NLog.Config; using NLog.LayoutRenderers; diff --git a/src/NLog.Extensions.Logging/Config/NLogLoggingConfiguration.cs b/src/NLog.Extensions.Logging/Config/NLogLoggingConfiguration.cs index 531b5e68..e085d492 100644 --- a/src/NLog.Extensions.Logging/Config/NLogLoggingConfiguration.cs +++ b/src/NLog.Extensions.Logging/Config/NLogLoggingConfiguration.cs @@ -205,7 +205,7 @@ public LoggingConfigurationElement(IConfigurationSection configurationSection, s } } } - + private static bool IgnoreTopElementChildNullValue(string configKey, object? configValue) { if (configValue is null) diff --git a/src/NLog.Extensions.Logging/Config/SetupExtensionsBuilderExtensions.cs b/src/NLog.Extensions.Logging/Config/SetupExtensionsBuilderExtensions.cs index 9026710b..b775ddf4 100644 --- a/src/NLog.Extensions.Logging/Config/SetupExtensionsBuilderExtensions.cs +++ b/src/NLog.Extensions.Logging/Config/SetupExtensionsBuilderExtensions.cs @@ -1,5 +1,4 @@ -using System; -using System.Reflection; +using System.Reflection; using Microsoft.Extensions.Configuration; using NLog.Config; diff --git a/src/NLog.Extensions.Logging/Layouts/MicrosoftConsoleJsonLayout.cs b/src/NLog.Extensions.Logging/Layouts/MicrosoftConsoleJsonLayout.cs index 22b2b07f..f9bb4c50 100644 --- a/src/NLog.Extensions.Logging/Layouts/MicrosoftConsoleJsonLayout.cs +++ b/src/NLog.Extensions.Logging/Layouts/MicrosoftConsoleJsonLayout.cs @@ -89,7 +89,7 @@ public string? TimestampFormat { Attributes.RemoveAt(index); } - + if (value != null && !string.IsNullOrEmpty(value)) { var dateLayoutRenderer = _timestampLayout.LayoutRenderers.OfType().First(); diff --git a/src/NLog.Extensions.Logging/Logging/NLogBeginScopeParser.cs b/src/NLog.Extensions.Logging/Logging/NLogBeginScopeParser.cs index 8272c31f..23430828 100644 --- a/src/NLog.Extensions.Logging/Logging/NLogBeginScopeParser.cs +++ b/src/NLog.Extensions.Logging/Logging/NLogBeginScopeParser.cs @@ -268,7 +268,7 @@ private static bool TryLookupExtractor(ExtractorDictionary stateExtracto return keyValueExtractor != null; } - private static bool TryBuildExtractor(Type propertyType, out Func>? keyValueExtractor) + private static bool TryBuildExtractor(Type propertyType, out Func>? keyValueExtractor) { keyValueExtractor = null; diff --git a/src/NLog.Extensions.Logging/Logging/NLogLoggerFactory.cs b/src/NLog.Extensions.Logging/Logging/NLogLoggerFactory.cs index f0f0da8c..43a2b2c3 100644 --- a/src/NLog.Extensions.Logging/Logging/NLogLoggerFactory.cs +++ b/src/NLog.Extensions.Logging/Logging/NLogLoggerFactory.cs @@ -18,7 +18,7 @@ public class NLogLoggerFactory : ILoggerFactory /// New factory with default options /// public NLogLoggerFactory() - :this(NLogProviderOptions.Default) + : this(NLogProviderOptions.Default) { } @@ -27,7 +27,7 @@ public NLogLoggerFactory() /// /// public NLogLoggerFactory(NLogProviderOptions options) - :this(options, LogManager.LogFactory) + : this(options, LogManager.LogFactory) { } diff --git a/src/NLog.Extensions.Logging/NLog.Extensions.Logging.csproj b/src/NLog.Extensions.Logging/NLog.Extensions.Logging.csproj index 4e67aba0..e4a71f3d 100644 --- a/src/NLog.Extensions.Logging/NLog.Extensions.Logging.csproj +++ b/src/NLog.Extensions.Logging/NLog.Extensions.Logging.csproj @@ -18,7 +18,7 @@ For ASP.NET Core, check: https://www.nuget.org/packages/NLog.Web.AspNetCore ChangeLog: -- Updated to NLog v6.0.3 (#806) (@snakefoot) +- Updated to NLog v6.0.4 (#808) (@snakefoot) Full changelog: https://github.com/NLog/NLog.Extensions.Logging/blob/master/CHANGELOG.MD @@ -70,7 +70,7 @@ List of major changes in NLog 6.0: https://nlog-project.org/2025/04/29/nlog-6-0- - + diff --git a/test/NLog.Extensions.Hosting.Tests/ExtensionMethodTests.cs b/test/NLog.Extensions.Hosting.Tests/ExtensionMethodTests.cs index 7677a33f..e6c9757b 100644 --- a/test/NLog.Extensions.Hosting.Tests/ExtensionMethodTests.cs +++ b/test/NLog.Extensions.Hosting.Tests/ExtensionMethodTests.cs @@ -85,7 +85,7 @@ public void AddNLog_withShutdownOnDispose_worksWithNLog() [Fact] public void UseNLog_withAddNLog_worksWithNLog() { - var actual = new HostBuilder().UseNLog().ConfigureServices((h,s) => s.AddLogging(l => l.AddNLog())).Build(); + var actual = new HostBuilder().UseNLog().ConfigureServices((h, s) => s.AddLogging(l => l.AddNLog())).Build(); TestHostingResult(actual, true); } diff --git a/test/NLog.Extensions.Hosting.Tests/Properties/AssemblyInfo.cs b/test/NLog.Extensions.Hosting.Tests/Properties/AssemblyInfo.cs index 4a0154fc..aeab832e 100644 --- a/test/NLog.Extensions.Hosting.Tests/Properties/AssemblyInfo.cs +++ b/test/NLog.Extensions.Hosting.Tests/Properties/AssemblyInfo.cs @@ -1,4 +1,3 @@ -using System.Reflection; using System.Runtime.InteropServices; [assembly: ComVisible(false)] diff --git a/test/NLog.Extensions.Logging.Tests/ApiTests.cs b/test/NLog.Extensions.Logging.Tests/ApiTests.cs index d9ee92e6..abdeb927 100644 --- a/test/NLog.Extensions.Logging.Tests/ApiTests.cs +++ b/test/NLog.Extensions.Logging.Tests/ApiTests.cs @@ -1,10 +1,10 @@ namespace NLog.Extensions.Logging.Tests { using System; - using System.Linq; - using System.Text; using System.Collections.Generic; + using System.Linq; using System.Reflection; + using System.Text; using NLog.Config; using NLog.Extensions.Logging; using NLog.LayoutRenderers; diff --git a/test/NLog.Extensions.Logging.Tests/CustomBeginScopeTest.cs b/test/NLog.Extensions.Logging.Tests/CustomBeginScopeTest.cs index 827b3e00..efdb1724 100644 --- a/test/NLog.Extensions.Logging.Tests/CustomBeginScopeTest.cs +++ b/test/NLog.Extensions.Logging.Tests/CustomBeginScopeTest.cs @@ -68,7 +68,7 @@ public void TestNonSerializableSaySomething() Assert.True(runner.SaySomething().Wait(5000)); Assert.Single(target.Logs); Assert.Equal("SaySomething", target.Logs[0]); - } + } public sealed class CustomBeginScopeTestRunner { @@ -110,7 +110,7 @@ public async Task SayHiToEarth() public async Task SayNothing() { - using (var scopeState = _logger.BeginScope(new Dictionary())) + using (var scopeState = _logger.BeginScope(new Dictionary())) { await Task.Yield(); _logger.LogInformation("Nothing"); diff --git a/test/NLog.Extensions.Logging.Tests/CustomLoggerCallSiteTest.cs b/test/NLog.Extensions.Logging.Tests/CustomLoggerCallSiteTest.cs index 128e16dd..0d551bb3 100644 --- a/test/NLog.Extensions.Logging.Tests/CustomLoggerCallSiteTest.cs +++ b/test/NLog.Extensions.Logging.Tests/CustomLoggerCallSiteTest.cs @@ -15,7 +15,7 @@ public void TestCallSiteSayHello() var runner = GetRunner(target: target); runner.SayHello(); - + Assert.Single(target.Logs); Assert.Contains("SayHello", target.Logs[0]); Assert.Contains("stuff", target.Logs[0]); diff --git a/test/NLog.Extensions.Logging.Tests/Extensions/ConfigureExtensionsTests.cs b/test/NLog.Extensions.Logging.Tests/Extensions/ConfigureExtensionsTests.cs index 49d84790..1860d3cd 100644 --- a/test/NLog.Extensions.Logging.Tests/Extensions/ConfigureExtensionsTests.cs +++ b/test/NLog.Extensions.Logging.Tests/Extensions/ConfigureExtensionsTests.cs @@ -1,13 +1,12 @@ -using Microsoft.Extensions.Logging; -using NLog.Config; -using NLog.Extensions.Logging; using System; +using System.Collections.Generic; using System.Linq; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using NLog.Config; using NLog.Targets; using Xunit; -using Microsoft.Extensions.DependencyInjection; -using System.Collections.Generic; -using Microsoft.Extensions.Configuration; namespace NLog.Extensions.Logging.Tests.Extensions { diff --git a/test/NLog.Extensions.Logging.Tests/Logging/NLogMessageParameterListTests.cs b/test/NLog.Extensions.Logging.Tests/Logging/NLogMessageParameterListTests.cs index d05d6d4a..9894e662 100644 --- a/test/NLog.Extensions.Logging.Tests/Logging/NLogMessageParameterListTests.cs +++ b/test/NLog.Extensions.Logging.Tests/Logging/NLogMessageParameterListTests.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using NLog.MessageTemplates; using Xunit; diff --git a/test/NLog.Extensions.Logging.Tests/MicrosoftConsoleJsonLayoutTests.cs b/test/NLog.Extensions.Logging.Tests/MicrosoftConsoleJsonLayoutTests.cs index c69e6d99..4e2503c2 100644 --- a/test/NLog.Extensions.Logging.Tests/MicrosoftConsoleJsonLayoutTests.cs +++ b/test/NLog.Extensions.Logging.Tests/MicrosoftConsoleJsonLayoutTests.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using Microsoft.Extensions.Logging; using Xunit; namespace NLog.Extensions.Logging.Tests diff --git a/test/NLog.Extensions.Logging.Tests/MicrosoftConsoleLayoutRendererTest.cs b/test/NLog.Extensions.Logging.Tests/MicrosoftConsoleLayoutRendererTest.cs index 338bd27f..0c65dbb3 100644 --- a/test/NLog.Extensions.Logging.Tests/MicrosoftConsoleLayoutRendererTest.cs +++ b/test/NLog.Extensions.Logging.Tests/MicrosoftConsoleLayoutRendererTest.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using Xunit; namespace NLog.Extensions.Logging.Tests diff --git a/test/NLog.Extensions.Logging.Tests/NLogLoggingConfigurationTests.cs b/test/NLog.Extensions.Logging.Tests/NLogLoggingConfigurationTests.cs index 3c651ff4..3b9ce9e7 100644 --- a/test/NLog.Extensions.Logging.Tests/NLogLoggingConfigurationTests.cs +++ b/test/NLog.Extensions.Logging.Tests/NLogLoggingConfigurationTests.cs @@ -7,7 +7,6 @@ using NLog.Targets; using NLog.Targets.Wrappers; using Xunit; -using Xunit.Sdk; namespace NLog.Extensions.Logging.Tests { @@ -27,7 +26,7 @@ public void LoadSimpleConfig() var memoryConfig = CreateMemoryConfigConsoleTargetAndRule(); memoryConfig["NLog:Targets:file:type"] = "File"; memoryConfig["NLog:Targets:file:fileName"] = "hello.txt"; - + var logConfig = CreateNLogLoggingConfigurationWithNLogSection(memoryConfig); Assert.Single(logConfig.LoggingRules); @@ -37,7 +36,7 @@ public void LoadSimpleConfig() Assert.Single(logConfig.AllTargets, (t) => t is ConsoleTarget); Assert.Equal("hello.txt", (logConfig.FindTargetByName("file") as FileTarget)?.FileName.Render(LogEventInfo.CreateNullEvent())); } - + [Fact] public void LoadConfigShouldIgnoreWellKnownEmptySections() { @@ -52,12 +51,12 @@ public void LoadConfigShouldIgnoreWellKnownEmptySections() } }"; var logConfig = CreateNLogLoggingConfigurationWithNLogSection(appSettings); - + Assert.False(logConfig.LoggingRules.Any()); Assert.False(logConfig.AllTargets.Any()); Assert.False(logConfig.Variables.Any()); } - + [Fact] public void LoadConfigShouldThrowForUnrecognisedSections() { @@ -70,9 +69,9 @@ public void LoadConfigShouldThrowForUnrecognisedSections() }"; var ex = Assert.Throws(() => CreateNLogLoggingConfigurationWithNLogSection(appSettings)); - Assert.Equal("Unrecognized value 'someRandomKey'='' for element 'NLog'", ex.Message); + Assert.Equal("Unrecognized value 'someRandomKey'='' for element 'NLog'", ex.Message); } - + [Fact] public void LoadConfigShouldThrowForUnrecognisedComplexSections() { @@ -85,7 +84,7 @@ public void LoadConfigShouldThrowForUnrecognisedComplexSections() }"; var ex = Assert.Throws(() => CreateNLogLoggingConfigurationWithNLogSection(appSettings)); - Assert.Equal("Unrecognized value 'someRandomKey'='' for element 'NLog'", ex.Message); + Assert.Equal("Unrecognized value 'someRandomKey'='' for element 'NLog'", ex.Message); } [Fact] @@ -129,9 +128,9 @@ public void LoadWrapperConfig() memoryConfig["NLog:Targets:file:type"] = "AsyncWrapper"; memoryConfig["NLog:Targets:file:target:wrappedFile:type"] = "File"; memoryConfig["NLog:Targets:file:target:wrappedFile:fileName"] = "hello.txt"; - + var logConfig = CreateNLogLoggingConfigurationWithNLogSection(memoryConfig); - + Assert.Single(logConfig.LoggingRules); Assert.Equal(2, logConfig.LoggingRules[0].Targets.Count); Assert.Equal(3, logConfig.AllTargets.Count); @@ -450,7 +449,7 @@ private static NLogLoggingConfiguration CreateNLogLoggingConfigurationWithNLogSe var logConfig = new NLogLoggingConfiguration(configuration.GetSection(sectionName), logFactory); return logConfig; } - + private static NLogLoggingConfiguration CreateNLogLoggingConfigurationWithNLogSection(string appSettingsContent, string sectionName = DefaultSectionName) { var configuration = new ConfigurationBuilder().AddJsonStream(new MemoryStream(Encoding.UTF8.GetBytes(appSettingsContent))).Build(); diff --git a/test/NLog.Extensions.Logging.Tests/NLogMessageParameterListTests.cs b/test/NLog.Extensions.Logging.Tests/NLogMessageParameterListTests.cs index e47fff6c..3fbdbd10 100644 --- a/test/NLog.Extensions.Logging.Tests/NLogMessageParameterListTests.cs +++ b/test/NLog.Extensions.Logging.Tests/NLogMessageParameterListTests.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using NLog.MessageTemplates; using Xunit; @@ -40,8 +39,8 @@ public void CreateNLogMessageParameterListWithOriginalFormatKey(object originalF Assert.Equal(2, list.Count); Assert.Equal(new MessageTemplateParameter("a", 2, null, CaptureType.Normal), list[0]); Assert.Equal(new MessageTemplateParameter("b", 3, null, CaptureType.Normal), list[1]); - } - + } + [Fact] public void CreateNLogMessageParameterDifferentCaptureTypes() { @@ -96,7 +95,7 @@ public void CreateNLogMessageParameterMixedPositional() [Fact] public void TryParseShouldReturnEmptyListWhenInputIsEmpty() { - var items = new List>{}; + var items = new List> { }; NLogMessageParameterList parsedList = NLogMessageParameterList.TryParse(items); var expectedCount = 0;