From 9676c5693d8bf7b946afd7cffded7a204afbec81 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 18 May 2026 20:10:26 +0000 Subject: [PATCH 1/2] perf: add float32/double/Guid fast-paths in toParam; replace String.Format with interpolation Add three new fast-path match arms to toParam before the expensive generic branch (which calls GetType() plus up to four type checks): - float32 / double: skip GetType() + IsGenericType + IsEnum checks for the two floating-point scalar types that are common in number- heavy OpenAPI schemas. - Guid: skip GetType() + FullName comparisons for the uuid format, which is one of the most frequent identifier types in OpenAPI APIs. All three fast-paths produce the same output as the generic fallback (obj.ToString()) since none of them need special formatting. Also replace the two remaining String.Format calls with string interpolation for consistency with the rest of the codebase: - RuntimeHelpers.fillHeaders error message - OperationCompiler cookie header builder inside quotation All 425 existing unit tests continue to pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/SwaggerProvider.DesignTime/OperationCompiler.fs | 2 +- src/SwaggerProvider.Runtime/RuntimeHelpers.fs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/SwaggerProvider.DesignTime/OperationCompiler.fs b/src/SwaggerProvider.DesignTime/OperationCompiler.fs index d96258a4..b3ee49aa 100644 --- a/src/SwaggerProvider.DesignTime/OperationCompiler.fs +++ b/src/SwaggerProvider.DesignTime/OperationCompiler.fs @@ -362,7 +362,7 @@ type OperationCompiler(schema: OpenApiDocument, defCompiler: DefinitionCompiler, let cookieHeader = %cookies |> Seq.filter(snd >> isNull >> not) - |> Seq.map(fun (name, value) -> String.Format("{0}={1}", name, value)) + |> Seq.map(fun (name, value) -> $"{name}={value}") |> String.concat ";" ("Cookie", cookieHeader) :: (%headers) diff --git a/src/SwaggerProvider.Runtime/RuntimeHelpers.fs b/src/SwaggerProvider.Runtime/RuntimeHelpers.fs index 48b48c06..459367c5 100644 --- a/src/SwaggerProvider.Runtime/RuntimeHelpers.fs +++ b/src/SwaggerProvider.Runtime/RuntimeHelpers.fs @@ -212,12 +212,15 @@ module RuntimeHelpers = | :? DateTimeOffset as dto -> dto.ToString("O") | null -> null // Fast paths for the most common scalar param types: - // these avoid calling GetType() and the four subsequent type checks + // these avoid calling GetType() and the subsequent type checks // (FullName twice, IsGenericType, IsEnum) that follow in the generic branch. | :? string as s -> s | :? int32 as i -> i.ToString() | :? int64 as i -> i.ToString() | :? bool as b -> b.ToString() + | :? float32 as f -> f.ToString() + | :? double as d -> d.ToString() + | :? Guid as g -> g.ToString() | _ -> // Hoist GetType() once; previously tryFormatDateOnly and tryFormatTimeOnly // each called GetType() internally, resulting in up to 3 GetType() calls for @@ -575,8 +578,7 @@ module RuntimeHelpers = |> Seq.filter(snd >> isNull >> not) |> Seq.iter(fun (name, value) -> if not <| msg.Headers.TryAddWithoutValidation(name, value) then - let errMsg = - String.Format("Cannot add header '{0}'='{1}' to HttpRequestMessage", name, value) + let errMsg = $"Cannot add header '{name}'='{value}' to HttpRequestMessage" if (name <> "Content-Type") then raise <| Exception(errMsg)) From 1c6fb3832751c42244ae21fffb789964a1f33c8c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 18 May 2026 20:10:30 +0000 Subject: [PATCH 2/2] ci: trigger checks