2023-06-12 15:18:25 +02:00
|
|
|
include::../why-dotnet.adoc[]
|
2023-05-03 11:06:20 +02:00
|
|
|
|
2023-06-12 15:18:25 +02:00
|
|
|
== How to fix it
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2023-06-12 15:18:25 +02:00
|
|
|
=== Code examples
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2023-06-12 15:18:25 +02:00
|
|
|
==== Noncompliant code example
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2023-06-12 15:18:25 +02:00
|
|
|
[source,csharp,diff-id=1,diff-type=noncompliant]
|
2022-11-07 09:12:18 +01:00
|
|
|
----
|
|
|
|
internal class MyException : Exception // Noncompliant
|
|
|
|
{
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
----
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2023-06-12 15:18:25 +02:00
|
|
|
==== Compliant solution
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2023-06-12 15:18:25 +02:00
|
|
|
[source,csharp,diff-id=1,diff-type=compliant]
|
2022-11-07 09:12:18 +01:00
|
|
|
----
|
|
|
|
public class MyException : Exception
|
|
|
|
{
|
|
|
|
// ...
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2023-06-12 15:18:25 +02:00
|
|
|
include::../resources-dotnet.adoc[]
|
2022-11-07 09:12:18 +01:00
|
|
|
|
2023-06-12 15:18:25 +02:00
|
|
|
* https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers[Access modifiers]
|
|
|
|
* https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/exceptions[Exceptions and Exception Handling]
|
2022-11-07 10:01:24 +01:00
|
|
|
|
2023-05-25 14:18:12 +02:00
|
|
|
include::../rspecator.adoc[]
|