可以标记系统类或方法在C#作为过时了吗? [英] Possible to mark system classes or methods as obsolete in C#?

查看:308
本文介绍了可以标记系统类或方法在C#作为过时了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能申请过时的属性系统类或方法?如果是这样,怎么样?如果没有,我可以指示Visual Studio中警告某些code模式?

Is it possible to apply Obsolete attribute to system classes or methods? If so, how? If not, can I instruct Visual Studio to warn on certain code patterns?

具体来说,我想,以纪念赞成可能单的使用会话/会话[钥匙]为过时的。

Specifically, I'd like to mark the use of Session/Session["key"] as obsolete in favor of a possible singleton.

推荐答案

有没有办法标志着其它组件如已废弃定义的类型。在 ObsoleteAttribute 只能在源$ C ​​$ C,你是编译应用类型。

There is no way to mark types defined in other assemblies as obselete. The ObsoleteAttribute can only be applied to types in source code that you are compiling.

有没有现有的Visual Studio工具,我知道其中提供此功能。如果你有兴趣,虽然persueing它,最好的选择是有可能写一个针对此类型的的FxCop规则。

There is no existing Visual Studio tool I'm aware of which provides this capability. If you are interested in persueing it though, the best option is likely to write an FxCop rule which targets this type.

这篇关于可以标记系统类或方法在C#作为过时了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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