From c31a5158942380e624f1e4f810428286d1923051 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Wed, 31 Jul 2024 08:59:30 +0200 Subject: [PATCH 1/2] sdk props --- FSharp.Profiles.props | 2 +- src/FSharp.Build/Fsc.fs | 20 ++++++++++++++++++++ src/FSharp.Build/Microsoft.FSharp.Targets | 3 ++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/FSharp.Profiles.props b/FSharp.Profiles.props index 4627fcace39..811ee0d0e40 100644 --- a/FSharp.Profiles.props +++ b/FSharp.Profiles.props @@ -23,7 +23,7 @@ - $(OtherFlags) /checknulls + enable diff --git a/src/FSharp.Build/Fsc.fs b/src/FSharp.Build/Fsc.fs index 9de88c9dbca..3da05502ceb 100644 --- a/src/FSharp.Build/Fsc.fs +++ b/src/FSharp.Build/Fsc.fs @@ -95,6 +95,7 @@ type public Fsc() as this = let mutable vslcid: string MaybeNull = null let mutable utf8output: bool = false let mutable useReflectionFreeCodeGen: bool = false + let mutable nullable: bool option = None /// Trim whitespace ... spaces, tabs, newlines,returns, Double quotes and single quotes let wsCharsToTrim = [| ' '; '\t'; '\"'; '\'' |] @@ -205,6 +206,13 @@ type public Fsc() as this = if not tailcalls then builder.AppendSwitch("--tailcalls-") + match nullable with + | Some true -> + builder.AppendSwitch("--checknulls+") + builder.AppendSwitch("--define:NULLABLE") + | Some false -> builder.AppendSwitch("--checknulls-") + | None -> () + // PdbFile builder.AppendSwitchIfNotNull("--pdb:", pdbFile) // Platform @@ -649,6 +657,18 @@ type public Fsc() as this = with get () = subsystemVersion and set (p) = subsystemVersion <- p + member _.Nullable + with get () = + match nullable with + | None -> "" + | Some true -> "enable" + | Some false -> "disable" + and set(p) = + match p with + | "enable" -> nullable <- Some true + | "disable" -> nullable <- Some false + | _ -> () + member _.HighEntropyVA with get () = highEntropyVA and set (p) = highEntropyVA <- p diff --git a/src/FSharp.Build/Microsoft.FSharp.Targets b/src/FSharp.Build/Microsoft.FSharp.Targets index 0ac058e30ba..7334f979086 100644 --- a/src/FSharp.Build/Microsoft.FSharp.Targets +++ b/src/FSharp.Build/Microsoft.FSharp.Targets @@ -412,7 +412,8 @@ this file. WarnOn="$(WarnOn)" Win32IconFile="$(ApplicationIcon)" Win32ManifestFile="$(Win32Manifest)" - Win32ResourceFile="$(Win32Resource)"> + Win32ResourceFile="$(Win32Resource)" + Nullable="$(Nullable)"> From ee5123833f15dcf9eb5551f0a40dde731fff4cd3 Mon Sep 17 00:00:00 2001 From: Tomas Grosup Date: Fri, 2 Aug 2024 21:04:18 +0200 Subject: [PATCH 2/2] fantomas --- src/FSharp.Build/Fsc.fs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/FSharp.Build/Fsc.fs b/src/FSharp.Build/Fsc.fs index 3da05502ceb..24952eceea1 100644 --- a/src/FSharp.Build/Fsc.fs +++ b/src/FSharp.Build/Fsc.fs @@ -207,7 +207,7 @@ type public Fsc() as this = builder.AppendSwitch("--tailcalls-") match nullable with - | Some true -> + | Some true -> builder.AppendSwitch("--checknulls+") builder.AppendSwitch("--define:NULLABLE") | Some false -> builder.AppendSwitch("--checknulls-") @@ -658,12 +658,12 @@ type public Fsc() as this = and set (p) = subsystemVersion <- p member _.Nullable - with get () = + with get () = match nullable with | None -> "" | Some true -> "enable" | Some false -> "disable" - and set(p) = + and set (p) = match p with | "enable" -> nullable <- Some true | "disable" -> nullable <- Some false