Skip to content

refactor: simplify null handling in serialization methods across converters#62

Merged
IvanMurzak merged 1 commit into
mainfrom
feature/extensible-field-property-serialization
Jan 20, 2026
Merged

refactor: simplify null handling in serialization methods across converters#62
IvanMurzak merged 1 commit into
mainfrom
feature/extensible-field-property-serialization

Conversation

@IvanMurzak

@IvanMurzak IvanMurzak commented Jan 20, 2026

Copy link
Copy Markdown
Owner

This pull request refactors and improves the serialization logic in the reflection-based converters. The main changes include introducing dedicated methods for field and property serialization, standardizing logging indentation, and updating how null values are handled. These updates enhance code clarity, maintainability, and consistency in serialization depth handling.

Refactoring serialization logic:

  • Added SerializeField and SerializeProperty helper methods to BaseReflectionConverter.Serialize.cs for handling field and property serialization, replacing inline calls to reflector.Serialize in the main serialization loop.
  • Updated calls in field and property serialization to use these new helper methods, and standardized the depth parameter to avoid incrementing it unnecessarily. [1] [2]

Logging improvements:

  • Standardized logging indentation by passing depth instead of depth + 1 to StringUtils.GetPadding in trace and warning log statements for both fields and properties. [1] [2] [3] [4]

Null value handling:

  • Changed null serialization to use SerializedMember.Null instead of SerializedMember.FromJson(..., json: null, ...) in both GenericReflectionConverter and PrimitiveReflectionConverter. [1] [2]

Depth handling in generic converter:

  • Updated the depth parameter when serializing fields and properties in GenericReflectionConverter to increment depth by 1, ensuring proper nesting in serialization.

@IvanMurzak IvanMurzak self-assigned this Jan 20, 2026
@IvanMurzak IvanMurzak added the enhancement New feature or request label Jan 20, 2026
@IvanMurzak IvanMurzak requested a review from Copilot January 20, 2026 05:35
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

    2 files  ±0      2 suites  ±0   8m 35s ⏱️ +28s
1 172 tests ±0  1 172 ✅ ±0  0 💤 ±0  0 ❌ ±0 
2 344 runs  ±0  2 344 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit a944f10. ± Comparison against base commit 372c836.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors serialization logic in reflection-based converters by introducing dedicated helper methods for field and property serialization, standardizing logging indentation, and simplifying null value handling.

Changes:

  • Introduced SerializeField and SerializeProperty helper methods to encapsulate field/property serialization logic
  • Replaced SerializedMember.FromJson(..., json: null, ...) with the cleaner SerializedMember.Null() method
  • Moved depth increment logic from inside serialization methods to the call site in GenericReflectionConverter

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
PrimitiveReflectionConverter.cs Updated null handling to use SerializedMember.Null() for cleaner null serialization
GenericReflectionConverter.cs Updated null handling and moved depth increment to call site when invoking SerializeFields and SerializeProperties
BaseReflectionConverter.Serialize.cs Added helper methods SerializeField and SerializeProperty, updated logging to use correct depth, and refactored field/property serialization to use the new helpers

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@IvanMurzak IvanMurzak merged commit 1129df8 into main Jan 20, 2026
8 checks passed
@IvanMurzak IvanMurzak deleted the feature/extensible-field-property-serialization branch January 20, 2026 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants