Skip to content

fix: Enhance JSON serialization with logging#45

Merged
IvanMurzak merged 2 commits into
mainfrom
update/json-serialization-logging
Jan 5, 2026
Merged

fix: Enhance JSON serialization with logging#45
IvanMurzak merged 2 commits into
mainfrom
update/json-serialization-logging

Conversation

@IvanMurzak
Copy link
Copy Markdown
Owner

This pull request introduces improvements to JSON serialization and logging capabilities across the codebase, focusing on enhancing traceability and flexibility when converting objects to JSON. The main changes include adding optional ILogger parameters to serialization extension methods, updating method calls to utilize these logging enhancements, and refining serialization options for better compatibility.

Logging and Serialization Enhancements

  • Added optional ILogger parameters to ExtensionsJson methods (ToJsonElement, ToJson, and related overloads) to enable trace-level logging during object serialization. Now, serialization actions log the type being serialized if a logger is provided. (ReflectorNet/src/Extension/ExtensionsJson.cs, [1] [2]
  • Updated usages of ToJson and related serialization methods throughout the codebase to pass the new logger argument, ensuring consistent logging during method execution and error handling. (ReflectorNet/src/Converter/Reflection/GenericReflectionConverter.cs, [1] [2]; ReflectorNet/src/Reflector/Reflector.CallMethod.cs, [3]; ReflectorNet/src/Reflector/Reflector.Error.cs, [4]

Serialization Options and Compatibility

  • Modified the default serialization options in Utils.JsonSerializer to allow named floating-point literals (e.g., "NaN", "Infinity") for improved compatibility with certain data types. (ReflectorNet/src/Utils/Json/JsonSerializer.cs, ReflectorNet/src/Utils/Json/JsonSerializer.csR81)

Dependency Updates

  • Added Microsoft.Extensions.Logging as a dependency in files where logging is now utilized. (ReflectorNet/src/Extension/ExtensionsJson.cs, [1]; ReflectorNet/src/Reflector/Reflector.Error.cs, [2]

@IvanMurzak IvanMurzak requested a review from Copilot January 5, 2026 06:10
@IvanMurzak IvanMurzak self-assigned this Jan 5, 2026
@IvanMurzak IvanMurzak added the enhancement New feature or request label Jan 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 5, 2026

Test Results

    3 files  ±0      3 suites  ±0   6m 47s ⏱️ + 2m 14s
  975 tests ±0    975 ✅ ±0  0 💤 ±0  0 ❌ ±0 
2 887 runs  ±0  2 887 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 46f4df4. ± Comparison against base commit b52932c.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 enhances JSON serialization capabilities by adding optional logging support throughout the serialization pipeline. The changes enable trace-level logging during object-to-JSON conversion operations and improve floating-point number handling for better data type compatibility.

  • Added optional ILogger parameters to JSON serialization extension methods for improved observability
  • Updated serialization method calls to pass logger instances for consistent tracing
  • Configured JSON serializer to handle named floating-point literals (NaN, Infinity)

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
ReflectorNet/src/Extension/ExtensionsJson.cs Added ILogger parameters to ToJsonElement and ToJson methods with trace-level logging, removed redundant ToJsonOrEmptyJsonObject method
ReflectorNet/src/Utils/Json/JsonSerializer.cs Configured NumberHandling to allow named floating-point literals for improved compatibility
ReflectorNet/src/Reflector/Reflector.Error.cs Added ILogger parameter to MoreThanOneMethodFound method and updated ToJson call to pass logger
ReflectorNet/src/Reflector/Reflector.CallMethod.cs Updated ToJson call on success path to include logger parameter for tracing
ReflectorNet/src/Converter/Reflection/GenericReflectionConverter.cs Refactored recursive serialization logic with clearer if/else structure and added logger parameter to ToJson call

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

@IvanMurzak IvanMurzak merged commit ea4b2e6 into main Jan 5, 2026
8 checks passed
@IvanMurzak IvanMurzak deleted the update/json-serialization-logging branch January 5, 2026 06:25
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