44 lines
1.0 KiB
Plaintext
44 lines
1.0 KiB
Plaintext
If Finalize or an override of Finalize throws an exception, and the runtime is not hosted by an application that overrides the default policy, the runtime terminates the process immediately without graceful cleanup (finally blocks and finalizers are not executed). This behavior ensures process integrity if the finalizer cannot free or destroy resources.
|
|
|
|
|
|
The rule reports on throw statements used in finalizers.
|
|
|
|
== Noncompliant Code Example
|
|
|
|
[source,vbnet]
|
|
----
|
|
Class MyClass
|
|
Protected Overrides Sub Finalize()
|
|
Throw New NotImplementedException() ' Noncompliant
|
|
End Sub
|
|
End Class
|
|
----
|
|
|
|
== Compliant Solution
|
|
|
|
[source,vbnet]
|
|
----
|
|
Class MyClass
|
|
Protected Overrides Sub Finalize()
|
|
' No throw
|
|
End Sub
|
|
End Class
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::message.adoc[]
|
|
|
|
include::highlighting.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::../comments-and-links.adoc[]
|
|
endif::env-github,rspecator-view[]
|