stylecop

StyleCop/FxCop 10 - How do you properly suppress a message only on a namespace level?

谁说我不能喝 提交于 2019-12-01 14:26:19
问题 FxCop 10 is complaining about the following: using XYZ.Blah; //CA1709 - "XYZ" using Xyz.Blah; //No complaint. using XylophoneSuperDuperLongFullName.Blah; //I don't want to have a long full name for my company name. The problem is... I want my company name to show up in all UPPERCASE because XYZ is an abbreviation. The long version of the name is much too long to be a useful namespace. Microsoft gets away with this kind of stuff because their acronym is only 2 letters. using MS.Something; //No

Temporarily disable StyleCop warnings on ReSharper 6

喜夏-厌秋 提交于 2019-12-01 14:09:02
问题 I downloaded StyleCop 4.6.3 which integrates with ReSharper 6 and the results are really fantastic! However on a specific project I would like to disable the StyleCop warnings (temporarily) and enable again later on. Is there any way of doing this? I can't seem to find it on the ReSharper menu (options, etc). 回答1: You can use different Settings.Stylecop settings for each project, just create one that ignores all the rules. Right click on a project and select Stylecop settings to modify them.

Providing a code analysis ruleset to a .net core project through NuGet

我与影子孤独终老i 提交于 2019-12-01 02:45:24
问题 I've run into a problem when upgrading a .NET 4.6 project to .NET Core 2.0. All our projects use a custom StyleCop ruleset which is provided by a NuGet package. The ruleset is in a file called custom.ruleset and lives in the content folder inside the package. All our projects consume this package and so get a copy of custom.ruleset. However, in Core 2.0 and Standard 2.0 projects this doesn't work. Files are no longer copied from the content folder of a package, and we're told to use the

Is it wrong to use braces for variable scope purposes?

◇◆丶佛笑我妖孽 提交于 2019-12-01 02:18:27
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 block { SqlCommand getCategories = new SqlCommand("select Title from Movie.Category where SourceId =

Is there a Visual Studio 2010 extension to sort methods?

ε祈祈猫儿з 提交于 2019-12-01 01:20:13
问题 StyleCop mandates a particular sort order for the contents of C# files. For example, fields should be declared before methods and public declarations should come before private ones. It would be useful to have a Visual Studio extension to move these things into that order automatically. Does a good extension exist for this (I've found CodeSorter, but the feedback suggests it's very buggy)? Or are there any extensions or shortcuts that make it less painful to reorder this content manually? 回答1

ReSharper - how to disable generation of rubbish documentation headers in Code Cleanup

半世苍凉 提交于 2019-12-01 00:49:25
问题 We're using ReSharper 6.0 with StyleCop for ReSharper. Although we use the StyleCop rule that members must have documentation headers, we don't want ReSharper's code cleanup facility to generate documentation headers for us, because they're inevitably rubbish. Bad doc headers are worse than none at all because they're less likely to be updated than added in the first place. We tried turning off the setting 'Insert text into documentation and file headers' in ReSharper => Options => Tools =>

Enforce custom stylecop rules for a checkin policy on TFS

帅比萌擦擦* 提交于 2019-12-01 00:00:42
I have installed StyleCop CheckIn policy (from here ) and it works great. However I have written some custom rules which I want to be enforced as part of the CheckIn policy (Visual Studio 2008, Team Explorer 2008, TFS 2005). The custom rules appear fine in the settings file when I right click on a project and click "StyleCop Settings". However when I add my CheckIn policy, and try to import the same settings.StyleCop file my Custom Rules don't appear in the editor window. Another problem, probably related, is that my custom rules appear in the StyleCop settings editor when I open the editor

How to get rid of StyleCop

半腔热情 提交于 2019-11-30 17:53:35
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? I disabled StyleCop by adding the following GlobalSettings configuration to the file settings.stylecop in the solution root. <StyleCopSettings Version="4.3"> <GlobalSettings> <BooleanProperty Name=

Disable stylecop analysis for specific projects within solution

三世轮回 提交于 2019-11-30 11:49:35
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 and I get a screen full of warnings every time I open a class. The only way I can think to remove these

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

那年仲夏 提交于 2019-11-30 11:09:46
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. Răzvan Flavius Panda 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 Settings.StyleCop with StyleCopSettingsEditor you will be able to set rule SP2001: