Lines between methods in the C# editor (CodeRush/DxCore plugin)

Like most .NET developers,  I used to do VB/VBA coding before C# came along. But, one thing I always missed in in the C# code editor was the lines that the VB editor puts between methods. An an avid user of CodeRush and Refactor! Pro, which itself does code structure painting in Visual Studio, I’ve created a DxCore Plugin that draws lines between methods which (IMHO) improves on the ones in the VB code editor.

Here’s a screen shot of it in action:

Draw Lines Between Methods - in action

And here’s the exciting options page:

Draw Lines Between Methods - settings

Even if you’re a VB.NET person you might like to try it to see if it works any better for you than VB’s built-in lines (although I guess you’d need to turn off the built-in method-separating lines somewhere in Tools Options).

The project is hosted on Rory Becker’s DX Core Community Plugins Google Code project, where you can download the source and binaries.

Let me know how you get on with it in the comments 🙂

41 thoughts on “Lines between methods in the C# editor (CodeRush/DxCore plugin)

  1. Hi, I got this from google code but I need a way to switch it off periodically. Should I just remove it from the DX Core plugins dir.

    PS it’s a really great example of whats possible, thanks.

  2. I’m having an issue getting this to work in DXCore/CR 9.1.3 in C# VS 2008. I followed the d/l instructions and put the DLL it in the correct folder. I restarted VS and still have no separators. The plug-in doesn’t show up in the options dialog under Painting either.

    Any idea what would cause this?

  3. Hey Duncan, I have a contribution on this project from a 3rd party (Increased configurability apparently) and thought you’d be the best one to give it the once over…. Can you mail me (rorybecker@gmail.com) and I’ll pass you a copy 🙂

  4. Hi, I would like to use this plugin too with VS2008 Prof SP1 and CodeRush Express 3.2. But actually I cannot get it to work. Symptoms:
    – will be shown within Plugins section
    – will not be shown under Painting
    – and, of course, no lines are drawn

    Thanks for help. Perhaps a new rebuild is needed as for DXCore version 3.1. …

    schue

  5. The 2 simplest ways to achieve this are:

    1.> Download SourceCode and Rebuild against the 3.2.x dlls
    2.> Upgrade to Coderush Xpress version 9.1.x

    Hmmm seems there is not a version of CodeRush Xpress available outside of the clientcenter. I’ll ping DevExpress about that.

    1. Ok the official line from DevExpress (or at least what they told me) is….

      … “v2009 vol 1 of CodeRush and Refactor Pro is available to our customers. This version is also available as Trial within the DXperience subscription. However, the official version of CodeRush Xpress is still v3.2. We are going to announce v2009 vol 1 a bit later.”

      I take this to mean that you should be able to download the DXPerience Trial and install Coderush Xpress 9.1.x from within that

  6. thanks, great job
    but it did not work for me in VS2008 Pro and Win7 with CodeRushX .
    I did not have that “Unblock” option either.
    and I cannot find where is this Options dialog that is in your snap shot?

    thanks foe help in advance

  7. Duncan — Please help. I really like this idea of line separators. Unfortunately, with VisualStudio 2008 Standard and CodeRushXpress-10.1.1.exe I cannot get it working. I have to use “Ctrl+Shift+Alt+O” to get the options. That is fine. I can see the “Draw Lines Between” settings and I have everything there turned on. When I view my file, however, there are no line speparators. Is there a way to get this to work? Please advise. Thank you. — Mark Kamoski

    1. Ah I see – you’re using 10.1. For some reason with 10.1 you now have to go to Editor\Painting\GDI Compatibility options page and make sure Enable EditorPaintLanguageElement event is checked. I’ve yet to work out why this isn’t enabled by default

      (The GDI Compatibility page will only be visible if the Level combo on the lower-left of the Options dialog is set to Expert)

      1. Please help. I’m using 10.1 version with Visual Studio 2010 Professional. EditorPaintLanguageElement event is enabled, but line separator does not show 😦

      2. Marek – yes sorry it doesn’t work under VS2010 for me either, yet. I’m waiting on DevExpress to update their documentation so I can figure out how to fix this. Stay tuned!

      3. Duncan —

        After doing as you said, it works now.

        Nice.

        (I always wondered why VB had this and CS did not– it is such a good idea.)

        Thank you.

        — Mark Kamoski

  8. Thanks Duncan. I hope, that it will be as soon as you can, because this plugin is very useful for me. 😉

  9. All — I had some issues with screen paints, issues on my end, that affected my screen paints on this and other functionality. FYI, I have Card=”NvidiaGeForce9500Gt”, Resolution=”1440×900″, Quality=”Higest32Bit”, Os=”WindowsXpPro”, etc. I had Refresh=”60″ and the screen painting was not keeping up with my scrolling, which sometimes means the horiz-line (and other elements like actual code itself) would get munged a bit and not display fully or at all. Anyway, I set Refresh=”75″, which is the max, and all seems well now. This is just FYI. I usually set Refresh=Max but somehow it was reset, probably when testing site display, etc. Even though I am brand new to CodeRush Xpress, this is a great plugin already. HTH. Thank you. — Mark Kamoski

      1. btw, I added a condition to avoid drawing a line in case of a one liner property e.g.:
        int MyProp { get; set; }

  10. add this code:
    if (args.LanguageElement.EndLine ==
    args.LanguageElement.StartLine)
    return;
    just after this line:
    if (!settings.Enabled)
    return;

    to the method EventNexus_DecorateLanguageElement in DrawLinesBetweenMethodsPlugIn.cs

    1. also added this:
      if (args.LanguageElement is Comment && args.LanguageElement.ToString() == “!”)
      {
      var adornment = new
      DrawLinesBetweenMethodsDocumentAdornment
      (args.LanguageElement.Range);
      args.AddBackgroundAdornment(adornment);
      return;
      }

      this will draw line on every “//!” comment.
      it enables you to draw lines wherever you want.

      sample:

      int MyPrpop1 { get; set; }
      int MyPrpop2 { get; set; }
      int MyPrpop3 { get; set; }
      //!———————————————

  11. Very nice plugin.

    I worked in vb.net for about 10 years and now I’m in c#. The lines betwen methods is not essential but it’s better to read code when you work 8 hours a day, 5 days a week.

    Thank you very much.

Leave a comment