rspec/rules/S2166/csharp/rule.adoc

58 lines
1.2 KiB
Plaintext

include::../description.adoc[]
== 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)
{
// ...
}
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]