Tutorial for writing code generation plugin for Visual Studio 2010
I would like to add an editor to Visual Studio 2010, that should be similar to the one you get for Entity Framework, i.e. you get have a visual designer that save its own configuration to its own file and then generate code from that.
So the two aspects involve for this would be a visual representation for a specific file extension and the second is the code generation (or should the code be generated as the file is edited or only on a build?)
I've done some surfing but could not get any resources on how to do these specific things (especially the code generation part), any pointing in the right direction with res开发者_如何学JAVAources maybe would be appreciated.
Microsoft's Visualization and Modeling SDK - Domain-Specific Languages:
http://msdn.microsoft.com/en-us/library/bb126259.aspx
Quoting from the site:
Using Visual Studio Visualization and Modeling SDK (VMSDK), you can create powerful model-based development tools that you can integrate into Visual Studio. As an example, the UML tools are created using VMSDK. In the same manner, you can create one or more model definitions and integrate them into a set of tools.
At the heart of VMSDK is the definition of a model that you create to represent concepts in your business area. You can surround the model with a variety of tools, such as a diagrammatic view, the ability to generate code and other artifacts, commands for transforming the model, and the ability to interact with code and other objects in Visual Studio. As you develop the model, you can combine it with other models and tools to form a powerful toolset that is centered on your development.
VMSDK lets you develop a model quickly in the form of a domain-specific language (DSL). You begin by using a specialized editor to define a schema or abstract syntax together with a graphical notation. From this definition, VMSDK generates:
A model implementation with a strongly-typed API that runs in a transaction-based store. A tree-based explorer. A graphical editor in which users can view the model or parts of it that you define. Serialization methods that save your models in readable XML. Facilities for generating program code and other artifacts using text templating.
You can customize and extend all of these features. Your extensions are integrated in such a way that you can still update the DSL definition and re-generate the features without losing your extensions.
Did you checked these links?
- http://www.olegsych.com/2008/09/t4-tutorial-creating-reusable-code-generation-templates/
- http://msdn.microsoft.com/en-us/library/bb126445.aspx
For code generation I will suggest you to lake a look on code DOM model.
I know nothing about VS plugin development but I think this page would be helpful (in case you didnt see it before) - Visual Studio plug-ins development, first steps
精彩评论