Skip to content

Commit 3c8a90e

Browse files
Copilotdsymegithub-actions[bot]Copilotsergey-tihon
authored
Merge master and fix CI: add RuntimeHelpers unit tests (#305)
* Fix Option types in form data not being unwrapped (issue #214) (#298) RuntimeHelpers.getPropertyValues now strips the FSharpOption<T> wrapper before returning property values. Previously, a property set to Some(true) was serialised as the string "Some(true)" in multipart/form-data and application/x-www-form-urlencoded bodies instead of the bare "True". None values were already handled (null). Also relax global.json SDK version constraint from 10.0.103 to 10.0.100 with rollForward:latestPatch so the project builds with any 10.0.1xx SDK available locally or in CI. Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Initial plan * Fix Build and Test workflow to run on all pull requests, not just PRs targeting master Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com> --------- Co-authored-by: Don Syme <dsyme@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: sergey-tihon <1197905+sergey-tihon@users.noreply.github.com>
1 parent b0387e7 commit 3c8a90e

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

.github/workflows/dotnetcore.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ on:
55
branches:
66
- master
77
pull_request:
8-
branches:
9-
- master
108

119
jobs:
1210
build:

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "10.0.103",
4-
"rollForward": "minor"
3+
"version": "10.0.100",
4+
"rollForward": "latestPatch"
55
}
66
}

src/SwaggerProvider.Runtime/RuntimeHelpers.fs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,22 @@ module RuntimeHelpers =
145145
content
146146
| _ -> failwith $"Unexpected parameter type {boxedStream.GetType().Name} instead of IO.Stream"
147147

148+
// Unwraps F# option values: returns the inner value for Some, null for None.
149+
// This prevents `Some(value)` from being sent as-is in form data.
150+
let private unwrapFSharpOption(value: obj) : obj =
151+
if isNull value then
152+
null
153+
else
154+
let ty = value.GetType()
155+
156+
if
157+
ty.IsGenericType
158+
&& ty.GetGenericTypeDefinition() = typedefof<option<_>>
159+
then
160+
ty.GetProperty("Value").GetValue(value)
161+
else
162+
value
163+
148164
let getPropertyValues(object: obj) =
149165
if isNull object then
150166
Seq.empty
@@ -162,6 +178,7 @@ module RuntimeHelpers =
162178
| _ -> prop.Name
163179

164180
prop.GetValue(object)
181+
|> unwrapFSharpOption
165182
|> Option.ofObj
166183
|> Option.map(fun value -> (name, value)))
167184

0 commit comments

Comments
 (0)