this (another C# programmer rant)
-
jbarton wrote:
Apparently this is the Microsoft recommended way of indicating member variable access.
Basically, StyleCop is being used more and more across Microsoft teams so expect more of it going forward. It's the Java house style btw. Note that StyleCop is customisable though. You can disable that rule for your team.
Kevin
I wish I could disable this warning. It was a decision from higher up that StyleCop would be used pretty much as is (a few warnings have been turned off, but for the most part they are all on). There is a check-in policy that says that there can't be any StyleCop warnings based on the global team settings. I can't turn it off just for my machine or I would get warnings and the check-in would fail.
-
I wish I could disable this warning. It was a decision from higher up that StyleCop would be used pretty much as is (a few warnings have been turned off, but for the most part they are all on). There is a check-in policy that says that there can't be any StyleCop warnings based on the global team settings. I can't turn it off just for my machine or I would get warnings and the check-in would fail.
Too bad for you. Personally I'm not much fussed by this rule. There are many things that irritate me more. :)
Kevin
-
In vs2k3, intilisense didn't start as soon as you began typing. IF you weren't sure what the variable was called you had to type
this.
to make it come up. Not needed int 2k8, I never used 2k5; could just be an old bad habit.Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots. -- Robert Royall
-
Code:
public override string ToString() { string s = String.Empty; for (long i = 0; i < this.k; ++i) { s += this.data\[i\].ToString() + " "; } return s; } // ToString()
I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc
-
Too bad for you. Personally I'm not much fussed by this rule. There are many things that irritate me more. :)
Kevin
i dont know why stylecop is pushing the "this." rule, while Resharper always yell at you when you do so.
Life - Dreams = Job TheCardinal CTC-RDG
-
Visual Studio generated code uses it everywhere. Drives me nuts coming from a C++ background.
Mark Salsbery Microsoft MVP - Visual C++ :java:
Mark Salsbery wrote:
Visual Studio generated code uses it everywhere.
Designer files look like a Christmas tree when running ReSharper (full of warning notifications). :P
-
Code:
public override string ToString() { string s = String.Empty; for (long i = 0; i < this.k; ++i) { s += this.data\[i\].ToString() + " "; } return s; } // ToString()
I HATE WHEN PROGRAMMERS USE THIS. this.k??? Give me a FB!!!! That doesn't even make sense from a "I'm saving keystrokes by prefixing with "this." so Intellisense kicks in." Marc
I admit I was doing
this
as well when I started C# programming. Now I'm running ReSharper and it marksthis
keyword use as a warning so I clean them up whenever I find them in my old code. One use is when a private field has the same name as a constructor parameter, e.g.public class A
{
private string name;public A (string name) { //name = name; // ERROR this.name = name; // OK! }
}
But of course this means you need some naming conventions. ;)
-
i dont know why stylecop is pushing the "this." rule, while Resharper always yell at you when you do so.
Life - Dreams = Job TheCardinal CTC-RDG
I don't think it should be mandated. But OTOH why would Resharper explicitly reject it? What's their rationale?
Kevin
-
I don't think it should be mandated. But OTOH why would Resharper explicitly reject it? What's their rationale?
Kevin
dont know about jetbrain stand about it...maybe thats why they flag it as a warning. for me its a personal choice ;)
Life - Dreams = Job TheCardinal CTC-RDG
-
I admit I was doing
this
as well when I started C# programming. Now I'm running ReSharper and it marksthis
keyword use as a warning so I clean them up whenever I find them in my old code. One use is when a private field has the same name as a constructor parameter, e.g.public class A
{
private string name;public A (string name) { //name = name; // ERROR this.name = name; // OK! }
}
But of course this means you need some naming conventions. ;)
Pawel Krakowiak wrote:
One use is when a private field has the same name as a constructor parameter, e.g.
Which is the only time I use this. Marc
-
Pawel Krakowiak wrote:
One use is when a private field has the same name as a constructor parameter, e.g.
Which is the only time I use this. Marc
Marc Clifton wrote:
Which is the only time I use this.
Wouldn't it be better though to name the fields differently? I prefix all private fields with an underscore _. Um, I'm not looking to start that debate again. :P
-
Marc Clifton wrote:
Which is the only time I use this.
Wouldn't it be better though to name the fields differently? I prefix all private fields with an underscore _. Um, I'm not looking to start that debate again. :P
Pawel Krakowiak wrote:
I prefix all private fields with an underscore _. Um, I'm not looking to start that debate again. :P
hehe. I personally don't like underscores, but at least I'm consistent in how I write my classes. :) Marc
-
No C++ programmers in that thread. This.IsGreat(true); Personally, I really hate to see “::someMetod() “ in the code. Why it is so difficult for someone to type the base class name?!? - especially if you have a multiple inheritance.
The narrow specialist in the broad sense of the word is a complete idiot in the narrow sense of the word. Advertise here – minimum three posts per day are guaranteed.
modified on Thursday, September 18, 2008 2:19 PM
Deyan Georgiev wrote:
Personally, I really hate to see “::someMetod() “ in the code.
That's not how the scope resolution operator is behaving in this instance. This usage says to look outside the class for resolution. So, if you're using a file function called: open, and you have a member of your class called open, and you want to open a file you'd prefix it as: ::open which would call the c function and not the C++ method.
I've heard more said about less.