Skip to content

Commit

Permalink
Upgrade to v2.1.0, .net 8, remove newtonsoft.json
Browse files Browse the repository at this point in the history
  • Loading branch information
zacbre committed Sep 24, 2024
1 parent aca6bf8 commit 852ad1b
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;

namespace CustomEnvironmentConfig.Tests.Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

<OutputType>Library</OutputType>

<LangVersion>8</LangVersion>
<LangVersion>12</LangVersion>

<Nullable>enable</Nullable>

<TargetFramework>net7.0</TargetFramework>
<TargetFrameworks>net7.0;net6.0;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
3 changes: 0 additions & 3 deletions CustomEnvironmentConfig/BuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using CustomEnvironmentConfig.Interfaces;
using CustomEnvironmentConfig.Repositories;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace CustomEnvironmentConfig
Expand Down
4 changes: 2 additions & 2 deletions CustomEnvironmentConfig/ConfigurationParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -204,7 +204,7 @@ private void GetProperties<T>(T instance, Type type, string? prefix, Stack<Type>
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;
}
Expand Down
4 changes: 2 additions & 2 deletions CustomEnvironmentConfig/ConfigurationWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -74,7 +74,7 @@ private void WriteProperties<T>(T instance, Type type, string? prefix, Stack<Typ
{
if (jsonEncode)
{
var serialized = JsonConvert.SerializeObject(value);
var serialized = JsonSerializer.Serialize(value);
fileStream.WriteLine($"{(prefix is {} ? $"{prefix + "_"}{itemName}" : itemName)} = {serialized}");
continue;
}
Expand Down
14 changes: 7 additions & 7 deletions CustomEnvironmentConfig/CustomEnvironmentConfig.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
<PackageProjectUrl>https://github.com/zacbre/CustomEnvironmentConfig/</PackageProjectUrl>
<PackageLicense>https://github.com/zacbre/CustomEnvironmentConfig</PackageLicense>
<RepositoryUrl>https://github.com/zacbre/CustomEnvironmentConfig/</RepositoryUrl>
<PackageVersion>2.0.1</PackageVersion>
<PackageVersion>2.1.0</PackageVersion>
<PackageLicenseUrl>https://github.com/zacbre/CustomEnvironmentConfig/master/LICENSE</PackageLicenseUrl>
<LangVersion>default</LangVersion>
<LangVersion>12</LangVersion>
<Nullable>enable</Nullable>
<PackageTags>environment, configuration</PackageTags>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.Text.Encodings.Web" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.1" />
<PackageReference Include="System.Text.Encodings.Web" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 852ad1b

Please sign in to comment.