Skip to content

Commit 4587b41

Browse files
refactor(http-client-csharp): simplify required nullable null fallback; drop changelog
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
1 parent d551834 commit 4587b41

2 files changed

Lines changed: 3 additions & 22 deletions

File tree

.chronus/changes/fix-required-nullable-patch-duplicate-2026-6-29-14-9-14.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2558,22 +2558,10 @@ private MethodBodyStatement CreateConditionalSerializationStatement(
25582558
_utf8JsonWriterSnippet.WriteNull(serializedName));
25592559
}
25602560

2561-
// When the property path is already present in the patch, the patched value is
2562-
// emitted by Patch.WriteTo(writer), so the null fallback must be gated on the patch
2563-
// check to avoid writing the property twice. Emit it as an "else if" so the fallback
2564-
// is skipped entirely when the path is patched.
2565-
if (patchCheck != null)
2566-
{
2567-
return new IfElseStatement(
2568-
new IfStatement(condition) { writePropertySerializationStatement },
2569-
[new IfStatement(patchCheck) { _utf8JsonWriterSnippet.WriteNull(serializedName) }],
2570-
null);
2571-
}
2572-
25732561
return new IfElseStatement(
2574-
condition,
2575-
writePropertySerializationStatement,
2576-
_utf8JsonWriterSnippet.WriteNull(serializedName));
2562+
new IfStatement(condition) { writePropertySerializationStatement },
2563+
patchCheck != null ? [new IfStatement(patchCheck) { _utf8JsonWriterSnippet.WriteNull(serializedName) }] : null,
2564+
patchCheck != null ? null : _utf8JsonWriterSnippet.WriteNull(serializedName));
25772565
}
25782566

25792567
if (shouldCheckJsonPath)

0 commit comments

Comments
 (0)