Skip to content

Enhance serialization handling for non-serialized fields#42

Merged
IvanMurzak merged 23 commits into
mainfrom
fix/serialization
Dec 26, 2025
Merged

Enhance serialization handling for non-serialized fields#42
IvanMurzak merged 23 commits into
mainfrom
fix/serialization

Conversation

@IvanMurzak
Copy link
Copy Markdown
Owner

Improve serialization by excluding fields marked with NonSerialized attributes, handling inaccessible fields gracefully, and adding tests to ensure robustness in serialization of interface fields.

@IvanMurzak IvanMurzak self-assigned this Dec 24, 2025
@IvanMurzak IvanMurzak requested a review from Copilot December 24, 2025 11:36
@IvanMurzak IvanMurzak added the bug Something isn't working label Dec 24, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 24, 2025

Test Results

    3 files      3 suites   6m 41s ⏱️
  920 tests   920 ✅ 0 💤 0 ❌
2 722 runs  2 722 ✅ 0 💤 0 ❌

Results for commit a3f54af.

♻️ This comment has been updated with latest results.

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 PR enhances the serialization system to properly handle NonSerialized attributes and improve error handling when serializing inaccessible members. The implementation adds filtering for fields marked with [NonSerialized], wraps field/property serialization in try-catch blocks with logging, and includes comprehensive tests for interface field serialization scenarios.

  • Adds NonSerializedAttribute filtering to GetSerializableFields() to exclude fields marked with [NonSerialized]
  • Improves exception handling by wrapping field and property serialization in try-catch blocks with structured logging
  • Adds comprehensive test coverage for interface fields/properties with and without NonSerializedAttribute

Reviewed changes

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

File Description
ReflectorNet/src/Converter/Reflection/Base/BaseReflectionConverter.cs Adds filtering for NonSerializedAttribute on fields; refactors methods from expression-bodied to block-bodied form
ReflectorNet/src/Converter/Reflection/Base/BaseReflectionConverter.Serialize.cs Enhances exception handling for field and property serialization with try-catch blocks and structured logging to gracefully skip inaccessible members
ReflectorNet.Tests/src/ReflectorTests/NonSerializedInterfaceTests.cs Adds comprehensive test suite covering serialization of interface fields/properties with [NonSerialized] attributes and without, including null and non-null scenarios and inheritance cases

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

Comment thread ReflectorNet.Tests/src/ReflectorTests/NonSerializedInterfaceTests.cs Outdated
Comment thread ReflectorNet.Tests/src/ReflectorTests/NonSerializedInterfaceTests.cs Outdated
Comment thread ReflectorNet/src/Converter/Reflection/Base/BaseReflectionConverter.Serialize.cs Outdated
Comment thread ReflectorNet/src/Converter/Reflection/Base/BaseReflectionConverter.Serialize.cs Outdated
- Implemented BigIntegerJsonConverter for handling System.Numerics.BigInteger.
- Added CharJsonConverter for char types, supporting nullable and single-character strings.
- Created ComplexJsonConverter for System.Numerics.Complex type serialization.
- Introduced ConstructorInfoConverter for System.Reflection.ConstructorInfo.
- Added DateOnlyJsonConverter for System.DateOnly type.
- Implemented ExceptionJsonConverter for System.Exception serialization.
- Created FieldInfoConverter for System.Reflection.FieldInfo.
- Added HalfJsonConverter for System.Half type.
- Implemented IPAddressJsonConverter for System.Net.IPAddress.
- Created IPEndPointJsonConverter for System.Net.IPEndPoint.
- Added IntPtrJsonConverter for System.IntPtr.
- Implemented JsonNodeConverter for JsonNode instances.
- Created JsonValueJsonConverter for JsonValue instances.
- Added ParameterInfoConverter for System.Reflection.ParameterInfo.
- Implemented PropertyInfoConverter for System.Reflection.PropertyInfo.
- Added TimeOnlyJsonConverter for System.TimeOnly type.
- Implemented UIntPtrJsonConverter for System.UIntPtr.
- Created UriJsonConverter for System.Uri.
- Added VersionJsonConverter for System.Version.
- Updated JsonSerializer to include new converters.
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

