not CLS-compliant

J

John

Hi

After importing my vs 2003 project into vs 2005 I am getting the error Name
'_DateColumn' is not CLS-compliant. on the second line of below code;

<System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Public ReadOnly Property _DateColumn() As System.Data.DataColumn
Get
Return Me.column_Date
End Get
End Property

What does that mean and how can I fix it? I suspect this code was generated
by vs 2003 itself.

Regards
 
M

Michael C

John said:
Hi

After importing my vs 2003 project into vs 2005 I am getting the error
Name '_DateColumn' is not CLS-compliant. on the second line of below code;

<System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Public ReadOnly Property _DateColumn() As System.Data.DataColumn
Get
Return Me.column_Date
End Get
End Property

What does that mean and how can I fix it? I suspect this code was
generated by vs 2003 itself.

I suspect it's the underscore.

Michael
 
F

Fabio Z

John said:
<System.Diagnostics.DebuggerNonUserCodeAttribute()> _
Public ReadOnly Property _DateColumn() As System.Data.DataColumn
Get
Return Me.column_Date
End Get
End Property

What does that mean and how can I fix it? I suspect this code was
generated by vs 2003 itself.

not CLS Compliant means that the *public* declaration doesn't follows the
CLR specifications.
This means that another .Net language may not understand correctly that
declaration if it uses your assembly as a reference.

In this case I think that the use of "_" as a name of a public member is a
bad practise.
 
A

_AnonCoward

:
: Hi
:
: After importing my vs 2003 project into vs 2005 I am getting the
: error Name '_DateColumn' is not CLS-compliant. on the second line
: of below code;
:
: <System.Diagnostics.DebuggerNonUserCodeAttribute()> _
: Public ReadOnly Property _DateColumn() As System.Data.DataColumn
: Get
: Return Me.column_Date
: End Get
: End Property
:
: What does that mean and how can I fix it? I suspect this code was
: generated by vs 2003 itself.
:
: Regards


It's the underscore.

http://msdn2.microsoft.com/en-us/library/k5645wwb.aspx

It's due the the fact that there are C/C++ compilers for .Net. In
these languages, names with leading underscore characters are reserved
for the "implementation" under certain specific rules (I've seen "the
implementation" defined as anything other than the code the programmer
is writing, btw). It states in the SDK documentation regarding
variable names in the C++ language:


Use of two sequential underscore characters ( __ ) at the
beginning of an identifier, or a single leading underscore
followed by a capital letter, is reserved for C++ implementations
in all scopes. You should avoid using one leading underscore
followed by a lowercase letter for names with file scope because
of possible conflicts with current or future reserved identifiers.


Since VB is not case sensitive, "_DateColumn" and "_dateColumn" are
identical. However, in C/C++/C# they are not. The first version of the
name is not legal in C++ but the second version is (although
discouraged). Since VB doesn't differentiate by case, neither version
is considered CLS compliant.


Ralf
 

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