Skip to content

MudTreeViewItem: Fix NullReferenceException#11108

Merged
ScarletKuro merged 5 commits intoMudBlazor:devfrom
masonwheeler:dev
Mar 30, 2025
Merged

MudTreeViewItem: Fix NullReferenceException#11108
ScarletKuro merged 5 commits intoMudBlazor:devfrom
masonwheeler:dev

Conversation

@masonwheeler
Copy link
Contributor

Description

When a MudTreeViewItem has a Value whose type that does not match the tree's type T, this compiles just fine, (and is quite necessary in many use cases,) but clicking on the node causes a crash, as detailed in the bug report.

Resolves #11093.

How Has This Been Tested?

Added a unit test that demonstrates this crash, and does not crash with the fix in place.

Type of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or improvement to the website or code docs)

Checklist

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

The debug asserts are asserting a case that's not necessarily true.  If the type `T` of the parent node is not the same as the type `T` of the current node, `this.MudTreeRoot` will be null.
@github-actions github-actions bot added bug Unexpected behavior or functionality not working as intended PR: needs review labels Mar 28, 2025
@ScarletKuro ScarletKuro self-requested a review March 28, 2025 21:51
@codecov
Copy link

codecov bot commented Mar 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.97%. Comparing base (abfc821) to head (0286278).
Report is 3 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev   #11108   +/-   ##
=======================================
  Coverage   90.97%   90.97%           
=======================================
  Files         431      431           
  Lines       14047    14051    +4     
  Branches     2726     2727    +1     
=======================================
+ Hits        12779    12783    +4     
  Misses        651      651           
  Partials      617      617           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ScarletKuro ScarletKuro changed the title Fixing a crash bug with heterogeneous tree Value types MudTreeViewItem: Fix NullReferenceException Mar 28, 2025
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@ScarletKuro ScarletKuro merged commit a9f0fda into MudBlazor:dev Mar 30, 2025
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Unexpected behavior or functionality not working as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Null dereference in MudTreeViewItem click

2 participants