NullKill


NullKill

Documentation

NullKill can be installed from NuGet:
PM> Install-Package NullKill

Example

This example usage of NullKill:

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
32: 
33: 
#r "NullKill.dll"
open NullKill

let myThing = System.DateTime.Now

match Check myThing with
| Some thing ->
    "myThing is not null, and neither are any of it's fields or properties."
| None ->
    "This will never get called."

let nastyThing = null

if HasNoNulls nastyThing then
    "This would be nice, but..."
else
    "nastyThing is null, so you'll run this path."

type NoGoodClass () =
    [<DefaultValue>] val mutable Field : System.DateTime
    member val Prop1 = null with get, set

match Check <| NoGoodClass () with
| Some ngc ->
    "Won't get here, as there are nasty nulls lurking."
| None ->
    "We'll get this instead."

match Check <| NoGoodClass(Field = System.DateTime.Now, Prop1 = "Hello world") with
| Some ngc ->
    "All set up this time."
| None ->
    "We only have to worry about nulls on this route."

Contributing and copyright

The project is hosted on GitHub where you can report issues, fork the project and submit pull requests. If you're adding new public API, please also consider adding samples that can be turned into a documentation. You might also want to read library design notes to understand how it works.

The library is available under Public Domain license, which allows modification and redistribution for both commercial and non-commercial purposes. For more information see the License file in the GitHub repository.

module NullKill
val myThing : System.DateTime

Full name: Index.myThing
namespace System
Multiple items
type DateTime =
  struct
    new : ticks:int64 -> DateTime + 10 overloads
    member Add : value:TimeSpan -> DateTime
    member AddDays : value:float -> DateTime
    member AddHours : value:float -> DateTime
    member AddMilliseconds : value:float -> DateTime
    member AddMinutes : value:float -> DateTime
    member AddMonths : months:int -> DateTime
    member AddSeconds : value:float -> DateTime
    member AddTicks : value:int64 -> DateTime
    member AddYears : value:int -> DateTime
    ...
  end

Full name: System.DateTime

--------------------
System.DateTime()
   (+0 other overloads)
System.DateTime(ticks: int64) : unit
   (+0 other overloads)
System.DateTime(ticks: int64, kind: System.DateTimeKind) : unit
   (+0 other overloads)
System.DateTime(year: int, month: int, day: int) : unit
   (+0 other overloads)
System.DateTime(year: int, month: int, day: int, calendar: System.Globalization.Calendar) : unit
   (+0 other overloads)
System.DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int) : unit
   (+0 other overloads)
System.DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, kind: System.DateTimeKind) : unit
   (+0 other overloads)
System.DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, calendar: System.Globalization.Calendar) : unit
   (+0 other overloads)
System.DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, millisecond: int) : unit
   (+0 other overloads)
System.DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, millisecond: int, kind: System.DateTimeKind) : unit
   (+0 other overloads)
property System.DateTime.Now: System.DateTime
val Check : thing:'a -> 'a option

Full name: NullKill.Check
union case Option.Some: Value: 'T -> Option<'T>
val thing : System.DateTime
union case Option.None: Option<'T>
val nastyThing : 'a (requires 'a : null)

Full name: Index.nastyThing
val HasNoNulls : thing:obj -> bool

Full name: NullKill.HasNoNulls
Multiple items
type NoGoodClass =
  new : unit -> NoGoodClass
  val mutable Field: DateTime
  member Prop1 : string
  member Prop1 : string with set

Full name: Index.NoGoodClass

--------------------
new : unit -> NoGoodClass
Multiple items
type DefaultValueAttribute =
  inherit Attribute
  new : unit -> DefaultValueAttribute
  new : check:bool -> DefaultValueAttribute
  member Check : bool

Full name: Microsoft.FSharp.Core.DefaultValueAttribute

--------------------
new : unit -> DefaultValueAttribute
new : check:bool -> DefaultValueAttribute
NoGoodClass.Field: System.DateTime
val set : elements:seq<'T> -> Set<'T> (requires comparison)

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.set
val ngc : NoGoodClass
Fork me on GitHub