Extracting property names from a c# source file
- by Pete
I want to parse a c# file. The only thing I want is to determine if it contains a property with a specific name; just a simple true/false response. Or rather, since I'd checking for more than one property in each run, extracting a list of property names could be helpful
I thought that I could create an elegant solution using the CodeDomProvider functionality (f# example):
use reader = new StreamReader(existingFile)
let codeProvider = new CSharpCodeProvider()
let codeUnit = codeProvider.Parse(reader)
Unfortunately, the Parse function is not implemented for the CSharpCodeProvider. Is there a way to get a CodeCompileUnit from a source file? Or is there another elegant way? (I had hoped to avoid regular expressions on this)?