You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code is valid, the function GetType<T>() is a generic function using one type parameter T and no function parameters. In C# you would call it as var int32Type = ReflectionHelper.GetType<System.Int32>(), KEBO80 gave the corresponding Python syntax (square brackets [] instead of <> to select the type parameter).
Thanks for the reply @filmor. I was confused for a couple of reasons.
GetType was not defined as a generic method and hence it didn't compile.
The square bracket part was also not there in the python code.
Also for my use case I need the method for a static class. And GetType() doesn't compile for static types in C#. However, for some reason it still works in python when writing GetTypeT for a static type T. I did not expect that.
Activity
den-run-ai commentedon Mar 22, 2017
@vivainio pull requests are welcome!
Your approach is in the right direction:
https://mail.python.org/pipermail/pythondotnet/2005-July/000371.html
vivainio commentedon Mar 22, 2017
@denfromufa Ok, I'll take a look if I can figure it out how to build & work with the codebase :)
den-run-ai commentedon Mar 22, 2017
@vivainio pythonnet runs on 2 CI servers: Travis and Appveyor. So the pull request will automatically do the builds and also run the tests.
You can also look at these docs to see how to build locally:
https://github.com/pythonnet/pythonnet/wiki/Troubleshooting-on-Windows-and-Linux
Please report any issues back about building locally, so that we can improve the wiki.
Support clr.GetClrType() - as in IronPython
Support clr.GetClrType() - as in IronPython (#433)
den-run-ai commentedon Mar 26, 2017
@vivainio thanks for this contribution!
Support clr.GetClrType() - as in IronPython (pythonnet#433)
Rebase with master (#2)
KEBO80 commentedon Nov 7, 2017
As an anlternative solution, I came up with the following by creating a static C# helper function:
This I can import this in Python code and use it for any NET type in the folllowing way:
intt32typeis ofSystem.RuntimeType.JoaBjo commentedon Dec 14, 2017
Could you elaborate a little bit on your alternative solution @KEBO80? That class doesn't compile since T is not defined.
filmor commentedon Dec 15, 2017
@JoaBjo Did you try to compile it? :)
This code is valid, the function
GetType<T>()is a generic function using one type parameterTand no function parameters. In C# you would call it asvar int32Type = ReflectionHelper.GetType<System.Int32>(), KEBO80 gave the corresponding Python syntax (square brackets[]instead of<>to select the type parameter).JoaBjo commentedon Dec 15, 2017
Thanks for the reply @filmor. I was confused for a couple of reasons.
Also for my use case I need the method for a static class. And GetType() doesn't compile for static types in C#. However, for some reason it still works in python when writing GetTypeT for a static type T. I did not expect that.
Anyways, thanks for clarifying things
den-run-ai commentedon Jan 28, 2018
Here is one corner case that was fixed, but needs review:
#606
Basically I scanned through all built-in types in
System.