C# method contents validation

Posted by user258651 on Stack Overflow See other posts from Stack Overflow or by user258651
Published on 2010-03-18T21:30:28Z Indexed on 2010/03/18 23:01 UTC
Read the original article Hit count: 123

Filed under:
|

I need to validate the contents of a C# method.

I do not care about syntax errors that do not affect the method's scope.

I do care about characters that will invalidate parsing of the rest of the code. For example:

method()
{
  /* valid comment */
  /*           <-- bad
  for (i..) {
  } 
  for (i..) {  <-- bad
}

I need to validate/fix any non-paired characters.

This includeds /* */, { }, and maybe others.

How should I go about this?

My first thought was Regex, but that clearly isn't going to get the job done.

© Stack Overflow or respective owner

Related posts about c#

Related posts about validate