NoxiousPluK
NoxiousPluK

Reputation: 33

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?

Upvotes: 3

Views: 2232

Answers (1)

Antoine Aubry
Antoine Aubry

Reputation: 12469

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

Upvotes: 2

Related Questions