Skip to content

Commit 5903519

Browse files
authored
System.Text.Json for .NET Standard 2.0 (#52)
1 parent 7320758 commit 5903519

6 files changed

Lines changed: 13 additions & 18 deletions

File tree

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ FluentHttpClient is optimized for .NET 10 and the newest .NET releases, while al
2828

2929
Projects targeting **.NETStandard 2.0** or **.NETStandard 2.1** do not include `System.Text.Json` in the framework. FluentHttpClient uses `System.Text.Json` internally for its JSON extensions, but the package is not referenced transitively.
3030

31-
If you are building against **netstandard2.0** or **netstandard2.1**, or any TFM that does **not** ship `System.Text.Json`, you will need to add an explicit package reference with a minimum version of 6.0.10 (a higher version is always recommended):
32-
33-
```xml
34-
<PackageReference Include="System.Text.Json" Version="6.0.10" />
35-
```
31+
If you are building against **netstandard2.0** or **netstandard2.1**, or any TFM that does **not** ship `System.Text.Json`, you will need to add an explicit package reference, with a minimum version of 4.6.0 or 6.0.10, respectively. A higher version is always recommended.
3632

3733
Apps targeting modern TFMs (such as .NET 5 and later) already include `System.Text.Json` and do not require this step.
3834

docs/docs/index.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ FluentHttpClient is optimized for .NET 10 and the newest .NET releases, while al
2626

2727
Projects targeting **.NETStandard 2.0** or **.NETStandard 2.1** do not include `System.Text.Json` in the framework. FluentHttpClient uses `System.Text.Json` internally for its JSON extensions, but the package is not referenced transitively.
2828

29-
If you are building against **netstandard2.0** or **netstandard2.1**, or any TFM that does **not** ship `System.Text.Json`, you will need to add an explicit package reference with a minimum version of 6.0.10 (a higher version is always recommended):
30-
31-
```xml
32-
<PackageReference Include="System.Text.Json" Version="6.0.10" />
33-
```
29+
If you are building against **netstandard2.0** or **netstandard2.1**, or any TFM that does **not** ship `System.Text.Json`, you will need to add an explicit package reference, with a minimum version of 4.6.0 or 6.0.10, respectively. A higher version is always recommended.
3430

3531
Apps targeting modern TFMs (such as .NET 5 and later) already include `System.Text.Json` and do not require this step.
3632

src/FluentHttpClient/FluentHttpClient.csproj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@
3535
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
3636
</PropertyGroup>
3737

38-
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' Or '$(TargetFramework)' == 'netstandard2.1'">
39-
<PackageReference Include="System.Text.Json" Version="6.0.10" PrivateAssets="All" />
38+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
39+
<PackageReference Include="System.Text.Json" Version="[4.6.0,)" PrivateAssets="All" />
40+
<PackageReference Include="System.Text.Encodings.Web" Version="[4.7.2,)" PrivateAssets="All" />
41+
</ItemGroup>
42+
43+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
44+
<PackageReference Include="System.Text.Json" Version="[6.0.10,)" PrivateAssets="All" />
4045
</ItemGroup>
4146

4247
<ItemGroup>

src/FluentHttpClient/FluentJsonSerializer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ internal static class FluentJsonSerializer
1515
public static readonly JsonSerializerOptions DefaultJsonSerializerOptions = new JsonSerializerOptions
1616
{
1717
PropertyNameCaseInsensitive = true,
18+
#if NETSTANDARD2_1_OR_GREATER
1819
NumberHandling = JsonNumberHandling.AllowReadingFromString,
1920
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
21+
#endif
2022
};
2123
}

src/FluentHttpClient/README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ FluentHttpClient is optimized for .NET 10 and the newest .NET releases, while al
2121

2222
Projects targeting **.NETStandard 2.0** or **.NETStandard 2.1** do not include `System.Text.Json` in the framework. FluentHttpClient uses `System.Text.Json` internally for its JSON extensions, but the package is not referenced transitively.
2323

24-
If you are building against **netstandard2.0** or **netstandard2.1**, or any TFM that does **not** ship `System.Text.Json`, you will need to add an explicit package reference with a minimum version of 6.0.10 (a higher version is always recommended):
25-
26-
```xml
27-
<PackageReference Include="System.Text.Json" Version="6.0.10" />
28-
```
24+
If you are building against **netstandard2.0** or **netstandard2.1**, or any TFM that does **not** ship `System.Text.Json`, you will need to add an explicit package reference, with a minimum version of 4.6.0 or 6.0.10, respectively. A higher version is always recommended.
2925

3026
Apps targeting modern TFMs (such as .NET 5 and later) already include `System.Text.Json` and do not require this step.
3127

src/version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
3-
"version": "5.0.0",
3+
"version": "5.0.1",
44
"publicReleaseRefSpec": [
55
"^refs/heads/main$",
66
"^refs/heads/v\\d+(?:\\.\\d+)?$"

0 commit comments

Comments
 (0)