StyleCop 4.7.28 for Resharper does not display Quick Fix for SA1126

Jun 1, 2012 at 5:01 PM

Hi,

I have installed the latest version of StyleCop today, and since that time - when warning SA1126 is in effect for some code line - the context menu for that line shows only the warning without Quick-Fix suggestion to add the required "this." prefix.

This used to work fine before this installation.

Thanks

DR

Coordinator
Jun 1, 2012 at 7:56 PM
There has never been a QuickFix for 1126. It's a new rule.


~A.

On 1 Jun 2012, at 18:01, DR12 <notifications@codeplex.com> wrote:

From: DR12

Hi,

I have installed the latest version of StyleCop today, and since that time - when warning SA1126 is in effect for some code line - the context menu for that line shows only the warning without Quick-Fix suggestion to add the required "this." prefix.

This used to work fine before this installation.

Thanks

DR

Jun 1, 2012 at 8:15 PM

Thanks for your reply.

I may be confusing it with a similar rule with a different code, that always existed and required to call a class method or object with a "this." prefix. There definitely was a quick-fix for it, which, when chosen from the context menu, entered the "this." string automatically. I used it all the time.

Maybe the new rule is hiding a similar built-in R# rule which had this quick-fix?

After the installation I chose in the ReSharper options to override R# rules by conflicting StyleCop rules, so this may have been the reason.

Is there a way to revert that?

 

Thanks

DR

Coordinator
Jun 1, 2012 at 8:26 PM
No it's behaving correctly.

1100 and 1101 can QuickFix.

1126 cannot. Stylecop isn't sure which prefix to use so you have to fix manually.


~A.

On 1 Jun 2012, at 21:15, DR12 <notifications@codeplex.com> wrote:

From: DR12

Thanks for your reply.

I may be confusing it with a similar rule with a different code, that always existed and required to call a class method or object with a "this." prefix. There definitely was a quick-fix for it, which, when chosen from the context menu, entered the "this." string automatically. I used it all the time.

Maybe the new rule is hiding a similar built-in R# rule which had this quick-fix?

After the installation I chose in the ReSharper options to override R# rules by conflicting StyleCop rules, so this may have been the reason.

Is there a way to revert that?

Thanks

DR

Apr 24, 2013 at 1:38 PM
Hi,

I also noticed that StyleCop does not provide a QuickFix for SA1126. Why not? What is wrong with using "this." as QuickFix? If no prefix is given, isn't it automatically "this"? I can't think of a situation at the moment where this is not the case (in fact, when manually fixing all the StyleCop errors, I don't think a lot about it either and just add "this" everywhere). Also, having it as QuickFix and especially in code cleanup would help a lot for files were StyleCop rules have not yet been applied and "this" is missing everywhere.

Would it be possible to add that?
Coordinator
Apr 24, 2013 at 3:06 PM
No.

It could be

this
base
Typename


~Andy.

Apr 24, 2013 at 5:45 PM
Can you tell me a code sample where an implicit "base" is used instead of an implicit "this"?
Coordinator
Apr 24, 2013 at 8:40 PM
There is an example in the docs for this rule.


~Andy.

Apr 25, 2013 at 10:29 AM
This one http://www.stylecop.com/docs/SA1126.html?

It doesn't include an example.
May 28, 2013 at 7:32 PM
Edited May 28, 2013 at 7:32 PM
interface IThing
{
 void DoWork();
}

class A : IThing
{
 public void DoWork()
 {
  // do work
 }
}

class B : A, IThing
{
 public override void DoWork()
 {
  // do work
 }

 public void DoOtherWork()
 {
  // do not call this implementation
  base.DoWork();
 }
}