I\'ve been through a few questions over the network about this subject but I didn\'t find any answer for my question, or it\'s for another language or it doesn\'t answer totally
Is (explicit or not) useless code ignored by the compiler?
You can't easily determine it's useless, so the compiler can't either. The getter of TestRunTime.Length
can have side-effects, for example.
The background is that I maintain a lot of code (that I didn't write) and I was wondering if useless code should be a target
Before you refactor a piece of code, you have to verify what it does in order to be able to change it and say afterwards it still has the same result. Unit tests are a great way of doing this.