JetBrains Rider 2026.1 Help

Code inspection: Struct member can be made readonly

This inspection reports an instance member of a struct that does not mutate the struct and can therefore be marked readonly. Adding readonly makes the member's intent explicit and can avoid defensive copies when the struct is used through readonly references.

Example

struct Counter { private int _value; public int GetValue() { return _value; } }
struct Counter { private int _value; public readonly int GetValue() { return _value; } }

Quick-fix

Add the readonly modifier to the struct member.

29 March 2026