2021-09-02 15:00:43 +03:00
It is expected that some methods should be called with caution, but others, such as `ToString`, are expected to "just work". Throwing an exception from such a method is likely to break callers' code unexpectedly.
2021-04-28 16:49:39 +02:00
An issue is raised when an exception is thrown from any of the following:
* Event accessors
2021-09-02 15:00:43 +03:00
* `Object.Equals`
* `IEquatable.Equals`
* `GetHashCode`
* `ToString`
* `static` constructors
* Module initializers
* `IDisposable.Dispose`
* operators ``++==, !=, <, >, <=, >=++``
* `implicit` cast operators
2021-04-28 16:49:39 +02:00
2021-04-28 18:08:03 +02:00
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
----
public override string ToString()
{
if (string.IsNullOrEmpty(Name))
{
throw new ArgumentException("..."); // Noncompliant
}
//...
----
2021-04-28 18:08:03 +02:00
2021-04-28 16:49:39 +02:00
== Exceptions
2021-09-02 15:00:43 +03:00
`System.NotImplementedException` and its derivatives are ignored.
2021-04-28 16:49:39 +02:00
2021-09-02 15:00:43 +03:00
`System.InvalidOperationException`, `System.NotSupportedException`, and `System.ArgumentException` and their derivatives are ignored in event accessors.
2021-04-28 18:08:03 +02:00
2021-06-02 20:44:38 +02:00
2021-06-03 09:05:38 +02:00
ifdef::env-github,rspecator-view[]
2021-06-08 15:52:13 +02:00
'''
2021-06-02 20:44:38 +02:00
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
2021-06-03 09:05:38 +02:00
endif::env-github,rspecator-view[]