Geeks With Blogs

News FAQ on the correct forum to post at: http://forums.asp.net/p/1337412/2699239.aspx#2699239
Tatworth

When updating code to be Style Cop compliant, one of the issues frequently encountered is SA1401:

SA1401: Fields must be declared with private access. Use properties to expose fields.  

The code concerned is:

    public TransitionSet Lookbacks = new TransitionSet();

The first step is to select Lookbacks. In the left margin, Reshaper has a series of actiosn and I select the one for "move initialization to constructor(s)".

The adds the following live to the constructor.

      Lookbacks = new TransitionSet();

This needs to be modified to avoid SA1101. " The call to Lookbacks must begin with the 'this.' prefix to indicate that the item is a member of the class." The line becomes:
      this.Lookbacks = new TransitionSet();

The original line is now:

    public TransitionSet Lookbacks;

This is modified to:
    public TransitionSet Lookbacks { get; set; }

I now select the line and do a control-shift-D and Ghost Doc documents the property. When doing several properties, I use the document file function of Ghost Doc Pro. I then run the unit tests again to check that nothing is broken.

Now I am down to 116 issues with Irony!

Posted on Sunday, April 24, 2011 2:53 PM | Back to top


Comments on this post: Style Cop 4.5, GhostDoc and Resharper - SA1401

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © TATWORTH | Powered by: GeeksWithBlogs.net