Search Unity

[RELEASED] LINQ to iOS

Discussion in 'Assets and Asset Store' started by Visartech, Oct 15, 2014.

  1. Visartech

    Visartech

    Joined:
    Aug 10, 2012
    Posts:
    27
    I would like to present you LINQ to iOS. If you've ever tried using LINQ to Objects in C# you know how convenient it is. However, when running on iOS it often crashes due to JIT-compile errors.

    LINQ to iOS is an easy way to use LINQ to Objects in your Unity3D iOS games.

    Website | Asset Store

    Features:
    Same API as in Microsoft .NET LINQ
    All the same convenient extension methods and operations you are accustomed to! We have implemented all 176 methods from .NET LINQ Enumerable class including Select, Where, OrderBy, ThenBy, All, Any and many others. All class and method definitions are the same as in LINQ to Objects.

    Exactly same behaviour even in non-trivial cases
    LINQ to iOS works like Microsoft .NET LINQ even in complex situations. It throws same exceptions when wrong parameters are passed and supports complex features such as deferred execution. So, all your previous code using LINQ will work fine with LINQ to iOS.

    Works flawlessly on any platform including iOS
    LINQ to iOS is well-tested on both mobile and desktop platforms. It causes no errors or crashes on any of them. Having problems with JIT-compile errors on iOS? Now you can solve them with LINQ to iOS!

    Compatible with Unity3D 4.x
    LINQ to iOS is well tested and supports Unity3D from v. 4.0.0 to the latest version. Every method is covered with numerous unit-tests included into the project that help us identify the problems and fix them quickly. In case if you encounter any problems we guarantee you quick responsive support and free updates.

    Just feel free to use LINQ now on any Unity3D platform!
     
    Last edited: Jan 13, 2015
  2. Visartech

    Visartech

    Joined:
    Aug 10, 2012
    Posts:
    27
    LINQ to iOS v.1.2 is now available on Asset Store.

    What's new in LINQ to iOS v.1.2:
    • Fixed "Error: Invalid character in input" error in XCode projects built with Unity 3D for Windows.
    • Removed tests that were not run since they were often misinterpreted as failed tests.
    • Test scene doesn't require Unity Pro to run anymore.
     
    Last edited: Oct 25, 2014
  3. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,433
    @alandyshev

    Your plugin looks awesome, do you think it will fix the following issue found in Linq.Expressions when I am running my project on an iOS device?

    ExecutionEngineException: Attempting to JIT compile method '(wrapper managed-to-managed) System.Linq.Expressions.ExpressionType[]:System.Collections.Generic.IEnumerable`1.GetEnumerator ()' while running with --aot-only at System.Linq.Enumerable.Any[ExpressionType] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0 at Linq2Rest.Provider.ExpressionWriter.WriteBinaryExpression (System.Linq.Expressions.Expression expression, System.Linq.Expressions.ParameterExpression rootParameterName) [0x000b5] in /Users/gregquinn/Documents/FlipTheChip/Assets/Scripts/Azure/OData/ExpressionWriter.cs:465

    You can have a look at ExpressionWriter.cs here

    Thanks
     
  4. Visartech

    Visartech

    Joined:
    Aug 10, 2012
    Posts:
    27
    @Meltdown

    Thanks for your interest. However the Expressions are not implemented in Linq to iOS at the moment. It implements only IEnumerable extension methods that are defined in System.Linq.Enumerable class.
     
  5. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,433
    Is it still worth a shot trying your plugin to see if it fixes it? Would you be willing to provide a refund if it doesn't?
     
  6. Visartech

    Visartech

    Joined:
    Aug 10, 2012
    Posts:
    27
    It definitely won't fix that issue. It doesn't fix System.Linq methods. It replaces them with the other implementations of same methods. In order to replace the methods from System.Linq with the new ones you need to change using System.Linq; to using LinqTools; in your code.

    However there are no Expression classes in LinqTools namespace. You need to use System.Linq.Expressions namespace. And inside Expression classes there's a using System.Linq line, not using LinqTools. So Linq to iOS plugin won't help you fix that issue. The only thing you can do is to write your own Expression classes to replace the implementation inside Linq.Expressions namespace. In that case my plugin can help you.
     
  7. jmcclure

    jmcclure

    Joined:
    May 5, 2009
    Posts:
    48
    Does LINQ to iOS work with Unity 5? How does the performance stack up against the native LINQ implementations?
     
  8. Visartech

    Visartech

    Joined:
    Aug 10, 2012
    Posts:
    27
    @jmcclure
    LINQ to iOS works on Unity 5 with Mono compiler. When using IL2CPP the unit tests engine is not working. So it's not tested with IL2CPP.
     
  9. Emirk

    Emirk

    Joined:
    Nov 26, 2012
    Posts:
    13
    I've had some crashes when building for IL2CPP and a couple of hours later I suspected it was because of LinqTools. Deleted LinqTools, compiled again, and everything works. Would be great if you could make sure LinqTools works with IL2CPP.
     
    ridil likes this.
  10. ID_GMS

    ID_GMS

    Joined:
    Feb 24, 2015
    Posts:
    1
    At first Linq to iOS is a great plugin. But i've a problem using the Any Method. In my camera code following exception is thrown:

    ExecutionEngineException: Attempting to JIT compile method '(wrapper managed-to-managed) UnityEngine.RaycastHit2D[]:System.Collections.Generic.IEnumerable`1.GetEnumerator ()' while running with --aot-only.
    at LinqTools.Enumerable.Any[RaycastHit2D] (IEnumerable`1 source, System.Func`2 predicate) [0x00000] in <filename unknown>:0
    at TouchCameraController.HandleInputExit (UnityEngine.RaycastHit2D[] hitObjects) [0x00000] in <filename unknown>:0
    at TouchCameraController.Update () [0x00000] in <filename unknown>:0


    The code causing this:

    Code (CSharp):
    1. if (!hitObjects.Any(h => h.transform.gameObject.GetInstanceID() == oldHitObject.transform.gameObject.GetInstanceID()))
    2. {
    3. oldHitObject.transform.gameObject.SendMessage("InputExit", options: SendMessageOptions.DontRequireReceiver);
    4. }
    Hope you can help me with this issue.
     
  11. Railon23

    Railon23

    Joined:
    Jan 30, 2014
    Posts:
    22
    @alandyshev did you see the latest review?
    Title: "Needs to be updated to support IL2CPP or its completely useless!"

    So this asset doesn't work right now on iOS?
     
  12. mossyblog

    mossyblog

    Joined:
    Jun 29, 2013
    Posts:
    16
    I'm not convinced this is fit for fit with LINQ in C# in that for example can you do DynamicInvoke, Invoke or Compile? using the same as LINQ for .NET? Can you confirm that this re-routes the JIT into AOT compliance?

    Also as the former Product Manager of .NET (and the one who launched that logo) i'd give a friendly caution to you about using the .NET logo in your branding, as the branding folk in the company tend to get a bit snippy about that sort of thing (That and since it was a logo i launched as well).

    Thx in advance
    Scott Barnes.
     
  13. Visartech

    Visartech

    Joined:
    Aug 10, 2012
    Posts:
    27
    Hi.

    Starting with Unity 5.2 unit-tests started working on iOS again. So we managed to test the plugin.
    11 failures and 1 error occur in 663 tests, in the following methods:
    Cast, Except, GroupBy, Intersect, Join, Reverse, ToArray, ToList.

    We're going to fix those errors and failures and I'll inform about the progress here.

    @mossyblog This is not fit to fit with LINQ in C#. It's missing some functionality. But this plugin implements all the methods from IEnumerable interface in a way that doesn't cause errors on iOS. And it implements those methods so that they behave exactly the same as in LINQ: with deferred execution, same exceptions, etc. At least it works this way with Mono compiler. For now it causes errors when IL2CPP compiler is used.
     
  14. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,233
    @alandyshev

    If possible, can you submit a bug report for the case which works with Mono and not with IL2CPP? This should not occur, and we would like to correct it.
     
  15. mossyblog

    mossyblog

    Joined:
    Jun 29, 2013
    Posts:
    16
    Yeah i'm with @JoshPeterson none of these occur from where i'm at - i'll do some more tests to see if i can zero in on them maybe. The only dangerous areas within LINQ is when you use the Invoke/Compile which are JIT specific and ideally there's a mapping issue from Unity to XCODE during that transpiling phase (which i'm hoping the special minds who do that body of work can reconcile for us all as without it makes JSON serializations overly complex or creates a reduction in LINQ beauty within the codebase as you're having to make defensive plays - dumbing code down).
     
  16. mossyblog

    mossyblog

    Joined:
    Jun 29, 2013
    Posts:
    16
    I've isolated a point of failure as well.. turns out if you use PropertyInfo GetValue in Mono AOT craps the bed. If however you use Mono Subset its fine? ....that has to be a bug.
     
  17. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,233
    @mossyblog

    There is a bad code path for AOT in the Mono class libraries in the full .NET 2.0 profile. This was corrected in 5.2.4 and 5.3.1p1. If you're seeing this problem, then one of these versions should correct it. Otherwise, I'm interested to know the managed call stack you see in the exception (if you see one), as we might have something else to correct for AOT.
     
  18. mossyblog

    mossyblog

    Joined:
    Jun 29, 2013
    Posts:
    16
    The error we commonly see is the InvokeAttribute error. We couldn't resolve it any of the above versions until we went Subset.. and it seems to us that Subset would be the better option anyway? as we looked through the comparison matrix and there seems to be an awful lot of excess features in "Full" vs "Subset". Curious to see why Subset isn't a default option given that use case (or did i miss something).

    We're using FullSerializer as a way to serialize JSON, and it turns out that something within the serialization process trips the Invoke AOT vs JIT errors. It centred around PropertyInfo and GetValue as being the culprit and no matter what tests I would write it would eventually throw the error at runtime (post XCODE copy/deploy phase).

    Yet once you revert back to Subset, problem self-corrects... I'll see if i can splice the code a bit to give a standalone test for you to use in the bug hunt.
     
  19. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,233
    @mossyblog

    Thanks for the information. We use the full profile by default instead of the subset profile because many third-party assemblies developers use require the full profile. So making that the default helps to head off some problems that are often difficult to debug.

    If you can come up with a standalone project that reproduces the error I would love to have a look at it and see if we can make this work with the full profile as well. Thanks!
     
  20. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,524
    I am really interested in this plugin and wondering if any progress has been made to work well in aot/ unity 5.3 combination? i am hoping to be able to use this on xboxone.. which i am hoping it behave similarly to ios.
     
  21. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,524
    Just bought the asset , crossing my fingers, but it doesn't work... in fact, it works even less successful than System.linq :( :(

    Anyone help? I am willing to pay $ for converting some part of code into non linq way...
     
unityunity