Skip to content

Add validation to Router component to prevent both NotFound and NotFoundPage being set #62625

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 9, 2025

In this PR:

  • Add nullability operator in type for Router.NotFoundPage
    public Type NotFoundPage { get; set; } -> public Type? NotFoundPage { get; set; }
  • Mark NotFound render fragment in Router as deprecated.
  • When both: NotFound and NotFoundPage are defined, log a warning. Do it in Router.SetParametersAsync in if (NotFoundPage != null) condition. Use the logger that is available there, add a new method to private static partial class Log with warning level. In the warning message, underline that we prefer NotFoundPage to be used and that NotFound will be deprecated. We are disabling treating warnings as errors, so they have to be disabled in some places to fix the build.

Fixes: #62409

…neously

Co-authored-by: ilonatommy <32700855+ilonatommy@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] API proposal for Router.NotFoundPage Add validation to Router component to prevent both NotFound and NotFoundPage being set Jul 9, 2025
@Copilot Copilot AI requested a review from ilonatommy July 9, 2025 07:40
Copilot finished work on behalf of ilonatommy July 9, 2025 07:40
Co-authored-by: ilonatommy <32700855+ilonatommy@users.noreply.github.com>
Copilot finished work on behalf of ilonatommy July 9, 2025 07:54
…dation

Co-authored-by: ilonatommy <32700855+ilonatommy@users.noreply.github.com>
@Copilot Copilot AI requested a review from ilonatommy July 9, 2025 08:27
Copilot finished work on behalf of ilonatommy July 9, 2025 08:27
Co-authored-by: ilonatommy <32700855+ilonatommy@users.noreply.github.com>
@ilonatommy
Copy link
Member

@copilot, add one unit test to RouterTest.cs to check if the warning is produced correctly when we have both: NotFound fragment and NotFoundPage.

Co-authored-by: ilonatommy <32700855+ilonatommy@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 9, 2025

@copilot, add one unit test to RouterTest.cs to check if the warning is produced correctly when we have both: NotFound fragment and NotFoundPage.

Added unit test LogsWarningWhenBothNotFoundAndNotFoundPageAreSet to RouterTest.cs that verifies the warning is logged correctly when both NotFound fragment and NotFoundPage are set. The test uses a custom TestLogger to capture the warning message and validates both the warning level and message content. Commit: aa54562

Copilot finished work on behalf of ilonatommy July 9, 2025 12:31
@ilonatommy ilonatommy added this to the 10.0-preview7 milestone Jul 11, 2025
@ilonatommy ilonatommy marked this pull request as ready for review July 11, 2025 11:16
@ilonatommy ilonatommy requested a review from a team as a code owner July 11, 2025 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API proposal for Router.NotFoundPage
2 participants