We Moved - This Forum is now Read-Only

Our new community is now available at https://support.submain.com/community/. We will leave historical discussions here in this forum view-only mode for search purposes, but moving forward, please post your questions in the appropriate category in the new community.

  SubMain - CodeIt.Right The First Time!


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

Suggestion to make "Do not declare externally visible instance fields " auto fix much nicer.

Last post 12-03-2008, 10:55 PM by Serge B. (SubMain). 1 replies.
Sort Posts: Previous Next
  •  12-01-2008, 6:10 AM 649

    Suggestion to make "Do not declare externally visible instance fields " auto fix much nicer.

    When you fix the following rule: 

    Do not declare externally visible instance fields

    Violation Description

    Externally visible type BuildLab.SharedFunctionality.Utility.ActiveDirectoryWrapper contains an instance field userData is externally visible because has public modifier.

    Correcting Violation

    The rule provides the following auto-correct options:

    • Change field modifier to private.
    • Create property from the field and set its modifier to public.
    • Create property from the field with name and modifier specified.

    you currently rename the public property to be userData1 by default.  I personally can't stand numbers being tagged on to things, but that is a minor problem  If the field was used globally, there is a very good chance that the name is what they want it to be referred to.  It would make much more sense to me to simply rename the filed to a different name and keep the property as the same name.  Then your code won't get littered with old field names with 1 tagged at the end.  Now the private field is being renamed, it can have a more sensible name like UserDataInternal, or MyUserData, or anything that is more descriptive than UserData1!

    So in this example:

    public string userData1;


    private string userDataInternal;
    public string
        get { return userDataInternal; }
        set { userDataInternal = value; }

    The options page should allow you to override both the public and the private default names, but ideally you need a useable default.




  •  12-03-2008, 10:55 PM 660 in reply to 649

    Re: Suggestion to make "Do not declare externally visible instance fields " auto fix much nicer.

    Great suggestion. Thank you. We will add another correction option to replace it with a default. (When CodeIt.Right runs in VS2008 or newer)
    Thank you,
    Serge Baranovsky
    http://submain.com - .NET Developer Tools  |  Microsoft MVP  |  ASP Insider
    » » CodeIt.Right Will Fix Your Code!™ - 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 |