Skip to content

Commit 86fed8d

Browse files
committed
Merge pull request #1853 from robertlyson/patch-2
Update breaking changes note with info about custom serialization settings.
2 parents 2983367 + cd3d683 commit 86fed8d

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

docs/2.0-breaking-changes/nest-breaking-changes.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,42 @@ public class StringTimeSpanConverter : JsonConverter
205205
}
206206
```
207207

208+
#Serialization settings
209+
210+
Serialization settings are now configurable through `ConnectionSettings` constructor and are stored in one single class.
211+
212+
213+
```c#
214+
var setting = new ConnectionSettings(..);
215+
216+
setting.AddContractJsonConverters(type => new MyPrettyConverter(), type => new SomeOtherConverter());
217+
setting.SetJsonSerializerSettingsModifier(settings => settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore);
218+
```
219+
220+
becomes
221+
222+
```c#
223+
var settings = new ConnectionSettings(connectionPool, connectionSettings => new MyJsonNetSerializer(connectionSettings))
224+
225+
public class MyJsonNetSerializer : JsonNetSerializer
226+
{
227+
public MyJsonNetSerializer(IConnectionSettingsValues settings) : base(settings)
228+
{
229+
}
230+
231+
protected override void ModifyJsonSerializerSettings(JsonSerializerSettings settings)
232+
{
233+
settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
234+
}
235+
236+
protected override IList<Func<Type, JsonConverter>> ContractConverters =>
237+
new List<Func<Type, JsonConverter>>
238+
{
239+
type => new MyPrettyConverter(),
240+
type => new SomeOtherConverter()
241+
};
242+
}
243+
```
208244

209245
#Renamed Types
210246

0 commit comments

Comments
 (0)