How to fin Class/Entity References and Line Number

Saifullah 1 Reputation point
2020-11-26T05:53:05.417+00:00

Hi folks,
I hope you are doing well.

I want to write a program in C# that extract the class/entity references and with there line numbers where it is used in solution.

I do research from internet I have found some references() but it can't me help.

Could anyone one suggest me how i do it or there is any nugget package available for it.

Thank you.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,247 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,119 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Cheong00 3,471 Reputation points
    2020-11-26T06:03:31.31+00:00

    You may want to check the PDB file format and read the PDB file generated when compiling projects.

    https://github.com/Microsoft/microsoft-pdb/


  2. Cheong00 3,471 Reputation points
    2020-11-26T07:48:20.357+00:00

    With the reference ISymbolReader in the blog page, you may want to see if you can get System.Diagnostics.SymbolStore.SymReader works for you. (Need to add reference to ISymWrapper.dll of your .NET runtime)

    And there is source code for the PDB2XML tool. Check SymUtil class to see how to load ISymbolReader in C#.


  3. Cheong00 3,471 Reputation points
    2020-11-26T07:55:22.757+00:00

    Btw, for .NET Core (i.e.: .NET 5+) there is another PDB format that is slightly different.