Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net framework version in Silverlight: no List<T>.Find methods?

Today I discovered something that makes me sad: objects of type System.Generic.Collections.List don't have a number of the useful extension methods I've come to love, such as Find, FindAll, FindIndex, Exists, RemoveAll, etc.

The object browser in VS2008 shows that those methods exist in the mscorlib version I'm using, but if I look at the assembly in ildasm they're not there.

Am I missing something obvious here or is there some way to make them available to my Silverlight app?

Also, I wonder if there's a good reference out there for what's different between Silverlight's runtime and the "real" one.

Thanks!

like image 900
mmacaulay Avatar asked Mar 02 '23 03:03

mmacaulay


2 Answers

What's likely happening here is that Object Browser is resolving to the normal 2.0 mscorlib instead of the version that is used for silverlight.

I don't find it suprising that the Find extension method is missing for a SilverLight app. The .Net framework for SilverLight is stripped down pretty far in order to make it small enough to be a speedy download for users. They had to make some hard cuts and many items didn't make it.

If you need the method though, why not just add it yourself? Adding all of them may get tiring after awhile but it can be used to work around this issue.

like image 131
JaredPar Avatar answered Mar 15 '23 13:03

JaredPar


Just one quick point: Find isn't an extension method. It's a perfectly normal instance method.

However, it doesn't entirely surprise me that there are bits "missing" from List<T> in Silverlight. It is a cut-down version of the framework. Unfortunately I don't know of any resource to say what's in and what's out.

like image 40
Jon Skeet Avatar answered Mar 15 '23 13:03

Jon Skeet