VS.NET:项目参考与程序集参考 [英] VS.NET: Project Refs vs. Assembly Refs

查看:104
本文介绍了VS.NET:项目参考与程序集参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里存在一些争论,那就是哪个项目更适合从其他项目中引用我们的通用代码库:按项目还是按程序集。我赞成引用该项目,尤其是因为我们有自动化的单元测试来证明通用代码可以完成所需的工作。

There's some debate here over which is better for referencing our common code base from other projects: by project or by assembly. I'm in favor of referencing the project, especially since we have automated unit tests that prove that the common code does what it needs to.

另一个阵营的想法是锁定这些项目,并且每月只发布一次程序集。然后强制所有项目引用程序集。他们认为这将保护他们避免部署未经测试的代码。他们太忙了以编写自动化的单元测试并配置他们的项目以进行持续集成,而我对此没有任何影响,所以请不要专注于这一方面。

The thought from the other camp is to lock down those projects and only release assemblies once a month or something. Then force all projects to reference the assemblies. They think this will protect them from deploying untested code. They are "too busy" to write automated unit tests and configure their projects for continuous integration and I have no influence on that, so please do not focus on this aspect.

这就是我可以想到为什么项目引用是更好的解决方案的原因。我也在寻找其他意见。

Here's the reasons I can think of why project references are the better solution. I'm looking for other opinions as well.

PROS:


  • 引用项目可确保您正在使用最新代码。您不必等待任何事情。

  • 减少重复。如果没有最新的代码,就更有可能重新发明轮子。

  • 如果开发人员需要某些东西而不能将其添加到其所属的程序集中,则会在其中创建任何可以使用的位置,都会造成许多不一致之处和代码重复。

  • 开发更容易,因为您可以轻松查看/调试引用代码中发生的事情。

  • 我们常见的东西不会经常改变,但是当它改变时,通常是有用的。为什么要增加额外的维护和组件发布管理负担。

  • Referencing projects ensures you are working with the latest code. You don't have to wait on anything.
  • Reducing duplication. Without having the latest code, there is a greater chance of reinventing the wheel.
  • If a developer needs something and can't add it to the assembly where it belongs, it will be created in any location that will work, creating many inconsistencies and code duplication.
  • Development is easier because you can easily see/debug what is happening in the referenced code.
  • Our common stuff doesn't change that often, but when it does, it's usually something useful. Why add the extra burden of maintenance and assembly release management.

CONS:


  • 加载时间可能会更长。

  • 将项目添加到新解决方案中,然后添加程序集引用可能会花费一些时间。

推荐答案

以下是您错过的几个专业人士

Here are a couple of pros you missed


  • 实时更新:更改API时,像intellisense之类的功能将在项目与项目引用之间自动更新

  • GoTo定义:如果您有程序集引用,则GoTo定义将带您到实际的代码定义。使用程序集引用,它将带您到生成的元数据签名。

  • 查找所有引用:将处理项目引用中的所有代码以供使用。对于程序集参考,您只会在元数据中看到用途

  • 快速搜索(仅2010年):类似于查找所有参考,在P2P参考中效果更好

  • Live Updating: Features like intellisense will update automatically between project to project references as you are changing the APIs
  • GoTo Definition: If you have an assembly reference, GoTo Definition will take you to the actual code definition. With an assembly reference it will take you to the generated metadata signature.
  • Find All References: Will process all code in project references for use of a reference. For an assembly reference you will only see uses within the metadata
  • Quick Search (2010 only): Similar to find all references, just works better in a P2P reference

针对您的缺点


  • 是:通常是加载项目比加载参考慢。在项目数量合理的情况下,时间差异并不大,并且不会影响您的日常开发例程。

  • 是的:在解决方案中添加项目通常比添加参考要慢。但是,差异以秒为单位,并且是一次性成本。我认为将其作为标准的一部分是错误的。

这篇关于VS.NET:项目参考与程序集参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