Skip to content

Commit

Permalink
Modify rule S2094: Add an exception (#3867)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim-Pohlmann authored Apr 15, 2024
1 parent a603a39 commit 2f851ec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 1 addition & 5 deletions rules/S2094/csharp/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ public interface IEmpty

=== Exceptions

Partial classes are ignored entirely, as they are often used with Source Generators.
Subclasses of System.Exception are ignored, as even an empty Exception class can provide useful information by its type name alone.
Subclasses of System.Attribute are ignored, as well as classes which are annotated with attributes.
Subclasses of generic classes are ignored, as even when empty they can be used for type specialization.
Subclasses of certain framework types - like the PageModel class used in ASP.NET Core Razor Pages - are also ignored.
include::../exceptions-dotnet.adoc[]

[source,csharp]
----
Expand Down
7 changes: 7 additions & 0 deletions rules/S2094/exceptions-dotnet.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- Partial classes are ignored entirely, as source generators often use them.
- Classes with names ending in `Command`, `Message`, or `Event` are ignored as messaging libraries often use them.
- Subclasses of `System.Exception` are ignored; even an empty Exception class can provide helpful information by its type name alone.
- Subclasses of `System.Attribute` and classes annotated with attributes are ignored.
- Subclasses of generic classes are ignored, as they can be used for type specialization even when empty.
- Subclasses of certain framework types — like the `PageModel` class used in ASP.NET Core Razor Pages — are ignored.
- Subclass of a class with non-public default constructors are ignored, as they widen the constructor accessibility.
9 changes: 3 additions & 6 deletions rules/S2094/vbnet/rule.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
== Why is this an issue?

There is no good excuse for an empty class. If it's being used simply as a common extension point, it should be replaced with an ``++Interface++``. If it was stubbed in as a placeholder for future development it should be fleshed-out. In any other case, it should be eliminated.
include::../description.adoc[]

=== Noncompliant code example

Expand All @@ -22,11 +22,8 @@ End Interface

=== Exceptions

Partial classes are ignored entirely, as they are often used with Source Generators.
Subclasses of System.Exception are ignored, as even an empty Exception class can provide useful information by its type name alone.
Subclasses of System.Attribute are ignored, as well as classes which are annotated with attributes.
Subclasses of generic classes are ignored, as even when empty they can be used for type specialization.
Subclasses of certain framework types - like the PageModel class used in ASP.NET Core Razor Pages - are also ignored.
include::../exceptions-dotnet.adoc[]

[source,vbnet]
----
Imports Microsoft.AspNetCore.Mvc.RazorPages
Expand Down

0 comments on commit 2f851ec

Please sign in to comment.