Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-24628] Windows: Hyperloop Collections support with Generics

GitHub Issuen/a
TypeImprovement
PriorityMedium
StatusClosed
ResolutionDuplicate
Resolution Date2017-04-27T08:33:31.000+0000
Affected Version/sHyperloop 2.1.0
Fix Version/sn/a
ComponentsWindows
Labelshyperloop
ReporterKota Iguchi
AssigneeKota Iguchi
Created2017-04-26T04:05:19.000+0000
Updated2017-04-27T08:33:31.000+0000

Description

On Hyperloop Windows, there's no way to handle collections with generics like IList<int>.
Platform::Collections::Vector<int>^ vec = ref new Platform::Collections::Vector<int>();
vec->Append(1);
vec->Append(2);
System.Collections.Generic.List<int> vec = new System.Collections.Generic.List<int>();
vec.Add(1);
vec.Add(2);

Comments

  1. Hans Knöchel 2017-04-26

    You have an idea about the syntax? iOS doesn't support generics as well, but I'm wondering how we would map those.
  2. Kota Iguchi 2017-04-27

    Syntax-wise, It turns out we can create generic instance work by just specifying generic parameter in require.
       var List = require('System.Collections.Generic.List<int>');
       var vec = new List();
       
    But then vec.Add(123); fails now. So this ticket is for following issue. This might be a type conversion issue that is not related to generic type. We might want to change ticket description then.
       System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> 
       System.ArgumentException: The value "123" is not of type "System.Int32" and cannot be used in this generic collection.
       Parameter name: value
          at System.ThrowHelper.ThrowWrongValueTypeArgumentException(Object value, Type targetType)
          at System.Collections.Generic.List`1.System.Collections.IList.Add(Object item)
       
  3. Kota Iguchi 2017-04-27

    ok, confirmed that we already support this by TIMOB-24637 using cast. So I would close this.
       var List = require('System.Collections.Generic.List<System.Int32>'),
           Int32 = require('System.Int32');
       
       var vec = new List();
       vec.Add(Int32.cast(1));
       vec.Add(Int32.cast(2));
       vec.Add(Int32.cast(3));
       
       alert(vec.Count);
       

JSON Source