djdd87
djdd87

Reputation: 68456

How can I check the validity of a code file?

I'm trying to check the validity of a particular 'stand-alone' code file from within my C#.Net app. Is there any way that I can check the file and get a visual studio's style errors list out?

I'm only interested in running a basic check to ensure that the basics would validate. I.e. all variables are declared and method names are valid.

Is this at all possible?

Upvotes: 1

Views: 198

Answers (3)

Abel
Abel

Reputation: 57159

If it's not the same as the referred to question (see my comment), you mention "VS style errors", consider using the CSharpCodeProvider. An example of its usage is in its documentation at MSDN.

Upvotes: 3

Anderson Imes
Anderson Imes

Reputation: 25650

You can use static code analysis. There are a few libraries that enable this. The one that cones to mind immediately is StyleCop. It is written in .NET so you should be able to reference and use it through code if that is what you are looking for.

Upvotes: 0

RichardOD
RichardOD

Reputation: 29157

Call the C# command line compiler (csc.exe)?

Upvotes: 1

Related Questions