I need to have a textbox on a ASP.NET page in which a user would paste code and select one of the preset languages (C#, VB.NET, Python, Ruby etc) and I need to verify if the code compiles successfully. If it doesn’t, then I need to show the errors and warnings with line numbers.
How do I go about doing this?
You’ll need to host all sorts of compilers you’d like to support and use their APIs. If a compiler doesn’t expose an API, you’d need to use
System.Diagnostics.Processto launch it and grab the output for parsing.This is far from a trivial task though.
If you’re confident you need this, ask yourself several questions.
And this is just the tip of the iceberg.
Answering your comment, yes, there is a compiler API for C# and VB .NET which is called CodeDOM.
There’s plenty of information about it on the net. You may want to check out this question as well.