Avoid using TryGetList method for List access

Coordinator
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
Hello!

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
Coordinator
May 1, 2014 at 8:20 PM
Edited May 1, 2014 at 8:35 PM
This is my result:

Image

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:
Image

Use ReSharper Extension Manager to get it:
Image
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.