Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 style-cop comments

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
haraldh Posted - Feb 08 2012 : 7:44:02 PM
i really like your feature of selecting a bunch of lines, then press / and all of them get a // in front.

however, style-cop insists on having 4 slashes when it's at the beginning of a line.

i am suggesting a flag in the VA options to choose whether one wants 2 or 4 slashes.
9   L A T E S T    R E P L I E S    (Newest First)
support Posted - Feb 29 2012 : 1:11:53 PM
case=64628 is implemented in build 1901


HKEY_CURRENT_USER\\Software\\Whole Tomato\\Visual Assist X\\VANet10

DWORD value: LineCommentSlashCount
default is 2

Replace VANet10 with appropriate subkey for other IDEs (VANet9, VANet8, VANet, VA6)
haraldh Posted - Feb 29 2012 : 06:57:06 AM
i just that a registry option (LineCommentSlashCount) was implemented in version 1901. thanks a lot! the quick response is much appreciated!
haraldh Posted - Feb 10 2012 : 9:24:17 PM
thanks a lot for making it a feature request and for the suggestions. i will try them.
feline Posted - Feb 10 2012 : 11:29:26 AM
As a temporary work around, you can use an IDE macro to comment and uncomment like this. Here is an initial attempt at a macro to do this, which I have tested in VS2008 with C++ code:

    ' select a block of lines and then trigger this
    ' it comments out code lines and uncomments comment lines
    Public Sub ToggleCommentStyleCop()
        Dim objTxtSel As TextSelection = DTE.ActiveDocument.Selection
        Dim colRanges As TextRanges = objTxtSel.TextRanges
        Dim objRange As TextRange
        Dim pointStart, pointEnd As EditPoint

        For Each objRange In colRanges
            Dim nLineLength As Integer = objRange.EndPoint.AbsoluteCharOffset - objRange.StartPoint.AbsoluteCharOffset
            If nLineLength > 0 Then
                pointStart = objRange.StartPoint
                pointEnd = objRange.EndPoint

                Dim strLine As String = pointStart.GetText(pointEnd)

                Dim RegexObj As New System.Text.RegularExpressions.Regex("^[\\t ]*////")
                If False = RegexObj.IsMatch(strLine) Then
                    pointStart.Insert("////")
                Else
                    ' work out what the line should turn into
                    ' by removing only the leading / characters
                    Dim nCommentPos, strBeforeComment, strAfterComment
                    nCommentPos = InStr(strLine, "/")
                    strBeforeComment = Mid(strLine, 1, nCommentPos - 1)
                    strAfterComment = Mid(strLine, nCommentPos + 4)
                    ' then replace the line with the new version
                    pointStart.ReplaceText(pointEnd, strBeforeComment & strAfterComment, vsEPReplaceTextOptions.vsEPReplaceTextKeepMarkers)
                End If
            End If
        Next
    End Sub


It probably has a few edge cases it does not handle correctly, but hopefully this will help for now. If the macro does something useful for you on your syste, you can bind a keyboard shortcut to this macro, so you can trigger it directly.
accord Posted - Feb 10 2012 : 07:56:17 AM
I have put in a feature request to see what the developers make of it:

case=64628

For now, you can use the uncomment feature to uncomment a commented block:

Edit -> Advanced -> Uncomment selection

You can assign a single shortcut for them, since they are also commands like the other menu items: Edit.CommentSelection and Edit.UncommentSelection. Use the following dialog to bind the shortcuts:

Tools -> Options... -> Environment -> Keyboard
haraldh Posted - Feb 09 2012 : 2:57:46 PM
i can use the ide's "Ctrl E, C" twice around a selection. that does the trick. but requires five key presses compared to pressing VA's / twice.
BUT - and this really makes the ide's Ctrl E,C a non-solution - it does not operate as a toggle. when i want to remove the comments i have to tediously select and remove them manually.

i have been a loyal customer for many years, paying my yearly subscription. this is the first time i am requesting a feature. this feature can be added in 10 minutes tops, since it doesn't effect anything else and the logic is already there. all you have to do is output 2 more / based on checking a check-box, which you can bind to a boolean.

i thought it wasn't too much to ask. guess i was wrong...
accord Posted - Feb 09 2012 : 12:38:10 PM
Thank you for the detailed description. And what about Edit -> Advanced -> Comment menu, which can be bound to a keyboard shortcut, and does a very similar thing? Generally, we try to avoid adding too much option to the option dialog, and also, this request is a kind of special case. Or pressing star over a selection is an another way to deal with this situation. It surrounds the code with the other style of comment.
haraldh Posted - Feb 08 2012 : 10:26:37 PM
style-cop enforces code style (not content, just looks) guidelines developed (and used) by microsoft. most of the .NET libs are written with it.

style-cop has no settings whatsoever. nothing can be configured. my current contract (C# and C++) enforces style-cop.

at first it is a huge pain in the ass because some of the rules are indeed way over the top and seem ridiculous. but now that i have used it for a while i must say the core set of rules it enforces makes my code much more readable and maintainable. i am seriously contemplating using it even for my private projects.

with regard to most of the rules VA is not in the way at all. in fact it is a great help, as it always has been.

it is just this comment with // thing that bugs me. i figure it is a very simple mod in your code. just make it an option in the "General" section of VA options. something like "use //// instead of //". shouldn't take more than 10 minutes to implement and test - et voila!

hope this helps.
i am sure there are others here who use style-cop (voluntarily or not) who would appreciate it. this is my second contract where the company insists on using it...
accord Posted - Feb 08 2012 : 9:00:26 PM
I would like to understand your background, first. I have never used style-cop myself, and I'm wondering if wasn't it be easier to just change this setting in the program? I mean, it is possible? Or is your company also expect you to use this style?

Have you tried Edit -> Advanced -> Comment selection (or the keyboard shortcut for it)?

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000