Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I just declared a global variable and a local one with the same name and used this.variableName to reference the global one, as you should in this case...and got no grey out...
VS 2015 Community Edition. -
@VenomCLC yeah which is the only valid use case.
I personally prefer underscore prefix to identify class fields. -
@BungleFunk well....yes....I mean you're not gonna use this.globalVar to identify a global variable if you don't have a local one with the same name, that's where it greys out, if stylecop tells you to put "this." when not needed it means yours is badly configured.
-
@azuredivay I have never needed "this" while creating commands in a view model so I don't understand where you are coming from.
-
@VenomCLC The stylecop rules were changed by another dev which caused the 3000 build errors :(
-
nickRm08yCompletely agree, probably the biggest reason why StyleCop is not enabled in our project.
-
@nickRm Rather then remove the rule they set all stylecop errors as warning so now we have 3000 warnings.
Kinda defeats the purpose. -
viking817408yI think the only time I use "this" is when assigning constructor parameters to local, if they have the same name - or using an extension for that interface / class (rare)
In C# using "this."
WHY? It doesn't help with readability. It just clutters up the code and adds nothing.
It should never be a required prefix.
What makes it worse is, Visual Studio greys it out because its not required!
Then there is stylecop. This got enabled on our project which generated 3000 build errors because of missing "this."
undefined
c# stylecop vs