Why isnt this CLS compliant?


S

Smokey Grindle

This class is coming up as not CLS compliant, why?
with this warrning
Warning 2 Type 'Account' is not CLS-compliant.

Namespace Accounts

''' <summary>

''' Represents an account

''' </summary>

''' <remarks></remarks>

Public Class Account

Private m_AccountID As Int64

Private m_Name As String = String.Empty



Public Property AccountID() As Int64

Get

Return m_AccountID

End Get

Set(ByVal value As Int64)

m_AccountID = value

End Set

End Property

Public Property Name() As String

Get

Return m_Name.Trim

End Get

Set(ByVal value As String)

m_Name = value

End Set

End Property

Public Sub New()

Me.AccountID = -1

Me.Name = String.Empty

End Sub

Public Sub New(ByVal accountID As Int64, ByVal name As String)

Me.AccountID = accountID

Me.Name = name.Trim

End Sub

Public Overrides Function ToString() As String

Return Me.Name

End Function

End Class

End Namespace
 
Ad

Advertisements

S

Smokey Grindle

nope, didnt change anything, I thought just unsigned integers, and unsigned
values where non-CLS
 
M

Michael D. Ober

The only errors I get in a VB 2005 console application for this code is

Warning 1 Only one XML comment block is allowed per language element.
C:\Documents and Settings\mdo\Local Settings\Application Data\Temporary
Projects\ConsoleApplication1\Module1.vb 11 5 ConsoleApplication1

I get this error on the ''' <summary>, ''' Represents and account, and '''
</summary> lines

Mike.
 
Ad

Advertisements

A

_AnonCoward

There isn't any reason why this code as presented here shouldn't be
considered CLS compliant. I gather you are using Visual Studio for
this. Have you tried compiling from a command line?

Ralf


: wierd its still throwing a CLS warrning to this day for me
:
: : > Works just fine for me. I'm not getting any warnings in .NET 2005
: >
: > /claes
: >
: > : >> This class is coming up as not CLS compliant, why?
: >> with this warrning
: >> Warning 2 Type 'Account' is not CLS-compliant.
: >>
: >> Namespace Accounts
: >>
: >> ''' <summary>
: >>
: >> ''' Represents an account
: >>
: >> ''' </summary>
: >>
: >> ''' <remarks></remarks>
: >>
: >> Public Class Account
: >>
: >> Private m_AccountID As Int64
: >>
: >> Private m_Name As String = String.Empty
: >>
: >>
: >>
: >> Public Property AccountID() As Int64
: >>
: >> Get
: >>
: >> Return m_AccountID
: >>
: >> End Get
: >>
: >> Set(ByVal value As Int64)
: >>
: >> m_AccountID = value
: >>
: >> End Set
: >>
: >> End Property
: >>
: >> Public Property Name() As String
: >>
: >> Get
: >>
: >> Return m_Name.Trim
: >>
: >> End Get
: >>
: >> Set(ByVal value As String)
: >>
: >> m_Name = value
: >>
: >> End Set
: >>
: >> End Property
: >>
: >> Public Sub New()
: >>
: >> Me.AccountID = -1
: >>
: >> Me.Name = String.Empty
: >>
: >> End Sub
: >>
: >> Public Sub New(ByVal accountID As Int64, ByVal name As String)
: >>
: >> Me.AccountID = accountID
: >>
: >> Me.Name = name.Trim
: >>
: >> End Sub
: >>
: >> Public Overrides Function ToString() As String
: >>
: >> Return Me.Name
: >>
: >> End Function
: >>
: >> End Class
: >>
: >> End Namespace
: >>
: >>
: >
: >
:
:
 
M

Michael D. Ober

Thanks - I hadn't used the XML comment creation in VB so I wasn't aware that
the all had to be consecutive lines.

Mike.
 
M

Michael D. Ober

Cut and paste your code into a new project. Something's wrong in how the
compiler is interpreting your code. I just had to do a similar move in a C#
catch block.

Mike Ober.
 
Ad

Advertisements

J

Jay B. Harlow

Smokey,
In addition to the other comments:

Is this the only class that is, or do you have other classes that are not
CLS compliant?

Do you have CLSComplaint(False) at the assembly level? For example the
following line in any files in the project:

<Assembly: CLSCompliant(False)>


As the others have stated, using your code as posted I do not receive a
warning.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top