[TIMOB-24628] Windows: Hyperloop Collections support with Generics
| GitHub Issue | n/a |
|---|---|
| Type | Improvement |
| Priority | Medium |
| Status | Closed |
| Resolution | Duplicate |
| Resolution Date | 2017-04-27T08:33:31.000+0000 |
| Affected Version/s | Hyperloop 2.1.0 |
| Fix Version/s | n/a |
| Components | Windows |
| Labels | hyperloop |
| Reporter | Kota Iguchi |
| Assignee | Kota Iguchi |
| Created | 2017-04-26T04:05:19.000+0000 |
| Updated | 2017-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);
You have an idea about the syntax? iOS doesn't support generics as well, but I'm wondering how we would map those.
Syntax-wise, It turns out we can create generic instance work by just specifying generic parameter in
require.But thenvar List = require('System.Collections.Generic.List<int>'); var vec = new List();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)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);