简体   繁体   中英

F# library expected to behave like C# when consumed

I'm developing a library in F# for consumption by another team using C#. What things should I look out for knowing that this other team expects this library to behave like any other C# library?

For example if I use Options types I'll need to convert them to null when I expose to C#. Some other possible transition areas could be computation expressions, FastFunc, events and naming issues.

F#组件设计指南是一个旨在回答这个问题的文档。

Make sure you don't expose any of the F# types, especially lists, maps, etc (exposing something of type Microsoft.FSharp.Collections.FSharpMap will surely make the C# team go nuts). When you're exposing a getter or a return type that is a F# collection, call List.toSeq and you'll end up with an IEnumerable , which is much nicer to work with in C#.

Other than that, you should be just fine. I've used F# and C# on only 1 project before, and that was my only real issue/annoyance interoperating the two.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM