When working with my .Net 2.0 code base ReSharper continually recommends applying the latest c# 3.0 language features, most notably; convert simple properties into auto-implement properties or declaring local variables as var. Amongst others.
When a new language feature arrives do you go back and religiously apply it across your existing code base or do you leave the code as originally written accepting that if new code is written using new language features there will be inconsistencies across your code?
If it ain’t broke, don’t fix it. Of course, if you have confidence in your unit tests, you can give it a whirl, but you shouldn’t really go randomly changing code ‘just because’.
Of course – in some cases, simplifying code is a valid reason to make a change – but even something as innocent as switching to an auto-implemented property could break code that makes assumptions and uses reflection to update the fields directly. Or it could break serialization.
Changing to ‘var’ can actually give you a different (more specific) type, which might cause a different method overload to get selected, etc.
So again; it comes down to your confidence in the unit tests.
Other considerations:
If neither of these are an issue, you should be OK to use the new features in new code… just be a little cautious before hitting ‘update all’ on old code…
Here’s a trivial example of ‘var’ as a breaking change:
Now switch to
var readeron the line marked[HERE]…