CLSCompliant属性默认 [英] CLSCompliant attribute default

查看:81
本文介绍了CLSCompliant属性默认的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

程序集中的CLSCompliant属性的默认值是''false''

级别?是否有任何工具可以检查各种

NET语言的CLS合规性?

解决方案



" Edward Diener" < ED ****** @ tropicsoft.com>在消息中写道

news:u6 ************** @ tk2msftngp13.phx.gbl ...

是默认的'' false''对于程序集
级别的CLSCompliant属性?是否有任何工具可以检查各种
NET语言的CLS合规性?


您可以自己找到的第一部分,来自msdn:

如果没有CLSCompliantAttribute应用于程序元素,那么通过

默认值:


a ..程序集不符合CLS。

b ..只有在封闭时类型才符合CLS类型或程序集是

CLS兼容。

c ..类型的成员只有在类型为

CLS时才符合CLS -compliant。

至于第二部分,fxcop [1]会在程序集中运行并给你

很多关于程序集的信息,包括命名和至少一些

cls合规。目前,任何MS的设计指南都经过修订

并张贴(通常通过Brad Abrams)包含对额外规则的建议

到fxcop。它也可以扩展为添加自己的规则。


1: http://www.gotdotnet.com/team/fxcop/



Daniel O''Connell写道:

" Edward Diener" < ED ****** @ tropicsoft.com>在消息中写道
新闻:u6 ************** @ tk2msftngp13.phx.gbl ...

默认为''false''为程序集
级别的CLSCompliant属性?是否有任何工具可以检查各种.NET语言的CLS合规性?
您可以自己找到的第一部分,来自msdn:
如果没有将CLSCompliantAttribute应用于程序元素,然后通过
默认:

a。程序集不符合CLS。
b ..该类型只有在其封闭类型或
装配符合CLS。
c ..只有符合CLS标准的类型才符合CLS标准。




这有点令人困惑,但我发现MSDN中的区域解释了

它。显然,如果没有CLSCompliantAttribute应用于特定程序

元素,如果将

CLSCompliantAttribute应用于程序集,则程序集仍然可以符合CLS,因此a。 "这是不正确的。

此外,如果相反,上述意思是如果没有CLSCompliantAttribute是

应用于任何程序元素,则会产生a。。正确,然后b。或

c。是无关紧要的,但我不认为这就是它的含义。但是,我从上面收集了
,在程序集中,CLS合规性的默认值是假,这是我想知道的原始问题。

至于第二部分,fxcop [1]会在程序集中运行并给你很多关于程序集的信息,包括命名和至少一些cls合规性。目前,MS的设计指南
经过修订和发布(通常通过Brad Abrams)包含对fxcop附加规则的建议。它也可以扩展到
添加自己的规则。

1: http://www.gotdotnet.com/team/fxcop/




感谢fxcop上的信息。我不知道这个程序以及

的作用。




" Edward Diener" < ED ****** @ tropicsoft.com>在消息中写道

新闻:%2 **************** @ TK2MSFTNGP10.phx.gbl ...

Daniel O ''康奈尔写道:

" Edward Diener" < ED ****** @ tropicsoft.com>在消息中写道
新闻:u6 ************** @ tk2msftngp13.phx.gbl ...

默认为''false''为程序集
级别的CLSCompliant属性?是否有任何工具可以检查各种.NET语言的CLS合规性?
您可以自己找到的第一部分,来自msdn:
如果没有将CLSCompliantAttribute应用于程序元素,然后通过
默认:

a。程序集不符合CLS。
b ..该类型只有在其封闭类型或
程序集符合CLS。
c ..只有当类型符合CLS标准时,类型的成员才符合CLS。



这是有点令人困惑,但我发现MSDN中的区域解释了它。显然,如果没有CLSCompliantAttribute应用于特定程序
元素,如果将
CLSCompliantAttribute应用于程序集,则程序集仍然可以符合CLS,因此a。另外,如果相反,上述意味着如果没有CLSCompliantAttribute应用于任何程序元素,则会产生a。正确,然后b。



或c。是无关紧要的,但我不认为这就是它的含义。但是,我从上面收集到,在程序集
级别的CLS合规性默认值为false,这是我想从原来的
问题中了解到的。 / blockquote>


根据我的理解,如果所有

的成员类型都是CLSCompliant,那么程序集可以被认为是CLSCompliant,但是我不完全确定,我/ b $ b会(而且确实)只是安全地玩它并且自由地应用CLSCompliant。

至于第二部分, fxcop [1]将遍历程序集并提供大量有关程序集的信息,包括命名和至少一些cls合规性。目前,MS的设计指南
经过修订和发布(通常通过Brad Abrams)包含对fxcop附加规则的建议。它也可以扩展到
添加自己的规则。

