I have a class that needs a generic indexer, however script# doesn’t compile this.
[Imported]
public class SomeCollection<T>
{
[IntrinsicProperty]
public T this[int index]
{
get { return null; }
set { }
}
}
I want the ‘SomeCollection’ class to be a javascript Array when script# compiles it down. I only want this class + indexer with generics to make it easier when I write c# to get proper intellisense for objects.
How do I get script# to compile the above?
For now you’ll have to write the above class in an import library, i.e. it is not just an imported type, but a type that isn’t compiled by script#. Instead it is only compiled by the c# compiler, and script# simply imports the type definitions.
That said, why not just use List<T>, or T[]? Is it because you only want an indexer and no other methods?