From 45545371ba221f044cb89e2fc7520a847c15e324 Mon Sep 17 00:00:00 2001 From: Vlad Zarytovskii Date: Wed, 11 Sep 2024 17:45:40 +0200 Subject: [PATCH 1/2] Add conditional null guards to autogenerated code, so it can be used with any shipped FSharp.Core --- src/FSharp.Build/FSharpEmbedResourceText.fs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/FSharp.Build/FSharpEmbedResourceText.fs b/src/FSharp.Build/FSharpEmbedResourceText.fs index 60e871761c2..b2be753acaf 100644 --- a/src/FSharp.Build/FSharpEmbedResourceText.fs +++ b/src/FSharp.Build/FSharpEmbedResourceText.fs @@ -288,7 +288,11 @@ open Printf if isNull s then System.Diagnostics.Debug.Assert(false, sprintf ""**RESOURCE ERROR**: Resource token %s does not exist!"" name) #endif + #if BUILDING_WITH_LKG || NO_NULLCHECKING_LIB_SUPPORT + s + #else Unchecked.nonNull s + #endif static let mkFunctionValue (tys: System.Type[]) (impl:obj->obj) = @@ -314,7 +318,11 @@ open Printf // PERF: this technique is a bit slow (e.g. in simple cases, like 'sprintf ""%x""') mkFunctionValue tys (fun inp -> impl rty inp) + #if BUILDING_WITH_LKG || NO_NULLCHECKING_LIB_SUPPORT + static let capture1 (fmt:string) i args ty (go: obj list -> System.Type -> int -> obj) : obj = + #else static let capture1 (fmt:string) i args ty (go: objnull list -> System.Type -> int -> obj) : obj = + #endif match fmt.[i] with | '%' -> go args ty (i+1) | 'd' @@ -336,7 +344,11 @@ open Printf if i >= len || (fmt.[i] = '%' && i+1 >= len) then let b = new System.Text.StringBuilder() b.AppendFormat(messageString, [| for x in List.rev args -> x |]) |> ignore + #if BUILDING_WITH_LKG || NO_NULLCHECKING_LIB_SUPPORT + box(b.ToString()) + #else box(b.ToString()) |> Unchecked.nonNull + #endif // REVIEW: For these purposes, this should be a nop, but I'm leaving it // in incase we ever decide to support labels for the error format string // E.g., ""%s%d"" @@ -655,4 +667,4 @@ open Printf _generatedResx <- generatedResx generatedResult && not this.Log.HasLoggedErrors with TaskFailed -> - false + false \ No newline at end of file From 86729d8733446d6caa0b1b76eaaaac684e694d1c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 11 Sep 2024 15:50:43 +0000 Subject: [PATCH 2/2] Automated command ran: fantomas Co-authored-by: vzarytovskii <1260985+vzarytovskii@users.noreply.github.com> --- src/FSharp.Build/FSharpEmbedResourceText.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FSharp.Build/FSharpEmbedResourceText.fs b/src/FSharp.Build/FSharpEmbedResourceText.fs index b2be753acaf..ac0adf8329d 100644 --- a/src/FSharp.Build/FSharpEmbedResourceText.fs +++ b/src/FSharp.Build/FSharpEmbedResourceText.fs @@ -667,4 +667,4 @@ open Printf _generatedResx <- generatedResx generatedResult && not this.Log.HasLoggedErrors with TaskFailed -> - false \ No newline at end of file + false