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

Version 10 #276

Merged
merged 14 commits into from
Jul 12, 2024
Merged

Version 10 #276

merged 14 commits into from
Jul 12, 2024

Conversation

a-gubskiy
Copy link
Member

No description provided.

@a-gubskiy a-gubskiy linked an issue Jul 12, 2024 that may be closed by this pull request
@a-gubskiy a-gubskiy marked this pull request as ready for review July 12, 2024 11:35
{
InitSubset(superset, keySelector.Compile(), pageNumber, pageSize);
}
InitSubset(superset, keySelector.Compile(), pageNumber, pageSize);
Copy link
Contributor

@adschmu adschmu Jul 12, 2024

Choose a reason for hiding this comment

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

Note that there isn't really much point to creating a PagedList without a superset.

Personally, I would make the superset argument here non-nullable, throw an exception if it is, and drop the nullable handling after that point.

If somebody really wants a PagedList that is empty, he could still supply an empty list to the constructor. This would look like this:

public PagedList(IQueryable<T> superset, Expression<Func<T, TKey>> keySelector, int pageNumber, int pageSize)
        : base(pageNumber, pageSize, superset.Count())
    {
        if (superset == null)
            throw new ArgumentNullException(nameof(superset));

        // add items to internal list
        if (TotalItemCount > 0)
        {
            InitSubset(superset, keySelector.Compile(), pageNumber, pageSize);
        }
    }

I would do the same to equivalent cases, i.e. never allow null for the superset anywhere.
This also means that you do not have to change InitSubset at all.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree

@adschmu
Copy link
Contributor

adschmu commented Jul 12, 2024

I'll prepare two commits for nullable changes as suggested above and for the direct Subset assignment.

@adschmu
Copy link
Contributor

adschmu commented Jul 12, 2024

I've taken the liberty to rebase this onto my #278 for a cleaner history in #279

@a-gubskiy a-gubskiy merged commit 25be3a1 into master Jul 12, 2024
3 checks passed
@a-gubskiy a-gubskiy deleted the version-10 branch July 12, 2024 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Release 10.x proposal
3 participants