In C#, you might see things such as:
[<DllImport("myUnmanagedDLL.dll")>]
or a similar line (but without the greater/less than symbols):
[assembly: AssemblyTitle("MyProject")]
I know that the first is called an attribute (it has gt and lt signs) and can be used to add a sort of metadata to methods, types, etc, but what does the syntax of the second mean? I'm trying to translate something with this syntax to F# -- namely, this line:
[MonoMac.Foundation.Register("AppDelegate")]
but what does the syntax of the second mean?
This means that the attribute is being applied to the assembly, not to a type (class or struct) or member.
In F#, the line you're trying to translate should be:
[<MonoMac.Foundation.Register("AppDelegate")>]
Without seeing more, it's impossible to tell where this should be applied, however (a type, a method, etc). I suspect this would go on your type
definition in F#, though, given that this is typically used on a C# class.
On a side note, [<DllImport("myUnmanagedDLL.dll")>]
is not valid C# - that's F# syntax. C# uses [Attribute]
for attributes (and VB.Net uses <Attribute>
).
In case it's helpful—in F#, assembly level attributes are typically applied to an empty do
block:
[<assembly: AssemblyTitle("MyProject")>]
do ()
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