fxcop

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

Why does FxCop think initializing fields to the default value is bad?

↘锁芯ラ 提交于 2019-12-01 13:42:46
问题 When assigning a default default-value to a field (here false to a bool), FxCop says: Resolution : "'Bar.Bar()' initializes field 'Bar.foo' of type 'bool' to false. Remove this initialization because it will be done automatically by the runtime." Now, I know that code as int a = 0 or bool ok = false is introducing some redundancy, but to me it seems a very, very good code-practice, one that my teachers insisted on righteously in my opinion. Not only is the performance penalty very little,

FxCop on build (Visual Studio 2008 Professional)

元气小坏坏 提交于 2019-12-01 10:39:44
I just learned how to integrate StyleCop into Visual Studio. Now it runs every build and its errors appears as warnings. Excelent! Now I just want to do the same thing with FxCop, but even installing MSBuild Community Tasks and adding to the proj file: <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/> Won't do. What else I have to do? Try putting this right before </Project> in your csproj/vbproj file: <PropertyGroup> <PostBuildEvent>"%25ProgramFiles%25\Microsoft FxCop 1.36\FxCopCmd.exe" /file:"$(TargetPath)" /console /searchgac</PostBuildEvent>

FxCop on build (Visual Studio 2008 Professional)

不羁岁月 提交于 2019-12-01 08:28:53
问题 I just learned how to integrate StyleCop into Visual Studio. Now it runs every build and its errors appears as warnings. Excelent! Now I just want to do the same thing with FxCop, but even installing MSBuild Community Tasks and adding to the proj file: <Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/> Won't do. What else I have to do? 回答1: Try putting this right before </Project> in your csproj/vbproj file: <PropertyGroup> <PostBuildEvent>"

Why is Microsoft.CodeAnalysis published with ASP.NET Core website?

牧云@^-^@ 提交于 2019-12-01 06:14:53
问题 I'm publishing an ASP.NET Core MVC 3.0 website and the output folder contains lots of reference in many language to Microsoft.CodeAnalysis librairies, someone knows why? Of course the FxCopAnalyzers Nuget package is installed on the project, but it was not published in an earlier version of the project, so I don't understand why it is now since it should be useful only at dev time not in a production environment. 回答1: contains lots of reference in many language to Microsoft.CodeAnalysis

Immutable readonly reference types & FXCop Violation: Do not declare read only mutable reference types

淺唱寂寞╮ 提交于 2019-12-01 04:51:51
I have been trying to wrap my head around this FXCop violation "DoNotDeclareReadOnlyMutableReferenceTypes" MSDN: http://msdn.microsoft.com/en-us/library/ms182302%28VS.80%29.aspx Code from MSDN which would cause this violation: namespace SecurityLibrary { public class MutableReferenceTypes { static protected readonly StringBuilder SomeStringBuilder; static MutableReferenceTypes() { SomeStringBuilder = new StringBuilder(); } } } From Jon's answer here and here , I understand that the field holding the reference to the object (in this case SomeStringBuilder) is readonly and not the object itself

Get FxCop to suppress warnings for a whole type?

这一生的挚爱 提交于 2019-12-01 03:06:08
How can I suppress FxCop warnings for a whole type? namespace ConsoleApplication1 { public static class Serializer<T> { public static string Serialize(T obj) { return string.Empty; } public static T Deserialize(string str) { return default(T); } } I tried this, but it is not working for me: [assembly: SuppressMessage("Microsoft.Design", "CA1000:DoNotDeclareStaticMembersOnGenericTypes", Scope = "Type", Target = "ConsoleApplication1.Serializer'1")] Nicole Calinoiu Unfortunately, this will not work. FxCop only processes suppressions that are declared against the same target as a detected

'SuppressMessage' for a whole namespace

自作多情 提交于 2019-12-01 02:12:11
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:IdentifiersShouldNotContainUnderscores", Scope = "namespace", Target = "Company.Product.Tests")] Leniaal

Immutable readonly reference types & FXCop Violation: Do not declare read only mutable reference types

浪尽此生 提交于 2019-12-01 01:20:07
问题 I have been trying to wrap my head around this FXCop violation "DoNotDeclareReadOnlyMutableReferenceTypes" MSDN: http://msdn.microsoft.com/en-us/library/ms182302%28VS.80%29.aspx Code from MSDN which would cause this violation: namespace SecurityLibrary { public class MutableReferenceTypes { static protected readonly StringBuilder SomeStringBuilder; static MutableReferenceTypes() { SomeStringBuilder = new StringBuilder(); } } } From Jon's answer here and here , I understand that the field

Treat Warnings as Errors has no effect

╄→尐↘猪︶ㄣ 提交于 2019-11-30 20:02:49
In my project's settings in Visual Studio, I have set 'Treat warnings as errors' to 'All'. The Warning level is set to 4. I tested this by deliberately introducing code that violates CA1305, but it builds (and rebuilds) successfully, returning a Warning. What I expected was that the build would fail and an Error would be returned. Is my understanding wrong? Code Analysis uses a different mechanism to treat warnings as errors. To have Code Analysis warnings treated as such, add a new Code Analysis Ruleset to your solution. To do so, rightclick your solution and choose "Add new item...". Search