Skip to content

Fix Prefix Matching Logic in PrefixContainer #58068

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

Closed
wants to merge 5 commits into from

Conversation

sami-daniel
Copy link

Fix Prefix Matching Logic in PrefixContainer

Description

This PR modifies the BinarySearch method in PrefixContainer to ensure that an exact match of a prefix does not incorrectly qualify as a valid prefix.

Now the ContainsPrefix method no longer gives a false positive if it has a prefix with the same name as the Action method parameter.

Fixes #57637

Sami Daniel Santos Silva and others added 3 commits September 25, 2024 05:00
Updated the BinarySearch method in PrefixContainer to ensure that an exact match of a prefix does not incorrectly qualify as a valid prefix. Enhanced comments to clarify the flow and decision-making process when checking for delimiters. This change improves the accuracy of prefix matching for hierarchical key structures.
…x if the Prefix is ​​equal to the keys
@sami-daniel sami-daniel requested a review from a team as a code owner September 25, 2024 09:58
@ghost ghost added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Sep 25, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Sep 25, 2024
@sami-daniel
Copy link
Author

@sami-daniel please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@dotnet-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@dotnet-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@dotnet-policy-service agree company="Microsoft"

Contributor License Agreement

@dotnet-policy-service agree

Copy link
Member

@gfoidl gfoidl left a comment

Choose a reason for hiding this comment

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

A small JIT-trick for better machine code.

This commit enhances the performance of the BinarySearch method by eliminating unnecessary boundary checks. The condition if ((uint)candidate.Length > (uint)prefix.Length) ensures that the index access candidate[prefix.Length] is safe, and the JIT compiler can now safely elide the boundary check, improving execution efficiency.

Co-authored-by: Günther Foidl <[email protected]>
@sami-daniel
Copy link
Author

A small JIT-trick for better machine code.

I didn't know that, but it makes sense, thanks!

@gfoidl
Copy link
Member

gfoidl commented Sep 26, 2024

I didn't know that

The nice thing on contributing: you help to improve the product and get the opportunity to learn something new. A win - win situation 😃.

Thanks for the PR 👍🏻

@sami-daniel
Copy link
Author

I didn't know that

The nice thing on contributing: you help to improve the product and get the opportunity to learn something new. A win - win situation 😃.

Thanks for the PR 👍🏻

Yessss, C# and .NET have been my focus of study since the beginning of my interest in technology and until now I don't even know half of its power. This is my first contribution and I already loved it. Thanks!

@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Oct 3, 2024
@sami-daniel sami-daniel closed this Oct 3, 2024
@sami-daniel sami-daniel reopened this Oct 3, 2024
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview1 milestone Oct 3, 2024
@adityamandaleeka
Copy link
Member

Yessss, C# and .NET have been my focus of study since the beginning of my interest in technology and until now I don't even know half of its power. This is my first contribution and I already loved it. Thanks!

Love it, welcome @sami-daniel!

@adityamandaleeka
Copy link
Member

/azp run

@dotnet-policy-service dotnet-policy-service bot removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Oct 4, 2024
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@adityamandaleeka
Copy link
Member

Ubuntu failure is unrelated; it failed during node installation. cc: @dotnet/aspnet-build

##[error]Request timeout: /dist/index.json

@FatTigerWang
Copy link
Contributor

/azp run

Copy link

Commenter does not have sufficient privileges for PR 58068 in repo dotnet/aspnetcore

@wtgodbe
Copy link
Member

wtgodbe commented Oct 10, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Oct 17, 2024
@adityamandaleeka
Copy link
Member

Not sure if there's something making our CI more flaky than normal...

/azp run

@sami-daniel
Copy link
Author

Hello again :).
Would it be possible to run the pipelines gain to see if the behavior is the same? I will make some changes if necessary

@wtgodbe
Copy link
Member

wtgodbe commented Dec 3, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@captainsafia
Copy link
Member

/azp run

@captainsafia captainsafia removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Dec 16, 2024
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Member

@captainsafia captainsafia left a comment

Choose a reason for hiding this comment

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

Thanks for opening this PR!

It looks like the test failures that were introduced here are legitimate failures. Specifically, the failures in Mvc.FunctionalTests can be debugged to investigate what regression was introduced here.

@captainsafia captainsafia requested a review from Copilot December 17, 2024 21:28
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

@mkArtakMSFT mkArtakMSFT added the pr: pending author input For automation. Specifically separate from Needs: Author Feedback label Dec 19, 2024
Copy link
Contributor

Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime.
To make sure no conflicting changes have occurred, please rerun validation before merging. You can do this by leaving an /azp run comment here (requires commit rights), or by simply closing and reopening.

@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Dec 26, 2024
Copy link
Contributor

Hi @sami-daniel.
It seems you haven't touched this PR for the last two weeks. To avoid accumulating old PRs, we're marking it as stale. As a result, it will be closed if no further activity occurs within 4 days of this comment. You can learn more about our Issue Management Policies here.

@dotnet-policy-service dotnet-policy-service bot added the stale Indicates a stale issue. These issues will be closed automatically soon. label Jan 5, 2025
@dotnet-policy-service dotnet-policy-service bot removed this from the 10.0-preview1 milestone Jan 9, 2025
@sami-daniel
Copy link
Author

Moved to #62459 because I lost the branch where this PR was attached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates community-contribution Indicates that the PR has been added by a community member pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun pr: pending author input For automation. Specifically separate from Needs: Author Feedback stale Indicates a stale issue. These issues will be closed automatically soon.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HttpGet [FromQuery] Model binding fails in case of propertity with the same name
7 participants