Closed ayomicahyo closed 4 months ago
In general, it is dangerous to throw exceptions within the Dispose method. Dispose is the last resort to safely clean up the resource in the event of some kind of error. So if more exceptions are thrown there, the behaviour cannot be guaranteed. Besides, Dispose can be called via the finaliser.
This can be found in the learn.microsoft guide. https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1065#dispose-methods As far as I know, most implementations of CompositeDisposable do not catch exceptions.
Hello, I apologize, but I'm encountering an issue while debugging my code in the disposable method. If an error occurs or an exception is thrown in the dispose method, the error log is displayed one by one and that will stop the exception of the disposal process following the disposable execution order. This process is exhausting for me because I have to repeatedly play and replay the Unity editor to catch any exceptions in the dispose method.
I guess, could you possibly add some try-catch blocks in the composite disposable class to ensure that any dispose method can be executed and any exceptions thrown are directly shown to eliminate the need for us to repeatedly play and replay due to the disposable execution order?
Thanks :)