0

I am trying to figure out how to make an editor extension (like T4 templates) or designer extension (like a WinForms designer) that produces a generated file and a "code-behind" file.

For the T4-style code generator I know that a single-file generator is an option but it is very limited (e.g. only a single output file is allowed) and I am not sure how to combine that development path (which seems incompatible with vsix deployment) with an extension that supports other features such as syntax highlighting or editor context menus.

So I would like to find a vsix-compatible approach. I would like to write an extension that works like this

  1. Offer a new *.xyz file extension in the New file dialog
  2. Upon creating the new *.xyz file, a text editor or custom editor (personally I want to use a text editor) appears to edit the file.
  3. When the *.xyz file is edited, one or more *.cs (or let's say *.vb files in a VB project) pop out as children of the *.xyz file in solution explorer and become part of the project. (I am also curious about how you can make one of the files non-generated, like the user-editable code-behind file that comes with a *.xaml file, but for my own purposes I only need to produce generated file(s).)

I know how to do #2 (syntax highlighting, and I saw something on MSDN about custom editors). #1 is a lower priority but I'm haven't quite figured it out yet; e.g. there are instructions on MSDN but no mention of how you would integrate an item template into a VSIX project.

The most important thing I want to know is #3. Does this feature even have a name I could google for?

Qwertie
  • 16,354
  • 20
  • 105
  • 148
  • I don't know the way exactly, but in principle, the children are marked with `parentItem` in .xxproj file. Googling for "ProjectItem DependentUpon" showed me some samples and how-tos. Do they help? – Ripple Aug 25 '14 at 14:54
  • Thanks but I don't think Visual Studio extensions work by directly editing the csproj file. – Qwertie Aug 25 '14 at 16:10
  • I didn't mean to edit .csproj directly. Those keywords will bring you some code snippets like `targetFileProjectItem.ProjectItems.AddFromFile(dependantFilePath);`. – Ripple Aug 26 '14 at 01:36

0 Answers0