CLS compliance problem

  • Thread starter Thread starter Lloyd Dupont
  • Start date Start date
L

Lloyd Dupont

In C++/CLI I defined an enum like that:
public enum class FontQuality : __int32
{
Default = DEFAULT_QUALITY,
Draft = DRAFT_QUALITY,
Proof = PROOF_QUALITY,
NonAntiAliased = NONANTIALIASED_QUALITY,
AntiAliased = ANTIALIASED_QUALITY,
ClearType = CLEARTYPE_QUALITY,
ClearTypeNatural = CLEARTYPE_NATURAL_QUALITY
};

Now I'm using it in C# library and the compiler warns me that it is not CLS
compliant...

Why is that? (and how to fix it?!)
When I define a similar enum in C# I have no CLS compliance issue!
 
You might have a look at the Microsoft one at
System.Windows.Forms.Internal.WindowsFontQuality. Compare the IL for all
three versions with .NET Reflector.

Also, try changing the __int32 base type to System.Int32, and put a
CLSCompliant attribute on your assembly.
 
Thanks for the tips!! ;-)

Ben Voigt said:
You might have a look at the Microsoft one at
System.Windows.Forms.Internal.WindowsFontQuality. Compare the IL for all
three versions with .NET Reflector.

Also, try changing the __int32 base type to System.Int32, and put a
CLSCompliant attribute on your assembly.
 
Back
Top