/Community

A Support Community for SubMain Products
in Search
Welcome to SubMain Community Sign in | Join | Help

Need help creating rules

Last post 01-29-2008, 12:37 AM by Serge B.. 10 replies.
Sort Posts: Previous Next
  •  01-10-2008, 2:34 AM 385

    Need help creating rules

    Hi

    I have a load of legacy code that uses a very out of date naming convention, and which i'd like to bring up to date. My naming scheme is as follows:

    Fields are prefixed with uppercase "F" followed by lowercase single char denoting field type:

       private object FoMyValue;         // object
       private int FiMyValue;               // int

     Local variables and parameters use the same convention to denote type, but without the "F" prefix:

       int iMyValue;   // int


    I'm having trouble setting up rules for this. Have tried creating one based on UseOrAvoidCertainPrefixes, but it doesn't work for me. I'm using the following values:

    NextCharCapitalizationStyle = Lower
    PrefixToCheck = Fi
    PrefixUsage = Avoid

    One final thing, is it possible to specify wildcard so that Fo, Fi, Fn, Fs etc would be caught by something like F* for example?

     

    Thanks

     

    Ben

  •  01-11-2008, 1:58 AM 386 in reply to 385

    Re: Need help creating rules

    Hi Ben,

    We have a rule on our to-do list that will handle prefixes/suffixes based on the code element type. This rule will allow to do what you described above.

    The rule is to be worked on for the rule update immediately following the release.

     


    Thank you,
    Serge Baranovsky
    http://submain.com - .NET Developer Tools  |  Microsoft VB MVP  |  http://vbcity.com - VB Developer Community
    » » (Static Code Analysis + Automatic Refactoring) / Painless Coding Guidelines = CodeIt.Right - http://submain.com/codeit.right
    » » C#/VB .NET Coding Guidelines - FREE 100+ page ebook (PDF) http://submain.com/guidelines
  •  01-14-2008, 3:18 AM 387 in reply to 386

    Re: Need help creating rules

    Hi Serge

    Thanks for your response. Any hint as to when the release will be out?

     
    Thanks

    Ben
     

  •  01-14-2008, 3:22 AM 388 in reply to 387

    Re: Need help creating rules

    Hi Ben, 

    We are targeting end of January.

     


    Thank you,
    Serge Baranovsky
    http://submain.com - .NET Developer Tools  |  Microsoft VB MVP  |  http://vbcity.com - VB Developer Community
    » » (Static Code Analysis + Automatic Refactoring) / Painless Coding Guidelines = CodeIt.Right - http://submain.com/codeit.right
    » » C#/VB .NET Coding Guidelines - FREE 100+ page ebook (PDF) http://submain.com/guidelines
  •  01-26-2008, 12:25 PM 421 in reply to 386

    Re: Need help creating rules

    Being able to handle prefixes/suffixes based on the code element type is very important to us as well.

    Anything you can do to prioritize this item would be appreciated.  In the meantime, is there any way that we can determine the type of a field in a custom rule?

     

  •  01-27-2008, 6:51 PM 424 in reply to 421

    Re: Need help creating rules

    Hi Grant,

    We actually did make it a priority - rules UsePrefixForReturnType, AvoidPrefixForReturnType, UsePrefixForDerivedType and AvoidPrefixForDerivedType were ready to be released last Friday and we had to hold on them to change (rule) naming scheme for consistency.

    The four rules will be published via Auto-Update on Monday, Tuesday the latest.

     


    Thank you,
    Serge Baranovsky
    http://submain.com - .NET Developer Tools  |  Microsoft VB MVP  |  http://vbcity.com - VB Developer Community
    » » (Static Code Analysis + Automatic Refactoring) / Painless Coding Guidelines = CodeIt.Right - http://submain.com/codeit.right
    » » C#/VB .NET Coding Guidelines - FREE 100+ page ebook (PDF) http://submain.com/guidelines
  •  01-28-2008, 11:50 AM 425 in reply to 424

    Re: Need help creating rules

    Thanks Serge.

    In order to fully support our naming conventions, we will also need to be able to alter the prefix of a variable name, based on whether it is a member variable, or, if it is a parameter, we need to know whether it is passed by value or by reference.  Will this be possible?

    Grant

     

  •  01-28-2008, 3:11 PM 428 in reply to 425

    Re: Need help creating rules

    Grant,

    I just published the rules - http://submain.com/blog/NewCodeItRightRulesUpdate20080128.aspx

    Yes, for the member/parameter you can play with the Target property of each rule instance. And I'm afraid we don't have a solution for the by val/by ref parameter differentiation - we will look into this.

     


    Thank you,
    Serge Baranovsky
    http://submain.com - .NET Developer Tools  |  Microsoft VB MVP  |  http://vbcity.com - VB Developer Community
    » » (Static Code Analysis + Automatic Refactoring) / Painless Coding Guidelines = CodeIt.Right - http://submain.com/codeit.right
    » » C#/VB .NET Coding Guidelines - FREE 100+ page ebook (PDF) http://submain.com/guidelines
  •  01-28-2008, 4:27 PM 429 in reply to 428

    Re: Need help creating rules

    Serge,

    I've downloaded RC1 and the rules update.  I don't really see how I can use these new rules to validate the following coding standards:

    Member-level variables

    Dim msVariable As String

    Dim miVariable As Integer

     

    Local variables

    Dim sVariable As String

    Dim iVariable As Integer

     

    Would you please provide some samples as to how this could be done?

    Thanks,

    Grant

  •  01-28-2008, 4:58 PM 430 in reply to 429

    Re: Need help creating rules

    Grant,

    I will post a tutorial at some point. Here are quick samples

    grparry:

    Member-level variables

    Dim msVariable As String

    Dim miVariable As Integer

    Rule: Use prefix for return type
    Target: Uncheck all but Member -> Field
    PrefixToCheck: ms
    TypeName: System.String

    and

    Rule: Use prefix for return type
    Target: Uncheck all but Member -> Field
    PrefixToCheck: mi
    TypeName: System.Int32

    grparry:

    Local variables

    Dim sVariable As String

    Dim iVariable As Integer

    Rule: Use prefix for return type
    Target: Uncheck all but Member -> Variable
    PrefixToCheck: s
    TypeName: System.String

    and

    Rule: Use prefix for return type
    Target: Uncheck all but Member -> Variable
    PrefixToCheck: i
    TypeName: System.Int32

    Is this helpful?

     


    Thank you,
    Serge Baranovsky
    http://submain.com - .NET Developer Tools  |  Microsoft VB MVP  |  http://vbcity.com - VB Developer Community
    » » (Static Code Analysis + Automatic Refactoring) / Painless Coding Guidelines = CodeIt.Right - http://submain.com/codeit.right
    » » C#/VB .NET Coding Guidelines - FREE 100+ page ebook (PDF) http://submain.com/guidelines
  •  01-29-2008, 12:37 AM 431 in reply to 430

    Re: Need help creating rules

    I corrected my post above - the type name should be full qualified - System.String and System.Int32

     


    Thank you,
    Serge Baranovsky
    http://submain.com - .NET Developer Tools  |  Microsoft VB MVP  |  http://vbcity.com - VB Developer Community
    » » (Static Code Analysis + Automatic Refactoring) / Painless Coding Guidelines = CodeIt.Right - http://submain.com/codeit.right
    » » C#/VB .NET Coding Guidelines - FREE 100+ page ebook (PDF) http://submain.com/guidelines
View as RSS news feed in XML