stylecop

Can StyleCop automatically fix anything?

為{幸葍}努か 提交于 2019-11-29 10:56:12
问题 I've decided to start running StyleCop on a medium sized project and am getting over 1000 warnings. Is there a quick easy way to fix most of these warnings? Most of the warnings could easily have been automated to resolve and would save me a lot of time. 回答1: This doesn't exactly "automatically fix anything" but there is a StyleCop plug-in for Resharper on Codeplex that will automatically highlight the style errors in your code. Update: According to the StyleCop for ReSharper website,

Code Anlysis Rule CA2000 / CA2202

醉酒当歌 提交于 2019-11-29 07:21:50
I am trying to ensure my coding follows correct disposal of objects so I am enforcing these rules as errors. But I am having trouble with this section of code using System; using System.IO; using System.Runtime.Serialization; using System.Xml; class MyClass { public String ToXml() { var objSerializer = new DataContractSerializer(GetType()); var objStream = new MemoryStream(); StreamReader objReader; String strResult; try { // Serialize the object objSerializer.WriteObject(objStream, this); // Move to start of stream to read out contents objStream.Seek(0, SeekOrigin.Begin); objReader = new

Is sa1200 All using directives must be placed inside the namespace (StyleCop) purely cosmetic? [duplicate]

我们两清 提交于 2019-11-29 05:34:06
Possible Duplicate: Should Usings be inside or outside the namespace sa1200 All using directives must be placed inside the namespace (StyleCop) Is this just for code readibility or is there any actual advantage to doing so? Does it help the GC somehow? It definitely won't help with GC. Here's the discussion about two styles: http://blogs.msdn.com/abhinaba/archive/2006/08/21/709051.aspx http://blogs.msdn.com/abhinaba/archive/2008/07/08/do-namespace-using-directives-affect-assembly-loading.aspx If you have multiple namespaces in your project, you can limit which namespaces are used by each one

StyleCop SA1124 DoNotUseRegions is reasonable? [closed]

Deadly 提交于 2019-11-29 05:29:36
SA1124 DoNotUseRegions suggest that region should not be used anywhere. Is it really reasonable? I think region is a way to group relative code together and make large class easy to read, for example, if you generate interface method for a class in vs2008 via context menu, a region will be automatically inserted. I would like to remove this rule while checking code style. May I know your opinions on this rule? This is going to be a personal preference thing. The only thing that matters here is what you and your team prefer . Forget what style cop says, you're the ones reading it, you're the

C# - StyleCop - SA1121: UseBuiltInTypeAlias - Readability Rules

早过忘川 提交于 2019-11-29 05:24:50
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 is wrong (depend on above rules) and string.Empty is good. Why using built-in aliases is better? Can

How to use StyleCop with TeamCity

空扰寡人 提交于 2019-11-28 17:36:44
问题 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). 回答1: 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

Stylecop vs FXcop

浪尽此生 提交于 2019-11-28 15:33:36
Has Stylecop superseded FXcop? Which product should we be using with Visual Studio 2008? Stylecop is a style analysis tool that works at the source code level. It exists primarily to provide a single common style that managed projects can use to remain consistent within the larger world of managed software. It makes decisions regarding style primarily to avoid holy wars (after all, style is almost always an inherently subjective thing). I don't think I've ever met someone who liked all of StyleCop's rules, but that's ok . It means that StyleCop is a generally good compromise amongst the vast

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

邮差的信 提交于 2019-11-28 15:30:18
问题 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

Disabling StyleCop rules

不想你离开。 提交于 2019-11-28 05:10:18
I'm using StyleCop. But there a couple of rules I want to ignore, for instance using this. in front of class members. How do I turn off a StyleCop rule. I've looked but can't find how to do it. bdukes In your StyleCop install, there's a Settings.StyleCop file. You can edit this to turn off rules globally. Drag that file onto the Settings Editor executable in that file to edit it. You can also put copies of the settings file into your projects to override the global settings. If you're using Visual Studio integration and not just MSBuild integration, you should be able to get to the settings

Best way to integrate StyleCop with TFS CI

醉酒当歌 提交于 2019-11-28 04:34:52
I've been doing research on how to enable source analysis for the project I'm working on and plan to use StyleCop. The setup I have is a TFS Server for source control, using TFS Continuous Integration. I want to enable source analysis for CI builds and daily builds run on the build machine, and not only for those run on developers' machines. Here's an article from the documentation of StyleCop that I read on the subject: http://blog.newagesolution.net/2008/07/how-to-use-stylecop-and-msbuild-and.html . It basically modifies the csproj file for the purpose. I've also read other opinions about