Problem with SA1101 and SA1126 in Power Collections

May 27, 2012 at 7:27 PM
Edited May 27, 2012 at 7:32 PM

I have installed the latest stylecop (4.7.26) and checked the Power Collection project that I submitted last year. At lot of missing this identifiers are now recognised, however I think I am getting some false positives.

I get  "SA1126: The call to ICollection<Deque<T>> must begin with the 'this.', 'base.', 'object.' or 'Deque<T>.' prefix to indicate the intended method call." on the following:

      ICollection<T> coll;
      if (collection is ICollection<Deque<T>>)
      {
        coll = (ICollection<T>)collection;
      }
      else
      {
        coll = new List<T>(collection);
      }  

I get "SA1101: The call to Hash<TestItem> must begin with the 'this.' prefix to indicate that the item is a member of the class." on:

      this.Hash = new Hash<TestItem>(new DataComparer());

Hash is a class, so adding this. to it generates an error.

I have the zipped up solution ready to send to you.

Coordinator
May 27, 2012 at 7:58 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
May 27, 2012 at 8:01 PM

the 'new' false positive is already checked in to 4.7.27 - other fixing now

Coordinator
May 27, 2012 at 8:11 PM

If you can email the sample that compiles with the SA1126 repro I'll fix it now.

May 28, 2012 at 6:43 AM

Done

Coordinator
May 28, 2012 at 11:38 AM

Fixed in upcoming 4.7.27

May 29, 2012 at 8:16 PM

I have installed 4.7.27 but still get SA1126 on the first line below: The call to ICollection<Deque<T>> must begin with the 'this.', 'base.', 'object.' or 'Deque<T>.' prefix to indicate the intended method call.

      if (collection is ICollection<Deque<T>>)
      {
        coll = (ICollection<T>)collection;
      }
      else
      {
        coll = new List<T>(collection);
      }

Coordinator
May 29, 2012 at 8:18 PM
Edited Jun 27, 2012 at 5:48 PM
Very odd.
I tested it with that and added that code to the tests. I'll have a look later.


~A.

 

Coordinator
May 29, 2012 at 8:54 PM
Edited Jun 1, 2012 at 11:18 AM
I've just checked and the test and fix for that are in 4.7.27. I removed the fix and the test failed, put the fix back and it passed. Are you sure you have .27 installed and it's not picked up an old one or a cached result from anywhere?


~A.

 

May 31, 2012 at 4:46 PM

I can confirm that I'm having the same issue and I've just updated to 4.7.27.

  1. SA1126: (Action<CopyItemContext<IDataItem>>)receivedContexts.Add,
  2. SA1126: this.CopySteps = new Action<CopyItemContext<TItem>>[]
  3. SA1101: this._roles = this.ArePermissionsSupported ? this.Connector.SecurityConnector.GetRoles(this.ListInfo.Web) : new List<SGRole>();
  4. SA1101: this.ViewFields = new List<string>();

In all cases, it wants a qualifier (this for the SA1101 and this, base, object or <Class> for SA1126).

Coordinator
May 31, 2012 at 4:54 PM
Edited Jun 1, 2012 at 11:18 AM
Can you attach a zip of the repro please as I need the full cs file to fix it


~A
May 31, 2012 at 11:33 PM

I have de-installed 4.7.27 (had the debug version as well) and then re-installed  4.7.27. Problem is now fixed.

Thank you.

Coordinator
Jun 1, 2012 at 11:22 AM

@cmerat: none of those lines report any issues in 4.7.28. Make sure you've removed any StyleCop.cache files.

Jun 1, 2012 at 12:56 PM

@andyr Uninstalled and reinstalled, deleted StyleCop.cache file. Still having the issue. We are using a custom Settings.StyleCop file for this project. Could this be what is interfering? http://pastebin.com/ASbebhpd

You're right about the lines, when I create a new project, they aren't flagged. However, they are flagged in our existing solution.

Jun 22, 2012 at 1:13 PM
Edited Jun 22, 2012 at 1:13 PM

Any suggestion on why old projects are being contaminated by these false positives? I've deleted all StyleCop cache files but it's still indicating a requirement for a prefix on generic delegates:

Warning 2 SA1126: The call to Action<CopyItemContext<TItem>> must begin with the 'this.', 'base.', 'object.' or 'BaseBulkEditExpert<TRepository,TItem>.' prefix to indicate the intended method call.

[e] Still occurs on 4.7.32

Coordinator
Jun 22, 2012 at 2:34 PM

Its a new rule and may have a bug. Please open a Work Item and attach a repro file file and I'll investigate

Jun 26, 2012 at 4:17 PM

I'm unable to reproduce the issue in a new solution, only our existing solution and I can't attach that. I've tried multiple times but am not getting the false positive. It only happens in our existing solution.

I cleared all of the StyleCop.cache files in my solution. Please note however that we are using a custom Settings.StyleCop (linked in my previous message). The error occurs every single time we run StyleCop. Is there another StyleCop cache we need to worry about?

Jul 10, 2012 at 4:21 PM

Still present in 4.7.34. Still cannot reproduce it in a new solution, but all our existing solutions are affected.

Aug 3, 2012 at 12:14 PM

I have this issue in 4.7.35.

 

I have windows form and checking ModifierKeys. And SA 1126 is showing,

Sep 6, 2012 at 5:56 PM

Resolved in 4.7.36.

Many thanks!!