rspec/rules/S2357/csharp/rule.adoc
2022-02-04 16:28:24 +00:00

55 lines
841 B
Plaintext

include::../description.adoc[]
== Noncompliant Code Example
[source,csharp]
----
public class Foo
{
public int MagicNumber = 42;
}
----
== Compliant Solution
[source,csharp]
----
public class Foo
{
public int MagicNumber
{
get { return 42; }
}
}
----
or
[source,csharp]
----
public class Foo
{
private int MagicNumber = 42;
}
----
== Exceptions
``++struct++``s are ignored, as are ``++static++`` and ``++const++`` fields in classes.
Further, an issue is only raised when the real accessibility is ``++public++``, taking into account the class accessibility.
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]