Skip to content

Fixed a NullReferenceException when starting application with empty shell on Windows #28879

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 4 commits into
base: main
Choose a base branch
from

Conversation

Shalini-Ashokan
Copy link
Contributor

@Shalini-Ashokan Shalini-Ashokan commented Apr 9, 2025

Issue Details

A NullReferenceException is thrown when starting the application with an empty shell on Windows.

Root Cause

The shell does not have any items, so the shell item is null. In the source code, a null check was not implemented.

Description of Change

Throws an InvalidOperationException when the Shell item or the current Shell item is null.

Reference

Ensured consistent behavior with Android by referring to the following code.

Validated the behavior in the following platforms

  • Android
  • Windows
  • iOS
  • Mac

Issues Fixed

Fixes #21562

Output ScreenShot

Before After
BeforeFix.3.mp4
After-Fix-1.mp4

Copy link
Contributor

Hey there @@Shalini-Ashokan! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service bot added community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration labels Apr 9, 2025
@rmarinho rmarinho added the area-controls-shell Shell Navigation, Routes, Tabs, Flyout label Apr 9, 2025
@@ -193,6 +193,12 @@ public override bool Equals(object obj) =>

internal void SwitchShellItem(ShellItem newItem, bool animate = true)
{
if (newItem is null)
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the behavior on other platforms? Would be nice to align the behavior and throw the same exception with the same message if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jsuarezruiz, On Android, the empty Shell throws a similar exception.

@Shalini-Ashokan Shalini-Ashokan marked this pull request as ready for review April 10, 2025 13:15
@Shalini-Ashokan Shalini-Ashokan requested a review from a team as a code owner April 10, 2025 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-shell Shell Navigation, Routes, Tabs, Flyout community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NullReferenceException when starting application with empty shell on Windows
3 participants