[repo-assist] perf: add float32/double/Guid fast-paths in toParam; replace String.Format with interpolation#443
Merged
sergey-tihon merged 2 commits intoMay 19, 2026
Conversation
…ormat 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>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes small runtime/design-time formatting optimizations in SwaggerProvider by adding direct scalar serialization paths and replacing remaining String.Format usages with interpolation.
Changes:
- Adds
float32,double, andGuidfast paths inRuntimeHelpers.toParam. - Replaces
String.Formatin header error construction and cookie header generation with interpolated strings.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/SwaggerProvider.Runtime/RuntimeHelpers.fs |
Adds scalar toParam fast paths and updates header error formatting. |
src/SwaggerProvider.DesignTime/OperationCompiler.fs |
Updates generated cookie header formatting to use interpolation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Two focused improvements to the runtime layer:
1. Fast-paths for
float32,double, andGuidintoParamtoParamalready has fast-path match arms forstring,int32,int64, andboolthat avoid the expensive generic branch (aGetType()call plus up to four subsequent type checks:FullName× 2,IsGenericType,IsEnum). This PR adds the same treatment for three more common OpenAPI scalar types:float32number(default)doublenumber/doubleGuidstring/uuidAll three produce the same output as the generic
obj.ToString()fallback — the change is purely in the code path taken, not the result.2. Replace two remaining
String.Formatcalls with string interpolationFor consistency with the rest of the codebase (all other format sites already use
$"{...}"):RuntimeHelpers.fillHeaderserror message:String.Format("Cannot add header '{0}'='{1}' ...", name, value)→$"Cannot add header '{name}'='{value}' ..."OperationCompilercookie header builder (inside quotation):String.Format("{0}={1}", name, value)→$"{name}={value}"Test Status
All 425 unit tests pass. The existing tests for
float32,double, andGuid(added in #442) now exercise the new fast-paths.