Add xUnit serializers for our types #833
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
xUnit v3 has introduced a new way to support serialization of objects via an external
IXunitSerializer(instead of implementing an interface on the object itself).See: https://xunit.net/docs/getting-started/v3/custom-serialization
Implementing a serializer means that a type can be used in theory data (I think xUnit v3 is a lot more strict about this, not even showing the individual rows anymore if a type is not serializable).
This PR adds serializers for
Option<T>,Either<L, R>andUnit.There is no serializer for
Result<T>sinceExceptions are not xUnit-serialisable.I also left out
EitherOrBoth<L, R>for now (rarely used).The serializers are discovered via assembly-level attributes implementing
IRegisterXunitSerializerAttribute.Funcky.Xunit.v3.targetsautomatically adds these attributes to projects depending onFuncky.Xunit.v3for a frictionless out-of-the-box experience :)I also had to introduce two marker interfaces:
IOptionandIEitherasIRegisterXunitSerializerAttributedoes not support open generics (e.g.typeof(Option<>)).Open Questions: