rspec/rules/S2357/csharp/rule.adoc

36 lines
541 B
Plaintext
Raw Normal View History

2020-06-30 12:48:07 +02:00
include::../description.adoc[]
== Noncompliant Code Example
----
public class Foo
{
public int MagicNumber = 42;
}
----
== Compliant Solution
----
public class Foo
{
public int MagicNumber
{
get { return 42; }
}
}
----
or
2020-06-30 12:48:07 +02:00
----
public class Foo
{
private int MagicNumber = 42;
}
----
== Exceptions
2021-01-27 13:42:22 +01:00
``++struct++``s are ignored, as are ``++stati{cpp}`` and ``++const++`` fields in classes.
Further, an issue is only raised when the real accessibility is ``++publi{cpp}``, taking into account the class accessibility.