From 430c82894eac68f83c900323685c1e5d80b8f2f8 Mon Sep 17 00:00:00 2001 From: Vladimir Pecanac Date: Sun, 23 Aug 2026 23:39:27 +0200 Subject: [PATCH] AutomapperIgnoreNullValues: retarget net10.0, bump AutoMapper 16.2.0, fix MapperConfiguration ctor, swap to System.Text.Json - Both projects retargeted from net7.0 to net10.0. - AutoMapper 12.0.1 -> 16.2.0. The current package declares no MapperConfiguration overload without an ILoggerFactory, so the existing one-argument call in Console/AutoMapperManager.cs failed with CS1729. It now passes NullLoggerFactory.Instance, via a Microsoft.Extensions.Logging.Abstractions reference. - Console output serialization moved from Newtonsoft.Json to System.Text.Json, removing the Newtonsoft.Json 10.0.3 package reference; output is unchanged. Build clean and 8/8 tests pass on .NET 10.0.10. --- .../Console/AutoMapperIgnoreNullValues.csproj | 6 +++--- .../Console/AutoMapperManager.cs | 7 ++++--- .../AutomapperIgnoreNullValues/Console/Program.cs | 4 ++-- .../Tests/AutoMapperIgnoreNullValuesTests.csproj | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/dotnet-client-libraries/AutomapperIgnoreNullValues/Console/AutoMapperIgnoreNullValues.csproj b/dotnet-client-libraries/AutomapperIgnoreNullValues/Console/AutoMapperIgnoreNullValues.csproj index 6ad9bfbf63..b0288ef8b2 100644 --- a/dotnet-client-libraries/AutomapperIgnoreNullValues/Console/AutoMapperIgnoreNullValues.csproj +++ b/dotnet-client-libraries/AutomapperIgnoreNullValues/Console/AutoMapperIgnoreNullValues.csproj @@ -2,12 +2,12 @@ Exe - net7.0 + net10.0 enable - - + + \ No newline at end of file diff --git a/dotnet-client-libraries/AutomapperIgnoreNullValues/Console/AutoMapperManager.cs b/dotnet-client-libraries/AutomapperIgnoreNullValues/Console/AutoMapperManager.cs index 167b01e36d..ff0b385204 100644 --- a/dotnet-client-libraries/AutomapperIgnoreNullValues/Console/AutoMapperManager.cs +++ b/dotnet-client-libraries/AutomapperIgnoreNullValues/Console/AutoMapperManager.cs @@ -1,5 +1,6 @@ using AutoMapper; -using Newtonsoft.Json; +using Microsoft.Extensions.Logging.Abstractions; +using System.Text.Json; namespace AutoMapperIgnoreNullValues; @@ -21,14 +22,14 @@ private static StudentEntity MapToStudentEntity(StudentItemDto source) var config = new MapperConfiguration(cfg => { cfg.AddProfile(); - }); + }, NullLoggerFactory.Instance); IMapper mapper = config.CreateMapper(); var destination = GetSampleEntity(); destination = mapper.Map(source, destination); Console.WriteLine("Destination : {0}", - JsonConvert.SerializeObject(destination, Formatting.Indented)); + JsonSerializer.Serialize(destination, new JsonSerializerOptions { WriteIndented = true })); if (destination.Department == null) throw new ArgumentNullException("Department", "Department is null"); diff --git a/dotnet-client-libraries/AutomapperIgnoreNullValues/Console/Program.cs b/dotnet-client-libraries/AutomapperIgnoreNullValues/Console/Program.cs index 4a096c8960..fcf6068d29 100644 --- a/dotnet-client-libraries/AutomapperIgnoreNullValues/Console/Program.cs +++ b/dotnet-client-libraries/AutomapperIgnoreNullValues/Console/Program.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using System.Text.Json; namespace AutoMapperIgnoreNullValues; internal class Program @@ -13,7 +13,7 @@ static void Main(string[] args) Grades = null }; - Console.WriteLine("\nSource : {0}", JsonConvert.SerializeObject(source, Formatting.Indented)); + Console.WriteLine("\nSource : {0}", JsonSerializer.Serialize(source, new JsonSerializerOptions { WriteIndented = true })); try { diff --git a/dotnet-client-libraries/AutomapperIgnoreNullValues/Tests/AutoMapperIgnoreNullValuesTests.csproj b/dotnet-client-libraries/AutomapperIgnoreNullValues/Tests/AutoMapperIgnoreNullValuesTests.csproj index 6bd7b8ebf2..ba5a71bba4 100644 --- a/dotnet-client-libraries/AutomapperIgnoreNullValues/Tests/AutoMapperIgnoreNullValuesTests.csproj +++ b/dotnet-client-libraries/AutomapperIgnoreNullValues/Tests/AutoMapperIgnoreNullValuesTests.csproj @@ -1,7 +1,7 @@ - net7.0 + net10.0 enable false