Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the DeserializerBuilder?

When trying to use YamlDotNet, I run into this warning:

Deserializer.Deserializer(IObjectFactory, INamingConvention, bool, YamlAttributeOverrides) is obsolete: 'Please use DeserializerBuilder to customize the Deserializer. This constructor will be removed in future releases.'

So I go to the official project homepage:

And click the 'Deserializing an object graph' example, which leads me here: https://dotnetfiddle.net/HD2JXM

And, surprisingly, this too is using the obsolete function.

I fixed it by doing this:

DeserializerBuilder groupIDsDB = new DeserializerBuilder();
groupIDsDB.WithNamingConvention(new CamelCaseNamingConvention());
Deserializer groupIDsDeserializer = groupIDsDB.Build();

Instead of my earlier:

Deserializer groupIDsDeserializer = new Deserializer(namingConvention: new CamelCaseNamingConvention());

Is this correct?

like image 689
NoxiousPluK Avatar asked Feb 13 '26 03:02

NoxiousPluK


1 Answers

That is the correct way of using the DeserializerBuilder. The examples have not all been updated and some still use the old constructor.

like image 135
Antoine Aubry Avatar answered Feb 14 '26 15:02

Antoine Aubry