Skip to content

Fix CancellationTokenSource usage so it gets disposed properly in Blazor.WebAssembly project#4714

Merged
rockfordlhotka merged 1 commit into
mainfrom
dev/4611-fix-blazor-sessionManager
Aug 23, 2025
Merged

Fix CancellationTokenSource usage so it gets disposed properly in Blazor.WebAssembly project#4714
rockfordlhotka merged 1 commit into
mainfrom
dev/4611-fix-blazor-sessionManager

Conversation

@StefanOssendorf

Copy link
Copy Markdown
Contributor

Make internals from csla visible to Blazor.WebAssembly.
Fix CancellationTokenSource usage so it gets disposed properly.

Fixes #4611

@StefanOssendorf StefanOssendorf self-assigned this Aug 9, 2025
Fix CancellationTokenSource usage so it gets disposed properly
Fixes #4611

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a memory leak issue in the Blazor WebAssembly project by properly disposing CancellationTokenSource instances and enables access to CSLA internals.

  • Adds InternalsVisibleTo attribute for Csla.Blazor.WebAssembly project
  • Replaces GetCancellationToken method with proper using statements for CancellationTokenSource disposal
  • Removes unused GetCancellationToken helper method

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Source/Csla/Properties/AssemblyInfo.cs Adds InternalsVisibleTo attribute to expose CSLA internals to Blazor.WebAssembly
Source/Csla.Blazor.WebAssembly/State/SessionManager.cs Fixes CancellationTokenSource disposal by using 'using' statements and removes helper method

try
{
return await RetrieveSession(GetCancellationToken(timeout));
using var cts = timeout.ToCancellationTokenSource();

Copilot AI Aug 12, 2025

Copy link

Choose a reason for hiding this comment

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

The method ToCancellationTokenSource() appears to be an extension method that may not exist in the standard .NET libraries. Ensure this extension method is properly implemented and available, or consider using new CancellationTokenSource(timeout) directly.

Suggested change
using var cts = timeout.ToCancellationTokenSource();
using var cts = new CancellationTokenSource(timeout);

Copilot uses AI. Check for mistakes.
@rockfordlhotka rockfordlhotka self-requested a review August 23, 2025 23:45
@rockfordlhotka rockfordlhotka merged commit cdd8b5d into main Aug 23, 2025
2 checks passed
@rockfordlhotka rockfordlhotka deleted the dev/4611-fix-blazor-sessionManager branch August 23, 2025 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

is not disposing of CancellationTokenSource in ToCancellationToken a problem?

3 participants