rspec/rules/S1048/csharp/rule.adoc

28 lines
660 B
Plaintext
Raw Normal View History

2020-06-30 12:47:33 +02:00
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
----
class MyClass
{
~MyClass()
{
throw new NotImplementedException(); // Noncompliant
}
}
----
== Compliant Solution
----
class MyClass
{
~MyClass()
{
// no throw
}
}
----