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

X.PagedList.Mvc.Core: Improve nullable handling for generatePageUrl #273

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

adschmu
Copy link
Contributor

@adschmu adschmu commented Jul 10, 2024

We only ever use the generatePageUrl argument (in various places) to set HTML attribute values with TagBuilder.Attributes.Add().

The latter specifically accepts nullable strings for the value. Thus, this commits adjusts the return type of the Func<int, string> for generatePageUrl to be nullable as well, i.e. to Func<int, string?>, for all affected cases.

This removes nullable warnings for actual use cases like the following:

@Html.PagedListPager(someModel, page => Url.Action(...), ...)

Here, Url.Action returns string? and thus creates a nullable warning CS8603 with the implementation before this commit. Since TagBuilder.Attributes.Add() allows string?, though, we can be more permissive here and do so with this commit.


This has been found while testing 10.0.0-pre

We only ever use the generatePageUrl argument (in various places) to set
HTML attribute values with TagBuilder.Attributes.Add().

The latter specifically accepts nullable strings for the value. Thus, this
commits adjusts the return type of the `Func<int, string>` for generatePageUrl
to be nullable as well, i.e. to `Func<int, string?>`, for all affected cases.

This removes nullable warnings for actual use cases like the following:

  @Html.PagedListPager(someModel, page => Url.Action(...), ...)

Here, Url.Action returns `string?` and thus creates a nullable warning CS8603
with the implementation before this commit. Since TagBuilder.Attributes.Add()
allows `string?`, though, we can be more permissive here and do so with this
commit.
@a-gubskiy a-gubskiy merged commit b1f69b8 into dncuug:master Jul 10, 2024
2 checks passed
@adschmu adschmu deleted the pr/nullable-mvc branch July 10, 2024 15:40
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.

2 participants