fix: Enhance JSON serialization with logging#45
Merged
IvanMurzak merged 2 commits intomainfrom Jan 5, 2026
Merged
Conversation
Contributor
Contributor
There was a problem hiding this comment.
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
ILoggerparameters 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.
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 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
ILoggerparameters to serialization extension methods, updating method calls to utilize these logging enhancements, and refining serialization options for better compatibility.Logging and Serialization Enhancements
ILoggerparameters toExtensionsJsonmethods (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]ToJsonand related serialization methods throughout the codebase to pass the newloggerargument, 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
Utils.JsonSerializerto 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
Microsoft.Extensions.Loggingas a dependency in files where logging is now utilized. (ReflectorNet/src/Extension/ExtensionsJson.cs, [1];ReflectorNet/src/Reflector/Reflector.Error.cs, [2]