Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Visual Studio replacing List<T>.Length with List<T>.Count?

I've noticed that if have a List<T> (or a few other types) and I press . then among the intellisense suggestions I get Length

enter image description here

If I select Length then what's actually typed is Count

enter image description here

I can see why this would happen, there's no Length property on a List<T> and if I'm looking for it I probably want Count. My question is, how does Visual Studio know to do this? I can't see anything in the List<T> class or anywhere else that encodes Length as an alias for Count.

like image 719
eoinmullan Avatar asked Dec 02 '15 10:12

eoinmullan


1 Answers

This is a ReSharper 10 feature.

It integrated the Postfix Templates plugin in this version, and this is one of the completions it supports (use the correct Length or Count property).

I'm excited to announce that this plugin is now integral part of ReSharper 10!

The project page states:

Length/Count code completion solves one of the most common mistypings when dealing with arrays or collections:

example

like image 90
Lucas Trzesniewski Avatar answered Oct 12 '22 22:10

Lucas Trzesniewski