Enhance serialization handling for non-serialized fields#42
Conversation
…s and updating non-serialized property checks
Test Results 3 files 3 suites 6m 41s ⏱️ Results for commit a3f54af. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
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
NonSerializedAttributefiltering toGetSerializableFields()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.
…eving deepest inner exceptions
…pestInnerException method
…emove ExtensionsException class
…le fields in serialization
- 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.
…PointJsonConverter
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
- 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
There was a problem hiding this comment.
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.
Improve serialization by excluding fields marked with NonSerialized attributes, handling inaccessible fields gracefully, and adding tests to ensure robustness in serialization of interface fields.