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

Fix #484: Use IEnumerable<T> instead of IList<T>. #485

Merged

Conversation

rossmills99
Copy link
Collaborator

Fix #484 by using IEnumerable in place of IList.

I've ended up expanding from the issue description to also update all places we used IList in interfaces and models.

As far as I can tell, this should not be a breaking change because every IList<T> is already an IEnumerable<T>, but IEnumerable<T> allows for greater flexibility in choice of the actual collection type implementations used.

@rossmills99 rossmills99 self-assigned this Dec 7, 2023
Copy link

@Arash-Sabet Arash-Sabet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and observed the changes.

@rossmills99 rossmills99 closed this Dec 8, 2023
@rossmills99 rossmills99 reopened this Dec 8, 2023
@rossmills99 rossmills99 merged commit a0c4b58 into ArangoDB-Community:master Dec 8, 2023
8 checks passed
@rossmills99 rossmills99 deleted the 484-use-IEnumerableT branch December 8, 2023 20:14
@Arash-Sabet
Copy link

@rossmills99 Is this release's Nuget package available?

@@ -9,14 +9,14 @@ namespace ArangoDBNetStandard.AqlFunctionApi.Models
public class PostExplainAqlQueryResponseNode
{
public string Type { get; set; }
public IList<int> Dependencies { get; set; }
public IEnumerable<int> Dependencies { get; set; }
Copy link
Collaborator

@DiscoPYF DiscoPYF Dec 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand, this is a breaking change. Any change from IList<T> to IEnumerable<T> in response models is a breaking change. (e.g. see the tests updates, Count to Count()).

The following code won't compile after the changes:

IList<string> projections = response.Projections; // CS0266 error
var projections = response.Projections;

// Anyting using IList<T> methods will cause errors, e.g. CS0021.

❓ Is it on purpose?

It's mostly beneficial for us, the library developers (or for customer implementation of serialization), to use IEnumerable<T> in response models, as we can change the implementation without breaking existing code. But honestly, I don't think it's worth introducing a breaking change, though it's a fairly minor one.

❓ Should we revert the change for response model and schedule it in a major release?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using IList seems to have been a strange choice which got repeated in several places - not sure why it was used in the first place. But yes you're right to point out this is a breaking change. Happy to see this change be reverted, or alternatively we just treat it as a breaking change and bump the version per semantic versioning? i.e. why do we need to "schedule" something, we can just bump the version with this change, if it makes sense.

Copy link
Collaborator

@DiscoPYF DiscoPYF Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using IList seems to have been a strange choice which got repeated in several places - not sure why it was used in the first place.

Not sure. If I had to guess, it's because IList<T> has a fixed Count property and the serializer uses List<T>. I agree that IEnumerable<T> is generally better, and callers can use .ToList() if they want a list.

Happy to see this change be reverted, or alternatively we just treat it as a breaking change and bump the version per semantic versioning? i.e. why do we need to "schedule" something, we can just bump the version with this change, if it makes sense.

I find it best to group breaking changes together and separate them from smaller enhancements. If someone updates to use the enhancements, they probably don't want to deal with breaking changes.

But yes, we can just bump the version. Were you thinking of bumping from 2.0.2 to 2.1.0 or 3.0.0? To follow the semantic versioning rules, we must bump to 3.0.0 but it makes it seem like a bigger update than it is.

I am working on #481 that we could release together before Christmas.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semantic versioning doesn't say anything about the size of the update, so bumping to 3.0 should be fine I think.

@DiscoPYF
Copy link
Collaborator

DiscoPYF commented Dec 11, 2023

@rossmills99 Is this release's Nuget package available?

Hey @Arash-Sabet , I would like to clarify the questions above with @rossmills99 before releasing this enhancement. We can get it out once done 👍

Depending on the outcome, it will be in a patch release, 2.0.2 or minor release 2.1.0

@Arash-Sabet
Copy link

Hey @rossmills99 & @DiscoPYF

Do you happen to know when you're planning to release the patch or minor release as the enhancements in our side are pending for your changes.

@rossmills99
Copy link
Collaborator Author

Per discussion above we can release as 3.0.0 along with a couple of other recently added improvements. I can prepare a release to go out today.

@Arash-Sabet
Copy link

@rossmills99 thanks for the prompt action.

@rossmills99
Copy link
Collaborator Author

@rossmills99 thanks for the prompt action.

No problem, thanks for the prompt 😄

The 3.0.0 package is now published in Nuget, you can view release notes here: https://github.com/ArangoDB-Community/arangodb-net-standard/releases/tag/3.0.0

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

Successfully merging this pull request may close these issues.

Support FrozenSet<T> in PostDocumentsAsync<T>(...), PutDocumentsAsync<T>(...) and PatchDocumentsAsync<T>(...)
4 participants