Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply attribute to return value - In F#

in C# it is possible to apply an attribute to the return of a method:

[return: DynamicAttribute]
public object Xyz() {
  return new ExpandoObject();
}

Is this possible in F#?

Background:

I would like a method of a library written in F# which will be consumed in a language like C# to return "dynamic" from a method. If I look into a similarly defined method compiled from C# it seems like the return type is object and the DynamicAttribute is applied to the return value of the object.

like image 386
flq Avatar asked Feb 03 '23 10:02

flq


1 Answers

Sure, you can apply a similar attribute target for the return value.

let SomeFunc x : [<return: SomeAttribute>] SomeType =
    SomeOperation x

See the table of how to specify attribute targets at the end of this MSDN page.

like image 54
Jeff Mercado Avatar answered Feb 04 '23 23:02

Jeff Mercado