1

I would like to know is there any way to lists all classes that use changed methods (after merging changes to master)? Best would be recursively, so if i got class with method that use method that use changed method it would be listed. Question is for C# but if there is universal tool to do this it would be ok. The thing is to check if recent commits does not make regression in project

eg.

class one
{
    int something()
    {
        //method that changes
    }
}

class two
{
    int doSomethingWithSomething()
    {
        one objectoOfOne = new one();
        return objectoOfOne.something() + 1;
    }
}

class three
{
    int usingTwoWithSomething()
    {
        two objectOfTwo = new two();
        return objectOfTwo.doSomethingWithSomething() +2;
    }
}

class four
{
    int independent;
}

I would like to have list of classes one, two, three, when in merged change method something() was modified.

byRadzio
  • 33
  • 1
  • 6
  • what do you mean by merge?Git?? – Shervin Ivari Apr 20 '20 at 12:49
  • Yes, after merging change in Git, it could be also before merging – byRadzio Apr 20 '20 at 12:53
  • To check whether u have a regression issue you should create unit/Integration tests, not try to find all usages. Anyway to the question - I don't know such way. – Aviad Hasidof Apr 20 '20 at 12:53
  • @byRadzio az Avaid said I don't think you should write tests.or a method with the reflection that checks program and store classes in somewhere when changed notify you – Shervin Ivari Apr 20 '20 at 13:03
  • I think OP's question is valid for he wants to document all the areas in his software that are affected by a recent change, which we call [impact analysis](https://en.wikipedia.org/wiki/Change_impact_analysis). Check out [NDepend](https://www.ndepend.com/) – Oguz Ozgul Apr 20 '20 at 13:26
  • Change methodName to methodName1 and see what breaks – patrick Apr 20 '20 at 14:31

1 Answers1

0

Source control tools like git has no way to understand what it is storing, except if the data is text or binary. This include merge tools, most only see that text has been inserted, removed and (maybe) reorganized.

There are some tools that actually parses the source code in order to provide better merging experience. See Semantic merge for an example. They know what methods and classes have been changed. If you know that classes have been changed, it should be possible to also list all dependent classes if you want that. I do not know if tools like this actually have an API if you want to hook it up to some other system.

JonasH
  • 28,608
  • 2
  • 10
  • 23