stylecop

Is StyleCop 4.7 compatible with C# 6.0 code

雨燕双飞 提交于 2019-12-22 05:22:00
问题 I installed StyleCop 4.7 for developing customized rules, to analyze our C# code. We write the code in Visual Studio 2015. I can analyze my C# 5.0 (Visual Studio 2013) code, and I get correct response, but when I analyze my C# 6.0 (Visual Studio 2015) code, StyleCop raises an exception for my rules. Now my question is: Is StyleCop 4.7 compatible with C# 6.0 code? If not, do we have any solution? 回答1: TL;DR - Yes. StyleCop 4.7 was updated to be compatible with C# 6 starting with 4.7.51 (Beta)

C# StyleCop - Using “this.” prefix for base class members like current class members or not?

喜欢而已 提交于 2019-12-22 04:36:12
问题 StyleCop has a rule about using "this." prefix to calling class members (SA1101). Is this rule holds true about a member (for example a method) of a class which is inherited from its base class. Example: class BaseClass { protected void F1() { ... } } class ChildClass : BaseClass { protected void F2() { ... } protected void F3() { this.F2(); // This is correct acording to SA1101 // F1 is a member of base class and if I dont put this prefix, stylecop will not show any message. this.F1(); // Is

C# StyleCop - Using “this.” prefix for base class members like current class members or not?

早过忘川 提交于 2019-12-22 04:36:09
问题 StyleCop has a rule about using "this." prefix to calling class members (SA1101). Is this rule holds true about a member (for example a method) of a class which is inherited from its base class. Example: class BaseClass { protected void F1() { ... } } class ChildClass : BaseClass { protected void F2() { ... } protected void F3() { this.F2(); // This is correct acording to SA1101 // F1 is a member of base class and if I dont put this prefix, stylecop will not show any message. this.F1(); // Is

Is there a .Net StyleCop rule which warns about lock(this), lock(typeof, lock(<string obj>, etc.?

删除回忆录丶 提交于 2019-12-21 17:23:37
问题 These 3 types of lock are apparently bad. What other type of locking is bad? Are there Stylecop / FxCop rules that would catch this? If not, then would you please help me with a custom rule implementation? They code for all of them must be similar, right? Thank you. 回答1: The samples (you may need to allow popups in your browser) of John Robbins' Debugging Microsoft .NET Applications book contain sources for such FxCop rules (DoNotLockOnPublicFields, DoNotLockOnThisOrMe, DoNotLockOnTypes, etc.

How to exclude private members from StyleCop rule SA1600

纵然是瞬间 提交于 2019-12-20 16:16:22
问题 Does anyone know how to change the StyleCop rule SA1600 that says elements must be documented so that it only applies to properties and not to private members? Our ORM (DevExpress XPO) requires that you have private members for all public properties (because you have to call a function in the setter to persist it as well as storing it in the private member), and commenting both the public property and the private member with the same thing is killing me considering that some of the tables

C# Is this initialiser really redundant?

自闭症网瘾萝莉.ら 提交于 2019-12-19 10:26:38
问题 I have the following line of code: var dmrReceived = new DownloadMessagesReport(); StyleCop and ReSharper are suggesting I remove the redundant initializer. However if I replace it with DownloadMessagesReport dmrReceived; surely this will generate an object reference not set to an instance of an object? I am using .NET 3.5. Do you no longer manually have to instantiate objects? Next line that follows is: dmrReceived = dc.DownloadNewMessages(param, param2, param3); It's worth noting that dc is

Is it wrong to use braces for variable scope purposes?

允我心安 提交于 2019-12-19 05:08:05
问题 I sometimes use braces to isolate a block of code to avoid using by mistake a variable later. For example, when I put several SqlCommand s in the same method, I frequently copy-paste blocks of code, ending by mixing the names and executing twice some commands. Adding braces helps to avoid this situation, because using a wrong SqlCommand in a wrong place will result in an error. Here's an illustration: Collection<string> existingCategories = new Collection<string>(); // Here a beginning of a

How to configure StyleCop to suppress warnings on generated code?

被刻印的时光 ゝ 提交于 2019-12-19 02:54:04
问题 Another project, Visual Studio's Code Analysis has this option. But I couldn't find it for StyleCop (AKA Source Analysis). The file I want to ignore is a dbml's .designer.cs code, that includes the // <autogenerated> tag. A blog post tells me that it would be sufficient, but in my case it is not. 回答1: StyleCop: How To Ignore Generated Code Edit: Here is the header I use in generated grammars for ANTLR. This is actually the body of a StringTemplate template, so the two \> entries are actually

FxCop/StyleCop for Delphi?

此生再无相见时 提交于 2019-12-18 12:23:52
问题 Does anyone know of an equivalent to FxCop/StyleCop for Delphi? I would really like to get the automatic checking of style, etc. into Continuous Integration. 回答1: The closest I've seen is CodeHealer from SOCK software. We use it, and we have integrated it into our FinalBuilder build. It differs from FxCop in one important way: It analyzes the source code, rather than the produced executable. It also doesn't check quite as much as FxCop does. But I think it is the best thing which is available

Transfer all ReSharper Settings between PCs

只愿长相守 提交于 2019-12-18 10:16:34
问题 I was wondering if there is a way to copy ALL my settings from ReSharper (including the StyleCop for ReSharper settings and the keyboard bindings I have set for ReSharper) from one PC to another? 回答1: Since the export option within Resharper is only for code styles, you'll need to be a bit craftier for all settings. From Peter Ritchie's blog... ...the settings are stored in "%userprofile%\application data\jetbrains\resharper\v4.0\vs9.0". There are a couple of xml files in there that store