File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed
Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ details about the cause of the failure
3131- Fix non-delegate types incorrectly appearing as callable.
3232- Indexers can now be used with interface objects
3333- Fixed a bug where indexers could not be used if they were inherited
34+ - Made it possible to use ` __len__ ` also on ` ICollection<> ` interface objects
3435
3536## [ 2.5.0] [ ] - 2020-06-14
3637
Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ public static bool CanAssgin(Type clrType)
3636 {
3737 return true ;
3838 }
39+ if ( clrType . IsInterface && clrType . IsGenericType && clrType . GetGenericTypeDefinition ( ) == typeof ( ICollection < > ) )
40+ {
41+ return true ;
42+ }
3943 return false ;
4044 }
4145
Original file line number Diff line number Diff line change @@ -47,3 +47,17 @@ def test_custom_generic_collection_explicit___len__():
4747 s .Add (1 )
4848 s .Add (10 )
4949 assert len (s ) == 2
50+
51+ def test_len_through_interface_generic ():
52+ """Test __len__ for ICollection<T>"""
53+ import System .Collections .Generic
54+ l = System .Collections .Generic .List [int ]()
55+ coll = System .Collections .Generic .ICollection [int ](l )
56+ assert len (coll ) == 0
57+
58+ def test_len_through_interface ():
59+ """Test __len__ for ICollection"""
60+ import System .Collections
61+ l = System .Collections .ArrayList ()
62+ coll = System .Collections .ICollection (l )
63+ assert len (coll ) == 0
You can’t perform that action at this time.
0 commit comments