通过为 Resharper 创建插件来静态分析 C# 代码来查找设计模式?

发布于 2024-10-21 16:43:35 字数 172 浏览 6 评论 0原文

我想通过静态分析来验证 C# 代码中的一些设计模式。我发现通过为 Resharper 创建插件,我可以在编码时即时验证模式。但我没有找到与其开放 API 相关的好的文档。是否有任何链接可以让我找到合适的文档。

我正在使用 MVVM 模式,所以我想验证视图模型类没有任何依赖项 与 UI 类或元素(WPF 元素)。

I wanted to verify few design patterns in C# code by static analysis. I found that by creating a plugin for Resharper I can verify the patterns on-the-fly while i am coding. But I did not find good documentation related to its open APIs. Are there any links where I can find suitable documentation.

I Am using MVVM pattern so i want to verify that View-Model classes are not having any dependency
with UI classes or elements (WPF elements).

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

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

发布评论

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

评论(3

清风挽心 2024-10-28 16:43:35

ReSharper 5 引入了模式目录,又称结构搜索和替换。它允许您轻松创建快速修复和上下文操作,而无需编写自己的 ReSharper 插件。我建议您在深入编写插件之前检查一下它是否足以满足您的需求。您可以在此处找到概述:

http ://blogs.jetbrains.com/dotnet/2010/04/introducing-resharper-50-structural-search-and-replace/

JetBrains 还提供了一个示例目录,其中展示了您可以执行的一些很酷的操作,在他们的下载页面上:

http://www.jetbrains.com/resharper/download/index。 html

ReSharper 5 introduced the Pattern Catalog AKA Structural Search and Replace. It allows you to create Quick Fixes and Context Actions easily without writing your own ReSharper plug-in. I would recommend checking it out to see if it will suffice for your needs before delving into writing a plug-in. You can find an overview here:

http://blogs.jetbrains.com/dotnet/2010/04/introducing-resharper-50-structural-search-and-replace/

JetBrains also provides a sample catalog, which showcases some cool things that you can do, on their download page:

http://www.jetbrains.com/resharper/download/index.html

戒ㄋ 2024-10-28 16:43:35

这篇文章看起来可能会有所帮助。有一个创建上下文感知插件的演练。 此处继续< /a>.

我认为第二篇文章与您最相关,因为它介绍了使用访问者模式挂钩 ReSharper 守护程序 - 并执行一些有用的工作。

此页面是 Open API 文档的根目录。

华泰

This article looks like it might help. There's a walkthrough for creating a context-aware plugin. It's continued here.

I reckon the second article is most relevant to you as it covers using the visitor pattern to hook into the ReSharper daemons - and perform some useful work.

This page is the root of the Open API documentation.

HTH

亢潮 2024-10-28 16:43:35

该文档目前有些碎片化。要开始使用,请查看我编写的 ReSharper 扩展性指南我认为目标是 4.5 版本,但仍然是一个好的开始。正如另一位发帖者提到的,Hadi Hariri 的博客是查找有关 ReSharper 插件编写信息的良好来源。另外,请查看 ReSharper PowerToys 以获取一些示例代码。

最后,关于 ReSharper 6 插件开发的文章(目前还很少)这里。更多内容将很快添加。

The documentation is currently somewhat fragmented. To get you started, take a look at the ReSharper Extensibility Guide which I think targets version 4.5 but is still a good start. As the other poster mentioned, Hadi Hariri's blog is a good source for finding information on ReSharper plugin writing. Also, check out the ReSharper PowerToys for some sample code.

Finally, there are (very few, as yet) articles on ReSharper 6 plugin development available here. More content will be added soon.

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