Skip to content

Commit

Permalink
Nullness - SDK prop alignment with C# - <Nullable> (#17486)
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Gro authored Aug 15, 2024
1 parent e124950 commit 5e035e2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion FSharp.Profiles.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</PropertyGroup>

<PropertyGroup Condition="'$(CheckNulls)' == 'true'">
<OtherFlags>$(OtherFlags) /checknulls</OtherFlags>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup Condition="'$(CheckNulls)' == 'false'">
Expand Down
20 changes: 20 additions & 0 deletions src/FSharp.Build/Fsc.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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'; '\"'; '\'' |]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/FSharp.Build/Microsoft.FSharp.Targets
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,8 @@ this file.
WarnOn="$(WarnOn)"
Win32IconFile="$(ApplicationIcon)"
Win32ManifestFile="$(Win32Manifest)"
Win32ResourceFile="$(Win32Resource)">
Win32ResourceFile="$(Win32Resource)"
Nullable="$(Nullable)">
<Output TaskParameter="CommandLineArgs" ItemName="FscCommandLineArgs" />
</Fsc>

Expand Down

0 comments on commit 5e035e2

Please sign in to comment.