Language-ext: Getting LanguageExt.Core to work with Unity

Created on 6 Jan 2018  Â·  18Comments  Â·  Source: louthy/language-ext

I found this while looking for functional libraries to use with Unity, and stumbled upon this, which seems to answer all my prayers.
Unfortunately Unity only supports .NET 4.6 which according to Unity is equivalent to C# 6, which means there are a bunch of features used that won't compile.
Is there any way to get the code to work with C# 6? Or can I somehow use a prebuilt DLL instead? Currently I just imported all of LanguageExt.Core into my project, and it complains about tons of files.
When looking at the errors using (csharp-omnisharp-codecheck) in emacs I'm informed that local functions aren't available in C# 6.

Are there any reasonable ways to solve this?

EDIT:

This is the way to do it

This library seems compatible on the latest (at the time of writing) Unity 2018.2 with incremental compiler (which enables C# 7). So this library should work well once Unity has official support for C# 7 on upcoming 2018.3. In the meanwhile, you can install incremental compiler instead.

examples / documentation

Most helpful comment

This library seems compatible on the latest unity 2018.2 with incremental compiler (which enable c# 7).
So I guess this library will work well once unity has officially support c# 7 on upcoming 2018.3.
In the meanwhile, you can install incremental compiler instead. But I just use limited function of this library without any test on il2cpp or mobile, so at your own risk.

All 18 comments

@Saikyun The nu-get packages contain DLLs for .NET 4.5.1 - they should work on any .NET 4.6 compatible system too. Have you tried those?

I have not! The thing is I'm sitting on OSX so I'm not sure about how to
import DLLs, but I'll google around a bit and get back when I've figured
out how Unity/Mono deals with DLLs outside Windows.

Den 6 jan. 2018 4:24 em skrev "Paul Louth" notifications@github.com:

@Saikyun https://github.com/saikyun The nu-get packages contain DLLs
for .NET 4.5.1 - they should work on any .NET 4.6 compatible system too.
Have you tried those?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/louthy/language-ext/issues/340#issuecomment-355753795,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACXPZ8YS8DedsPh2sgPjwkGC-E1bsAc0ks5tH5AegaJpZM4RVUuq
.

I don't think you have to do anything special. Just have the exe and DLLs in the same arrangement that you would in Windows and then run the exe with mono.

I'm getting the following error, and I'm not finding anything that helps when I'm googling:

error CS0009: Metadata file '.../Assets/LanguageExt.Core.dll' does not contain valid metadata
Compilation failed: 1 error(s), 0 warnings

Any ideas...? :)

Why is the DLL in a folder called Assets? Did you add language-ext as a dependency via NuGet? Are you compiling in Windows or somewhere else?

Oh, it's how Unity does it. :) You just pull DLLs into the Unity project.

2018-01-07 15:18 GMT+01:00 bender2k14 notifications@github.com:

Why is the DLL in a folder called Assets? Did you add language-ext as a
dependency via NuGet? Are you compiling in Windows or somewhere else?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/louthy/language-ext/issues/340#issuecomment-355825763,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACXPZ98devNT7IcYjcFY8d1QJh9HgaKjks5tINIjgaJpZM4RVUuq
.

Currently I'm using OSX, and it's Unity that does the compiling, using Mono.

2018-01-07 15:19 GMT+01:00 Jona Ekenberg saikyun@gmail.com:

Oh, it's how Unity does it. :) You just pull DLLs into the Unity project.

2018-01-07 15:18 GMT+01:00 bender2k14 notifications@github.com:

Why is the DLL in a folder called Assets? Did you add language-ext as a
dependency via NuGet? Are you compiling in Windows or somewhere else?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/louthy/language-ext/issues/340#issuecomment-355825763,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACXPZ98devNT7IcYjcFY8d1QJh9HgaKjks5tINIjgaJpZM4RVUuq
.

I have similar issue. I have manually downloaded binaries from nuget and moved them to the asset folder (only the dll). I am getting:

Assets/OptionTest.cs(4,7): error CS0246: The type or namespace name `LanguageExt' could not be found. Are you missing an assembly reference?

I have tried both dlls, both behave exactly the same way. I have added a reference in IDE (using Rider) and in IDE it looks fine. I have no clue if this is a problem with this library or with Unity (I don't have much experience with .NET ecosystem, going back to C# world after several years working in JS/TS/Scala). I am trying it on Kubuntu 16.04. Is this library Mono compatible?

I have been using it with Mono without any problems.

After switching player configuration to use newer Mono (it says ".NET 4.x equivalent"), I am getting same error as @Saikyun :disappointed:.

error CS0009: Metadata file `/mnt/xxx/unity/test03/test03-lang-ext/Assets/LanguageExt.Core.dll' does not contain valid metadata

I'll try posting this issue to some Unity forum, since it works with Mono, the issue seems to be on the Unity side. Thank you for your assistance.

Just got bitten by this D:
Since I'm neither a Unity nor a C# expert I am stuck here...

@sne11ius The library isn't built for Unity. I am not aware of the restrictions of Unity and therefore won't be spending any time looking into it. It would make more sense to find answers on Unity forums or to find someone who understands the issues that Unity has in building lang-ext. If, as implied in the first question, Unity is still only C# 6 compliant then you're right out of luck - as I am not willing to compromise this project to support the legacy language, sorry. If the binaries (DLLs) are incompatible with Unity projects, that's a Unity issue.

When @mnn askes "I have no clue if this is a problem with this library or with Unity" - I can quite easily confirm: it's Unity that's the problem. This project builds and links when used with the official C# compiler, runtime, and framework.

I am not willing to compromise this project to support the legacy language, sorry.

I completely understand. But to be clear - it is not legacy, Unity uses Mono which seems to be the only multiplatform solution for .NET platform. So this is not that much about Unity, but rather about multiplaform support. Or I might be wrong (don't know much about .NET world) and official build tools do support Linux, Mac, PS4, Switch and other platforms Unity can run on?

Unity does run a modified version of Mono though, so it's not that simple
either. :/

Den mån 28 maj 2018 20:28monnef notifications@github.com skrev:

I am not willing to compromise this project to support the legacy
language, sorry.

I completely understand. But to be clear - it is not legacy, Unity uses
Mono which seems to be the only multiplatform solution for .NET platform.
So this is not that much about Unity, but rather about multiplaform
support. Or I might be wrong (don't know much about .NET world) and
official build tools do support Linux, Mac, PS4, Switch and other platforms
Unity can run on?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/louthy/language-ext/issues/340#issuecomment-392583181,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACXPZ3quEGJX9_Zg1ODYIcjeyzGjCNQ3ks5t3EHegaJpZM4RVUuq
.

Unity uses Mono which seems to be the only multiplatform solution for .NET platform.

There is also .Net Core.

Unity does run a modified version of Mono though, so it's not that simple either. :/

I saw people were able to get this library running when it was written in older C#. Is there anything suggesting that it won't run with Unity's Mono if/when C# version is supported by both?

There is also .Net Core.

It doesn't seem that it supports (or at least officially) everything Unity runs on. From https://github.com/dotnet/core/blob/master/release-notes/2.1/2.1-supported-os.md I would say that all consoles and even Android devices are unsupported by .NET core.

This library seems compatible on the latest unity 2018.2 with incremental compiler (which enable c# 7).
So I guess this library will work well once unity has officially support c# 7 on upcoming 2018.3.
In the meanwhile, you can install incremental compiler instead. But I just use limited function of this library without any test on il2cpp or mobile, so at your own risk.

@quabug Thanks for the update, that's very useful. I have added a slightly reworded version of your comment to the home page.

Was this page helpful?
0 / 5 - 0 ratings