Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is ImmutableArray?

Why does ImmutableArray seem to not be there in Microsoft Immutable Collections NuGet package version 1.0.34?

enter image description here

like image 648
thomius Avatar asked Mar 26 '15 07:03

thomius


1 Answers

ImmutableArray is not present in your version of the library.

As you can see in the version history, the release notes for 1.1.20 mention "Re-included ImmutableArray<T>"

You can find the explanation for why ImmutableArray was absent from the 1.0 version on the .NET blog, in this announcement. (In short - the Roslyn team had a noticeable performance hit when they tried to use that type instead of regular arrays, and the team in charge of the library was not sure how to fix that, while keeping a reasonable API.)

You will find newer versions of the library under its new NuGet package, System.Collections.Immutable.

N.B.: According to the source code in the new versions of System.Collections.Immutable, they have apparently decided to take the API hit - that is, some operations on a unitialized ImmutableArray will throw a surprising NullReferenceExceptions. Clearly, ImmutableArray should never be instantiated with new. (ImmutableArray<T>.Empty should be used instead)

like image 63
Jean Hominal Avatar answered Sep 28 '22 10:09

Jean Hominal