anchor.diff:          | _ ->
               raise DecoderException
   
  -let isOptionalField (mi: System.Reflection.MemberInfo) (mt: System.Type) =
  +let isOptionalField (i: FormatSettings) (mi: System.Reflection.MemberInfo) (mt: System.Type) =
       mt.IsGenericType &&
       mt.GetGenericTypeDefinition() = typedefof<option<_>> &&
  -    (mi.GetCustomAttributes(false)
  -    |> Array.exists (fun t -> t.GetType() = typeof<A.OptionalFieldAttribute>))
  +    (i.RepresentNullUnionsAsAbsentField ||
  +        (mi.GetCustomAttributes(false)
  +        |> Array.exists (fun t -> t.GetType() = typeof<A.OptionalFieldAttribute>)))
  +
  +let isNullableUnion (i: FormatSettings) (mt: System.Type) =
  +    i.RepresentNullUnionsAsAbsentField &&
  +    FST.IsUnion mt &&
  +    (mt.GetCustomAttributesData()
  +    |> Seq.exists (fun cad ->
  +        cad.Constructor.DeclaringType = typeof<CompilationRepresentationAttribute> &&
  +        let flags = cad.ConstructorArguments.[0].Value :?> CompilationRepresentationFlags
  +        flags &&& CompilationRepresentationFlags.UseNullAsTrueValue <> enum 0))
   
   let encodeOptionalField dE (i: FormatSettings) (mi: System.Reflection.MemberInfo) (mt: System.Type) : obj -> option<Encoded> =
  -    if isOptionalField mi mt then
  +    if isOptionalField i mi mt then
           let vt = mt.GetGenericArguments().[0]
           let enc = dE vt
           let ucis = FST.GetUnionCases(mt, flags)
  
positive.code:                 None
              else
                  Some (enc (getSome x).[0])
      else
          let enc = dE mt
          fun x -> Some (enc x)
  
  let decodeOptionalField dD (i: FormatSettings) (mi: System.Reflection.MemberInfo) (mt: System.Type) : option<Value> -> obj =
      if isOptionalField mi mt then
          let vt = mt.GetGenericArguments().[0]
          let dec = dD vt
          let ucis = FST.GetUnionCases(mt, flags)
  
negative.code:             match x with
              | None -> none
              | Some v -> some [| dec v |]
      elif isNullableUnion i mt then
          let dec = dD mt
          let ucis = FST.GetUnionCases(mt, flags)
          let none = FSV.PreComputeUnionConstructor(ucis.[0], flags) [||]
          function
          | Some v -> dec v
          | None -> none
      else
          let dec = dD mt
          function
  