-
Notifications
You must be signed in to change notification settings - Fork 16
Closed
Description
Is there a reason that all of the methods have a class requirement for TResponse? As far as I can tell, my IJsonSerializer does not have the same requirement, and I can theoretically have my serializer return different concrete classes depending on what the data is, as long as it follows some interface. I don't actually have any use cases for when I would need to do this, but I'm trying to plug this into a library where I need to be able to pass an unconstrainted generic into TResponse, and I'm just not seeing why that constraint exists.
public async Task<IEnumerable<TResult>> GetManyAsync<TResult>(IQuery query)
{
// Following line fails because TResult does not have class constraint
var response = await _getClient().ScanAsync<TResult>(
// some code to map query to something ScanAsync can understand
);
return response.Data;
}I'm not sure if there's a simple workaround to this, other than checking that TResult IsByRef at runtime and using reflection to call ScanAsync.
Any thoughts/ideas?
Metadata
Metadata
Assignees
Labels
No labels