We have a very old code base(that actually is not horrible quality). It dates back to when .Net was pre-release, which I suspect is the cause of some of these weird conventions.
Anyway, we just began to drop .Net 1.1 support and are having a hay-day with converting things to generics and using Linq and all that fun stuff. One of the most annoying patterns in our code base though is we'll have something like
private ArrayList mylist;
public IEnumerator MyList
{
get
{
if(mylist==null)
return new EmptyEnumerator.Enumerator;
return mylist.GetEnumerator();
}
}
This pattern is particularly horrible because it prevents us from simply doing foreach(var item in MyList)
because IEnumerator doesn't implement IEnumerable. Instead we must do something like this:
IEnumerator enumerator=MyList;
while(enumerator.MoveNext())
{
object item=enumerator.Current;
}
So, for refactoring, we of course want to use something like ReadOnlyCollection<T>
or IList<T>
or similar. To do this however, we have to update every single reference to MyList
to do:
IEnumerator enumerator=MyList;
to
IEnumerator enumerator=MyList.GetEnumerator();
In some cases, we can have over a hundred references to one property. Are there any tools out there that can make this easier? We recently got Resharper(not for this issue, but just for general use), but it doesn't appear to cover this type of scenario.