Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullness - SDK prop alignment with C# - <Nullable> #17486

Merged
merged 5 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading