looking to output the .cs filename in a project to a .txt file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I found that if I use system.reflection.assembly I can extract alot of
information about the code I am running, but in a multiple code project, I
would also like the filename of the .cs where the code class or code function
came from.

Where can I find that?

Any help would be highly appreciated.

Thanks in advance.
 
Once you’ve built a block of code into MSIL, any semblance of multiple .cs
files is lost. One of the main reasons for multiple .cs files is for you
during development, as it is often more logical to break an application up
into different files.

One option would be to output your textfiles based on the namespace and/or
class of the code you are dealing with, should you be reflecting on a class
named SuperFoo, output it as SuperFoo.txt. Granted it’s not the most perfect,
it’s as close as you will get without building in extensive logic whose job
it is is to guess what code might have been in what files and what their
names might have been.

One way to do it though, would be to to do something similar to an example
from http://www.oreilly.com/catalog/progcsharp2/chapter/ch18.html and build a
custom attribute to store such information.

Brendan
 
Back
Top