trmcnvn / DigitalOcean.API

:whale2: .NET implementation of the DigitalOcean API
MIT License
126 stars 49 forks source link

Upgrade RestSharp dependency #137

Open nicholi opened 1 year ago

nicholi commented 1 year ago

RestSharp made quite a few breaking changes to their library (unsure at what version exactly). Running into some dependency problems with other libraries wanting more recent versions of RestSharp. So these are the changes necessary to use most recent releases.

You'll see the majority of changes are simple method/verb types, and parameter type changes.

The real "significant" changes are in Http.Connection and Extensions.RestSharpExtensions, where JSON (de)serialization is occurring. RestSharp was actually using its own hybrid JSON (de)serializer. It was not using Newtonsoft internally (what I originally thought was happening, but unfortunately not). With their updates they abstracted out all serialization completely and deprecated their hybrid serialization in favor of dependencies to handle that. So they have components to choose between using Newtonsoft or System.Text.Json now.

We chose to use Newtonsoft as simplest to make a mostly 1:1 conversion. As Newtonsoft's serializer is quite forgiving, compared to System.Text.Json. Switching to .NET's System.Text.Json would likely be preferable in long run, but would require significantly more testing and checks to assure all is ok. Also this library was already partially using Newtonsoft as well (yet to make the System.Text.Json plunge).

So the major changes controlling (de)serialization were in those classes (Http.Connection and Extensions.RestSharpExtensions). Attempting to keep the current design/flow as much as possible.

We are primarily only using the client for Droplets, so primarily have only tested against those endpoints. Assuming all others should be ok as well. All Unit Tests still pass.

nicholi commented 1 year ago

Have noted some issues with certain calls. CreateTag for example is responding from API with MethodNotAllowed. Which is odd, as its definitely sending as a POST with correct JSON... still looking into this.

nicholi commented 1 year ago

Resolved now.