ClearScript / V8 should support lists implementing IReadOnlyList<T> but not IList<T>
Use case
I've a internal module, which returns a readonly collection.
public interface IDataObject {
int ID: string;
// more properties and functions
}
public interface IQueryResult : IReadOnlyList<IDataObject>
{
int Length { get; }
}
public sealed class QueryResult : IQueryResult
{
private readonly IReadOnlyList<IDataObject> _list;
public int Count => _list.Count;
[ScriptMember("length")]
public int Length => Count;
public IDataObject this[int index] => _list[index];
public QueryResult() => _list = ImmutableArray<IDataObject>.Empty;
public QueryResult(IEnumerable<IDataObject> items) => _list = items.ToImmutableArray();
public IEnumerator<IDataObject> GetEnumerator() => _list.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
This allows me to access list.length but not list[0].
If i convert / destruct to array [...list][0] i get the expected result.
Reactions are currently unavailable
ClearScript / V8 should support lists implementing IReadOnlyList<T> but not IList<T>
Use case
I've a internal module, which returns a readonly collection.
This allows me to access list.length but not list[0].
If i convert / destruct to array [...list][0] i get the expected result.