stylecop

What is the static analysis rule to warn about unused using statements?

落花浮王杯 提交于 2021-02-09 07:16:21
问题 Is there any FxCop or StyleCop that warns when there is an using statement that is no longer referenced by any object in the file? 回答1: You can enable the rule IDE0005 C# Using directive is unnecessary. in the category Style . 回答2: In addition to Udo's answer and this answer, I also needed to uncheck Suppress results from generated code (managed only) which can be found under Properties > Code Analyses . So all in all: Set the Warning Level to 4 for code analyzers to fire. Set rules CS8019

What is the static analysis rule to warn about unused using statements?

强颜欢笑 提交于 2021-02-09 07:13:24
问题 Is there any FxCop or StyleCop that warns when there is an using statement that is no longer referenced by any object in the file? 回答1: You can enable the rule IDE0005 C# Using directive is unnecessary. in the category Style . 回答2: In addition to Udo's answer and this answer, I also needed to uncheck Suppress results from generated code (managed only) which can be found under Properties > Code Analyses . So all in all: Set the Warning Level to 4 for code analyzers to fire. Set rules CS8019

What is the static analysis rule to warn about unused using statements?

时光毁灭记忆、已成空白 提交于 2021-02-09 07:13:22
问题 Is there any FxCop or StyleCop that warns when there is an using statement that is no longer referenced by any object in the file? 回答1: You can enable the rule IDE0005 C# Using directive is unnecessary. in the category Style . 回答2: In addition to Udo's answer and this answer, I also needed to uncheck Suppress results from generated code (managed only) which can be found under Properties > Code Analyses . So all in all: Set the Warning Level to 4 for code analyzers to fire. Set rules CS8019

What is the static analysis rule to warn about unused using statements?

北城余情 提交于 2021-02-09 07:10:59
问题 Is there any FxCop or StyleCop that warns when there is an using statement that is no longer referenced by any object in the file? 回答1: You can enable the rule IDE0005 C# Using directive is unnecessary. in the category Style . 回答2: In addition to Udo's answer and this answer, I also needed to uncheck Suppress results from generated code (managed only) which can be found under Properties > Code Analyses . So all in all: Set the Warning Level to 4 for code analyzers to fire. Set rules CS8019

How to ship the stylecop.json and custom.ruleset files with a NuGet package in VS2017

末鹿安然 提交于 2021-02-08 05:22:23
问题 At the moment we are switching from VS2015 to VS2017. One of our upgrade steps is to switch from stylecop to the new Stylecop.Analyzer package. The new Stylecop is using 2 files. The stylecop.json and the Stylecop.ruleset. The target: I want to provide the stylecop files as a custom nuget package. But I dont know how to create the needed .csproj entries. <Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> ... <CodeAnalysisRuleSet>packages\My.StyleCop.1.0.0-pre15\RuleSet\My.StyleCop.ruleset<

Stop Visual Studio from putting using directives outside namespace

半世苍凉 提交于 2021-02-06 14:51:06
问题 Is there a setting in Visual Studio (or Resharper) that allows you to specify what namespaces should be default and which scope they are put in? The default for an MVC project for example is using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace Namespace { public class Class1 { } } but Resharper and Stylecop complain: All using directives must be placed inside of the namespace. [StyleCop Rule: SA1200] Using directive is not required by the code and can

Code Analysis is not working with ruleset from nuget package (from .props)

五迷三道 提交于 2021-01-27 13:57:15
问题 I'm trying to use custom ruleset file form our nuget package. I've added to the build folder of the package .props file: <Project> <PropertyGroup> <CodeAnalysisRuleSet> $(MSBuildThisFileDirectory)..\My.Shared.ruleset </CodeAnalysisRuleSet> <RunCodeAnalysis>true</RunCodeAnalysis> </PropertyGroup> </Project> Rule set file is in the package root folder, the paths are correct, it's adding import of the .props file into csproj file. <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com

SA1401 Fields must be declared with private access. Use properties to expose fields

試著忘記壹切 提交于 2020-12-26 20:09:12
问题 I facing the following StyleCop violation. How can I fix this? Warning SA1401 : CSharp.Maintainability : Fields must be declared with private access. Use properties to expose fields. MonitoringGitLabProjectStatus My code is public class EmailConfig { public EmailConfig() { this.AmazonClient = new AmazonSimpleEmailServiceClient(this.amazonUserName, this.amazonPassword); } protected MailMessage mailMessage = new MailMessage(); //Fields must be declared with private access. Use properties to

SA1401 Fields must be declared with private access. Use properties to expose fields

霸气de小男生 提交于 2020-12-26 20:00:46
问题 I facing the following StyleCop violation. How can I fix this? Warning SA1401 : CSharp.Maintainability : Fields must be declared with private access. Use properties to expose fields. MonitoringGitLabProjectStatus My code is public class EmailConfig { public EmailConfig() { this.AmazonClient = new AmazonSimpleEmailServiceClient(this.amazonUserName, this.amazonPassword); } protected MailMessage mailMessage = new MailMessage(); //Fields must be declared with private access. Use properties to

SA1401 Fields must be declared with private access. Use properties to expose fields

血红的双手。 提交于 2020-12-26 19:58:24
问题 I facing the following StyleCop violation. How can I fix this? Warning SA1401 : CSharp.Maintainability : Fields must be declared with private access. Use properties to expose fields. MonitoringGitLabProjectStatus My code is public class EmailConfig { public EmailConfig() { this.AmazonClient = new AmazonSimpleEmailServiceClient(this.amazonUserName, this.amazonPassword); } protected MailMessage mailMessage = new MailMessage(); //Fields must be declared with private access. Use properties to