在Roslyn中使用编译器API与工作区API时性能差异

发布于 2025-02-03 01:33:54 字数 79 浏览 4 评论 0原文

我知道罗斯林提供了几种API。但是,我不确定使用编译器API和工作区API时的性能差异是什么。工作区API是否构建了整个解决方案并生成IL代码?

I know that there are several API provided by Roslyn; however, I was not sure what is the difference in performance when using Compiler API and Workspace API. Does Workspace API build the entire solution and generate the IL code?

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

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

发布评论

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

评论(1

怂人 2025-02-10 01:33:54

可以将工作区API视为助手,只是为了使编译器API对象。因此,它不必手动将所有各种编译器API调用以解析语法树并进行编译,而是为您提供了汇编。它真正做到的有趣的部分是:

  1. 允许您拥有多个项目,我们将为每个项目创建多个汇编并将它们拼接在一起。同样,您什么都不能做自己,但要做一些详细的事情。
  2. 当您对项目具有更高的级别更改(更改解析选项,更改引用)时,我们将尽力更新汇编。
  3. 协调多个线程要求数据,试图共享所有内容。即,这是一个大型懒惰的API,可以协调一切,但也尊重取消等等。

The workspace API can be thought of as a helper just to make the Compiler API objects. So rather than having to manually call all the various compiler APIs to parse syntax trees and make Compilations, it does it for you. The interesting bits it really does is:

  1. Allow you to have multiple projects, where we're going to create multiple Compilations for each project and stitch them together. Again, nothing you can't do yourself, but it gets a bit verbose to do.
  2. When you have a higher level change to a project (change parse options, change references), we'll try to update the Compilations as efficiently as we can.
  3. Coordinates multiple threads asking for data, trying to share everything. i.e it's one big Lazy API that coordinates everything but also respects cancellation and such.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文