Skip to content

Commit d5623e0

Browse files
Ensure that in-process helper instances are also disposed.
1 parent 8c2268a commit d5623e0

4 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/KristofferStrube.Blazor.FileAPI/Blob.InProcess.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,12 @@ public BlobInProcess Slice(long? start = null, long? end = null, string? content
9595
IJSInProcessObjectReference jSInstance = JSReference.Invoke<IJSInProcessObjectReference>("slice", start, end, contentType);
9696
return new BlobInProcess(JSRuntime, InProcessHelper, jSInstance, new() { DisposesJSReference = true });
9797
}
98+
99+
/// <inheritdoc/>
100+
public new async ValueTask DisposeAsync()
101+
{
102+
await InProcessHelper.DisposeAsync();
103+
await base.DisposeAsync();
104+
GC.SuppressFinalize(this);
105+
}
98106
}

src/KristofferStrube.Blazor.FileAPI/File.InProcess.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,12 @@ public BlobInProcess Slice(long? start = null, long? end = null, string? content
108108
/// </summary>
109109
/// <returns>A new <see cref="DateTime"/> object representing when the file was last modified.</returns>
110110
public DateTime LastModified => DateTime.UnixEpoch.AddMilliseconds(InProcessHelper.Invoke<ulong>("getAttribute", JSReference, "lastModified"));
111+
112+
/// <inheritdoc/>
113+
public new async ValueTask DisposeAsync()
114+
{
115+
await InProcessHelper.DisposeAsync();
116+
await base.DisposeAsync();
117+
GC.SuppressFinalize(this);
118+
}
111119
}

src/KristofferStrube.Blazor.FileAPI/FileReader.InProcess.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,12 @@ public void InvokeOnLoadEnd(IJSInProcessObjectReference jsProgressEvent)
239239

240240
OnLoadEnd.Invoke(new ProgressEventInProcess(JSRuntime, InProcessHelper, jsProgressEvent, new() { DisposesJSReference = true }));
241241
}
242+
243+
/// <inheritdoc/>
244+
public new async ValueTask DisposeAsync()
245+
{
246+
await InProcessHelper.DisposeAsync();
247+
await base.DisposeAsync();
248+
GC.SuppressFinalize(this);
249+
}
242250
}

src/KristofferStrube.Blazor.FileAPI/ProgressEvent.InProcess.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,12 @@ protected internal ProgressEventInProcess(IJSRuntime jSRuntime, IJSInProcessObje
5353
/// </summary>
5454
/// <returns>The total length of the read.</returns>
5555
public ulong Total => InProcessHelper.Invoke<ulong>("getAttribute", JSReference, "total");
56+
57+
/// <inheritdoc/>
58+
public new async ValueTask DisposeAsync()
59+
{
60+
await InProcessHelper.DisposeAsync();
61+
await base.DisposeAsync();
62+
GC.SuppressFinalize(this);
63+
}
5664
}

0 commit comments

Comments
 (0)