Added support for custom serialization formats for date/time. DateTim…#38
Merged
Conversation
…eOffset, TimeSpan. Generated code now respects [SerializationFormat] for JSON, XML, and type converters. Updated tests and runtime helpers to cover all supported types. Updated package versions and improved string escaping in generated code.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds/extends generator + runtime support so domain primitives based on date/time types (DateOnly, DateTime, DateTimeOffset, TimeOnly, TimeSpan) can honor [SerializationFormat] consistently across JSON, XML, and type converters, with updated tests/snapshots and some dependency/version housekeeping.
Changes:
- Added new unit tests and generator snapshot tests covering
[SerializationFormat]for supported date/time primitives. - Updated generator to escape format strings correctly in generated code and to use format-aware XML reader helpers.
- Added runtime XML reader helpers for parsing date/time primitives with an explicit serialization format; bumped package/app versions and formatting.
Reviewed changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/AltaSoft.DomainPrimitives.UnitTests/SerializationFormatTests/SerializationFormatTests.cs | New end-to-end tests for JSON/XML/type-converter behavior with custom formats. |
| tests/AltaSoft.DomainPrimitives.UnitTests/SerializationFormatTests/CustomTimeSpan.cs | Test primitive using [SerializationFormat] for TimeSpan. |
| tests/AltaSoft.DomainPrimitives.UnitTests/SerializationFormatTests/CustomTimeOnly.cs | Test primitive using [SerializationFormat] for TimeOnly. |
| tests/AltaSoft.DomainPrimitives.UnitTests/SerializationFormatTests/CustomDateTimeOffset.cs | Test primitive using [SerializationFormat] for DateTimeOffset. |
| tests/AltaSoft.DomainPrimitives.UnitTests/SerializationFormatTests/CustomDateTime.cs | Test primitive using [SerializationFormat] for DateTime. |
| tests/AltaSoft.DomainPrimitives.UnitTests/SerializationFormatTests/CustomDateOnly.cs | Test primitive using [SerializationFormat] for DateOnly. |
| tests/AltaSoft.DomainPrimitives.UnitTests/AltaSoft.DomainPrimitives.UnitTests.csproj | Enables generator features for unit test project. |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomTimeSpan_GeneratesAllInterfacesAndConvertersWithSerializationFormat#OpenApiHelper.g.verified.cs | Snapshot for OpenAPI helper generation (TimeSpan). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomTimeSpan_GeneratesAllInterfacesAndConvertersWithSerializationFormat#CustomTimeSpanTypeConverter.g.verified.cs | Snapshot for TypeConverter generation (TimeSpan). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomTimeSpan_GeneratesAllInterfacesAndConvertersWithSerializationFormat#CustomTimeSpanJsonConverter.g.verified.cs | Snapshot for JSON converter generation (TimeSpan). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomTimeSpan_GeneratesAllInterfacesAndConvertersWithSerializationFormat#CustomTimeSpan.g.verified.cs | Snapshot for generated domain primitive (TimeSpan). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomTimeOnly_GeneratesAllInterfacesAndConvertersWithSerializationFormat#OpenApiHelper.g.verified.cs | Snapshot for OpenAPI helper generation (TimeOnly). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomTimeOnly_GeneratesAllInterfacesAndConvertersWithSerializationFormat#CustomTimeOnlyTypeConverter.g.verified.cs | Snapshot for TypeConverter generation (TimeOnly). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomTimeOnly_GeneratesAllInterfacesAndConvertersWithSerializationFormat#CustomTimeOnlyJsonConverter.g.verified.cs | Snapshot for JSON converter generation (TimeOnly). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomTimeOnly_GeneratesAllInterfacesAndConvertersWithSerializationFormat#CustomTimeOnly.g.verified.cs | Snapshot for generated domain primitive (TimeOnly). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomDateTime_GeneratesAllInterfacesAndConvertersWithSerializationFormat#OpenApiHelper.g.verified.cs | Snapshot for OpenAPI helper generation (DateTime). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomDateTime_GeneratesAllInterfacesAndConvertersWithSerializationFormat#CustomDateTimeTypeConverter.g.verified.cs | Snapshot for TypeConverter generation (DateTime). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomDateTime_GeneratesAllInterfacesAndConvertersWithSerializationFormat#CustomDateTimeJsonConverter.g.verified.cs | Snapshot for JSON converter generation (DateTime). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomDateTime_GeneratesAllInterfacesAndConvertersWithSerializationFormat#CustomDateTime.g.verified.cs | Snapshot for generated domain primitive (DateTime). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomDateTimeOffset_GeneratesAllInterfacesAndConvertersWithSerializationFormat#OpenApiHelper.g.verified.cs | Snapshot for OpenAPI helper generation (DateTimeOffset). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomDateTimeOffset_GeneratesAllInterfacesAndConvertersWithSerializationFormat#CustomDateTimeOffsetTypeConverter.g.verified.cs | Snapshot for TypeConverter generation (DateTimeOffset). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomDateTimeOffset_GeneratesAllInterfacesAndConvertersWithSerializationFormat#CustomDateTimeOffsetJsonConverter.g.verified.cs | Snapshot for JSON converter generation (DateTimeOffset). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomDateTimeOffset_GeneratesAllInterfacesAndConvertersWithSerializationFormat#CustomDateTimeOffset.g.verified.cs | Snapshot for generated domain primitive (DateTimeOffset). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomDateOnly_GeneratesAllInterfacesAndConvertersWithSerializationFormat#OpenApiHelper.g.verified.cs | Snapshot for OpenAPI helper generation (DateOnly). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomDateOnly_GeneratesAllInterfacesAndConvertersWithSerializationFormat#CustomDateOnlyTypeConverter.g.verified.cs | Snapshot for TypeConverter generation (DateOnly). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomDateOnly_GeneratesAllInterfacesAndConvertersWithSerializationFormat#CustomDateOnlyJsonConverter.g.verified.cs | Snapshot for JSON converter generation (DateOnly). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/Snapshots/DomainPrimitiveGeneratorTest.CustomDateOnly_GeneratesAllInterfacesAndConvertersWithSerializationFormat#CustomDateOnly.g.verified.cs | Snapshot for generated domain primitive (DateOnly). |
| tests/AltaSoft.DomainPrimitives.Generator.Tests/DomainPrimitiveGeneratorTest.cs | Adds new snapshot-based generator tests for serialization formats. |
| src/AltaSoft.DomainPrimitives/XmlReaderExt.cs | Adds XML parsing helpers that accept an explicit serialization format. |
| src/AltaSoft.DomainPrimitives.Generator/Helpers/MethodGeneratorHelper.cs | Generator updates for format escaping and XML serialization codegen paths. |
| src/AltaSoft.DomainPrimitives.Generator/Executor.cs | Adds conditional System.Globalization using when serialization format is present. |
| Examples/AltaSoft.DomainPrimitives.Demo/Program.cs | Swagger configuration formatting change. |
| Examples/AltaSoft.DomainPrimitives.Demo/AltaSoft.DomainPrimitives.Demo.csproj | Package version bumps for OpenAPI packages. |
| Directory.Packages.props | Switches several packages to floating versions + enables floating versions. |
| Directory.Build.props | Package/version bump from 7.0.2 to 7.1.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Co-authored-by: temonk <47372530+temonk@users.noreply.github.com>
Fix culture-dependent parsing and incorrect XML doc tags in XmlReaderExt
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.
…eOffset, TimeSpan.
Generated code now respects [SerializationFormat] for JSON, XML, and type converters.
Updated tests and runtime helpers to cover all supported types.
Updated package versions and improved string escaping in generated code.