在F#中编写符合CLS的代码 [英] Writing CLS compliant code in F#

查看:85
本文介绍了在F#中编写符合CLS的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对F#非常陌生,我开始在OpenGL之上编写函数包装.我还打算用它来编写一个图形引擎,该引擎应与所有.Net语言互操作.

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.

但是很难找到有关F#中的哪些代码构造不符合CLS的信息.

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

例如,我已经知道一些不符合CLS的内容:

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

  • 静态类型约束
  • 无元函数
  • 可能'T list and Seq
  • 甚至工会类型
  • static type constrains
  • tupleless functions
  • probably 'T list and Seq
  • maybe even union types

我怎么知道F#的哪些功能不符合CLS?

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

推荐答案

使用

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

赞:

module myProject.AssemblyInfo

open System

[<assembly: CLSCompliant(true)>]

do()

来源: Mike-Ward.Net:学习F#–装配级属性

有关CLSCompliant属性的更完整讨论,请参见

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

这篇关于在F#中编写符合CLS的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