C# 的 Lint

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/748631/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 23:39:45  来源:igfitidea点击:

Lint for C#

c#.netcode-analysislint

提问by Ken

Is there a lint-like tool for C#? I've got the compiler to flag warnings-as-errors, and I've got Stylecop, but these only catch the most egregious errors. Are there any other must-have tools (especially for newbie C#ers like me) that point out probably-dumb things I'm doing?

是否有用于 C# 的类似 lint 的工具?我让编译器将警告标记为错误,并且我有 Stylecop,但这些只能捕获最严重的错误。是否有其他必备工具(尤其是对于像我这样的 C# 新手)指出我正在做的可能是愚蠢的事情?

采纳答案by Mehrdad Afshari

Tried FxCop? It's integrated into VS as "Code Analysis"

试过FxCop吗?它作为“代码分析”集成到 VS 中

In the newer versions of Visual Studio, it is called "Microsoft Code Analysis" and can be downloaded from the Visual Studio Marketplace: https://marketplace.visualstudio.com/items?itemName=VisualStudioPlatformTeam.MicrosoftCodeAnalysis2017

在较新版本的 Visual Studio 中,它被称为“Microsoft 代码分析”,可以从 Visual Studio Marketplace 下载:https: //marketplace.visualstudio.com/items?itemName =VisualStudioPlatformTeam.MicrosoftCodeAnalysis2017

回答by Kris Erickson

Resharperperforms a fair bit of static analysis as well as doing a ton of other useful things. Since version 8.0analysis can run in command line mode. Currently I wouldn't code in C# without it.

Resharper执行大量静态分析以及执行大量其他有用的操作。由于8.0 版分析可以在命令行模式下运行。目前我不会在没有它的情况下用 C# 编码。

As well as FxCop, Gendarmeis another tool to look at (it is Mono's version of FxCop but they are different in approach and the errors that they actually find).

与 FxCop 一样,Gendarme是另一种查看工具(它是 Mono 的 FxCop 版本,但它们的方法和实际发现的错误不同)。

回答by Nathan Koop

Gendarme for Monois similar to FxCop

Mono的宪兵类似于FxCop

回答by this. __curious_geek

You can try .Net Reflector by Red-Gate, you can get it from here. Many useful plugins for .Net Reflector are available on CodePlex which you can get it from here.

你可以试试 Red-Gate 的 .Net Reflector,你可以从这里得到它。CodePlex 上提供了许多用于 .Net Reflector 的有用插件,您可以从这里获取。

回答by dimhotepus

This question already has an answer, but for reference...

这个问题已经有了答案,但仅供参考......

You can try PVS-Studio. That's not free, but, IMHO, must have one. Quote from their site:

你可以试试PVS-Studio。这不是免费的,但是,恕我直言,必须有一个。从他们的网站报价:

PVS-Studio is a tool used to detect bugs in the source code of programs written in C, C++ and C#.

PVS-Studio performs static code analysis and generates a report that helps a programmer find and fix bugs. PVS-Studio does a wide range of code checks; but it is especially useful to search for misprints and Copy-Paste errors.

The analyzer is designed for developers who use Visual Studio.

PVS-Studio 是一种用于检测用 C、C++ 和 C# 编写的程序源代码中的错误的工具。

PVS-Studio 执行静态代码分析并生成一份报告,帮助程序员查找和修复错误。PVS-Studio 进行广泛的代码检查;但搜索印刷错误和复制粘贴错误特别有用。

该分析器专为使用 Visual Studio 的开发人员设计。

回答by Mrchief

SonarLint(free, open source) is pretty sweet!

SonarLint(免费,开源)非常棒!

SonarLint for Visual Studio is based on and benefits from the .NET Compiler Platform ("Roslyn") and its code analysis API to provide a fully-integrated user experience in Visual Studio 2015. SonarLint is free, open source, and available in the Visual Studio Gallery.

适用于 Visual Studio 的 SonarLint 基于并受益于 .NET 编译器平台(“Roslyn”)及其代码分析 API,以在 Visual Studio 2015 中提供完全集成的用户体验。SonarLint 是免费、开源的,可在 Visual Studio 中使用工作室画廊。