2023-02-06 16:01:57 +01:00
|
|
|
include::../description.adoc[]
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2023-02-06 14:10:38 +01:00
|
|
|
== Noncompliant Code Example
|
|
|
|
|
|
|
|
[source,csharp]
|
|
|
|
----
|
|
|
|
public class FruitException // Noncompliant - this has nothing to do with Exception
|
|
|
|
{
|
|
|
|
private Fruit expected;
|
|
|
|
private string unusualCharacteristics;
|
|
|
|
private bool appropriateForCommercialExploitation;
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
|
|
|
|
public class CarException // Noncompliant - does not derive from any Exception-based class
|
|
|
|
{
|
|
|
|
public CarException(string message, Exception inner)
|
|
|
|
{
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
|
|
|
|
[source,csharp]
|
|
|
|
----
|
|
|
|
public class FruitSport // Compliant - class name does not end with 'Exception'
|
|
|
|
{
|
|
|
|
private Fruit expected;
|
|
|
|
private string unusualCharacteristics;
|
|
|
|
private bool appropriateForCommercialExploitation;
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
|
|
|
|
public class CarException: Exception // Compliant - correctly extends System.Exception
|
|
|
|
{
|
|
|
|
public CarException(string message, Exception inner): base(message, inner)
|
|
|
|
{
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2021-06-03 09:05:38 +02:00
|
|
|
ifdef::env-github,rspecator-view[]
|
2021-09-20 15:38:42 +02:00
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../message.adoc[]
|
|
|
|
|
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[]
|
2023-02-06 14:10:38 +01:00
|
|
|
endif::env-github,rspecator-view[]
|