Click here to Skip to main content
15,909,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like to know, if i want to add another check to my code during run-time, beside the regular code check, what do i need to do? for example counting how many times I've got the letter 'a' in my code. or how many times i have a variable containing the letter 'a'.
i'm assuming that the compiler does that part, so do i need to inherit from the compiler classes in order to get access to the words in my code? or does it have to do with visual studio?
i'm sort of stuck and have to give in a school project very soon i would be very happy if anyone can help me!


What I have tried:

i tried to learn the classes of the compiler of c# and didn't have much luck...
Posted
Updated 12-Nov-18 22:57pm
Comments
Richard MacCutchan 13-Nov-18 3:53am    
What exactly is the project supposed to do?
Afzaal Ahmad Zeeshan 13-Nov-18 9:30am    
Why don't you just read the source code file and do a quick scan?

1 solution

Hi,
There are several ways of doing this, I will short listed the most well know ones:
1- Use
System.CodeDom.Compiler
this will give you access almost to everything that C# compiler contains. For example, you can call the parser at run-time and ask for a query that you are interested in it.
2- You can use bath files and pre-post build events which allows you to run some batch files before and after each build. Read more in here
3- You can make your own C# compiler which I do not advice but if you are interested in it then just go ahead and download the source code from the official links such as C# Compiler Mono
4- Combination of solution 1 and 2 which is also a nice idea.

I hope this will help you to solve your problem if not please do not hesitate to leave a comment then I can improve this solution until your problem got solved or apologize if I was not able to be of help. Good luck.

Cheers,
AH
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900