If in F# I have methods like:
drawBox
drawSphere
paintImage
Would they be transferred to C#, exactly the same?
If that's the case, then wouldn't it compromise the naming conventions in C#, where methods are supposed to be PascalCase?
Or should I make them PascalCase in F# as well to remedy this?
You should follow the F# Component Design Guidelines.
The notable parts are:
invalidArg
), and for the "standard collection functions" (e.g. List.map
). In both these cases, the function names act much like keywords in the language.Another way to slice it:
As others already pointed out, the names of compiled members are exactly the same as the names you wrote in the F# code. In general, it is a good idea to follow standard C# naming conventions when declaring classes. When declaring an F# module then you can either use camelCase
(especially for modules that are intended for F# users) or PascalCase
if you want to use them from C#.
Also, there is one trick that you can use (this is used in the F# core library for functions like List.map
that are actually compiled as List.Map
). You can use the CompiledName
attribute to specify the name in the compiled version:
module Bar =
[<CompiledName("Foo")>]
let foo a = a + 1
It is probably better to use a unified naming convention, but if you want to keep a nice short name for F# users and standard .NET name for C# users, this is an interesting option.
type methods names will be the same both in F# and C#. if you want PascalCase in C# - you should use this naming convention in F#, the same with camelCase.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With