10 lines
738 B
Plaintext
10 lines
738 B
Plaintext
== Why is this an issue?
|
|
|
|
Most developers expect property access to be as efficient as field access. However, if a property returns a copy of an array or collection, it will be much slower than a simple field access, contrary to the caller's likely expectations. Therefore, such properties should be refactored into methods so that callers are not surprised by the unexpectedly poor performance.
|
|
|
|
This rule tracks calls to the following methods inside properties:
|
|
|
|
* https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.tolist[Enumerable.ToList]
|
|
* https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.toarray[Enumerable.ToArray]
|
|
* https://learn.microsoft.com/en-us/dotnet/api/system.array.clone[Array.Clone]
|