Skip to content

Commit 7db15ca

Browse files
committed
Replace newtonsoft with system.text.json on all product code
1 parent 63bf21f commit 7db15ca

File tree

289 files changed

+268
-68079
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

289 files changed

+268
-68079
lines changed

Directory.Packages.props

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@
3030
<PackageVersion Include="System.Xml.XDocument" Version="4.3.0" />
3131
<PackageVersion Include="System.Xml.XmlDocument" Version="4.3.0" />
3232
<PackageVersion Include="Xamarin.AndroidX.Browser" Version="1.4.0" PrivateAssets="All" />
33+
<PackageVersion Include="System.Formats.Asn1" Version="9.0.0"/>
34+
<PackageVersion Include="System.CodeDom" Version="6.0.0" />
35+
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="6.35.0" />
36+
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
37+
<PackageVersion Include="System.Reflection.TypeExtensions" Version="4.7.0" />
38+
<PackageVersion Include="System.Security.Cryptography.Cng" Version="5.0.0" />
39+
<PackageVersion Include="System.Text.Json" Version="6.0.11" />
40+
<PackageVersion Include="System.Threading" Version="4.3.0" />
41+
<PackageVersion Include="System.Threading.Tasks" Version="4.3.0" />
42+
<PackageVersion Include="System.Threading.Tasks.Parallel" Version="4.3.0" />
43+
<PackageVersion Include="System.Threading.Thread" Version="4.3.0" />
44+
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
45+
<PackageVersion Include="System.Windows.Forms" Version="4.0.0" />
3346
</ItemGroup>
3447
<ItemGroup>
3548
<!-- Analyzers and dev packages -->
@@ -55,6 +68,10 @@
5568
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
5669
<PackageVersion Include="MSTest.TestAdapter" Version="3.1.1" />
5770
<PackageVersion Include="MSTest.TestFramework" Version="3.1.1" />
71+
<!-- Since MSAL uses the minimum possible System.Text.Json version,
72+
tests are unable to move away from Newtonsoft. For example DeepEquals method is only available in System.Text.Json 9
73+
Newtonsoft reference is preferable to bumping the version System.Text.Json in tests,
74+
to avoid changing the product behavior. -->
5875
<PackageVersion Include="Newtonsoft.Json" Version="13.0.1" />
5976
<PackageVersion Include="NSubstitute" Version="5.3.0" />
6077
<PackageVersion Include="NSubstitute.Analyzers.CSharp" Version="1.0.17" />
@@ -67,20 +84,6 @@
6784
<PackageVersion Include="Selenium.Support" Version="4.19.0" />
6885
<PackageVersion Include="Selenium.WebDriver" Version="4.19.0" />
6986
<PackageVersion Include="StrongNamer" Version="0.2.5" />
70-
<PackageVersion Include="System.CodeDom" Version="6.0.0" />
71-
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="6.35.0" />
72-
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
73-
<PackageVersion Include="System.Reflection.TypeExtensions" Version="4.7.0" />
74-
<PackageVersion Include="System.Security.Cryptography.Cng" Version="5.0.0" />
75-
<PackageVersion Include="System.Text.Json" Version="6.0.10" />
76-
<PackageVersion Include="System.Threading" Version="4.3.0" />
77-
<PackageVersion Include="System.Threading.Tasks" Version="4.3.0" />
78-
<PackageVersion Include="System.Threading.Tasks.Parallel" Version="4.3.0" />
79-
<PackageVersion Include="System.Threading.Thread" Version="4.3.0" />
80-
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
81-
<PackageVersion Include="System.Windows.Forms" Version="4.0.0" />
8287
<PackageVersion Include="CommandLineParser" Version="2.8.0" />
83-
<PackageVersion Include="System.Formats.Asn1" Version="9.0.0"/>
84-
8588
</ItemGroup>
8689
</Project>

