Avoid using TryGetList method for List access

Apr 29, 2014 at 9:06 PM
Edited May 1, 2014 at 8:22 PM
Here is a place to discuss about rule.
Old discussion is here.
Apr 30, 2014 at 7:28 PM
Edited Apr 30, 2014 at 7:45 PM

I've uploaded project.
Here is a link.

Waiting for results at your environment.

Thanks in advance!

I also tried to run test at web with 30000 lists, but gap is the same (10-100).

For the SPList at the beginning of SPLists list:
Test 01: Lists 28966    TryGetList      List found      00:00:00.0012878
Test 02: Lists 28966    GetList(Url)    List found      00:00:00.0183808
At the end:
Test 01: Lists 28966    TryGetList      List found      00:00:00.0069378
Test 02: Lists 28966    GetList(Url)    List found      00:00:00.0233184
May 1, 2014 at 8:20 PM
Edited May 1, 2014 at 8:35 PM
This is my result:


But if you check the rule help page you will see that we avoid using TryGetList method for other reason: becasue List name is culture specific string or could be changed later.

But thank you for investigation. You've made an awesome work.

BTW. This a first rule we've ported to ReSharper tool. You can download and use it in your VS as free.

Validated cases:

Use ReSharper Extension Manager to get it:
Marked as answer by dvd73 on 5/3/2014 at 11:49 AM
May 3, 2014 at 7:44 AM
Thanks for the answer.

Yes, I know other restrictions of TryGetList (rename, culture-specific). But in some cases it is much more appropriate.

Thanks for the plugin, I'll try it.
Jan 23 at 10:10 AM
Hello! I’m representative of SerfCompany. Our scope of work is Mobile Development, Web Development, Custom Software Development, Automatisation and robot-applications
We use B2C (business to customer) and B2B (business to business) models.