locked
How to programmatically get all methods reference to a class using C#? RRS feed

  • Question

  • User2032762197 posted

    Hi everyone,
    Can I programmatically get all methods reference to a class using C#?
    Example scenario:
    I have class:

    public class SearchScreen
    {
    }

    Inner the test case below, I have a calling to that class:

    public void Test_Search()
    {
    var searchScreen = ScreenFactory.GetScreen<SearchScreen >();
    }

    What I want:
    Input: "SearchScreen"
    Output: "Test_Search"

    The reason why I have this demand because I want to get all test case methods for a specific screen to limit the list of test cases to execute in order to reduce time. There are a thousand test cases in total.

    Could you tell me is it possible or any other idea to perform this?

    Thank you so much!
    An Nhien

    Thursday, April 12, 2018 2:25 PM

All replies

  • User1120430333 posted

    Can I programmatically get all methods reference to a class using C#?

    Your friend Bing or Google can do search on a topic.

    https://www.c-sharpcorner.com/blogs/getting-all-methods-of-class-using-reflection-c-sharp1

    Thursday, April 12, 2018 8:19 PM
  • User2032762197 posted

    This just gets all method of a class, but I want to get all references method of a class. In your example, I would like to input "Student" and get output "GetMethodsUsingReflection"

    Friday, April 13, 2018 2:03 AM
  • User1120430333 posted

    This just gets all method of a class, but I want to get all references method of a class. In your example, I would like to input "Student" and get output "GetMethodsUsingReflection"

    Oh, you could get all references for a method in a class by using something like Resharper that you can use the full version (free) for 30 days.

    Find Usages Advanced

    https://www.jetbrains.com/resharper/features/navigation_search.html

    Friday, April 13, 2018 4:25 AM
  • User2032762197 posted

    :( Yes, but I have to programmatically implement it. 

    Do you have any idea about that?

    Sunday, April 15, 2018 1:35 PM