Skip to content

Commit

Permalink
Always explicitly reference System.Text.Json dependencies
Browse files Browse the repository at this point in the history
Motivation
----------
The source generated JSON serializer is sometimes incorrectly generated
with the bug dotnet/runtime#96404 still
present. We believe this is because in some environments Yardarm is
still using System.Text.Json 8.0.0 to perform source generation.

Modifications
-------------
Always explicitly reference the latest System.Text.Json version, rather
than only for targets < .NET 8.

Fixes #277
  • Loading branch information
brantburnett committed Dec 13, 2024
1 parent 48fd3de commit ba94a96
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions src/main/Yardarm.SystemTextJson/JsonDependencyGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,27 @@ public class JsonDependencyGenerator : IDependencyGenerator
{
public IEnumerable<LibraryDependency> GetDependencies(NuGetFramework targetFramework)
{
if (targetFramework.Framework != NuGetFrameworkConstants.NetCoreApp || targetFramework.Version < new Version(8, 0))
{
// Only add System.Text.Json if we're not already targeting .NET 8
// Add System.Text.Json even if we're targeting .NET 8 to ensure we get bug fixes, especially for the source generator

yield return new LibraryDependency
yield return new LibraryDependency
{
LibraryRange = new LibraryRange
{
LibraryRange = new LibraryRange
{
Name = "System.Text.Json",
TypeConstraint = LibraryDependencyTarget.Package,
VersionRange = VersionRange.Parse("8.0.5")
}
};
Name = "System.Text.Json",
TypeConstraint = LibraryDependencyTarget.Package,
VersionRange = VersionRange.Parse("8.0.5")
}
};

yield return new LibraryDependency
yield return new LibraryDependency
{
LibraryRange = new LibraryRange
{
LibraryRange = new LibraryRange
{
Name = "System.Net.Http.Json",
TypeConstraint = LibraryDependencyTarget.Package,
VersionRange = VersionRange.Parse("8.0.1")
}
};
}
Name = "System.Net.Http.Json",
TypeConstraint = LibraryDependencyTarget.Package,
VersionRange = VersionRange.Parse("8.0.1")
}
};
}
}
}

0 comments on commit ba94a96

Please sign in to comment.