Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify rule S2094: Add an exception #3867

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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