I'm just curious if there is a good reason to write such code ever
Depending on how you look, unfortunately, yes, there is. Since the identifier that we are talking about is a property, assigning a property to a property sounds inactive, but actually calls methods, a getter and setter, and these methods can have side effects.
A special case, which is very common, is when the installer does something like a property notification or calls an observer, but anything can happen when you call either the receiver or the installer. This is why code does not generate a warning: because this coding style is really useful and used in working code.
Edit:
For comparison, if the identifier is a field and not a property, it generates this warning:
warning CS1717: assignment to the same variable; Did you want to assign something else?
source share