Open thomaslevesque opened 4 years ago
Hello a version 2.0 will support Async Formatter ! And support .netstandard2.1. :)
After a small discussion we choose to change IFormatter like below
public interface IFormatter
{
string DefaultMediaType { get; }
bool IsMediaTypeSupported (string mediaType);
Task SerializeAsync<T>(T data, Stream stream, Encoding encoding);
Task<T> DeserializeAsync<T>(Stream stream, Encoding encoding);
}
hello, do you intend to delete the reference to newtonsoft in your next version? this could be compatible with netstandard 2.0 so that it is also compatible with Xamarin
And maybe be inspired by the instantiation of Restclient.net https://github.com/MelbourneDeveloper/RestClient.Net
var client = new Client(new ProtobufSerializationAdapter(), new Uri("http://localhost:42908/person"));
var client = new Client(new NewtonsoftSerializationAdapter(), new Uri("https://jsonplaceholder.typicode.com"));
// for System.Text.Json
var client = new Client(new Uri("https://jsonplaceholder.typicode.com"));
In any case I find TinyRest the best library for webrequest, simple to use and read, great work.
Hello, @auriou Yes, the next major version of TinyRestClient will remove the need of newtonsoft. :) The main idea is to be dependency less!
I am working on it!
For the instanciation in the 2.0 version it will be also more configurable.
being able to change serializer would be great. also be able to use protobuf since the GRPC Protocol is increasingly used
being able to change serializer would be great
It's already possible today, by providing your own implementation of IFormatter. Anyway, maybe Newtonsoft.Json support could be provided as a separate package.
also be able to use protobuf since the GRPC Protocol is increasingly used
Yes, but GRPC is not ReST...
yes it's true, then just the possibility of using a protobuf serializer for a private API.
Hello guys,
I have a PR ready which remove NewtownSoft.Json and make library compatible with System.Text.Json.
I will release this week the version 2.0 of the library
I am also writing benchmarks to try to remove unecessary allocations.
The built-in JSON serializer uses Newtonsoft.Json. But in ASP.NET Core 3.0, the default serializer is System.Text.Json. It would be nice if Tiny.RestClient supported it, because:
It's easy enough to implement a
IFormatter
that uses System.Text.Json, but there's a bit of an impedance mismatch between theIFormatter
and System.Text.Json APIs...IFormatter
only has synchronous methods that take aStream
. But System.Text.Json doesn't have synchronous methods that accept a stream, only async ones. And they return aValueTask
, so we can't just use.Result
. Maybe the solution would be to add aIAsyncFormatter
interface. If the formatter implements it, use the async methods, if not, use the sync methods.