doghappy / socket.io-client-csharp

socket.io-client implemention for .NET
MIT License
721 stars 124 forks source link

OptionsProvider does not exists #312

Closed BennoArnautovic closed 1 year ago

BennoArnautovic commented 1 year ago

After updating package to 3.0.8 I am receveing following error:

'NewtonsoftJsonSerializer' does not contain a definition for 'OptionsProvider' and no accessible extension method 'OptionsProvider' accepting a first argument of type 'NewtonsoftJsonSerializer' could be found (are you missing a using directive or an assembly reference?)

I can see that readme still shows following line as usable

var jsonSerializer = new NewtonsoftJsonSerializer();
jsonSerializer.OptionsProvider = () => new JsonSerializerSettings
{
    ContractResolver = new DefaultContractResolver
    {
        NamingStrategy = new CamelCaseNamingStrategy()
    }
};

But I dont think it works anymore, could you please explain on what we need to do in order to use Newtonsoft.Json

Thanks!

doghappy commented 1 year ago

please use following instead:

var io = new SocketIO(...);
io.JsonSerializer = new NewtonsoftJsonSerializer(new JsonSerializerSettings
{
    ContractResolver = new DefaultContractResolver
    {
        NamingStrategy = new CamelCaseNamingStrategy()
    }
});
BennoArnautovic commented 1 year ago

Thank you, that works perfectly.