1: http://www.gotdotnet.com/team/fxcop/



感谢fxcop上的信息。我不知道这个程序及它的作用。



Is the default ''false'' for the CLSCompliant attribute at the assembly
level ? Are there any tools to check for CLS compliance for the various
NET languages ?

解决方案


"Edward Diener" <ed******@tropicsoft.com> wrote in message
news:u6**************@tk2msftngp13.phx.gbl...

Is the default ''false'' for the CLSCompliant attribute at the assembly
level ? Are there any tools to check for CLS compliance for the various
NET languages ?
The first part you could have found on your own, from msdn:
If no CLSCompliantAttribute is applied to a program element, then by
default:

a.. The assembly is not CLS-compliant.
b.. The type is CLS-compliant only if its enclosing type or assembly is
CLS-compliant.
c.. The member of a type is CLS-compliant only if the type is
CLS-compliant.
as for the second part, fxcop[1] will run across assemblies and give you
alot of information about the assembly, including naming and atleast some
cls compliance. Currently, any of MS''s design guidelines that are revised
and posted(usually via Brad Abrams) contain suggestions for additional rules
to fxcop. It can also be extended to add your own rules.

1: http://www.gotdotnet.com/team/fxcop/



Daniel O''Connell wrote:

"Edward Diener" <ed******@tropicsoft.com> wrote in message
news:u6**************@tk2msftngp13.phx.gbl...

Is the default ''false'' for the CLSCompliant attribute at the assembly
level ? Are there any tools to check for CLS compliance for the
various NET languages ?
The first part you could have found on your own, from msdn:
If no CLSCompliantAttribute is applied to a program element, then by
default:

a.. The assembly is not CLS-compliant.
b.. The type is CLS-compliant only if its enclosing type or
assembly is CLS-compliant.
c.. The member of a type is CLS-compliant only if the type is
CLS-compliant.



That is a bit confusing, but I have found the area in MSDN which explains
it. Obviously if no CLSCompliantAttribute is applied to a specific program
element, the assembly could still be CLS-compliant if the
CLSCompliantAttribute is applied to the assembly, so "a." is incorrect.
Furthermore if instead the above means "If no CLSCompliantAttribute is
applied to any program element", which would make "a." correct, then "b." or
"c." is irrelevant, but I don''t think that is what it means. However, I do
gather from the above that the default for CLS compliance at the assembly
level is ''false'', which is what I wanted to know from the original question.
as for the second part, fxcop[1] will run across assemblies and give
you alot of information about the assembly, including naming and
atleast some cls compliance. Currently, any of MS''s design guidelines
that are revised and posted(usually via Brad Abrams) contain
suggestions for additional rules to fxcop. It can also be extended to
add your own rules.

1: http://www.gotdotnet.com/team/fxcop/



Thanks for the info on fxcop. I was not aware of this program and what it
does.



"Edward Diener" <ed******@tropicsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...

Daniel O''Connell wrote:

"Edward Diener" <ed******@tropicsoft.com> wrote in message
news:u6**************@tk2msftngp13.phx.gbl...

Is the default ''false'' for the CLSCompliant attribute at the assembly
level ? Are there any tools to check for CLS compliance for the
various NET languages ?
The first part you could have found on your own, from msdn:
If no CLSCompliantAttribute is applied to a program element, then by
default:

a.. The assembly is not CLS-compliant.
b.. The type is CLS-compliant only if its enclosing type or
assembly is CLS-compliant.
c.. The member of a type is CLS-compliant only if the type is
CLS-compliant.



That is a bit confusing, but I have found the area in MSDN which explains
it. Obviously if no CLSCompliantAttribute is applied to a specific program
element, the assembly could still be CLS-compliant if the
CLSCompliantAttribute is applied to the assembly, so "a." is incorrect.
Furthermore if instead the above means "If no CLSCompliantAttribute is
applied to any program element", which would make "a." correct, then "b."


or "c." is irrelevant, but I don''t think that is what it means. However, I do
gather from the above that the default for CLS compliance at the assembly
level is ''false'', which is what I wanted to know from the original question.



By my understanding, an assembly can be considered CLSCompliant if all of
its member types are CLSCompliant, however I''m not entirely sure, I
would(and do) simply play it safe and apply CLSCompliant liberally.

as for the second part, fxcop[1] will run across assemblies and give
you alot of information about the assembly, including naming and
atleast some cls compliance. Currently, any of MS''s design guidelines
that are revised and posted(usually via Brad Abrams) contain
suggestions for additional rules to fxcop. It can also be extended to
add your own rules.

1: http://www.gotdotnet.com/team/fxcop/



Thanks for the info on fxcop. I was not aware of this program and what it
does.



这篇关于CLSCompliant属性默认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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