Reputation: 4560
I'm wondering if the default rules specified on the Implement a Dispose method still apply when writing classes/components for Blazor (specifically on the SuppressFinalize
method call, which is nowhere to be seen on blazor wasm samples I've seen).
Thanks.
Upvotes: 1
Views: 130
Reputation: 273621
if the default rules specified on the Implement a Dispose method still apply ...
No.
But then again, they don't apply to application code on other platforms either.
From that same page:
Therefore, we recommend that you construct System.Runtime.InteropServices.SafeHandle objects instead of implementing a finalizer.
So you shouldn't write Finalizers (in C#: ~MyClass() {}
) and without Finalizers you don't need SuppressFinalize
. In Blazor Wasm it's all n/a anyway, you don't have unmanaged resources there.
The complexity that remains is the virtual Dispose(bool)
pattern. That has everyhing to do with derived classes that need IDisposable too.
We usually ignore this, and when you can make your class sealed
you're good. Otherwise follow the pattern.
Upvotes: 1