fxcop

FxCop: custom rule for checking assembly info values

筅森魡賤 提交于 2019-12-19 18:29:57
问题 Is there a reasonably simple way to get FxCop to check that all my assemblies declare a particular attribute value? I want to make sure everyone has changed the default you get on creating a project: [assembly: AssemblyCompany("Microsoft")] // fail [assembly: AssemblyCompany("FooBar Inc.")] // pass 回答1: This is actually a pretty easy rule once you know that FxCop's "largest" analysis target is a module, not an assembly. In most cases, there is one module per assembly, so this won't pose a

'SuppressMessage' for a whole namespace

Deadly 提交于 2019-12-19 05:03:17
问题 I use underscores for my test methods for a better readability and I want to suppress FxCop errors/warnings for the whole test namespace. How can I achieve this? I played with GlobalSuppressions.cs but nothing worked: [module: System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", Scope = "namespace", Target = "Company.Product.Tests")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Naming", "CA1707

How does one implement FxCop / static analysis on an existing code base

给你一囗甜甜゛ 提交于 2019-12-18 16:56:21
问题 What are some of the strategies that are used when implementing FxCop / static analysis on existing code bases with existing violations? How can one most effectively reduce the static analysis violations? 回答1: Make liberal use of [SuppressMessage] attribute to begin with. At least at the beginning. Once you get the count to 0 via the attribute, you then put in a rule that new checkins may not introduce FxCop violations. Visual Studio 2008 has a nice code analysis feature that allows you to

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

Are there any good workarounds for FxCop warning CA1006?

狂风中的少年 提交于 2019-12-18 01:44:29
问题 I am having trouble with FxCop warning CA1006, Microsoft.Design "DoNotNestGenericTypesInMemberSignatures". Specifically, I am designing a ReportCollection<T> class that inherits from ReadOnlyCollection<Report<T>> , and its public constructor takes an IList<Report<T>> as a parameter. The suggestion for fixing this warning is not very useful: "To fix a violation of this rule, change the design to remove the nested type argument." There are two ways I can see so far to change the design as

Is there a custom FxCop rule that will detect unused PUBLIC methods?

落花浮王杯 提交于 2019-12-17 19:29:01
问题 I just tried FxCop. It does detect unused private methods, but not unused public. Is there a custom rule that I can download, plug-in that will detect public methods that aren't called from within the same assembly? 回答1: Corey, my answer of using FxCop had assumed you were interested in removing unused private members, however to solve the problem with other cases you can try using NDepend. Here is some CQL to detect unused public members (adapted from an article listed below): // <Name

Creating a custom rule in FxCop

早过忘川 提交于 2019-12-17 12:37:19
问题 I want to create extra rules in FXCop. Custom Rules to help ensure specific best practices like checking against inline sql. I'm really looking for good resources and examples. Thanks! 回答1: This tutorial seems really comprehensive. 回答2: The tutorial above is pretty good. I knocked together a sample VS project that also might be useful, since I couldn't find any example projects http://www.doogal.co.uk/files/FxCopRules.zip 回答3: You can also use the commercial tool NDepend to write your custom

How do I extend a WinForm's Dispose method?

断了今生、忘了曾经 提交于 2019-12-17 10:49:08
问题 I am getting this warning from FxCop: "'RestartForm' contains field 'RestartForm.done' that is of IDisposable type: 'ManualResetEvent'. Change the Dispose method on 'RestartForm' to call Dispose or Close on this field." Ok, I understand what this means and why this is what needs to be done... Except System.Windows.Forms.Form doesn't allow you to override either .Close() or .Dispose() , so what to do? Currently I'm running with this solution: private void RestartForm_FormClosing(object sender,

Running Code Analysis (FxCop > 10) on build agent without installing Visual Studio

ぃ、小莉子 提交于 2019-12-17 07:01:43
问题 After FxCop 10 Microsoft stopped shipping a separate installer for FxCop. Officially one can currently only run code analysis (FxCop 12.0 / 14.0 / 15.0) after installing Visual Studio 2013 / 2015 / 2017. However, we are adamant about not installing Visual Studio on the build agents (the installation needs then to be kept in-sync with what we have got on the developer computers etc.). So how would i go about getting FxCop 12.0 / 14.0 / 15.0 to work on a build agent, preferrably without

Globally disabling FxCop errors in TeamCity

对着背影说爱祢 提交于 2019-12-14 02:06:54
问题 Ok, another FxCop question for today. I've read the arguments regarding the IdentifiersShouldBeCasedCorrectly rule, and whether or not it should be "XML" or "Xml". Well, I'm an "XML" guy and I want to stay that way. Therefore, I do not want FxCop to correct me all of the time. I have been using the SuppressMessage attribute only for specific cases. I have also used FxCop to mark a ton of errors and copied them as "module" level SuppressMessage statements into assemblyinfo.cs. That works