Hello fellow coders. I have run across an infuriating issue. I am using System.Threading.Tasks in my project. I recently imported a new plugin (Google Firebase) which ships with it’s own dll (Unity.Tasks). Well, it seems like the geniuses at Google didn’t realize that Unity has full support of System.Threading.Tasks and decided to bundle that namespace with their dll. I cannot get rid of Unity.Tasks or it breaks Firebase. I cannot use an extern alias to reference mscorelib or I get errors stating that my code doesn’t return a Task<> (when it indeed did before I used the alias). I am at a loss of what I should do here. I would really like to use firebase as it is very easy to implement, but I also need to use Tasks in my project for asynchronous programming. Anybody have any bright ideas?
Note: I am using Unity 2020 beta 2 and .Net 4.0 with the IL2CPP backend. I have tried with .NET 2.0, mono backend, and Unity 2019.x. No success. Any and all help appreciated.
use Firebase tasks as Firebase.Task
use System tasks as System.Threading.Task
if you want to favor one task over the other, use i.e. using Task = System.Threading.Task;
or you can easily distinguish both if you just using FBTask = Firebase.Task; using SysTask = System.Threading.Task;
So unfortunately I have tried using aliases already. The problem is that they both use the same namespace in different assemblies. so systask referencing System.Threading.Tasks wouldn’t work because System.Threading.Tasks exists in 2 different dll’s (mscorelib AND Unity.Tasks).
One workaround that almost worked was defining an alias in the reference tab in Visual Studio. I then called extern alias above my using statements. However for some reason that changed the type that my Task was so I couldn’t use my async method
I was able to fix it. Sorry I have not answered. I uninstalled Firebase from my project and re-installed it using the Package Manager (with .NET set to 4.x). I can now use System.Threading.Tasks just fine with Firebase working as well. One thing to note is (for now) Firebase does not work on Android builds in the Unity 2020 beta. Just food for thought.