是否有工具可以在一组库代码(.net C#)中查找冗余?

发布于 2024-12-20 01:36:56 字数 161 浏览 4 评论 0原文

是否有工具可以在一组库代码(.net C#)中查找冗余?

问题是我有许多 .NET 库,但它们往往有很多类似/重复的“帮助程序”或“实用程序”功能。有时,代码可能并不完全实用,但遵循相似的模式,但命名略有不同。

是否有某种工具可以发现这些相似之处并在一批 C# 库上报告它们?

Is there a tool to finding redundancy through out a set of library code (.net C#)?

The problem is I have a number of .NET libraries, but they tend to have a lot of similar/duplicate "helper" or "utility" functions. Some times the code may not be exactly utility, but follows similar patterns with slightly different naming.

Is there a tool of some kind that can spot these similarities and report them on a batch of C# libraries?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心不设防 2024-12-27 01:36:56

Visual Studio 11(目前只有开发者预览版)具有此功能。您可以免费下载开发者预览版来查看。

它称为代码克隆分析,它会搜索您的代码以寻找相似性,并生成从完全匹配到可能匹配的报告。

在这里您可以找到小例子。

Visual Studio 11 (currently only a developer preview) has this functionality. You can download the Developer Preview for free to check it out.

It's called Code Clone Analysis and it searches trough your code looking for similarities and generates a report that varies from exact matches to probable matches.

Here you can find a small example.

债姬 2024-12-27 01:36:56

CodeRush 现在内置了重复代码查找器。我不知道您的是什么预算是用于这样的工具,但我发现 CodeRush / Refactor 的好处!足以抵消许可证费用。

CodeRush now has a Duplicate Code finder built in. I don't know what your budget is for such a tool, but I find the benefits of CodeRush / Refactor! to more than offset the cost of the licence.

飞烟轻若梦 2024-12-27 01:36:56

请参阅我们的 CloneDR 工具,用于在大量源代码中查找精确的和几乎未命中的重复代码块。

CloneDR 的工作原理是使用编译器质量的前端解析源文本、构建表示代码的编译器数据结构(“AST”)并匹配树。这意味着无论布局、换行符或注释如何,它都可以找到重复项。匹配过程可以找到在可参数化意义上相似的代码块;它可以轻松找到具有重命名变量或已被替换的语句或代码块的类似块。

有许多语言的版本,包括 C#。可以在网站上找到 C# 克隆检测报告示例。

CloneDR 不是“开发预览版”。我早在 1998 年就写了一篇关于如何做好这项工作的原始论文,从那时起就一直在开发 CloneDR;请参阅使用抽象语法树进行克隆检测。 (Microsoft 克隆检测器进行基于标记的克隆检测,而不是基于树的克隆检测,恕我直言,产生的答案不太好;事实上,这种标记式检测器就是我写这篇论文的原因)。

See our CloneDR tool for finding exact and near-miss blocks of duplicate code across large bodies of source code.

CloneDR works by parsing the source text using a compiler-quality front end, building compiler data structures ("AST"s) that represent the code, and matching the trees. This means it can find duplicates in spite of layouts, line breaks or comments. The matching process can find code blocks that are similar in the sense that can be parameterized; it easily find similar blocks with renamed variables, or with statements or blocks of code that have been replaced.

There are versions for many languages, including C#. A sample C# clone detection report can be found at the website.

CloneDR is not a "development preview". I wrote one the original papers on how to do this well back in 1998 and have been developing CloneDR ever since; see Clone Detection Using Abstract Syntax Trees. (The Microsoft Clone detector does token-based, not tree-based clone detection, and produces, IMHO, answers that are not as good; in fact, such token-style detectors are why I wrote the paper).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文