pythonnet: Calling generic method in Python returns incorrect value
Environment
- Pythonnet version: 2.3.0
- Python version: 3.6.0
- Operating System: Win10
Details
I’m trying to call a generic method from Python. So far it seems it’s executing but the result is not the same when calling it from C#.
So the actual method looks like:
public T GetService<T>() where T : class, IEngineeringService;
The method call in C# is:
SoftwareContainer softwareContainer = deviceItem.GetService<SoftwareContainer>();
And as expected it returns an object of type SoftwareContainer
.
Calling it from python like:
software_container = device_item.GetService[SoftwareContainer]()
While it seems like the method is called as expected the returned value is None
.
Note: I have an engineering project and I’m accessing it via a C# API. Both snippets act on the same project, so I guess the results should be the same for both cases.
Why does the Python code return an incorrect value?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 17 (9 by maintainers)
also can you show the results of
deviceItem.GetService.Overloads
?And you are sure that this doesn’t return a
(SoftwareContainer)null
?