Add MethodInfo.MakeGenericMethod() and Type[].Where() or IEnumerable<Type>.Where() #1031
Replies: 3 comments
-
Moving this to a discussion as it's not a bug. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the feedback. I will try other ways to achieve the same functionality. |
Beta Was this translation helpful? Give feedback.
-
Check the Unit Test Launcher: https://github.com/nanoframework/nanoFramework.TestFramework/blob/871c6a0494cecfc53f0ead1775a402f0363afb02/source/UnitTestLauncher/Program.cs#L25 It uses attributes to find functions. Depending on what you need, it can be a good way. Check out as well the json class, there are a lot of boxing and un boxing: it checks simple types, it checks arrays and hashtable, it check objects. |
Beta Was this translation helpful? Give feedback.
-
Description
MakeGenericMethod
I need to call a generic function with a type decided at runtime, the only way to do this in c# is to use MakeGenericMethod with a type.
*.Where()
I often need a list of all methods that implement a certain interface and to do this it is very convenient to use .where instead of looping through all of the classes manually.
How to solve the problem
MakeGenericMethod()
MakeGenericMethod needs an implementation.
*.Where()
the IEnumerable interface needs a Where method
Describe alternatives you've considered
MakeGenericMethod
I believe that there are no alternatives to this function in the c# standard library
*.Where()
You can manually loop through all the items in the list and filter them that way.
Aditional context
example MakeGenericMethod use:
example *.where use:
Beta Was this translation helpful? Give feedback.
All reactions