/Community

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

Detecting control names

Last post 07-29-2008, 12:06 PM by Serge B.. 10 replies.
Sort Posts: Previous Next
  •  01-15-2008, 8:29 AM 394

    Detecting control names

    Is there any existing way to detect control names and enforce a certain prefix on them like "ux"?

    If not, what is the possiblity of adding this feature?

     Tod

    Filed under:
  •  01-15-2008, 9:43 AM 395 in reply to 394

    Re: Detecting control names

    Hi Tod,

    This requires new rule which we have on our list for the early next week update.

    Just clarify, you want to enforce a specific prefix for types derived from System.Windows.Forms.Control, correct?

     


    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-31-2008, 7:21 AM 432 in reply to 395

    Re: Detecting control names

    Yes, that is correct.  We want all of our controls to start with 'ux'.  

    Private orderNumber as TextBox   'should be flagged 

    Private uxOrderNumber as TextBox   'would be accepted.

    Is this type of rule in your latest rules update from Jan 28?

    Filed under:
  •  01-31-2008, 10:19 AM 433 in reply to 432

    Re: Detecting control names

    Yes, the rule is in the Jan 28 update.

    You need to new add rule (see How to add rule to User Profile) with

    Rule: Use prefix for derived type (Naming category)

    Target: Choose appropriate target (i.e. Field)

    MustImplement: System.Windows.Forms.Control

    PrefixToCheck: ux

     


    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
  •  04-04-2008, 7:36 AM 502 in reply to 433

    Re: Detecting control names

    Hi Serge,

    Using this rule, is it possible to check that certain variable types are using a certain prefix, ie. string respectively System.String should always be prefixed with str? I tried this rule but it did not trigger at all:

    Rule: Use prefix for derived type (Naming category)

    Target: Field, Parameter, Variable, Local Constant

    MustImplement: System.String

    PrefixToCheck: str

    Also tried defining all a number of strings using System.String instead of the usual alias but that have no effect either.

     Best Regards

     Fred

  •  04-08-2008, 1:01 AM 503 in reply to 502

    Re: Detecting control names

    Hi Fred,

    The rule you want to use for this is "Use prefix for return type  (Naming) "

     

     


    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
  •  06-27-2008, 3:17 AM 574 in reply to 503

    Re: Detecting control names

    Hi,

    How could I do the same checking for WebControls? I tried the same way by using System.Web.UI.WebControls.TextBox for example but it doesn't work.

    Please advice.

    Thank you

  •  06-27-2008, 9:07 AM 575 in reply to 574

    Re: Detecting control names

    Yes, that's how you configure rule instance for WebForms controls.

    Few questions:

    Are your WebFroms controls declared just in the HTML mark up or in the code-behind (or in-page code) as well? Like the snippet below
    public partial class _Default : System.Web.UI.Page
    {
        private TextBox textBox1;

        protected void Page_Load(object sender, EventArgs e)
        {
       
        }
    }

    If your web project is written in VB.NET using VS2005 then you need to declare the following Imports in the code-behind module explicitly
    Imports System.Web.UI.WebControls
    then CodeIt.Right will find your WebForms control. Visual Studio implicitly declares number of imports for VB.NET and hides it in web.config file. VS2005 has an issue when it does not return the reference list to hosted VS Packages.

    Please let me know if any of this helps.


    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
  •  06-27-2008, 11:55 PM 578 in reply to 575

    Re: Detecting control names

    Hi,

    I am using drag and drop html control to web form. I didn't see any code behind declaration, therefore should be in the HTML mark up.

    I checked code behind code and see using System.Web.UI.WebControls there. But analysis still not work.

    Does it CIR not support this?

    Please advice. Thank you
     

  •  07-24-2008, 8:33 PM 589 in reply to 578

    Re: Detecting control names

    Hi,

    Any updates? Thank you

  •  07-29-2008, 12:06 PM 594 in reply to 578

    Re: Detecting control names

    If you reference System.Web.UI.WebControls CIR should pick up the web controls in HTML markup as well. If we can reproduce we should fix this soon.

    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