Visual Studio: Collapse Methods, but not Comments (Summary etc.)

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2009-08-09T04:00:06Z Indexed on 2010/04/04 16:13 UTC
Read the original article Hit count: 230

Filed under:

Hello,

is there a way (settings? "macro"? extension?) that I can simply toggle outlining so that only the using section and my methods collapse to their signature line, but my comments (summary and double slash comments) and classes stay expanded?

Examples:

1) Uncollapsed

using System;
using MachineGun;

namespace Animals
{

    /// <summary>
    /// Angry animal
    /// Pretty Fast, too
    /// </summary>
    public partial class Lion
    {
        //
        // Dead or Alive
        public Boolean Alive;

        /// <summary>
        /// Bad bite
        /// </summary>
        public PieceOfAnimal Bite(Animal animalToBite)
        {
              return animalToBite.Shoulder;
        }

        /// <summary>
        /// Fatal bite
        /// </summary>
        public PieceOfAnimal Kill(Animal animalToKill)
        {
              return animalToKill.Head;
        }
     }
}

2) Collapsed (the following is my desired result):

using[...]

namespace Animals
{

    /// <summary>
    /// Angry animal
    /// Pretty Fast, too
    /// </summary>
    public partial class Lion
    {
        //
        // Dead or Alive
        public Boolean Alive;

        /// <summary>
        /// Bad bite
        /// </summary>
        public PieceOfAnimal Bite(Animal animalToBite)[...]

        /// <summary>
        /// Fatal bite
        /// </summary>
        public PieceOfAnimal Kill(Animal animalToKill)[...]
     }
}

This is how I prefer seeing my class files (the collapsed form). I've been doing the collapsing by hand a million times by now and I think there should be a way to automate/customize/extend VS to do it the way I want?

Every time I debug/hit a breakpoint, it uncollapses and messes up things. If I collapse via the context menu's collapse to outline etc. it also collapses my comments which isn't desired.

Appreciate your help!

© Stack Overflow or respective owner

Related posts about visual-studio