By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,887 Members | 1,003 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,887 IT Pros & Developers. It's quick & easy.

CLS-Compliance and Array Parameter Rank

P: n/a
TC
I just upgraded some code to VB 2005. When I did so, Visual Studio
generated several warnings telling me about things which weren't quite
perfect in my code. I resolved all the warnings except one. I need help
with this one.

'Public Function Multiply(A(,) As Double, B() As Double) As Double()'
is not CLS-compliant because it overloads 'Public Function
Multiply(A(,) As Double, B(,) As Double) As Double(,)' which differs
from it only by array of array parameter types or by the rank of the
array parameter types.

Apparently, my code is not CLS-compliant because B() has the same
parameter signature as B(,) under the CLS rules. I understand this
problem, but I don't know how to fix it.

The only solution I see is to stop overloading (i.e. change the name of
one of the two functions), but that will change the public signature of
my code. Can anyone suggest a better solution?
-TC

May 28 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
>The only solution I see is to stop overloading (i.e. change the name of
one of the two functions), but that will change the public signature of
my code. Can anyone suggest a better solution?


If you don't care about CLS compliance you can apply the
CLSCompliant(False) attribute to the method to get rid of the warning.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
May 29 '06 #2

P: n/a
TC
Mattias,

Thanks for the advice. Unfortunately, I'm forced to care about CLS
compliance. The module in question is referenced by many projects, some
of which must be CLS compliant.

-TC

May 29 '06 #3

P: n/a
TC,
What Mattias was suggesting was:

<Assembly: CLSCompliant(True)>

Public Class Something

<CLSCompliant(False)> _
Public Function Multiply(ByVal A(,) As Double, ByVal B() As Double) As
Double()
Return Nothing
End Function

Public Function Multiply(ByVal A(,) As Double, ByVal B(,) As Double) As
Double(,)
Return Nothing
End Function

End Class

You can have the entire assembly CSL compliant, except selected types &
methods, as above.

NOTE: I don't know why but it makes a difference which one you use
<CLSCompliant(False)> on...

This is similar to System.Convert.ToUInt32() method. The System.Convert
class is CLS Compliant, however the ToUInt32 is not, as UInt32 is not.

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"TC" <go*********@yahoo.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
| Mattias,
|
| Thanks for the advice. Unfortunately, I'm forced to care about CLS
| compliance. The module in question is referenced by many projects, some
| of which must be CLS compliant.
|
| -TC
|
May 29 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.