GitHub
05/05/2023, 1:28 PMJsonSerializerSettings
to System.Text.Json.JsonSerializerOptions
.
This will create a minimal impact during migration whilst still allowing us to change serialiser.
Internally, PactNet will use System.Text.Json
to serialise matchers and dynamic request/response bodies supply by users,
and to deserialise message interaction requests from the FFI during message interaction verification. To the user these
are entirely transparent changes.
The library will continue to ship as netstandard2.0
instead of changing to a direct .Net version so that existing compatibility
is maintained. System.Text.Json
supports netstandard2.0
explicitly.
Caveats/Drawbacks
Version
There is an open question on exactly which version of STJ to reference. If we pick the current version then we may prevent people from upgrading if they're on older version. If we pick an older version then which one?
Breaking Serialisation Changes
Any custom serialisation options applied to objects previously which were not being used may now start to be used, and so
potential behavioural differences might happen post-upgrade. For example, given the class:
public class MyDto
{
public int Foo { get; init; }
[System.Text.Json.Serialization.JsonIgnore]
public string Bar { get; init; }
}
In PactNet 4.x the Bar
property would still be serialised, whereas following this change it would no longer be serialised.
This behaviour seems advantageous rather than problematic, as it also wouldn't be serialised by the real API under real usage
and thus the pacts were technically using the wrong format.
However, there are situations where the behaviour of serialisation itself may have been altered which could potentially cause
behavioural changes. It's not felt the risk is high or that the consequence is severe in these situations though. The correct
action to perform in that case would ensure that the pacts and API are as close as possible anyway.
pact-foundation/pact-net