PC Review


Reply
Thread Tools Rate Thread

CLSCompliant attribute default

 
 
Edward Diener
Guest
Posts: n/a
 
      17th Dec 2003
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 ?



 
Reply With Quote
 
 
 
 
Daniel O'Connell
Guest
Posts: n/a
 
      17th Dec 2003

"Edward Diener" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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/

>
>
>



 
Reply With Quote
 
Edward Diener
Guest
Posts: n/a
 
      17th Dec 2003
Daniel O'Connell wrote:
> "Edward Diener" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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.


 
Reply With Quote
 
Daniel O'Connell
Guest
Posts: n/a
 
      17th Dec 2003

"Edward Diener" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Daniel O'Connell wrote:
> > "Edward Diener" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >> 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.
>
>



 
Reply With Quote
 
Edward Diener
Guest
Posts: n/a
 
      17th Dec 2003
Daniel O'Connell wrote:
> "Edward Diener" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Daniel O'Connell wrote:
>>> "Edward Diener" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> 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.


One could always mark the assembly itself as CLSCompliant(true) I believe,
and then all enclosing types, meaning all the types in the assembly, become
CLSCompliant unless marked otherwise. I am not sure how one does this in the
assembly file but I am guessing it is just another attribute added to the
file.


 
Reply With Quote
 
Daniel O'Connell
Guest
Posts: n/a
 
      17th Dec 2003

"Edward Diener" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Daniel O'Connell wrote:
> > "Edward Diener" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> >> Daniel O'Connell wrote:
> >>> "Edward Diener" <(E-Mail Removed)> wrote in message
> >>> news:(E-Mail Removed)...
> >>>> 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.

>
> One could always mark the assembly itself as CLSCompliant(true) I believe,
> and then all enclosing types, meaning all the types in the assembly,

become
> CLSCompliant unless marked otherwise. I am not sure how one does this in

the
> assembly file but I am guessing it is just another attribute added to the
> file.
>

Yeah, generally in AssemblyInfo, for C# its [assembly: CLSCompliant(true)].
I think the rules apply when there is no CLSCompliant rule attached to the
assembly. I will look through the standards later on this issue as well.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Default value attribute for type. Mr. X. Microsoft C# .NET 2 13th Jul 2010 09:33 PM
not CLSCompliant but the compilers is happy anyway Tony Johansson Microsoft C# .NET 4 18th Feb 2010 12:19 PM
CLSCompliant Tony Johansson Microsoft C# .NET 3 31st Jan 2010 06:09 PM
Where to put [assembly: CLSCompliant(true)]? Brett Romero Microsoft C# .NET 2 7th Feb 2006 11:22 PM
How do I change the default attribute in excel? =?Utf-8?B?d29ya2Vu?= Microsoft Excel Misc 2 31st Jan 2006 01:56 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:53 AM.