是否有可能标志着pcated的组件,德$ P $? [英] Is it possible to mark an assembly as deprecated?

查看:151
本文介绍了是否有可能标志着pcated的组件,德$ P $?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想产生一个警告信息,当用户编译code,引用我们计划在拆卸组装。本次大会的内容已被合并到另一个,我想鼓励用户停止引用旧组件。

I'd like to produce a warning message when users compile code that references an assembly we're planning on removing. The contents of this assembly have been merged with another, and I'd like to encourage users to stop referencing the old assembly.

不幸的是,它看起来像ObsoleteAttribute是无效的组件。是否有造成当一个项目引用的程序集是建立一个编译器警告任何其他方式?

Unfortunately, it looks like ObsoleteAttribute is not valid for assemblies. Is there any other way to cause a compiler warning when a project referencing an assembly is built?

感谢。

编辑:为了澄清,这里是什么组件看起来像以前一样,并在合并后

For clarification, here's what the assemblies look like before and after the merge

在合并之前:

Assembly1:
namespace A.B.C {
    class C1
    ...
}

Assembly2:
namespace A.B.D {
    class D1
    ...
}

在合并:

Assembly1:
(empty)

Assembly2:
namespace A.B.C {
    class C1
    ...
}

namespace A.B.D {
    class D1
    ...
}

在合并之前,用户参考这两个Assembly1和Assembly2。合并后,他们只需要引用Assembly2,但我宁愿产生警告,Assembly1不再需要超过打破他们建立去除Assembly1的时候了。

Before the merge, users referenced both Assembly1 and Assembly2. After the merge, they only need to reference Assembly2, but I'd rather produce a warning that Assembly1 is no longer necessary than break their builds by removing Assembly1 right away.

这听起来像我应该使用类型转发,以确保那些已经建成针对这些组件的程序继续,而不需要重新编译工作,但我不想离开Assembly1存根类只是标志大会为过时

It sounds like I should use type forwarders to make sure that programs that have already been built against these assemblies continue to work without requiring recompilation, but I don't want to leave stub classes in Assembly1 just to flag the assembly as obsolete.

推荐答案

在移动从一个组件类型到另正确的做法是用<一个href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.typeforwardedtoattribute.aspx"相对=nofollow>键入转发 ,不是为了纪念老总成类为过时。

When moving types from one assembly to another the correct thing to do is to use a type forwarder, not to mark the old assembly classes as obsolete.

请参阅:<一href="http://web.archive.org/web/20080430195823/http://hoser.lander.ca/2005/09/14/TheWondersOfWhidbeyFactoringFeaturesPartITypeForwarders.aspx"相对=nofollow>CLR霍谢尔 - 惠德贝保理奇观特点 - 第一部分:输入代理由理查德·兰德(2005)

这篇关于是否有可能标志着pcated的组件,德$ P $?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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