From 852ad1b849112f584d3b00d93186103f45dd324c Mon Sep 17 00:00:00 2001 From: zacbre Date: Tue, 24 Sep 2024 13:33:39 -0400 Subject: [PATCH] Upgrade to v2.1.0, .net 8, remove newtonsoft.json --- .../Configuration/ConvertibleClass.cs | 1 - .../CustomEnvironmentConfig.Tests.csproj | 12 ++++++------ CustomEnvironmentConfig/BuilderExtensions.cs | 3 --- CustomEnvironmentConfig/ConfigurationParser.cs | 4 ++-- CustomEnvironmentConfig/ConfigurationWriter.cs | 4 ++-- .../CustomEnvironmentConfig.csproj | 14 +++++++------- .../Repositories/EnvironmentVariableRepository.cs | 5 ----- README.md | 3 +++ 8 files changed, 20 insertions(+), 26 deletions(-) diff --git a/CustomEnvironmentConfig.Tests/Configuration/ConvertibleClass.cs b/CustomEnvironmentConfig.Tests/Configuration/ConvertibleClass.cs index 409ecb5..73dbe77 100644 --- a/CustomEnvironmentConfig.Tests/Configuration/ConvertibleClass.cs +++ b/CustomEnvironmentConfig.Tests/Configuration/ConvertibleClass.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; namespace CustomEnvironmentConfig.Tests.Configuration diff --git a/CustomEnvironmentConfig.Tests/CustomEnvironmentConfig.Tests.csproj b/CustomEnvironmentConfig.Tests/CustomEnvironmentConfig.Tests.csproj index 7cf44b0..52ab140 100644 --- a/CustomEnvironmentConfig.Tests/CustomEnvironmentConfig.Tests.csproj +++ b/CustomEnvironmentConfig.Tests/CustomEnvironmentConfig.Tests.csproj @@ -6,18 +6,18 @@ Library - 8 + 12 enable - net7.0 + net7.0;net6.0;net8.0 - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CustomEnvironmentConfig/BuilderExtensions.cs b/CustomEnvironmentConfig/BuilderExtensions.cs index 76974a2..8d09e46 100644 --- a/CustomEnvironmentConfig/BuilderExtensions.cs +++ b/CustomEnvironmentConfig/BuilderExtensions.cs @@ -1,7 +1,4 @@ -using CustomEnvironmentConfig.Interfaces; -using CustomEnvironmentConfig.Repositories; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace CustomEnvironmentConfig diff --git a/CustomEnvironmentConfig/ConfigurationParser.cs b/CustomEnvironmentConfig/ConfigurationParser.cs index b72c53d..e870bd3 100644 --- a/CustomEnvironmentConfig/ConfigurationParser.cs +++ b/CustomEnvironmentConfig/ConfigurationParser.cs @@ -3,10 +3,10 @@ using System.Linq; using System.Reflection; using System.Runtime.Serialization; +using System.Text.Json; using CustomEnvironmentConfig.Exceptions; using CustomEnvironmentConfig.Interfaces; using CustomEnvironmentConfig.Repositories; -using Newtonsoft.Json; namespace CustomEnvironmentConfig { @@ -204,7 +204,7 @@ private void GetProperties(T instance, Type type, string? prefix, Stack if (jsonDecode && val is {}) { var escaped = val.Replace("\\\"", "\""); - var deserialized = JsonConvert.DeserializeObject(escaped, isNullable ?? prop.PropertyType); + var deserialized = JsonSerializer.Deserialize(escaped, isNullable ?? prop.PropertyType); prop.SetValue(instance, deserialized); continue; } diff --git a/CustomEnvironmentConfig/ConfigurationWriter.cs b/CustomEnvironmentConfig/ConfigurationWriter.cs index 5e8abf5..c772b06 100644 --- a/CustomEnvironmentConfig/ConfigurationWriter.cs +++ b/CustomEnvironmentConfig/ConfigurationWriter.cs @@ -3,8 +3,8 @@ using System.IO; using System.Linq; using System.Reflection; +using System.Text.Json; using CustomEnvironmentConfig.Exceptions; -using Newtonsoft.Json; namespace CustomEnvironmentConfig { @@ -74,7 +74,7 @@ private void WriteProperties(T instance, Type type, string? prefix, Stackhttps://github.com/zacbre/CustomEnvironmentConfig/ https://github.com/zacbre/CustomEnvironmentConfig https://github.com/zacbre/CustomEnvironmentConfig/ - 2.0.1 + 2.1.0 https://github.com/zacbre/CustomEnvironmentConfig/master/LICENSE - default + 12 enable environment, configuration - net6.0;net7.0 + net6.0;net7.0;net8.0 README.md - - - - + + + + diff --git a/CustomEnvironmentConfig/Repositories/EnvironmentVariableRepository.cs b/CustomEnvironmentConfig/Repositories/EnvironmentVariableRepository.cs index 7fc1273..8145732 100644 --- a/CustomEnvironmentConfig/Repositories/EnvironmentVariableRepository.cs +++ b/CustomEnvironmentConfig/Repositories/EnvironmentVariableRepository.cs @@ -1,8 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.IO; -using System.Runtime.InteropServices; using CustomEnvironmentConfig.Interfaces; namespace CustomEnvironmentConfig.Repositories diff --git a/README.md b/README.md index 01be665..2225a4c 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,9 @@ Enables binding environment variables and/or environment files to classes. ## Changelog ``` +08/24/2024 [v2.1.0] +- Remove Newtonsoft.Json dependency. +- Add .net 8 support. 07/24/2023 [v2.0.1] - Update System.Text.Json to patch vulnerability. - Add .net 7 support.