| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2e6d12f commit 7870a9f
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,6 +32,7 @@ details about the cause of the failure | |||
| 32 | 32 | - Indexers can now be used with interface objects | |
| 33 | 33 | - Fixed a bug where indexers could not be used if they were inherited | |
| 34 | 34 | - Made it possible to use `__len__` also on `ICollection<>` interface objects | |
| 35 | + - Made it possible to call `ToString`, `GetHashCode`, and `GetType` on inteface objects | ||
| 35 | 36 | ||
| 36 | 37 | ### Removed | |
| 37 | 38 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -341,6 +341,17 @@ private static ClassInfo GetClassInfo(Type type) | |||
| 341 | 341 | } | |
| 342 | 342 | } | |
| 343 | 343 | } | |
| 344 | + | ||
| 345 | + // All interface implementations inherit from Object, | ||
| 346 | + // but GetMembers don't return them either. | ||
| 347 | + var objFlags = BindingFlags.Public | BindingFlags.Instance; | ||
| 348 | + foreach (var mi in typeof(object).GetMembers(objFlags)) | ||
| 349 | + { | ||
| 350 | + if (local[mi.Name] == null) | ||
| 351 | + { | ||
| 352 | + items.Add(mi); | ||
| 353 | + } | ||
| 354 | + } | ||
| 344 | 355 | } | |
| 345 | 356 | ||
| 346 | 357 | for (i = 0; i < items.Count; i++) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -136,3 +136,14 @@ def test_interface_collection_iteration(): | |||
| 136 | 136 | untyped_list.Add(elem) | |
| 137 | 137 | for e in untyped_list: | |
| 138 | 138 | assert type(e).__name__ == "int" | |
| 139 | + | ||
| 140 | + | ||
| 141 | + def test_methods_of_Object_are_available(): | ||
| 142 | + """Test calling methods inherited from Object""" | ||
| 143 | + import System | ||
| 144 | + clrVal = System.Int32(100) | ||
| 145 | + i = System.IComparable(clrVal) | ||
| 146 | + assert i.Equals(clrVal) | ||
| 147 | + assert clrVal.GetHashCode() == i.GetHashCode() | ||
| 148 | + assert clrVal.GetType() == i.GetType() | ||
| 149 | + assert clrVal.ToString() == i.ToString() | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments