I'm searching for a function (perhaps there is one in the .Net-Framework) which I can use to validate C#-syntax. It can also be a c# parser with build-in validation.
Background: I'm building a little Code-Generator where the user can enter some definitions and gets back full implemented properties etc., but I want to check if the user entered correct C# and if the result is correct, too.
Edit:
I don't want to compile the code, and it could be uncomplete code. So that for example the User could enter a code-snippet with classes from his code, I don't know, and I only want to validate the syntax, not the 'content'
Examples
Input:
Car car = new Car();
car.drive("50");
Output:
Same as input, because it's valid and nothing to do.
Input:
Car car = new Car()
car.drive("50");
Output:
Message that it is not valid, beause of missing ';'
etc.
I don't know the class Car and therefore I can't compile it, I only want to check the syntax.
Caris a type, namespace, variable identifier, type parameter etc, you can't validate the syntax fully. The snippet might be valid or invalid (syntax-wise). What then do you mean by 'validate'?