not CLSCompliant but the compilers is happy anyway

T

Tony Johansson

Hi!

Here I have a simple program that is not CLSCompliant because of two things
1. Two methods with same name but differ in case.
2. The program return an uint which should not be CLSCompliant

As you can see I have declared the CLSCompliantAttribute as an assembly
attribut but the compilers is happy
and give not a single warning about this.
Can somebody explain this ?

using System;
using System.Collections.Generic;
using System.Text;

[assembly: CLSCompliantAttribute(true)]

namespace ConsoleApplication8
{
class Program
{
uint tal = 2;

public uint Foo()
{
return tal;
}

public uint FOO()
{
return tal;
}

static void Main(string[] args)
{
Program prog = new Program();
}
}
}

//Tony
 
H

Heandel

From what I've seen in previous experiences, the compiler simply "trusts"
you and doesn't perform any kind of check.

Heandel
 
P

Peter Duniho

Patrice said:
Hello,

Just add the "public" modifier. Else the class is private and the CLS
compliance is not checked...

Minor nit: the class is "internal" by default, not "private".
 
P

Patrice

Minor nit: the class is "internal" by default, not "private".

Good point. I realized after posting that choosing this word was
confusing...
 

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