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

53 lines
1.3 KiB
Plaintext

== Why is this an issue?
The difference between ``++private++`` and ``++protected++`` visibility is that child classes can see and use ``++protected++`` members, but they cannot see ``++private++`` ones. Since a ``++sealed++`` class cannot have children, marking its members ``++protected++`` is confusingly pointless.
=== Noncompliant code example
[source,csharp]
----
public sealed class MySealedClass
{
protected string name = "Fred"; // Noncompliant
protected void SetName(string name) // Noncompliant
{
// ...
}
}
----
=== Compliant solution
[source,csharp]
----
public sealed class MySealedClass
{
private string name = "Fred";
public void SetName(string name)
{
// ...
}
}
----
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)
=== on 21 Feb 2017, 16:32:27 Valeri Hristov wrote:
Removing the "static" part because the C# compiler generates an error if you try to add protected member in a static class. It does not generate error for sealed classes, so the rule still has value.
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]