rspec/rules/S4052/csharp/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

63 lines
1.4 KiB
Plaintext

== Why is this an issue?
With the advent of .NET framework version 2, certain practices have become obsolete.
In particular, exceptions should now extend ``++System.Exception++`` instead of ``++System.ApplicationException++``. Similarly, generic collections should be used instead of the older, non-generic, ones. Finally when creating an XML view, you should not extend ``++System.Xml.XmlDocument++``.
This rule raises an issue when an externally visible type extends one of these types:
* ``++System.ApplicationException++``
* ``++System.Xml.XmlDocument++``
* ``++System.Collections.CollectionBase++``
* ``++System.Collections.DictionaryBase++``
* ``++System.Collections.Queue++``
* ``++System.Collections.ReadOnlyCollectionBase++``
* ``++System.Collections.SortedList++``
* ``++System.Collections.Stack++``
=== Noncompliant code example
[source,csharp]
----
using System;
using System.Collections;
namespace MyLibrary
{
public class MyCollection : CollectionBase // Noncompliant
{
}
}
----
=== Compliant solution
[source,csharp]
----
using System;
using System.Collections;
namespace MyLibrary
{
public class MyCollection : Collection<T>
{
}
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Refactor this type not to derive from an outdated type '{0}'.
endif::env-github,rspecator-view[]