Added support for customizing serializer settings
Use 'ICustomSnapshotSerializerSettings' to implement a custom class in order target different serializer settings for Json storage addresses #79
Not sure if using Customizing Func<JsonSerialzerSettings> like https://github.com/tomasbruckner/jest-dotnet#configuring-serialization would be better since the behaviour highly depends on the test runner but would allow multi configuration. @theramis happy to hear your thoughts 😄
Hey @SbiCA,
Thanks for your PR!
Not sure if using Customizing Func<JsonSerialzerSettings> like https://github.com/tomasbruckner/jest-dotnet#configuring-serialization would be better since the behaviour highly depends on the test runner but would allow multi configuration. @theramis happy to hear your thoughts 😄
I think I prefer the way you have done it over having a static SnapshotSettings class. This way it forces the user to think of it like a global setting. With a static class it can be easy to set a value in test A and then test B would also be affected.
There are two things that are on my mind.
- I'm not sure if exposing
Newtonsoft.Jsonis a great idea which makes me reluctant to exposeJsonSerializerSettings(see https://github.com/theramis/Snapper/issues/79) - Might be a good idea to rename
ICustomSnapshotSerializerSettings->ISnapperSettingsso that the user can customise other things like folder name, file extension etc (this might become a fairly big change)
@theramis
- I'm not sure if exposing
Newtonsoft.Jsonis a great idea which makes me reluctant to exposeJsonSerializerSettings(see #79)
I agree on that but on the other hand I'm not sure If the user actually cares that much (at least on my end I use it in test projects and this would only relate to settings not the public API for the assertion), and on the other hand you could also anticipate that change (to System.Text.Json if you wish to change) by only depending on this Settings class in the Json related parts which would contradict your 2nd point. Since you'd not want to tie even closer to Newtonsoft but rather make it a configuration of JObjectHelper or maybe even inline the usage in JsonSnapshotSanitiser, JsonSnapshotStore and in JsonSnapshotComparer. So TLDR not sure what direction you would like to move?
- Might be a good idea to rename
ICustomSnapshotSerializerSettings->ISnapperSettingsso that the user can customise other things like folder name, file extension etc (this might become a fairly big change)
Agreed, but also depends on the outcome of the first point
I've update the design slightly to come up with some middle ground solution 😃