build/platform_and_feature_flags.props

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<Project>
2-
<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNetCore)' or '$(TargetFramework)' == '$(TargetFrameworkNet)'">
3-
<DefineConstants>$(DefineConstants);SUPPORTS_SYSTEM_TEXT_JSON;NET_CORE;SUPPORTS_CONFIDENTIAL_CLIENT;SUPPORTS_CUSTOM_CACHE;SUPPORTS_BROKER;SUPPORTS_WIN32;</DefineConstants>
2+
<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNet)'">
3+
<DefineConstants>$(DefineConstants)SUPPORTS_MTLS;NET_CORE;SUPPORTS_CONFIDENTIAL_CLIENT;SUPPORTS_CUSTOM_CACHE;SUPPORTS_BROKER;SUPPORTS_WIN32;</DefineConstants>
44
</PropertyGroup>
55
<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNet)' or '$(TargetFramework)' == '$(TargetFrameworkNetDesktop462)' or '$(TargetFramework)' == '$(TargetFrameworkNetDesktop472)' or '$(TargetFramework)' == '$(TargetFrameworkNetStandard)'">
66
<DefineConstants>$(DefineConstants);SUPPORTS_OTEL;</DefineConstants>
77
</PropertyGroup>
8-
<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNet)' or '$(TargetFramework)' == '$(TargetFrameworkNetDesktop472)'">
8+
<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNetDesktop472)'">
99
<DefineConstants>$(DefineConstants);SUPPORTS_MTLS;</DefineConstants>
1010
</PropertyGroup>
1111
<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNetAndroid)'">
@@ -15,10 +15,10 @@
1515
<DefineConstants>$(DefineConstants);SUPPORTS_BROKER;SUPPORTS_CONFIDENTIAL_CLIENT;SUPPORTS_CUSTOM_CACHE;SUPPORTS_WIN32</DefineConstants>
1616
</PropertyGroup>
1717
<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNetIos)'">
18-
<DefineConstants>$(DefineConstants);iOS;SUPPORTS_BROKER</DefineConstants>
18+
<DefineConstants>$(DefineConstants);iOS;SUPPORTS_BROKER</DefineConstants>
1919
</PropertyGroup>
2020
<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNetStandard)'">
21-
<DefineConstants>$(DefineConstants);NETSTANDARD;SUPPORTS_CONFIDENTIAL_CLIENT;SUPPORTS_BROKER;SUPPORTS_CUSTOM_CACHE;SUPPORTS_WIN32;</DefineConstants>
21+
<DefineConstants>$(DefineConstants);NETSTANDARD;SUPPORTS_CONFIDENTIAL_CLIENT;SUPPORTS_BROKER;SUPPORTS_CUSTOM_CACHE;SUPPORTS_WIN32;IS_TRIMMABLE</DefineConstants>
2222
</PropertyGroup>
2323
<PropertyGroup Condition="'$(TargetFramework)' == '$(TargetFrameworkNetAndroid)' or '$(TargetFramework)' == '$(TargetFrameworkNetIos)'">
2424
<DefineConstants>$(DefineConstants);MOBILE</DefineConstants>

src/client/Microsoft.Identity.Client/AppConfig/AbstractApplicationBuilder.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@
1313
using Microsoft.Identity.Client.PlatformsCommon.Interfaces;
1414
using Microsoft.Identity.Client.Utils;
1515
using Microsoft.IdentityModel.Abstractions;
16-
#if SUPPORTS_SYSTEM_TEXT_JSON
1716
using System.Text.Json;
18-
#else
19-
using Microsoft.Identity.Json;
20-
#endif
2117

2218
namespace Microsoft.Identity.Client
2319
{

src/client/Microsoft.Identity.Client/AppConfig/BaseAbstractApplicationBuilder.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414
using Microsoft.Identity.Client.Utils;
1515
using Microsoft.IdentityModel.Abstractions;
1616
using Microsoft.Identity.Client.Internal;
17-
#if SUPPORTS_SYSTEM_TEXT_JSON
1817
using System.Text.Json;
19-
#else
20-
using Microsoft.Identity.Json;
21-
#endif
2218

2319
namespace Microsoft.Identity.Client
2420
{

src/client/Microsoft.Identity.Client/AppConfig/TraceTelemetryConfig.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
using System.ComponentModel;
77
using System.Diagnostics;
88
using Microsoft.Identity.Client.Utils;
9-
#if SUPPORTS_SYSTEM_TEXT_JSON
109
using JObject = System.Text.Json.Nodes.JsonObject;
11-
#else
12-
using Microsoft.Identity.Json.Linq;
13-
#endif
1410

1511
namespace Microsoft.Identity.Client
1612
{

src/client/Microsoft.Identity.Client/AuthScheme/PoP/PopAuthenticationOperation.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,8 @@
1111
using Microsoft.Identity.Client.Internal;
1212
using Microsoft.Identity.Client.OAuth2;
1313
using Microsoft.Identity.Client.Utils;
14-
#if SUPPORTS_SYSTEM_TEXT_JSON
1514
using JObject = System.Text.Json.Nodes.JsonObject;
1615
using JToken = System.Text.Json.Nodes.JsonNode;
17-
#else
18-
using Microsoft.Identity.Json;
19-
using Microsoft.Identity.Json.Linq;
20-
#endif
2116

2217
namespace Microsoft.Identity.Client.AuthScheme.PoP
2318
{

src/client/Microsoft.Identity.Client/Cache/Adal/AdalResult.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
#if SUPPORTS_SYSTEM_TEXT_JSON
54
using Microsoft.Identity.Client.Platforms.net;
65
using JsonProperty = System.Text.Json.Serialization.JsonIncludeAttribute;
7-
#else
8-
using Microsoft.Identity.Json;
9-
#endif
106

117
namespace Microsoft.Identity.Client.Cache
128
{

src/client/Microsoft.Identity.Client/Cache/Adal/AdalResultWrapper.cs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,21 @@
22
// Licensed under the MIT License.
33

44
using Microsoft.Identity.Client.Utils;
5-
#if SUPPORTS_SYSTEM_TEXT_JSON
65
using Microsoft.Identity.Client.Platforms.net;
7-
#else
8-
using Microsoft.Identity.Json;
9-
#endif
106

117
namespace Microsoft.Identity.Client.Cache
128
{
139
[JsonObject]
1410
[Preserve(AllMembers = true)]
1511
internal class AdalResultWrapper
1612
{
17-
18-
#if !SUPPORTS_SYSTEM_TEXT_JSON
19-
[JsonProperty]
20-
#endif
2113
public AdalResult Result { get; set; }
2214

23-
#if !SUPPORTS_SYSTEM_TEXT_JSON
24-
[JsonProperty]
25-
#endif
2615
public string RawClientInfo { get; set; }
2716

2817
/// <summary>
2918
/// Gets the Refresh Token associated with the requested Access Token. Note: not all operations will return a Refresh Token.
3019
/// </summary>
31-
#if !SUPPORTS_SYSTEM_TEXT_JSON
32-
[JsonProperty]
33-
#endif
3420
public string RefreshToken { get; set; }
3521

3622
/// <summary>
@@ -40,9 +26,6 @@ internal class AdalResultWrapper
4026

4127
// This is only needed for AcquireTokenByAuthorizationCode in which parameter resource is optional and we need
4228
// to get it from the STS response.
43-
#if !SUPPORTS_SYSTEM_TEXT_JSON
44-
[JsonProperty]
45-
#endif
4629
internal string ResourceInResponse { get; set; }
4730

4831
/// <summary>
@@ -63,9 +46,6 @@ public string Serialize()
6346
return JsonHelper.SerializeToJson(this);
6447
}
6548

66-
#if !SUPPORTS_SYSTEM_TEXT_JSON
67-
[JsonProperty]
68-
#endif
6949
public string UserAssertionHash { get; set; }
7050

7151
internal AdalResultWrapper Clone()

src/client/Microsoft.Identity.Client/Cache/Adal/AdalUserInfo.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
// Licensed under the MIT License.
33

44
using System;
5-
#if SUPPORTS_SYSTEM_TEXT_JSON
65
using Microsoft.Identity.Client.Platforms.net;
76
using JsonProperty = System.Text.Json.Serialization.JsonIncludeAttribute;
8-
#else
9-
using Microsoft.Identity.Json;
10-
#endif
117

128
namespace Microsoft.Identity.Client.Cache
139
{

src/client/Microsoft.Identity.Client/Cache/ITokenCacheSerializable.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
// Licensed under the MIT License.
33

44
using System.Collections.Generic;
5-
#if SUPPORTS_SYSTEM_TEXT_JSON
65
using JToken = System.Text.Json.Nodes.JsonNode;
7-
#else
8-
using Microsoft.Identity.Json.Linq;
9-
#endif
106

117
namespace Microsoft.Identity.Client.Cache
128
{

0 commit comments

Comments
 (0)