rspec/rules/S4225/csharp/rule.adoc

16 lines
472 B
Plaintext
Raw Normal View History

2022-07-25 13:40:35 +02:00
Creating an extension method that extends ``++object++`` is not recommended because it makes the method available on _every_ type. Extensions should be applied at the most specialized level possible, and that is very unlikely to be ``++object++``.
2022-07-25 13:40:35 +02:00
== Noncompliant Code Example
2022-07-25 13:40:35 +02:00
[source,csharp]
----
public static class MyExtensions
{
public static void SomeExtension(this object obj) // Noncompliant
{
// ...
}
}
----
2022-07-25 13:40:35 +02:00
include::../rspectator.adoc[]