roslynator icon indicating copy to clipboard operation
roslynator copied to clipboard

RCS1231 can cause perf implications and should probably be avoided in most scenarios when the struct is small

Open prezaei opened this issue 1 year ago • 6 comments
trafficstars

I wouldn't enable this rule, at least not unless all the readonly structs are massive. It seems like the intent is to avoid costs associated with copying of structs, but passing by reference then means that all accesses are indirections, which has its own costs.

prezaei avatar Aug 11 '24 17:08 prezaei

This analyzer is not enabled by default.

josefpihrt avatar Aug 12 '24 19:08 josefpihrt

This analyzer is not enabled by default.

Correct. But is it even safe to enable?

prezaei avatar Aug 13 '24 02:08 prezaei

So you are suggesting to simply remove it completely. Ok, but generally it could be a problem because it's a breaking change. Some can then complain that it was removed.

josefpihrt avatar Aug 13 '24 20:08 josefpihrt

So you are suggesting to simply remove it completely. Ok, but generally it could be a problem because it's a breaking change. Some can then complain that it was removed.

Thank you. Yes, I was proposing that it should be deprecated. I believe you have other deprecated rules already.

Btw, I absolutely love what you have done with this library. Simply put: it is a work of art. Thank you

prezaei avatar Aug 14 '24 03:08 prezaei

Btw, I absolutely love what you have done with this library. Simply put: it is a work of art. Thank you

Thank you very much! ❤️

josefpihrt avatar Aug 14 '24 20:08 josefpihrt

This lint is useful in performance critical code, where it can be manually enabled with a pragma, for example. 👍🏻

BenjaminBrienen avatar May 01 '25 20:05 BenjaminBrienen