astrowalker astrowalker - 6 days ago 5
C# Question

How to tell where the given method/property is declared?

Say I have a class (shown as meta data) -- code lies in dll:

class Foo : IA, IB, IC, ID...
{
public void Bar(); // implementation
}


I would like to know where this
Bar
method was declared -- in IA, or IB, or... ... or it is fresh implementation -- without referring to any external sources like MSDN.

Can I do this in Visual Studio? If yes -- how?

If this was editable file (like my own code) this would be easy -- simply comment out for a while this method and see which interface becomes flagged.

Answer

If you are looking to get the source code of any .dll file you cannot do it with Visual Studio, But you can make use of decompiler tools like JustDecomplie , dotPeek etc

But even with these decompilers it is not guaranteed to get back the source code 100% accurately.