rspec/rules/S2333/csharp/rule.adoc

64 lines
1.2 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2020-06-30 12:48:07 +02:00
Unnecessary keywords simply clutter the code and should be removed. Specifically:
2021-01-27 13:42:22 +01:00
* ``++partial++`` on type declarations that are completely defined in one place
* ``++sealed++`` on members of ``++sealed++`` classes
* ``++unsafe++`` method or block inside construct already marked with ``++unsafe++``, or when there are no ``++unsafe++`` constructs in the block
* ``++checked++`` and ``++unchecked++`` blocks with no integral-type arithmetic operations
2020-06-30 12:48:07 +02:00
=== Noncompliant code example
2020-06-30 12:48:07 +02:00
2022-02-04 17:28:24 +01:00
[source,csharp]
2020-06-30 12:48:07 +02:00
----
public partial class MyClass // Noncompliant
{
public virtual void Method()
{
}
}
public sealed class MyOtherClass : MyClass
{
public sealed override void Method() // Noncompliant
{
}
}
----
=== Compliant solution
2020-06-30 12:48:07 +02:00
2022-02-04 17:28:24 +01:00
[source,csharp]
2020-06-30 12:48:07 +02:00
----
public class MyClass
{
public virtual void Method()
{
}
}
public sealed class MyOtherClass : MyClass
{
public override void Method()
{
}
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
include::highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]