C#

C#

Made by DeepSource

Properties should not return arrays as they are not write protected CS-W1096

Bug risk
Critical

Accessors, i.e. getters to be precise, returns a specific value. There are no constraints placed on what a getter can return. However, in this case, the accessor seems to return an array that is a private field. In such cases, the returned array may be modified by the user as they are not write-protected. Instead, it is recommended that you either not return an array or convert this property to a method and return a copy instead.

Bad Practice

public int[] Buffer => _arr;

Recommended

public int[] GetBuffer() => (int[]) _arr.Clone();

References