Skip to content

DruidClient methods have class requirement on TResponse #20

@monodop

Description

@monodop

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions