SubMain - CodeIt.Right The First Time!

/Community

A Support Community for SubMain Products
 Home Products Services Download Purchase Support
in Search
 
Home Forums Blogs Tutorials Downloads
Welcome to SubMain Community Sign in | Join | Help

Control Prefixes

Last post 09-25-2009, 12:27 AM by Serge B.. 7 replies.
Sort Posts: Previous Next
  •  09-23-2009, 5:27 AM 922

    Control Prefixes

    I read a couple of forum posts about checking control prefixes, but I cant seem to get them to work. Below is my setup:

    Rule: Use prefix for derived type

    Scope: Any

    Target: Variable, LocalConstant, Method, Event, Property, Parameter, Constant, Field

    MustImplement: System.Windows.Forms.TextBox

    PrefixToCheck: txt 

    Filed under: ,
  •  09-23-2009, 6:27 AM 923 in reply to 922

    Re: Control Prefixes

    Hi Forrest,

    You should use Use prefix for return type rule in this case.

     


    Thank you,
    Misha Zhutov
    http://submain.com - .NET Developer Tools | Microsoft VB MVP
  •  09-23-2009, 6:43 AM 924 in reply to 923

    Re: Control Prefixes

    I tried the Use prefix for return type rule and it didn't catch the button that missing the btn prefix. I used the default settings for the rule and only changed the following:

    PrefixToCheck: btn

    TypeName: System.Windows.Forms.Button 

    I'm sure that I'm forgetting something. Thanks.

    Filed under: ,
  •  09-23-2009, 7:19 AM 925 in reply to 924

    Re: Control Prefixes

    By default, designer files are excluded from analysis.

    You can check "Exclude *.designer files" OFF in Options -> Exclude.

    BTW, by default "Windows Form Designer generated code" region is excluded from analysis along with other "generated" regions (see Options -> Exclude Regions)

     


    Thank you,
    Misha Zhutov
    http://submain.com - .NET Developer Tools | Microsoft VB MVP
  •  09-23-2009, 7:40 AM 926 in reply to 925

    Re: Control Prefixes

    Thank you very much, the button in question showed up once I unchecked the "Exclude *.Designer files".

    I also have a question about the Source file should have a header rule. My company requires a comment header but not like the example in the Template property. Ours looks something like this:

    /////////////////////////////////////////////////////////////////////////////////////////

    // Programmer: forrestb

    // Date: 03/21/2009

    // Description: A description goes here

    ////////////////////////////////////////////////////////////////////////////////////////

    What I'm trying to get at is, we have no dynamic content in these headers (they are just comments). Is there a way to use the Source file header rule with our headers. 

    Filed under: ,
  •  09-23-2009, 7:56 AM 927 in reply to 926

    Re: Control Prefixes

    Sure, you can. Just set Template property to:

    <#@ template language="C#" #>
    /////////////////////////////////////////////////////////////////////////////////////////

    // Programmer: forrestb

    // Date: 03/21/2009

    // Description: A description goes here

    ////////////////////////////////////////////////////////////////////////////////////////

    and save the rule.

     


    Thank you,
    Misha Zhutov
    http://submain.com - .NET Developer Tools | Microsoft VB MVP
  •  09-23-2009, 8:07 AM 928 in reply to 927

    Re: Control Prefixes

    Worked nicely, thanks.

    Now, can I include the designer files on a per rule basis. And what I mean by this is can I have the controls rule include the designer files and the header rule exclude the designer files. 

    Filed under: ,
  •  09-25-2009, 12:27 AM 929 in reply to 928

    Re: Control Prefixes

    Forrest,

    We were mulling over a number of ideas on excluding rules on per file basis but did not find an elegant solution and this feature is still up on the list.

    Meanwhile, you can exclude rules as needed in the violation list.

    Thanks!


    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
 
     
 
Home |  Products |  Services |  Download |  Purchase |  Support |  Community |  About Us |