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

NA00003: AvoidLanguageSpecificTypeNamesInParameters

Last post 12-14-2009, 6:56 AM by Serge B.. 6 replies.
Sort Posts: Previous Next
  •  12-07-2009, 8:23 AM 1017

    NA00003: AvoidLanguageSpecificTypeNamesInParameters

    I'm getting this warning on a parameter called callbackObject and offering to rename it to callback.

    Why is this a language specific type name?

    Wouldn't callback trigger the same rule?

    What am I missing?

     


    Paulo Morgado
    Paulo Morgado
    Filed under: , ,
  •  12-07-2009, 9:44 AM 1018 in reply to 1017

    Re: NA00003: AvoidLanguageSpecificTypeNamesInParameters

    Good catch, Paulo!

    Shall the rule trigger violation for callbackObject parameter? No, it shouldn't. And yes, it should. The triggered violation in this particular case is somewhat arbitrary. But ultimately the MS guidelines are very clear on this -

    "Avoid using language-specific types name in parameters and members and data type identifiers in parameters. Types names might not be intuitive for all developers. It is recommended that you select a generic name, such as 'value', instead. If this is not sufficient, be sure to use the type name as it is defined in the .NET Framework Library and avoid language-specific type names completely."

    And even for the callbackObject below:

        public class A
        {
            public void Test(object callbackObject)
            {
            }
        }

    "In member 'A.Test(object)', consider replacing the data type identifier 'Object' in parameter name 'callbackObject' with a more generic term, such as 'value'."

    After all the parameter callbackObject above is of a type object...

    So, while the rule is configured to follow MS guidelines pretty strictly, I do agree with your point. In CodeIt.Right we provide multiple ways to tweak rules to you needs if disagree. In this case you can add callbackObject into the ExcludeList property (comma delimited list) of your instance of the rule "NA00003: AvoidLanguageSpecificTypeNamesInParameters" - this will solve the issue.

    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
    Filed under: ,
  •  12-13-2009, 5:01 PM 1026 in reply to 1018

    Re: NA00003: AvoidLanguageSpecificTypeNamesInParameters

    Ok. I totally missed that one. I was thinking the it was refering to callback.

    I'm not changing it here because it's what it is - an object. I won't do what has been done in some BCL classes like using obj instead.

    I do agree that CodeIt.Right should use the same rules as FxCop (and StyleCop).

    Instead of an exclude list, why not consider the SupressMessageAttribute?


    Paulo Morgado
    Paulo Morgado
  •  12-13-2009, 6:02 PM 1027 in reply to 1026

    Re: NA00003: AvoidLanguageSpecificTypeNamesInParameters

    Paulo,

    Paulo Morgado:

    I do agree that CodeIt.Right should use the same rules as FxCop (and StyleCop).

    Instead of an exclude list, why not consider the SupressMessageAttribute?

    We look at this very similar - CodeIt.Right in the default profile is following MS Guidelines :)

    As for the SupressMessage attribute, CodeIt.Right does support it and even extends a bit. Here are examples:

    // excludes all violations of the Design category
    [SuppressMessage("SubMain.CodeItRight.Rules.Design", "")]


    // excludes violation by rule ID
    [SuppressMessage("SubMain.CodeItRight.Rules.Design", "DE00010")]


    // excludes violation by rule name
    [SuppressMessage("SubMain.CodeItRight.Rules.Design", "TypesContainStaticMembersShouldBeSealed")]


    // excludes violation by rule ID and rule name
    [SuppressMessage("SubMain.CodeItRight.Rules.Design", "DE00010:TypesContainStaticMembersShouldBeSealed")]


    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
  •  12-14-2009, 3:44 AM 1030 in reply to 1027

    Re: NA00003: AvoidLanguageSpecificTypeNamesInParameters

    Is there a list of this suppressions?

    This is a strange request, but here it goes: if CodeIt.Right knows the corresponding FxCop or StyleCop rule being supressed, it should also supress its corresponding rule (a supression attribute migth be needed).


    Paulo Morgado
    Paulo Morgado
  •  12-14-2009, 6:40 AM 1032 in reply to 1030

    Indifferent [:|] Re: NA00003: AvoidLanguageSpecificTypeNamesInParameters

    Paulo Morgado:

    This is a strange request, but here it goes: if CodeIt.Right knows the corresponding FxCop or StyleCop rule being supressed, it should also supress its corresponding rule (a supression attribute migth be needed).

    CodeIt.Right does that too :)  It will respect the FxCop SuppressMessage attribute for the FxCop rules that CodeIt.Right has a corresponding rulle.

    Paulo Morgado:

    Is there a list of this suppressions?

    Are you looking for a tutorial? The SuppressMessage attribute takes two arguments - the Rule Category or the Rule ID/Class Name - both of these parameters are optional but one of them is required.

    For example:

    // exclude category "Design"
    [SuppressMessage("SubMain.CodeItRight.Rules.Design", "")] 

    // Exclude rule by Rule ID
    [SuppressMessage("
    ", "DE00010")] 

    // Exclude rule by Rule Name
    [SuppressMessage("", "TypesContainStaticMembersShouldBeSealed")] 

    // Exclude rule by Rule ID and Rule Name
    [SuppressMessage("", "DE00010TypesContainStaticMembersShouldBeSealed")] 

    // for the custom rules in the "MyOwnCategory"
    [SuppressMessage("
    MyOwnCategory", "")] 

    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
  •  12-14-2009, 6:56 AM 1033 in reply to 1032

    Re: NA00003: AvoidLanguageSpecificTypeNamesInParameters

    Paulo,

    I believe I misread part of your question. I edited my post above.

     


    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 |