stylecop

CA1500 vs. SA1309 - Which one wins?

本小妞迷上赌 提交于 2019-11-30 11:08:24
I'll prefix by saying that I understand that both Code Analysis and StyleCop are meant as guidelines, and many people chose to ignore these anyway. But having said that, I'd like to see what the general consensus is with regard to these two rules. Rule CA1500 says don't make parameter names and private field names the same. Rule SA1309 , on the other hand, says don't prefix members with underscore or "m_". This leaves us with little options for distinguishing private backing fields from their corresponding parameters. Take these examples. SA1309 complains: class SomeClass { int _someField;

How can you force StyleCop for ReSharper to ignore files?

别等时光非礼了梦想. 提交于 2019-11-30 08:38:43
We’ve just been working on introducing StyleCop to our team and are using the StyleCop ReSharper plugin from Code Plex. Problem is, every single file in the project appears to be getting analysed and we can’t find a way to exclude particular files. This includes files such as the designer.cs file from the DBML or third party components included in the project. What this means is your site wide code analysis in ReSharper always shows up errors and you can never get it to go “green”. There’s always the ExcludeFromStyleCop tag which you can put in the .csproj but this is only used by MSBuild.

C# - StyleCop - SA1121: UseBuiltInTypeAlias - Readability Rules

纵然是瞬间 提交于 2019-11-30 07:45:00
问题 Not found it in StyleCop Help Manual, on SO and Google so here it is ;) During StyleCop use I have a warning: SA1121 - UseBuiltInTypeAlias - Readability Rules The code uses one of the basic C# types, but does not use the built-in alias for the type. Rather than using the type name or the fully-qualified type name, the built-in aliases for these types should always be used: bool, byte, char, decimal, double, short, int, long, object, sbyte, float, string, ushort, uint, ulong. so String.Empty

How to get rid of StyleCop

不问归期 提交于 2019-11-30 01:52:01
问题 Someone on our team installed StyleCop and since then all of the projects he loaded up and committed to source control refuse to load unless stylecop is installed. I know I can manually edit the .csproj files to get rid of it, but is there an easy way to automatically remove these stylecop parts from the project files so they can be loaded and built on a non-stylecop-infected Visual Studio machine? 回答1: I disabled StyleCop by adding the following GlobalSettings configuration to the file

Is there a StyleCop/FxCop autofixing tool? [closed]

旧城冷巷雨未停 提交于 2019-11-30 01:28:27
Is there a tool that can automatically fix StyleCop and FxCop rules, rather than manually fixing thousands of warning and errors? There must be one, it is such a good business opportunity! No, frustratingly . That's why Style Cop is counter-productive. Consistent formatting looks nice, but there's little productivity benefit to it (what really makes code hard to read is length and indirection ). Perfect spacing is not worth spending hours adjusting lines by hand. If there were an automated tool to achieve consistent formatting, I might hook it up post-check-in. But Style Cop is made by sadists

Disable stylecop analysis for specific projects within solution

南楼画角 提交于 2019-11-30 01:13:39
问题 Is there a way to easily stop StyleCop warnings from being displayed within specific projects in a solution. Or, more pointedly, a way to select which projects StyleCop analysis should be performed on by Visual Studio? We have a solution with 9 projects in it. There are only 2 projects that I actually want to see StyleCop warnings for, so I've created StyleCop.Settings files within those project root directories. This means that, for the rest of the projects, the default rule set is applied

How to use StyleCop with TeamCity

六月ゝ 毕业季﹏ 提交于 2019-11-29 21:47:42
Has anyone had any success with running StyleCop from TeamCity? I know StyleCop supports a command line mode, however i am not sure how this will integrate into the report output by TeamCity. I've checked out this plugin found here: https://bitbucket.org/metaman/teamcitydotnetcontrib/src/753712db5df7/stylecop/ However could not get it running. I am using TeamCity 6.5.1 (latest). I don't know how familiar you are with MSBuild, but you should be able to add a new Build Step in TC 6 and above, and set MSBuild as the build runner, and point it to a .proj file which does something similar to the

Transfer all ReSharper Settings between PCs

跟風遠走 提交于 2019-11-29 20:23:37
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? 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 your settings. Before you upgrade to the latest build, just copy those to another directory. It's very likely

The mystery of stuck inactive msbuild.exe processes, locked Stylecop.dll, Nuget AccessViolationException and CI builds clashing with each other

心不动则不痛 提交于 2019-11-29 19:40:00
Observations: On our Jenkins build server, we were seeing lots of msbuild.exe processes (~100) hanging around after job completion with around 20mb memory usage and 0% CPU activity. Builds using different versions of stylecop were intermittently failing: workspace\packages\StyleCop.MSBuild.4.7.41.0\tools\StyleCop.targets(109,7): error MSB4131: The "ViolationCount" parameter is not supported by the "StyleCopTask" task. Verify the parameter exists on the task, and it is a gettable public instance property. Nuget.exe was intermittently exiting with the following access violation error (0x0000005)

Is there a way to enforce using tabs instead of spaces?

微笑、不失礼 提交于 2019-11-29 16:46:21
问题 StyleCop offers to check for consistent use of spaces, but sadly lacks the opposite idea: Force source code to use tabs. Is there some way to add this functionality? It does not have to be StyleCop, other tools are welcome as well. 回答1: You can use StyleCop+ plugin to enforce usage of tabs. After downloading StyleCopPlus.dll place it in Custom Rules folder inside the main StyleCop folder C:\Program Files (x86)\StyleCop 4.7\Custom Rules or directly in the main folder. Now, when opening a