Copilot reviewed 26 out of 26 changed files in this pull request and generated 19 comments.


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

Comment thread ReflectorNet/src/Converter/Json/ConstructorInfoConverter.cs Outdated
Comment thread ReflectorNet/src/Converter/Json/TimeOnlyJsonConverter.cs Outdated
Comment thread ReflectorNet/src/Converter/Json/ExceptionJsonConverter.cs Outdated
Comment thread ReflectorNet/src/Converter/Json/FieldInfoConverter.cs Outdated
Comment thread ReflectorNet/src/Converter/Json/UIntPtrJsonConverter.cs
Comment thread ReflectorNet/src/Converter/Json/PropertyInfoConverter.cs Outdated
Comment thread ReflectorNet/src/Converter/Json/AssemblyJsonConverter.cs
Comment thread ReflectorNet/src/Converter/Json/HalfJsonConverter.cs
Comment thread ReflectorNet/src/Converter/Json/FieldInfoConverter.cs Outdated
Comment thread ReflectorNet/src/Converter/Json/ConstructorInfoConverter.cs
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

Copilot reviewed 26 out of 26 changed files in this pull request and generated 13 comments.


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

Comment thread ReflectorNet/src/Converter/Json/PropertyInfoConverter.cs Outdated
Comment thread ReflectorNet/src/Converter/Json/FieldInfoConverter.cs Outdated
Comment thread ReflectorNet/src/Converter/Json/ParameterInfoConverter.cs Outdated
Comment thread ReflectorNet/src/Converter/Json/ConstructorInfoConverter.cs Outdated
Comment thread ReflectorNet/src/Converter/Json/ExceptionJsonConverter.cs Outdated
Comment thread ReflectorNet/src/Converter/Json/AssemblyJsonConverter.cs Outdated
Comment thread ReflectorNet/src/Converter/Json/IPAddressJsonConverter.cs Outdated
Comment thread ReflectorNet/src/Converter/Json/IPEndPointJsonConverter.cs Outdated
Comment thread ReflectorNet/src/Converter/Json/TimeOnlyJsonConverter.cs
Comment thread ReflectorNet/src/Converter/Json/BigIntegerJsonConverter.cs
- Implement tests for JsonNode serialization and deserialization, covering objects, arrays, and null values.
- Introduce tests for network types, including IPAddress and IPEndPoint serialization and deserialization.
- Add tests for primitive types such as IntPtr, UIntPtr, Char, BigInteger, Complex, and Half.
- Create reflection type tests for Assembly, PropertyInfo, ConstructorInfo, and ParameterInfo converters, ensuring proper handling of serialization and deserialization.
…g Enum, Exception, FieldInfo, MethodInfo, Type, UInt16, UInt32, UInt64, DateTime, and Guid
- Removed AdditionalConverterTests.cs and integrated its tests into existing test files.
- Added EnumConverterTests.cs to handle enum serialization and deserialization.
- Added ExceptionConverterTests.cs to cover exception serialization and deserialization.
- Enhanced PrimitiveConverterTests.cs with tests for UInt16, UInt32, and UInt64 serialization and deserialization.
- Updated ReflectionConverterTests.cs to include tests for FieldInfo and MethodInfo serialization and deserialization.
- Added DateTime serialization and deserialization tests to DateTimeConverterTests.cs.
- Added Guid serialization and deserialization tests to CommonTypesConverterTests.cs.
…r, BigInteger, DateTimeOffset, Numeric types, TimeSpan, and UIntPtr
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

Copilot reviewed 51 out of 51 changed files in this pull request and generated 4 comments.


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

Comment thread ReflectorNet/src/Converter/Json/CharJsonConverter.cs
Comment thread ReflectorNet/src/Converter/Json/HalfJsonConverter.cs Outdated
@IvanMurzak IvanMurzak merged commit 811610e into main Dec 26, 2025
2 checks passed
@IvanMurzak IvanMurzak deleted the fix/serialization branch December 26, 2025 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants