Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pre-release Collections.Immutable

Has anyone succeeded in opening the pre-release System.Collections.Immutable from NuGet in F#?

I'm getting this error:

The type 'IEnumerable`1' is required here and is unavailable. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Even though my project is .NET 4.5

Tried explicitly opening System.Runtime and that did not work either. I am referencing .NETCore\v4.5\System.Runtime.dll

like image 551
Jack Fox Avatar asked Dec 24 '12 04:12

Jack Fox


People also ask

Are collections immutable?

The collections returned by the convenience factory methods added in JDK 9 are conventionally immutable. Any attempt to add, set, or remove elements from these collections causes an UnsupportedOperationException to be thrown.

Are kotlin collections immutable?

4. Kotlin Collections. In Kotlin, all non-mutable collections, such as List, are compile-time read-only by default, and not immutable. While the defined interfaces do not support methods to change data within the collection, the underlying data can still be changed.

What is System collections immutable DLL?

NuGet Package System. Collections. Immutable. This package provides collections that are thread safe and guaranteed to never change their contents, also known as immutable collections. Like strings, any methods that perform modifications will not change the existing instance but instead return a new instance.

What is immutable collection c#?

Generally, when an instance of a type is described to be immutable, it means that its value never changes. Immutability, like many things in software engineering, is a design choice. You don't really have to use it, but in some scenarios, you can benefit from it in terms of code performance or understandability.


1 Answers

This is a known issue that the relevant teams at Microsoft are investigating. In the meantime, here are the workaround steps:

  1. Create an F# Application project that targets .NET Framework 4.5
  2. Install-Package Microsoft.Bcl.Immutable -pre
  3. Add a reference to "%ProgramFiles%\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\Facades\System.Runtime.dll"
  4. Add a reference to the System.ComponenModel.Composition.dll assembly from the Framework.

After that, early testing suggests F# works with the immutable collections just fine.

like image 184
Andrew Arnott Avatar answered Sep 27 '22 22:09

Andrew Arnott