lundi 29 février 2016

Reflecting C# types in F#

I've loaded a C# dll in a Fsi session. Running C# methods returns some C# types. I've written a helper function to explore the Properties for a given C# type.

The program is failing with an error:

stdin(95,21): error FS0039: The type 'RuntimePropertyInfo' is not defined

Is this possible to do? Or am I beating a dead horse?

let getPropertyNames (s : System.Type)=
    Seq.map (fun (t:System.Reflection.RuntimePropertyInfo) -> t.Name) (typeof<s>.GetProperties())

typeof<TypeName>.GetProperties() //seems to work.

I'm just aiming for a pretty print of C# fields.





Aucun commentaire:

Enregistrer un commentaire