I have the requirement to generate and read some CS classes with a DSL, I have adopted one method for reading the CS files using EnvDTE and my colleague has used CodeDom to produce the CS files.
Is it just sugar or is there a big difference between...
codeClass.AddFunction("DoSomething", vsCMFunction.vsCMFunctionFunction, "bool");
and
CodeMemberMethod membMethod = new CodeMemberMethod();
membMethod.Attributes = MemberAttributes.Static;
membMethod.ReturnType = new CodeTypeReference("bool");
membMethod.Name = "DoSomething";
I subjectively prefer the EnvDTE but do not know what the 'real' difference is.
Info: C#, Visual Studio 2010
Using EnvDTE, I'm not sure you can manipulate AST like you can with CodeDOM. I would go with CodeDOM, or NRefactory from SharpDevelop project, which is another open source C# parser/generator.
CodeDOM does not have a way to read source code to produce an AST. If all you need to do is generate C#, then CodeDOM ships with the .NET framework and so your application would not require Visual Studio to be installed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.