Toggle comments bug in Xamarin Studio

I’m currently working on several Xamarin project, among others adapting the MVVMbasics framework to support the Xamarin.Forms target platform. This means I’m playing around a lot with Xamarin Studio, and today I located a minor but annoying bug in version 5.7 of the Xamarin Studio development environment:

Xamarin Studio features the useful Toggle Line Comment(s) command that can be found either in the text editor’s context menu or in the Edit > Format > menu, or invoked using the Ctrl+Alt+C hotkey. In the C# editor, this command adds a code comment (//) at the beginning of the line the cursor is positioned in, or removes an existing comment. If several full lines are selected, it adds the comment markers to the beginning to all currently selected lines.

In the XML editor, however, when several full lines are selected, the command creates an XML comment (<!– –>) that starts at the beginning of the first selected line, and reaches not only until the end of the last selected line but until the end of the line that follows the last selected one. The following two images illustrate this behavior by showing a sample XML code snippet before and after applying the Toggle Line Comment(s) command:

Short line

Short line

I’ve just reported this behavior to the official Xamarin bug tracking system, let’s see what they do with it. Meanwhile, it’s good to know that in the XML editor, you should always select one line less than you’d actually like to comment!