开发者

F# library expected to behave like C# when consumed

开发者 https://www.devze.com 2023-01-29 12:54 出处:网络
I\'m developing a library in F# f开发者_JS百科or consumption by another team using C#.What things should Ilook out for knowing that this other team expects this library to behave like any other C# lib

I'm developing a library in F# f开发者_JS百科or 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.


The F# Component Design Guidelines is a document designed to answer exactly this question.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消