Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Visual-Studio
Hi Everyone,
 
When we write some code of incorrect synatx,Visual studio suggests with a Red mark which tells that syntax is wrong and code need to checked out.At this time..Is the compiler running behind the scenes?
 

 
Regards
Chaithanya M
Posted 14-Apr-11 22:16pm
Comments
SAKryukov at 15-Apr-11 13:00pm
   
This is pretty interesting question, thanks for asking. My 5.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It isn't doing a complete compilation process as this would require code generation, but yes the source being edited is parsed while you're changing it and some analysis is done on the resulting syntax tree. Like checks if a variable you are using has already been declared, if types are compatible and matching the usage of a method call with the available signatures for that method. So yes there is quite a lot going on behind the scenes when you are using VS to edit your codes.
 
I hope I could clarify your issue!
 
Happy coding (and editing Wink | ;) )!
 
-MRB
  Permalink  
Comments
M.CHAITHANYA at 15-Apr-11 4:26am
   
Hi Manfred,
 
Who does this ?like is there any program that monitors the code and give suggestions.?
Manfred R. Bihy at 15-Apr-11 4:53am
   
Simply put is it a part of the VS IDE program. It monitors if changes were made to the source code and when a certain threshold of changes has been made the source code is parsed (AST) and the result is analyzed.
SAKryukov at 15-Apr-11 5:20am
   
This is basically what happens, my 5.
As to the detail of how it works -- please see my Answer.
 
Teamwork again?
--SA
Sandeep Mewara at 15-Apr-11 5:56am
   
Lots of tagging for you... ;) Great work!

I am a lot busy these days... :( meeting & meetings.
Sandeep Mewara at 15-Apr-11 5:56am
   
My 5 Manfred! :)
Manfred R. Bihy at 15-Apr-11 6:31am
   
Thanks Sandeep!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Compiler may or may not be running it any given moment. I can run while showing warnings and errors. The compiler is usually a normal console application. You can even create this effect yourself.
 
IDE is running a compiler as an external process using System.Diagnostic.Process, but the standard console output is redirected to two separate streams (stdout and stderr). IDE implements special stream type; a separate thread(s) in the host (IDE) process reads the line from the streams as they appear and redirect the lines to UI (it can be done via Dispatcher.Invoke or Dispatcher.BeginInvoke. In this way, the UI can show warnings/error while the compiler is still working, with the UI remaining responsive all the time.
 
I explained how to do it in detail in my past Answer:
How to read from command prompt[^].
 
—SA
  Permalink  
Comments
Sandeep Mewara at 15-Apr-11 5:56am
   
My 5 SA! :)
Sandeep Mewara at 15-Apr-11 5:57am
   
Wanted to know the deeper details myself... thanks for sharing.
SAKryukov at 15-Apr-11 12:59pm
   
Thank you, Sandeep.
--SA
Manfred R. Bihy at 15-Apr-11 6:30am
   
I'm not sure SA if it is really a full blown compile, I thought more about AST generation and some analysis thereof. If you have more information about the inner workings of VS IDE's syntax check mechanism please share it with us!
 
Still a 5+!
SAKryukov at 15-Apr-11 12:59pm
   
Thank you, Manfred.
I never pretended (and I could not) this is a full blown compile/build as it is done in VS; this is rather a point of view of a maker of a home-baked IDE. For OP is could be quite interesting due to his purely educational motivation (which is a very good thing)...
--SA
SAKryukov at 15-Apr-11 13:01pm
   
Chaithanya, that was I good Question, so I voted for it.
Thanks for accepting this Answer.
Good luck, call again.
--SA

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



Advertise | Privacy | Mobile
Web02 | 2.8.141022.2 | Last Updated 15 Apr 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100