diff --git a/rules/S2094/csharp/rule.adoc b/rules/S2094/csharp/rule.adoc index e01bf1734b4..34f7d21cc25 100644 --- a/rules/S2094/csharp/rule.adoc +++ b/rules/S2094/csharp/rule.adoc @@ -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] ---- diff --git a/rules/S2094/exceptions-dotnet.adoc b/rules/S2094/exceptions-dotnet.adoc new file mode 100644 index 00000000000..2dacca9cff7 --- /dev/null +++ b/rules/S2094/exceptions-dotnet.adoc @@ -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. \ No newline at end of file diff --git a/rules/S2094/vbnet/rule.adoc b/rules/S2094/vbnet/rule.adoc index 1bc34ea4566..4de99520fff 100644 --- a/rules/S2094/vbnet/rule.adoc +++ b/rules/S2094/vbnet/rule.adoc @@ -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 @@ -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