Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support FrozenSet<T> in PostDocumentsAsync<T>(...), PutDocumentsAsync<T>(...) and PatchDocumentsAsync<T>(...) #484

Closed
Arash-Sabet opened this issue Dec 5, 2023 · 4 comments · Fixed by #485
Labels
enhancement New feature or request

Comments

@Arash-Sabet
Copy link

FrozenSet<T> is now shipped with .NET 8.0 and we started leveraging it. We have to convert our frozen sets to List<T> using .ToList() extension method when calling any of the methods in the title. It makes sense to introduce three more overloads of the aforementioned methods to support frozen sets in ArangoDB's .NET client library.

@rossmills99
Copy link
Collaborator

Signature of e.g. PostDocumentsAsync:

public virtual async Task<PostDocumentsResponse<T>> PostDocumentsAsync<T>(
            string collectionName,
            IList<T> documents,
            PostDocumentsQuery query = null,
            ApiClientSerializationOptions serializationOptions = null,
            DocumentHeaderProperties headers = null,
            CancellationToken token = default)

I assume you are referring to IList<T> documents. I'm not sure why the decision was made to use IList<T> there, but looking at documentation, I think that both FrozenSet<T> and IList<T> implement IEnumerable<T>. So perhaps the best way to fix this is to change IList to IEnumerable in the method signatures?

@Arash-Sabet
Copy link
Author

@rossmills99 That might help, or preferably a separate extension method to intake the FrozenSet<T> would be a better way. As a side note, typecasting to IList<T> throws an exception and therefore .ToList() had to be used.

@rossmills99
Copy link
Collaborator

Thanks. Yes, I think using the more general IEnumerable<T> type here will be the best option - it then allows for any collection type that supports that interface, which includes FrozenSet<T>, or anything that implements IList<T>. This is better than creating overloads specific to any particular collection type. I can push up a quick PR.

@Arash-Sabet
Copy link
Author

@rossmills99 That's amazing. thanks for the prompt action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants