Skip to content

Commit 7573efb

Browse files
Update System.Text.Json and enable transitive pinning (microsoft#938)
This commit updates the System.Text.Json package version to 7.0.0 and enables the CentralPackageTransitivePinningEnabled property in the Directory.Packages.props file. This property allows the central package management feature to pin the versions of transitive dependencies to the ones specified in the props file, avoiding potential conflicts or inconsistencies. This change improves the reliability and maintainability of the dotnet projects that use the Directory.Packages.props file. The test ReadFromJsonThrowsWithInvalidJson was passing an invalid JSON string to the JsonSerializer.Deserialize method, which was expected to throw a JsonException. However, the method actually throws an ArgumentNullException in System.Text.Json 7.0.0 when the named property is missing. This commit fixes the test by updating the expected exception type. It also adds a pragma directive to suppress the JSON001 warning for the invalid JSON string. [Central Package Management | Microsoft Learn](https://learn.microsoft.com/en-us/nuget/consume-packages/Central-Package-Management) [Update dependencies | Docs - Microsoft Open Source](https://docs.opensource.microsoft.com/tools/cg/how-to/updating-dependencies/#nuget)
1 parent 7cd0fea commit 7573efb

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎dotnet/Directory.Packages.props‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
<!-- Enable central package management -->
44
<!-- https://learn.microsoft.com/en-us/nuget/consume-packages/Central-Package-Management -->
55
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
6+
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
67
</PropertyGroup>
78
<ItemGroup>
89
<PackageVersion Include="Azure.Search.Documents" Version="11.5.0-beta.2" />
910
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="[1.1.0, )" />
1011
<PackageVersion Include="System.Linq.Async" Version="[6.0.1, )" />
11-
<PackageVersion Include="System.Text.Json" Version="[6.0.0, )" />
12+
<PackageVersion Include="System.Text.Json" Version="[7.0.0, )" />
1213
<PackageVersion Include="Azure.AI.OpenAI" Version="[1.0.0-beta.5, )" />
1314
<!-- Microsoft.Extensions.Logging -->
1415
<PackageVersion Include="Microsoft.Extensions.Logging" Version="[6.0.0, )" />

‎dotnet/src/SemanticKernel.UnitTests/Orchestration/ContextVariablesConverterTests.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ public void ReadFromJsonReturnsDefaultWithEmpty()
164164
public void ReadFromJsonThrowsWithInvalidJson()
165165
{
166166
// Arrange
167+
#pragma warning disable JSON001
167168
string json = /*lang=json,strict*/ @"[{""Key"":""a"", ""Value"":""b""";
169+
#pragma warning restore JSON001
168170
var options = new JsonSerializerOptions();
169171
options.Converters.Add(new ContextVariablesConverter());
170172

@@ -181,6 +183,6 @@ public void ReadFromJsonThrowsWithInvalidJson2()
181183
options.Converters.Add(new ContextVariablesConverter());
182184

183185
// Act & Assert
184-
Assert.Throws<JsonException>(() => JsonSerializer.Deserialize<ContextVariables>(json, options));
186+
Assert.Throws<ArgumentNullException>(() => JsonSerializer.Deserialize<ContextVariables>(json, options));
185187
}
186188
}

0 commit comments

Comments
 (0)