List(of T) should not be exposed on a public interface…

I ran some code analysis on my audio streaming solution today and learned something new:

There is a recommendation within the code analysis engine that looks for cases where the List(of T) type is exposed as a public property or on a public method of a class. The recommendation is to use something like System.Collections.ObjectModel.Collection(of T) instead.

This seemed kind of strange to me, so I looked into it a bit. Here an article from the code analysis team blog that explains the rational:

I’m still looking into this a bit. There may be consequences to completely cutting over to Collection(of T) that we don’t know yet, so I won’t go rewrite things yet. But, I’m going to consider using Collection(of T) instead of List(of T) when passing data over the public interface of a class (or web service).

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at

Up ↑

%d bloggers like this: