Writing CLS compliant code in F#

人盡茶涼 提交于 2019-12-19 06:26:11

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/21028833/writing-cls-compliant-code-in-f

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!