473,396 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to parse the names of methods & variables in a cs file

I would like to make a list of all the names of methods and variables
in a cs file. I need to open up a file, create the list of all methods
and properties, and variables, contained in that file, and close the
file.

Is there any class that will help me doing that?

Cheers,
Simone

Jan 21 '06 #1
5 1333
Hello Simone,

How would u like to do it? Statically? Use CodeSmith tool for this case

SM> I would like to make a list of all the names of methods and
SM> variables in a cs file. I need to open up a file, create the list of
SM> all methods and properties, and variables, contained in that file,
SM> and close the file.
SM>
SM> Is there any class that will help me doing that?
SM>
SM> Cheers,
SM> Simone
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/members/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Jan 21 '06 #2
Simone M <si************@hotmail.com> wrote:
I would like to make a list of all the names of methods and variables
in a cs file. I need to open up a file, create the list of all methods
and properties, and variables, contained in that file, and close the
file.

Is there any class that will help me doing that?


Do you definitely need to do it on the C# file itself, rather than the
assembly which is produced? It's much easier to do with reflection on
the generated code than it is to effectively do a lot of the parsing
work that the C# compiler does.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 21 '06 #3
Jon,
Thanks for the tip. I thought there would be a class available to do it
directly on the cs file.
But I will give Reflection a try.
Cheers!
Simone

Jan 21 '06 #4
Michael,
Thanks for the tip. Will take a look at CodeSmith.
Simone

Jan 21 '06 #5
As well, you could look into FxCop, which validates .NET code by
examining the compiled assemblies.

FxCop allows you to add custom rules, so if you're doing this in order
to check a naming convention (for example), you could get that "for
free" by reading up on how to write custom rules in FxCop and
leveraging off that framework. They've done all the heavy lifting for
you... all you have to supply are the additional rules to check.

Of course, if you want the names for some other purpose, that may not
work for you.

Jan 21 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jonathan Epstein | last post by:
I have a collection of CSV datasets which will all contain different numbers of columns and different column headers. There will always be a fixed number of such files and they have some common...
6
by: Mayer | last post by:
Hello: Is there a way to see at the python prompt the names of all the public methods of a class or the names exported by a module? I know that GUI-based IDEs have a nifty way of displaying...
24
by: | last post by:
Hi, I need to read a big CSV file, where different fields should be converted to different types, such as int, double, datetime, SqlMoney, etc. I have an array, which describes the fields and...
4
by: arak123 | last post by:
Lets say i have file with the following structure and the following code snippet: --------------------BEGIN FILE----------------------- name1 name2 name3 name4 ; name5
7
by: amfr | last post by:
I was wondering how i could parse the contents of a file into an array. the file would look something like this: gif:image/gif html:text/html jpg:image/jpeg .... As you can see, it contains...
7
by: jccorreu | last post by:
I've got to read info from multiple files that will be given to me. I know the format and what the data is. The thing is each time we run the program we may be using a differnt number of files,...
16
by: per9000 | last post by:
Hi, I recently started working a lot more in python than I have done in the past. And I discovered something that totally removed the pretty pink clouds of beautifulness that had surrounded my...
4
by: Victor Lagerkvist | last post by:
Hello, I have the need to parse variable names from a string and save them somewhere safe for future usage. Here's my first attempt (I don't have any rules for valid names yet) - but I have a...
1
by: maconbot | last post by:
hi all, please exuse my email ">" i am working on location. > hey team, thanks for the quick reply. > > i am trying to parse a pop3 account and populate it into flash. > > the how to code......
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.