Skip to content

Add support for System.DateOnly and System.TimeOnly types#440

Closed
WanjohiSammy wants to merge 4 commits intoOData:masterfrom
WanjohiSammy:fix/add-support-for-dateonly-and-timeonly
Closed

Add support for System.DateOnly and System.TimeOnly types#440
WanjohiSammy wants to merge 4 commits intoOData:masterfrom
WanjohiSammy:fix/add-support-for-dateonly-and-timeonly

Conversation

@WanjohiSammy
Copy link
Member

@WanjohiSammy WanjohiSammy commented Dec 5, 2025

Related Issues

Fixes #439

Description

This PR adds support for System.DateOnly and System.TimeOnly types in OData Connected Service code generation, replacing the legacy Microsoft.OData.Edm.Date and Microsoft.OData.Edm.TimeOfDay types.

Changes Made

Core Template Changes

  • Renamed internal property DateTypeName -> DateOnlyTypeName
  • Renamed internal property TimeOfDayTypeName -> TimeOnlyTypeName
  • Updated type mapping for EdmPrimitiveTypeKind.Date to generate System.DateOnly
  • Updated type mapping for EdmPrimitiveTypeKind.TimeOfDay to generate System.TimeOnly
  • Applied changes to both C# and VB.NET templates

Test Infrastructure

  • Added .NET Framework 4.7.2 compatibility layer in test helpers
    • Tests target .NET Framework 4.7.2 because Visual Studio extensions don't support .NET 10 yet
    • Added type replacement logic to convert System.DateOnly/TimeOnly back to EDM types during test compilation

Breaking Changes

BREAKING CHANGE: Generated code now uses System.DateOnly and System.TimeOnly instead of Microsoft.OData.Edm.Date and Microsoft.OData.Edm.TimeOfDay.

Impact:

  • Projects targeting .NET 6 or later: Will work seamlessly with modern types
  • Projects targeting .NET Framework or older .NET versions: Will need to use OData EDM library types or upgrade to .NET 6+

Migration Guide:

  • If your project targets .NET 6+, no changes needed - the new types are part of the BCL
  • If your project targets .NET Framework or .NET Standard 2.0, you may need to:
    • Continue using the previous version of OData Connected Service, OR
    • Upgrade to .NET 6+ (recommended)

@WanjohiSammy
Copy link
Member Author

Close as duplicate of #442

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Microsoft.OData.Edm.Date is obsolete

1 participant