Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing CLS compliant code in F#

Tags:

f#

I am very new to F# and I started to write my functional wrapper on top of OpenGL. I also intend to use it to write a graphics engine which should have interop with all .Net languages.

But it is hard to find information about which code constructs in F# are not CLS compliant.

For example I already know of a few that are not CLS compliant:

  • static type constrains
  • tupleless functions
  • probably 'T list and Seq
  • maybe even union types

How do I know what features of F# are not CLS compliant?

like image 504
Maik Klein Avatar asked Jan 09 '14 18:01

Maik Klein


People also ask

What does CLS compliant mean?

The CLSCompliantAttribute attribute is used to indicate whether a particular program element complies with the Common Language Specification (CLS), which defines the features that any language that targets . NET must support.


1 Answers

Use the CLSCompliant attribute. It will guarantee that your code is CLS-Compliant at compile time.

Like this:

module myProject.AssemblyInfo

open System

[<assembly: CLSCompliant(true)>]

do()

Source: Mike-Ward.Net: Learning F#–Assembly Level Attributes

For a more complete discussion of the CLSCompliant attribute, see C# Corner: Making Your Code CLS Compliant

like image 139
JDB Avatar answered Oct 11 '22 16:10

JDB