All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.plugins.vbnet.S2357.html Maven / Gradle / Ivy

There is a newer version: 10.5.0.109200
Show newest version

Why is this an issue?

Fields should not be part of an API, and therefore should always be private. Indeed, they cannot be added to an interface for instance, and validation cannot be added later on without breaking backward compatibility. Instead, developers should encapsulate their fields into properties. Explicit property getters and setters can be introduced for validation purposes or to smooth the transition to a newer system.

Noncompliant code example

Class Foo
    Public Foo = 42          ' Noncompliant
End Class

Compliant solution

Class Foo
    Public Property Foo = 42 ' Compliant
End Class

Exceptions

Shared and Const fields are ignored.





© 2015 - 2025 Weber Informatics LLC | Privacy Policy