什么时候可以打破CLS合规性? [英] When is it acceptable to break CLS compliance?

查看:61
本文介绍了什么时候可以打破CLS合规性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道存在哪些可能使

I was wondering which edge cases exist that could make Common Language Specification compliance acceptable. Even when not intending to be accessed from other languages, I think that the tenets asserted by the CLSCompliantAttribute are good best practices.

您是否遇到过/知道 YAGNI 胜过最佳做法的情况?

Do you have encountered / know of cases where YAGNI outweighs the best practices?

推荐答案

"[原文]符合CLS有什么用?"

"[sic] What use is there for being CLS compliant?"

中级信任

Medium trust, ClickOnce, running from a shared network drive, guest profiles in a domain setting, etc. There are lots of security situations where your code cannot run if you break the CLS Compliance.

我亲自看到很多情况,用户试图从共享的网络驱动器上运行他们的应用程序,但由于本地管理员在安全性配置文件中杀死了不符合CLS的应用程序而无法这样做.

I have personally seen a lot of situations where users are trying to run their application from a shared network drive and can't because the local admin has killed non-CLS compliant applications in the security profile.

通常,无论如何,通常都有解决此问题的方法.对于上面的评论,我会采取相反的方法,为什么要破坏它呢?您正在编写托管代码,为什么要故意限制应用程序?

In general, there are usually ways to work around the issue anyway. I would take the opposite approach to the comments above, why break it? You are writing managed code, why would you want to limit your application on purpose?

我要说的是,如果要构建API程序集或组件,则应始终遵循它们.尝试从中等信任度运行时,太多的第三方组件会采取简单的方法,只是将它们标记为已损坏.在某些情况下,这是它们无法运行的唯一原因.如果他们花了更多时间来遵守指南,则用户将不会受到如何使用其组件的限制.

I would say that if you are building an API assembly or component, you should always adhere to them. Too many third-party components take the easy way out and just flag them as broken when attempting to run from medium trust. In some cases, this is the only reason they can't run. If they had taken a little more time to adhere to the guidelines, users would not be limited as to how they can use their component.

这篇关于什么时候可以打破CLS合规性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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