Skip to content

New Blazor querystring building APIs. #34813

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

Merged
merged 14 commits into from
Aug 3, 2021
Merged

Conversation

MackinnonBuck
Copy link
Member

@MackinnonBuck MackinnonBuck commented Jul 28, 2021

New Blazor querystring building APIs.
Added new APIs for building URLs with querystrings from one or multiple parameter names and values.

PR Description
I've added all three APIs documented here. The current implementation doesn't make a massive effort to avoid allocations, but that is something I've been investigating along the way. If we deem it unnecessary to optimize further, I'm fine with the implementation strategy currently in place.

Addresses #34115

@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Jul 28, 2021
@MackinnonBuck MackinnonBuck marked this pull request as ready for review July 29, 2021 00:03
@MackinnonBuck MackinnonBuck requested a review from a team as a code owner July 29, 2021 00:03
@pranavkm pranavkm added the api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews label Jul 29, 2021
@ghost
Copy link

ghost commented Jul 29, 2021

Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:

  • The PR contains changes to the reference-assembly that describe the API change. Or, you have included a snippet of reference-assembly-style code that illustrates the API change.
  • The PR describes the impact to users, both positive (useful new APIs) and negative (breaking changes).
  • Someone is assigned to "champion" this change in the meeting, and they understand the impact and design of the change.

public bool Equals(ReadOnlyMemory<char> x, ReadOnlyMemory<char> y)
=> x.Span.Equals(y.Span, StringComparison.OrdinalIgnoreCase);

public int GetHashCode([DisallowNull] ReadOnlyMemory<char> obj)
Copy link
Contributor

Choose a reason for hiding this comment

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

Weird you had to do DisallowNull. Is that part of the signature?

Copy link
Member Author

Choose a reason for hiding this comment

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

This implementation was pulled out of QueryParameterValueSupplier.cs, but also I implemented my own comparer before doing that, and iirc it auto generated the DisallowNull attribute. Found this discussion about it: dotnet/runtime#30998.

@MackinnonBuck
Copy link
Member Author

Another thing - there isn't implemented support for having IEnumerable<T> values for UriWithQueryParameters (the one that accepts an IReadOnlyDictionary<string, object> for parameter assignments). Thoughts about whether this is something worth having?

@SteveSandersonMS
Copy link
Member

If it doesn’t blow up the complexity of implementation to support adding multi-valued parameters as part of a dictionary, I think it would be beneficial. Do you think it would work out?

@MackinnonBuck
Copy link
Member Author

@SteveSandersonMS I've just added support for multi-valued parameters in UriWithQueryParameters. It required a bit of finessing but it thankfully didn't blow up the complexity.

Copy link
Member

@SteveSandersonMS SteveSandersonMS left a comment

Choose a reason for hiding this comment

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

This looks awesome! I think you've done a great job of making such a large number of overloads manageable, and came up with some great abstractions to simplify the shared code in an efficient way.

@SteveSandersonMS
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@MackinnonBuck MackinnonBuck merged commit 7cb2f68 into main Aug 3, 2021
@MackinnonBuck MackinnonBuck deleted the t-mbuck/query-string-apis branch August 3, 2021 16:05
@ghost ghost added this to the 6.0-rc1 milestone Aug 3, 2021
@pranavkm pranavkm removed the api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews label Aug 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants