Library for parsing/modifying C# source code (and compiling after that) [duplicate]
Possible Duplicate:
Parser for C#
Any (free) libraries that can parse C# source code and make a DOM of it?
I need to add an attribute to all classes in bunch of .cs files and then compile them to an assembly. This needs to be done in an asp.net application, so I'm not interested in Visual Studio plugins or开发者_StackOverflow社区 similar.
I need to achieve this
input: ~/plugins/MyPlugin/MyPlugin.cs
public class MyPlugin : PluginBase, IEntitySavingPlugin
{
}
output: Plugins.dll
[PluginDirectory("~/plugins/MyPlugin/")]
public class MyPlugin : PluginBase, IEntitySavingPlugin
{
}
You can try to use Antlr Parser, a framework for constructing recognizers, interpreters, compilers, and translators from grammatical descriptions. Support C#; C# 2 ;C# 3
http://www.antlr.org/
Duplicate of question Parser for C#.
Your best bet may be one of these:
http://csparser.codeplex.com/
http://wiki.sharpdevelop.net/NRefactory.ashx
精彩评论