Tag, you are it... Another way to organize your files in Visual Studio

Sign in to queue

Description

If you're reading this blog, it's pretty likely you're a Visual Studio user. And like most dev's you like to organize your project files and folder is "just this way". But what if you wanted to provide a different organization? Or have multiple file layouts? Wouldn't it be cool if you could tag a file and view them via those tags? Even applying multiple tags so you can have multiple views of your Project? Like a "business' layout and a dev layout?

VsTagExplorer

Don’t you just hate that you have to view the files in your solution the Visual Studio way? Now you can you start viewing your files in a much more useful way! Start tagging your files in very easy steps!

Right click in your solution explorer, set the tags for each file, and then start navigating by tags from the Tag Explorer! (go to view -> other windows -> tag explorer)

Visual Studio Tags (http://vstags.codeplex.com/)

image

image 

Taking a look at the Project...

image

 public void Tag()
{
     IEnumerable<FileItem> selectedItems = envDte.SelectedItems
         .OfType<SelectedItem>()
         .Select(si => new FileItem {Name = si.Name});
     IEnumerable<string> candidateTags = GetCandidateStrings(selectedItems);
     IEnumerable<string> tags = selector.Select(candidateTags);
     if (!selector.Selected) return;
     foreach (SelectedItem rootProjectItem in envDte.SelectedItems.OfType<SelectedItem>())
     {
         IVsHierarchy hierarchy;
         ((IVsSolution) solution).GetProjectOfUniqueName(
             rootProjectItem.ProjectItem.ContainingProject.UniqueName, out hierarchy);
         var buildPropertyStorage = hierarchy as IVsBuildPropertyStorage;
         if (buildPropertyStorage != null)
         {
             uint itemId;
             var fullPath =
                 (string) rootProjectItem.ProjectItem.Properties.Item("FullPath").Value;
             hierarchy.ParseCanonicalName(fullPath, out itemId);
             string newTags = string.Join(" ", tags);
             string currentTags;
             buildPropertyStorage.GetItemAttribute(itemId, "Tags", out currentTags);
             ApplyTags(currentTags, newTags, buildPropertyStorage, itemId);
         }
     }
} 

This project shows off a couple things. That you don't have to be satisfied with how Visual Studio organizes your files, how to hook into Visual Studio/Project and finally creating distributable Visual Studio Extension.

 

The page image, Tagged!, is curtsey of JD Hancock

The Discussion

  • User profile image
    DFBerry

    I was just talking to another dev that we might have organized the project (folders and file names) wrong. It became clear we thought about the project differently and we needed to be able to represent all perspectives of the project. We couldn't think of a good fix but this is perfect. I can tag files with what they represent to me (different layers so I can jump to the layer I want fast) regardless of how visual studio has them organized. 

Add Your 2 Cents