MudDataGrid: Add CancellationToken support for ServerData#11841
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces CancellationToken support to the ServerData delegate in MudDataGrid, which is a great improvement for preventing unnecessary data loading, especially when users navigate through pages quickly. The implementation looks solid. My feedback focuses on updating the XML documentation to reflect this new parameter and ensuring the example files correctly demonstrate its usage by passing the token to Task.Delay calls.
src/MudBlazor.Docs/Pages/Components/DataGrid/Examples/DataGridServerSideExample.razor
Outdated
Show resolved
Hide resolved
Adds `[SetCulture("en-US")]` attribute to ensure consistent number formatting during test execution.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces CancellationToken support for ServerData in MudDataGrid, which is a valuable enhancement to prevent unnecessary data loading, particularly when navigating through pages quickly. The implementation correctly propagates the cancellation token to asynchronous operations in most of the updated examples and tests.
My review has identified a critical memory leak in the new cancellation logic within MudDataGrid.razor.cs. The CancellationTokenSource is not being disposed of correctly, which could lead to performance degradation over time. Additionally, there are several violations of the C# style guide regarding the naming of asynchronous methods across multiple files. Addressing these issues will improve the stability and maintainability of the code.
src/MudBlazor.Docs/Pages/Components/DataGrid/Examples/DataGridGroupingMultiLevelExample.razor
Show resolved
Hide resolved
src/MudBlazor.Docs/Pages/Components/DataGrid/Examples/DataGridServerSideExample.razor
Show resolved
Hide resolved
src/MudBlazor.UnitTests.Viewer/TestComponents/DataGrid/DataGridFilterableServerDataTest.razor
Show resolved
Hide resolved
...azor.UnitTests.Viewer/TestComponents/DataGrid/DataGridGroupExpandedFalseServerDataTest.razor
Show resolved
Hide resolved
...Blazor.UnitTests.Viewer/TestComponents/DataGrid/DataGridServerDataColumnFilterMenuTest.razor
Show resolved
Hide resolved
...dBlazor.UnitTests.Viewer/TestComponents/DataGrid/DataGridServerDataColumnFilterRowTest.razor
Show resolved
Hide resolved
src/MudBlazor.UnitTests.Viewer/TestComponents/DataGrid/DataGridServerMultiSelectionTest.razor
Show resolved
Hide resolved
src/MudBlazor.UnitTests.Viewer/TestComponents/DataGrid/DataGridServerPaginationTest.razor
Show resolved
Hide resolved
src/MudBlazor.UnitTests.Viewer/TestComponents/DataGrid/DataGridServerSideSortableTest.razor
Show resolved
Hide resolved
|
@ScarletKuro Can it have a default value to not be a breaking change? |
You can't have default value for a Anyone using the ServerData parameter will now be required to include a CancellationToken argument, regardless of whether they use it or not. Your changes to every single test case demonstrate this very well. Therefore, it's a breaking change.
|
|
Thanks for the explanation. |
yeah |
|
Okay, is there a separate branch for there to move the PR there? |
|
Just leave here for now and since it's a breaking change, go ahead and change the name to append Async and add the ?.Dispose to CancelServerData. This will likely need to be updated to the latest dev occasionally. V |
This comment was marked as duplicate.
This comment was marked as duplicate.
…-cancellationtoken
I renamed Is Dispose on the correct place? b43c399 Should I rename test razor files also from ServerData to ServerDataAsync in filenames? I also updated to recent |
I don't think that's a good idea. Yes, normal properties or methods should have an And I don't think having inconsistency is a good thing. |
Description
Add CancellationToken support for ServerData with to prevent unnecessary data loading.
My main issue was with rapidly go over multiple pages and it loaded the data for every skipped page.
Try to resolve: #11185
Type of Changes
Checklist