Tech Off Thread

4 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

FxCop vs Static Constructors

Back to Forum: Tech Off
  • User profile image
    aza

    Hi All,

    FxCop displays particular vehemence towards static constructors: it actually displays vehemence towards a lot of things but time is short. The argument proposed by the FxCop documentation is that, "Initializing static data in explicit static constructors results in less performant code.", which is fair enough. But what if the static constructor is being used for more then just initialising static data?

    For example I use a static logging class and initialise the logger in the static constructor. The logger is thread safe and I prefer to have a one stop shop for logging to make it for application wide changes. But back to the original question, why does FxCop object to static constructors when they present a valid useful purpose? Is there a reason why thread safe static constructors should be avoided?

    Regards,
    Aaron

  • User profile image
    JParrish

    I also have a question about FXCop.. it picks on naming conventions when I have named something that is a 3 letter acronym followed by capitalization of the next work. For instance FTPAddress.. it doesn't like that, but is FtpAddress actually preffered? I have seen some member names in the FCL that are named this way.. but since the rule was for acronyms up to 3 letters you capitalize, I am not sure.

  • User profile image
    brantonb

    JParrish wrote:
    I also have a question about FXCop.. it picks on naming conventions when I have named something that is a 3 letter acronym followed by capitalization of the next work. For instance FTPAddress.. it doesn't like that, but is FtpAddress actually preffered? I have seen some member names in the FCL that are named this way.. but since the rule was for acronyms up to 3 letters you capitalize, I am not sure.


    The design guidelines state: "When using acronyms, use Pascal case or camel case for acronyms more than two characters long. For example, use HtmlButton or htmlButton. However, you should capitalize acronyms that consist of only two characters, such as System.IO instead of System.Io". I believe FxCop is trying to enforce those guidelines.

  • User profile image
    JParrish

    Aha.. that is obvious now. I had thought it said 3 letters.. thanks for the correction =)

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.