Skip to content

Commit 0f31b2f

Browse files
Removed referencing System.Text.Json when targeting modern .NET (#497)
* Removed referencing System.Text.Json when targeting modern .NET * Bumped version, updated dependencies, added changelog --------- Co-authored-by: Alex Batishchev <[email protected]>
1 parent 5498313 commit 0f31b2f

File tree

15 files changed

+73
-69
lines changed

15 files changed

+73
-69
lines changed

CHANGELOG.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,34 @@
11
# Unreleased
22

3-
# 10.1.1
3+
# JWT 11.0.0-beta1, JWT.Extensions.AspNetCore 11.0.0-beta1, JWT.Extensions.DependencyInjection 3.0.0-beta1
4+
5+
- Remove System.Text.Json when referring .NET 6 and higher as it's provided by the framework
6+
- Updated Newtonsoft.Json to version to 13.0.3
7+
- Updated System.Text.Json to version 6.0.9
8+
9+
# JWT 10.1.1
410

511
- Made ctor of ValidationParameters public, set default values for boolean properties to true
612

7-
# 10.1.0
13+
# JWT 10.1.0
814

915
- Unmarked HMAC SHA based algorithms as insecure and obsolete (was done in 9.0.0-beta4)
1016

11-
# 10.0.3
17+
# JWT 10.0.3
1218

1319
- Added default ctor to JwtHeader and decorated it with `[JsonConstructor]`
1420

15-
# 10.0.2
21+
# JWT 10.0.2
1622

1723
- Disallowed Encode(payload) with AddClaim(s)
1824

19-
# 10.0.1
25+
# JWT 10.0.1
2026

2127
- Fixed deserializing JWT header
2228
- Updated Newtonsoft.Json to version to 13.0.2
2329
- Updated System.Text.Json to version 6.0.7
2430

25-
# 10.0.0
31+
# JWT 10.0.0
2632

2733
- **Breaking:** Made System.Text.Json the default serializer on the platforms where it's available
2834
- **Breaking:** Made verify=true by default in IJwtDecoder methods

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</PropertyGroup>
2828

2929
<ItemGroup>
30-
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.0">
30+
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.4">
3131
<PrivateAssets>all</PrivateAssets>
3232
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
3333
</PackageReference>

JWT.sln

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{44284230
5151
EndProjectSection
5252
EndProject
5353
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{C86A941F-F655-4EF5-A6A1-47BD4A7FC748}"
54-
ProjectSection(SolutionItems) = preProject
55-
src\Directory.Build.targets = src\Directory.Build.targets
56-
EndProjectSection
5754
EndProject
5855
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JWT.Tests.Net70", "tests\JWT.Tests.Net70\JWT.Tests.Net70.csproj", "{D7F24AC9-D178-4BAB-BF93-4BAD8028416D}"
5956
EndProject

src/Directory.Build.targets

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/JWT.Extensions.AspNetCore/JWT.Extensions.AspNetCore.csproj

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
<Authors>Alexander Batishchev</Authors>
1111
<PackageTags>jwt;json;asp.net;asp.net core;.net core;authorization</PackageTags>
1212
<PackageLicenseExpression>MIT</PackageLicenseExpression>
13-
<Version>10.1.1</Version>
14-
<FileVersion>10.0.0.0</FileVersion>
15-
<AssemblyVersion>10.0.0.0</AssemblyVersion>
13+
<Version>11.0.0-beta1</Version>
14+
<FileVersion>11.0.0.0</FileVersion>
15+
<AssemblyVersion>11.0.0.0</AssemblyVersion>
1616
<RootNamespace>JWT.Extensions.AspNetCore</RootNamespace>
1717
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1818
</PropertyGroup>
@@ -28,15 +28,16 @@
2828
</PropertyGroup>
2929

3030
<ItemGroup>
31-
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.13 " Condition="'$(TargetFramework)' == 'net6.0'" />
32-
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.10" Condition="'$(TargetFramework)' == 'netcoreapp3.1'" />
33-
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
34-
<PackageReference Include="System.Text.Json" Version="6.0.7" Condition="$(DefineConstants.Contains(MODERN_DOTNET))" />
31+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
32+
</ItemGroup>
33+
34+
<ItemGroup>
35+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
3536
</ItemGroup>
3637

3738
<ItemGroup>
38-
<ProjectReference Include="..\JWT.Extensions.DependencyInjection\JWT.Extensions.DependencyInjection.csproj" />
3939
<ProjectReference Include="..\JWT\JWT.csproj" />
40+
<ProjectReference Include="..\JWT.Extensions.DependencyInjection\JWT.Extensions.DependencyInjection.csproj" />
4041
</ItemGroup>
4142

42-
</Project>
43+
</Project>

src/JWT.Extensions.DependencyInjection/JWT.Extensions.DependencyInjection.csproj

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
5-
<TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>
4+
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
65
</PropertyGroup>
76

87
<PropertyGroup>
@@ -11,9 +10,9 @@
1110
<Authors>Alexander Batishchev</Authors>
1211
<PackageTags>jwt;json;asp.net;asp.net core;.net core;authorization;dependenсy injection</PackageTags>
1312
<PackageLicenseExpression>MIT</PackageLicenseExpression>
14-
<Version>2.2.3</Version>
15-
<FileVersion>2.0.0.0</FileVersion>
16-
<AssemblyVersion>2.0.0.0</AssemblyVersion>
13+
<Version>3.0.0-beta1</Version>
14+
<FileVersion>3.0.0.0</FileVersion>
15+
<AssemblyVersion>3.0.0.0</AssemblyVersion>
1716
<RootNamespace>JWT</RootNamespace>
1817
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1918
</PropertyGroup>
@@ -30,12 +29,11 @@
3029

3130
<ItemGroup>
3231
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.32" />
33-
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
34-
<PackageReference Include="System.Text.Json" Version="6.0.7" Condition="$(DefineConstants.Contains(MODERN_DOTNET))" />
32+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
3533
</ItemGroup>
3634

3735
<ItemGroup>
3836
<ProjectReference Include="..\JWT\JWT.csproj" />
3937
</ItemGroup>
4038

41-
</Project>
39+
</Project>

src/JWT/Builder/JwtBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using JWT.Serializers;
66
using Newtonsoft.Json;
77

8-
#if MODERN_DOTNET
8+
#if NET462_OR_GREATER || NET6_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER
99
using System.Text.Json.Serialization;
1010
#endif
1111

@@ -489,7 +489,7 @@ private string GetPropName(MemberInfo prop)
489489
}
490490
break;
491491
}
492-
#if MODERN_DOTNET
492+
#if NET462_OR_GREATER || NET6_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER
493493
case SystemTextSerializer:
494494
{
495495
if (attribute is JsonPropertyNameAttribute stjProperty)

src/JWT/Builder/JwtHeader.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if MODERN_DOTNET
1+
#if NET462_OR_GREATER || NET6_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER
22
using System.Text.Json.Serialization;
33
#endif
44

@@ -11,50 +11,50 @@ namespace JWT.Builder
1111
/// </summary>
1212
public class JwtHeader
1313
{
14-
#if MODERN_DOTNET
14+
#if NET462_OR_GREATER || NET6_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER
1515
[System.Text.Json.Serialization.JsonConstructor]
1616
public JwtHeader()
1717
{
1818
}
19-
#endif
19+
#endif
2020
[JsonProperty("typ")]
21-
#if MODERN_DOTNET
21+
#if NET462_OR_GREATER || NET6_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER
2222
[JsonPropertyName("typ")]
2323
#endif
2424
public string Type { get; set; }
2525

2626
[JsonProperty("cty")]
27-
#if MODERN_DOTNET
27+
#if NET462_OR_GREATER || NET6_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER
2828
[JsonPropertyName("cty")]
2929
#endif
3030
public string ContentType { get; set; }
3131

3232
[JsonProperty("alg")]
33-
#if MODERN_DOTNET
33+
#if NET462_OR_GREATER || NET6_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER
3434
[JsonPropertyName("alg")]
3535
#endif
3636
public string Algorithm { get; set; }
3737

3838
[JsonProperty("kid")]
39-
#if MODERN_DOTNET
39+
#if NET462_OR_GREATER || NET6_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER
4040
[JsonPropertyName("kid")]
4141
#endif
4242
public string KeyId { get; set; }
4343

4444
[JsonProperty("x5u")]
45-
#if MODERN_DOTNET
45+
#if NET462_OR_GREATER || NET6_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER
4646
[JsonPropertyName("x5u")]
4747
#endif
4848
public string X5u { get; set; }
4949

5050
[JsonProperty("x5c")]
51-
#if MODERN_DOTNET
51+
#if NET462_OR_GREATER || NET6_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER
5252
[JsonPropertyName("x5c")]
5353
#endif
5454
public string[] X5c { get; set; }
5555

5656
[JsonProperty("x5t")]
57-
#if MODERN_DOTNET
57+
#if NET462_OR_GREATER || NET6_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER
5858
[JsonPropertyName("x5t")]
5959
#endif
6060
public string X5t { get; set; }

src/JWT/JWT.csproj

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFrameworks>netstandard1.3;netstandard2.0;net6.0;net35;net40;net462;</TargetFrameworks>
@@ -25,9 +25,9 @@
2525
</PropertyGroup>
2626

2727
<PropertyGroup>
28-
<Version>10.1.1</Version>
29-
<FileVersion>10.0.0.0</FileVersion>
30-
<AssemblyVersion>10.0.0.0</AssemblyVersion>
28+
<Version>11.0.0-beta1</Version>
29+
<FileVersion>11.0.0.0</FileVersion>
30+
<AssemblyVersion>11.0.0.0</AssemblyVersion>
3131
</PropertyGroup>
3232

3333
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@@ -41,15 +41,19 @@
4141
</PropertyGroup>
4242

4343
<ItemGroup>
44-
<PackageReference Condition="$(DefineConstants.Contains(MODERN_DOTNET))" Include="System.Text.Json" Version="6.0.7" />
45-
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
44+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
45+
</ItemGroup>
46+
47+
<ItemGroup Condition="'$(TargetFramework)' == 'net462' or '$(TargetFramework)' == 'netstandard2.0'">
48+
<PackageReference Include="System.Text.Json" Version="6.0.9" />
4649
</ItemGroup>
4750

4851
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3' OR '$(TargetFramework)' == 'netstandard2.0'">
4952
<PackageReference Include="System.ComponentModel.Primitives" Version="4.3.0" />
5053
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.7.0" />
5154
<PackageReference Include="System.Security.Cryptography.Csp" Version="4.3.0" />
5255
</ItemGroup>
56+
5357
<ItemGroup Condition="'$(TargetFramework)' == 'net35'">
5458
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2">
5559
<PrivateAssets>all</PrivateAssets>
@@ -61,4 +65,4 @@
6165
<None Include="..\..\README.md" Pack="true" PackagePath="\" />
6266
</ItemGroup>
6367

64-
</Project>
68+
</Project>

src/JWT/Serializers/Converters/DictionaryStringObjectJsonConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if MODERN_DOTNET
1+
#if NET462_OR_GREATER || NET6_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER
22
using System;
33
using System.Collections.Generic;
44
using System.Text.Json;

0 commit comments

Comments
 (0)