I saw there are lots of questions asked on this topic (C#, Roslyn, Find References and Definitions). But I still not got answer for what I want. Here is explanations. I have interface:
public interface IRepository {
IEnumerable<X> Abc(long customerIdentity, ...);
}
Now, this interface in implemented by on class like:
public abstract class RepositoryBase : IRepository {
public virtual IEnumerable<X> Abc(long customerIdentity, long? associatedOrderIdentity, ...) { ... }
}
Since this is abstract class, then other classes may have redefined this method as this method is virtual. Also, interface can have property with other interface as well.
public sealed class CustRepository : RepositoryBase {
public override IEnumerable<X> Abc(long customerIdentity, long? associatedOrderIdentity, ...){ ... }
}
Another thing is here like this
public interface IRepositoryManager {
IRepository Repository { get; }
}
In my class variable is declared like this:
private IRepositoryManager _repositoryManager;
and I can call method like this:
this._repositoryManager.Repository.Abc(customerIdentity, ...)
Here are my questions now.
- How I get to know which method it will call at run time?. I want this to get the definition/declaration using Roslyn. I can use invocation expression to get this statement.
- Should I take method from base class which directly implements the interface. Or do I need to see definitions from inheritance chain?.
I found some useful answers from: here and here: here
Please do not close this question as I'm really struggling to get this answer. Thanks in advance!!.