4 people like it.

.NET Interop

Facilities for interop with languages supporting null.

1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
[<AutoOpen>]
module Interop =

    let (===) a b = obj.ReferenceEquals(a, b)
    let (<=>) a b = not (a === b)
    let inline isNull value = value === null
    let inline nil<'T> = Unchecked.defaultof<'T>
    let inline safeUnbox value = if isNull value then nil else unbox value
    let (|Null|_|) value = if isNull value then Some() else None
Multiple items
type AutoOpenAttribute =
  inherit Attribute
  new : unit -> AutoOpenAttribute
  new : path:string -> AutoOpenAttribute
  member Path : string

Full name: Microsoft.FSharp.Core.AutoOpenAttribute

--------------------
new : unit -> AutoOpenAttribute
new : path:string -> AutoOpenAttribute
module Interop

from Script
val a : 'a
val b : 'b
type obj = System.Object

Full name: Microsoft.FSharp.Core.obj
System.Object.ReferenceEquals(objA: obj, objB: obj) : bool
val not : value:bool -> bool

Full name: Microsoft.FSharp.Core.Operators.not
val isNull : value:'a -> bool

Full name: Script.Interop.isNull
val value : 'a
val nil<'T> : 'T

Full name: Script.Interop.nil
module Unchecked

from Microsoft.FSharp.Core.Operators
val defaultof<'T> : 'T

Full name: Microsoft.FSharp.Core.Operators.Unchecked.defaultof
val safeUnbox : value:'a -> 'b

Full name: Script.Interop.safeUnbox
val unbox : value:obj -> 'T

Full name: Microsoft.FSharp.Core.Operators.unbox
union case Option.Some: Value: 'T -> Option<'T>
union case Option.None: Option<'T>
Next Version Raw view Test code New version

More information

Link:http://fssnip.net/4G
Posted:13 years ago
Author:Daniel Robinson
Tags: interop , null handling