All rules
CA1044Design Enabled by default: No

Properties should not be write only

Properties should not be write only

Microsoft docs

Description

Get accessors provide read access to a property and set accessors provide write access. Although it is acceptable and often necessary to have a read-only property, the design guidelines prohibit the use of write-only properties. This is because letting a user set a value and then preventing the user from viewing the value does not provide any security. Also, without read access, the state of shared objects cannot be viewed, which limits their usefulness.

Cause

A property has a set accessor but not a get accessor.

By default, this rule only looks at externally visible types, but this is configurable.

How to fix violations

To fix a violation of this rule, add a get accessor to the property. Alternatively, if the behavior of a write-only property is necessary, consider converting this property to a method.

When to suppress

It's recommended that you don't suppress warnings from this rule.

Group results
0 yes 0 no
ConsensusNone (disabled)
Severity preference (yes voters)
Suggestion0
Warning0
Error0