AA1100 - Interface Properties Should Be Read-Only
Report code: AA1100-InterfacePropertiesShouldBeReadOnly
Summary
Status | Implemented |
Description | To provide encapsulation, properties should only make getters publicly available, so interfaces should not define setters for properties. |
Category | Encapsulation Analyzers |
Enabled by default: | Yes |
Severity: | Error |
Cause
Interface properties should not have setters. Doing so forces implemnting classes to have public setters on those properties and so they become mutable from any other point in the code that has access to the object instance, making it much harder to track changes to the object’s state.
How to fix violations
There currently aren’t any implemented code-fixes for this rule.
How to suppress violations
This rule can be suppressed using the following attributes:
[MutableProperty]
A public setter may sometimes be required. It is therefore allowed if decorated with the MutableProperty attribute as it explicitly asserts the need for the property to be mutable.