From 8f58a032ad657818ff90b0d9b91cad0ce2c300c8 Mon Sep 17 00:00:00 2001 From: Samuel Wanjohi Date: Sat, 22 Nov 2025 20:16:06 +0300 Subject: [PATCH 1/8] Update to OData Lib 9.x preview, .NET 10 and bump version to 3.x preview 1 --- build/builder.versions.settings.targets | 6 +-- .../Commons/EdmLibHelpers.cs | 4 -- .../Commons/TypeHelper.cs | 13 +++++- .../ColumnAttributeEdmPropertyConvention.cs | 2 +- ...icrosoft.OData.ModelBuilder.Nightly.nuspec | 8 ++-- ...icrosoft.OData.ModelBuilder.Release.nuspec | 8 ++-- .../Microsoft.OData.ModelBuilder.csproj | 6 +-- .../Microsoft.OData.ModelBuilder.xml | 40 ++++++++++--------- ...rimitivePropertyConfigurationExtensions.cs | 27 ++++++++++++- .../SRResources.Designer.cs | 11 ++++- .../SRResources.resx | 3 ++ ...turalTypeConfigurationOfTStructuralType.cs | 26 ------------ .../CapabilitiesVocabularyExtensionMethods.cs | 8 ++-- .../VocabularyTermConfigurationExtensions.tt | 2 +- .../Commons/CsdlSerializer.cs | 2 +- .../Commons/ExceptionAssert.cs | 8 ++-- ...olumnAttributeEdmPropertyConventionTest.cs | 4 +- .../CsdlMetadataTest.cs | 2 +- .../Microsoft.OData.ModelBuilder.Tests.csproj | 10 ++--- .../ODataConventionModelBuilderTest.cs | 4 +- .../ODataModelBuilderTest.cs | 14 +++---- .../Operations/ActionConfigurationTest.cs | 10 ++--- .../Operations/FunctionConfigurationTest.cs | 10 ++--- .../CollectionPropertyConfigurationTest.cs | 16 ++++---- ...Microsoft.OData.ModelBuilder.PublicApi.bsl | 13 +++--- .../Types/ComplexTypeTest.cs | 16 ++++---- .../Types/EntityTypeTest.cs | 18 ++++----- .../Types/PrimitiveTypeTest.cs | 16 ++++---- .../Core/RevisionsConfigurationTests.cs | 10 ++--- 29 files changed, 170 insertions(+), 147 deletions(-) diff --git a/build/builder.versions.settings.targets b/build/builder.versions.settings.targets index 1b602df..0e22a0a 100644 --- a/build/builder.versions.settings.targets +++ b/build/builder.versions.settings.targets @@ -1,15 +1,15 @@ - 2 + 3 0 0 - + preview.1 - [8.0.0, 9.0.0) + [9.0.0-preview.3, 10.0.0) [4.6.0,) diff --git a/src/Microsoft.OData.ModelBuilder/Commons/EdmLibHelpers.cs b/src/Microsoft.OData.ModelBuilder/Commons/EdmLibHelpers.cs index 262ea8a..37b8521 100644 --- a/src/Microsoft.OData.ModelBuilder/Commons/EdmLibHelpers.cs +++ b/src/Microsoft.OData.ModelBuilder/Commons/EdmLibHelpers.cs @@ -70,10 +70,6 @@ internal static class EdmLibHelpers new KeyValuePair(typeof(DateTimeOffset?), GetPrimitiveType(EdmPrimitiveTypeKind.DateTimeOffset)), new KeyValuePair(typeof(TimeSpan), GetPrimitiveType(EdmPrimitiveTypeKind.Duration)), new KeyValuePair(typeof(TimeSpan?), GetPrimitiveType(EdmPrimitiveTypeKind.Duration)), - new KeyValuePair(typeof(Date), GetPrimitiveType(EdmPrimitiveTypeKind.Date)), - new KeyValuePair(typeof(Date?), GetPrimitiveType(EdmPrimitiveTypeKind.Date)), - new KeyValuePair(typeof(TimeOfDay), GetPrimitiveType(EdmPrimitiveTypeKind.TimeOfDay)), - new KeyValuePair(typeof(TimeOfDay?), GetPrimitiveType(EdmPrimitiveTypeKind.TimeOfDay)), new KeyValuePair(typeof(DateOnly), GetPrimitiveType(EdmPrimitiveTypeKind.Date)), new KeyValuePair(typeof(DateOnly?), GetPrimitiveType(EdmPrimitiveTypeKind.Date)), new KeyValuePair(typeof(TimeOnly), GetPrimitiveType(EdmPrimitiveTypeKind.TimeOfDay)), diff --git a/src/Microsoft.OData.ModelBuilder/Commons/TypeHelper.cs b/src/Microsoft.OData.ModelBuilder/Commons/TypeHelper.cs index 9bd4372..807fa38 100644 --- a/src/Microsoft.OData.ModelBuilder/Commons/TypeHelper.cs +++ b/src/Microsoft.OData.ModelBuilder/Commons/TypeHelper.cs @@ -214,7 +214,7 @@ public static bool IsDateTime(Type clrType) public static bool IsDateOnly(Type clrType) { Type underlyingTypeOrSelf = GetUnderlyingTypeOrSelf(clrType); - return underlyingTypeOrSelf.FullName == "System.DateOnly"; + return underlyingTypeOrSelf == typeof(DateOnly); } /// @@ -228,6 +228,17 @@ public static bool IsTimeSpan(Type clrType) return underlyingTypeOrSelf == typeof(TimeSpan); } + /// + /// Determine if a type is a TimeOnly. + /// + /// The type to test. + /// True if the type is a TimeOnly; false otherwise. + public static bool IsTimeOnly(Type clrType) + { + Type underlyingTypeOrSelf = GetUnderlyingTypeOrSelf(clrType); + return underlyingTypeOrSelf == typeof(TimeOnly); + } + /// /// Determine if a type is an enumeration. /// diff --git a/src/Microsoft.OData.ModelBuilder/Conventions/Attributes/ColumnAttributeEdmPropertyConvention.cs b/src/Microsoft.OData.ModelBuilder/Conventions/Attributes/ColumnAttributeEdmPropertyConvention.cs index 812133f..1705493 100644 --- a/src/Microsoft.OData.ModelBuilder/Conventions/Attributes/ColumnAttributeEdmPropertyConvention.cs +++ b/src/Microsoft.OData.ModelBuilder/Conventions/Attributes/ColumnAttributeEdmPropertyConvention.cs @@ -61,7 +61,7 @@ public override void Apply(PropertyConfiguration edmProperty, StructuralTypeConf } else if (String.Compare(typeName, "time", StringComparison.OrdinalIgnoreCase) == 0) { - primitiveProperty.AsTimeOfDay(); + primitiveProperty.AsTimeOnly(); } } } diff --git a/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.Nightly.nuspec b/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.Nightly.nuspec index 7ffda52..b2b6b55 100644 --- a/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.Nightly.nuspec +++ b/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.Nightly.nuspec @@ -15,7 +15,7 @@ images\odata.png - + @@ -23,9 +23,9 @@ - - - + + + \ No newline at end of file diff --git a/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.Release.nuspec b/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.Release.nuspec index 619bfaa..fc45c4c 100644 --- a/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.Release.nuspec +++ b/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.Release.nuspec @@ -16,7 +16,7 @@ images\odata.png - + @@ -24,9 +24,9 @@ - - - + + + \ No newline at end of file diff --git a/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.csproj b/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.csproj index 6b5f8e8..134d188 100644 --- a/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.csproj +++ b/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.csproj @@ -1,7 +1,7 @@  - net8.0 + net10.0 Microsoft.OData.ModelBuilder $(OutputPath)$(AssemblyName).xml README.md @@ -23,8 +23,8 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.xml b/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.xml index d7f17bb..81ec44c 100644 --- a/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.xml +++ b/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.xml @@ -686,6 +686,13 @@ The type to test. True if the type is a TimeSpan; false otherwise. + + + Determine if a type is a TimeOnly. + + The type to test. + True if the type is a TimeSpan; false otherwise. + Determine if a type is an enumeration. @@ -3639,7 +3646,7 @@ If this primitive property is , this method will make the target - Edm type kind as + Edm type kind as Reference to the calling primitive property configuration. Returns itself so that multiple calls can be chained. @@ -3647,7 +3654,15 @@ If this primitive property is , this method will make the target - Edm type kind as + Edm type kind as + + Reference to the calling primitive property configuration. + Returns itself so that multiple calls can be chained. + + + + If this primitive property is , this method will make the target + Edm type kind as Reference to the calling primitive property configuration. Returns itself so that multiple calls can be chained. @@ -4327,6 +4342,11 @@ Looks up a localized string similar to The type '{0}' must be a primitive type.. + + + Looks up a localized string similar to The property '{0}' on type '{1}' must be a System.TimeOnly property.. + + Looks up a localized string similar to The property '{0}' on type '{1}' must be a System.TimeSpan property.. @@ -5340,22 +5360,6 @@ For example, in C# t => t.MyProperty and in Visual Basic .NET Function(t) t.MyProperty. A configuration object that can be used to further configure the property. - - - Adds an time-of-day primitive property to the EDM type. - - A lambda expression representing the navigation property for the relationship. - For example, in C# t => t.MyProperty and in Visual Basic .NET Function(t) t.MyProperty. - A configuration object that can be used to further configure the property. - - - - Adds an time-of-day primitive property to the EDM type. - - A lambda expression representing the navigation property for the relationship. - For example, in C# t => t.MyProperty and in Visual Basic .NET Function(t) t.MyProperty. - A configuration object that can be used to further configure the property. - Adds a primitive property to the EDM type. diff --git a/src/Microsoft.OData.ModelBuilder/Property/PrimitivePropertyConfigurationExtensions.cs b/src/Microsoft.OData.ModelBuilder/Property/PrimitivePropertyConfigurationExtensions.cs index 4e85ade..bafd230 100644 --- a/src/Microsoft.OData.ModelBuilder/Property/PrimitivePropertyConfigurationExtensions.cs +++ b/src/Microsoft.OData.ModelBuilder/Property/PrimitivePropertyConfigurationExtensions.cs @@ -12,7 +12,7 @@ public static class PrimitivePropertyConfigurationExtensions { /// /// If this primitive property is , this method will make the target - /// Edm type kind as + /// Edm type kind as /// /// Reference to the calling primitive property configuration. /// Returns itself so that multiple calls can be chained. @@ -35,7 +35,7 @@ public static PrimitivePropertyConfiguration AsDate(this PrimitivePropertyConfig /// /// If this primitive property is , this method will make the target - /// Edm type kind as + /// Edm type kind as /// /// Reference to the calling primitive property configuration. /// Returns itself so that multiple calls can be chained. @@ -46,6 +46,29 @@ public static PrimitivePropertyConfiguration AsTimeOfDay(this PrimitivePropertyC throw Error.ArgumentNull("property"); } + if (!TypeHelper.IsTimeSpan(property.RelatedClrType) && !TypeHelper.IsTimeOnly(property.RelatedClrType)) + { + throw Error.Argument("property", SRResources.MustBeTimeSpanProperty, property.PropertyInfo.Name, + property.DeclaringType.FullName); + } + + property.TargetEdmTypeKind = EdmPrimitiveTypeKind.TimeOfDay; + return property; + } + + /// + /// If this primitive property is , this method will make the target + /// Edm type kind as + /// + /// Reference to the calling primitive property configuration. + /// Returns itself so that multiple calls can be chained. + public static PrimitivePropertyConfiguration AsTimeOnly(this PrimitivePropertyConfiguration property) + { + if (property == null) + { + throw Error.ArgumentNull("property"); + } + if (!TypeHelper.IsTimeSpan(property.RelatedClrType)) { throw Error.Argument("property", SRResources.MustBeTimeSpanProperty, property.PropertyInfo.Name, diff --git a/src/Microsoft.OData.ModelBuilder/SRResources.Designer.cs b/src/Microsoft.OData.ModelBuilder/SRResources.Designer.cs index 3188d67..c642c69 100644 --- a/src/Microsoft.OData.ModelBuilder/SRResources.Designer.cs +++ b/src/Microsoft.OData.ModelBuilder/SRResources.Designer.cs @@ -19,7 +19,7 @@ namespace Microsoft.OData.ModelBuilder { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class SRResources { @@ -492,6 +492,15 @@ internal static string MustBePrimitiveType { } } + /// + /// Looks up a localized string similar to The property '{0}' on type '{1}' must be a System.TimeOnly property.. + /// + internal static string MustBeTimeOnlyProperty { + get { + return ResourceManager.GetString("MustBeTimeOnlyProperty", resourceCulture); + } + } + /// /// Looks up a localized string similar to The property '{0}' on type '{1}' must be a System.TimeSpan property.. /// diff --git a/src/Microsoft.OData.ModelBuilder/SRResources.resx b/src/Microsoft.OData.ModelBuilder/SRResources.resx index 1328077..9c3cabd 100644 --- a/src/Microsoft.OData.ModelBuilder/SRResources.resx +++ b/src/Microsoft.OData.ModelBuilder/SRResources.resx @@ -270,6 +270,9 @@ The property '{0}' on type '{1}' must be a System.TimeSpan property. + + The property '{0}' on type '{1}' must be a System.TimeOnly property. + The multiplicity of the '{0}' property must be '{1}'. diff --git a/src/Microsoft.OData.ModelBuilder/Types/StructuralTypeConfigurationOfTStructuralType.cs b/src/Microsoft.OData.ModelBuilder/Types/StructuralTypeConfigurationOfTStructuralType.cs index 9f1af73..e0d9d49 100644 --- a/src/Microsoft.OData.ModelBuilder/Types/StructuralTypeConfigurationOfTStructuralType.cs +++ b/src/Microsoft.OData.ModelBuilder/Types/StructuralTypeConfigurationOfTStructuralType.cs @@ -142,32 +142,6 @@ public DecimalPropertyConfiguration Property(Expression - /// Adds an time-of-day primitive property to the EDM type. - /// - /// A lambda expression representing the navigation property for the relationship. - /// For example, in C# t => t.MyProperty and in Visual Basic .NET Function(t) t.MyProperty. - /// A configuration object that can be used to further configure the property. - [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "Nested generics appropriate here")] - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", Justification = "More specific expression type is clearer")] - public PrecisionPropertyConfiguration Property(Expression> propertyExpression) - { - return GetPrimitivePropertyConfiguration(propertyExpression, nullable: true) as PrecisionPropertyConfiguration; - } - - /// - /// Adds an time-of-day primitive property to the EDM type. - /// - /// A lambda expression representing the navigation property for the relationship. - /// For example, in C# t => t.MyProperty and in Visual Basic .NET Function(t) t.MyProperty. - /// A configuration object that can be used to further configure the property. - [SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures", Justification = "Nested generics appropriate here")] - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters", Justification = "More specific expression type is clearer")] - public PrecisionPropertyConfiguration Property(Expression> propertyExpression) - { - return GetPrimitivePropertyConfiguration(propertyExpression, nullable: false) as PrecisionPropertyConfiguration; - } - /// /// Adds a primitive property to the EDM type. /// diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/CapabilitiesVocabularyExtensionMethods.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/CapabilitiesVocabularyExtensionMethods.cs index 20b462e..bcbdde8 100644 --- a/src/Microsoft.OData.ModelBuilder/Vocabularies/CapabilitiesVocabularyExtensionMethods.cs +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/CapabilitiesVocabularyExtensionMethods.cs @@ -267,11 +267,11 @@ public static List ToEdmProperties(this Dictionary <#@ assembly name="System.Core" #> <#@ assembly name="System.Runtime" #> -<#@ assembly name="$(NuGetPackageRoot)microsoft.odata.edm\7.9.0\lib\net45\Microsoft.OData.Edm.dll" #> +<#@ assembly name="$(NuGetPackageRoot)microsoft.odata.edm\9.0.0-preview.3\lib\net10\Microsoft.OData.Edm.dll" #> <#@ import namespace="System.IO" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> diff --git a/test/Microsoft.OData.ModelBuilder.Tests/Commons/CsdlSerializer.cs b/test/Microsoft.OData.ModelBuilder.Tests/Commons/CsdlSerializer.cs index c78b529..152851f 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/Commons/CsdlSerializer.cs +++ b/test/Microsoft.OData.ModelBuilder.Tests/Commons/CsdlSerializer.cs @@ -25,7 +25,7 @@ public static string SerializeAsXml(this IEdmModel model) StringWriter writer = new StringWriter(); var xwriter = XmlWriter.Create(writer); IEnumerable errors; - if (CsdlWriter.TryWriteCsdl(model, xwriter, CsdlTarget.OData, out errors)) + if (CsdlWriter.TryWriteCsdl(model, xwriter, out errors)) { xwriter.Flush(); return writer.ToString(); diff --git a/test/Microsoft.OData.ModelBuilder.Tests/Commons/ExceptionAssert.cs b/test/Microsoft.OData.ModelBuilder.Tests/Commons/ExceptionAssert.cs index 5bee2c7..73f7cf3 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/Commons/ExceptionAssert.cs +++ b/test/Microsoft.OData.ModelBuilder.Tests/Commons/ExceptionAssert.cs @@ -555,11 +555,13 @@ private static void VerifyExceptionMessage(Exception exception, string expectedM // Custom ThrowsException so we can filter the stack trace. [Serializable] - private class ThrowsException : Xunit.Sdk.ThrowsException + private class ThrowsException : Xunit.Sdk.XunitException { - public ThrowsException(Type type) : base(type) { } + public ThrowsException(Type type) + : base($"Assert.Throws() Failure: Expected exception type: {type.FullName}") { } - public ThrowsException(Type type, Exception ex) : base(type, ex) { } + public ThrowsException(Type type, Exception ex) + : base($"Assert.Throws() Failure: Expected exception type: {type.FullName}, Actual: {ex.GetType().FullName}") { } } } } diff --git a/test/Microsoft.OData.ModelBuilder.Tests/Conventions/Attributes/ColumnAttributeEdmPropertyConventionTest.cs b/test/Microsoft.OData.ModelBuilder.Tests/Conventions/Attributes/ColumnAttributeEdmPropertyConventionTest.cs index d204ea6..a937896 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/Conventions/Attributes/ColumnAttributeEdmPropertyConventionTest.cs +++ b/test/Microsoft.OData.ModelBuilder.Tests/Conventions/Attributes/ColumnAttributeEdmPropertyConventionTest.cs @@ -60,9 +60,9 @@ public void Apply_SetsDateTimeProperty_AsEdmDate(string typeName, bool expect) [InlineData("time", true)] [InlineData("tIme", true)] [InlineData("edm.timeofday", false)] - [InlineData("eDm.TimeOfDay", false)] + [InlineData("Edm.TimeOfDay", false)] [InlineData("any", false)] - public void Apply_SetsTimeSpanProperty_AsEdmTimeOfDay(string typeName, bool expect) + public void Apply_SetsTimeSpanProperty_AsEdmTimeOnly(string typeName, bool expect) { // Arrange MockType type = new MockType("Customer") diff --git a/test/Microsoft.OData.ModelBuilder.Tests/CsdlMetadataTest.cs b/test/Microsoft.OData.ModelBuilder.Tests/CsdlMetadataTest.cs index 4c97385..67eef38 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/CsdlMetadataTest.cs +++ b/test/Microsoft.OData.ModelBuilder.Tests/CsdlMetadataTest.cs @@ -178,7 +178,7 @@ public static string GetCSDL(IEdmModel model) StringWriter writer = new StringWriter(); var xwriter = XmlWriter.Create(writer); IEnumerable errors; - if (CsdlWriter.TryWriteCsdl(model, xwriter, CsdlTarget.OData, out errors)) + if (CsdlWriter.TryWriteCsdl(model, xwriter, out errors)) { xwriter.Flush(); return writer.ToString(); diff --git a/test/Microsoft.OData.ModelBuilder.Tests/Microsoft.OData.ModelBuilder.Tests.csproj b/test/Microsoft.OData.ModelBuilder.Tests/Microsoft.OData.ModelBuilder.Tests.csproj index 42784ef..afabb92 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/Microsoft.OData.ModelBuilder.Tests.csproj +++ b/test/Microsoft.OData.ModelBuilder.Tests/Microsoft.OData.ModelBuilder.Tests.csproj @@ -1,7 +1,7 @@  - net8.0 + net10.0 Microsoft.OData.ModelBuilder.Tests Microsoft.OData.ModelBuilder.Tests @@ -24,13 +24,11 @@ - + - - - - + + diff --git a/test/Microsoft.OData.ModelBuilder.Tests/ODataConventionModelBuilderTest.cs b/test/Microsoft.OData.ModelBuilder.Tests/ODataConventionModelBuilderTest.cs index 1594747..b151967 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/ODataConventionModelBuilderTest.cs +++ b/test/Microsoft.OData.ModelBuilder.Tests/ODataConventionModelBuilderTest.cs @@ -3471,9 +3471,9 @@ public class Product public DateTimeOffset? ReleaseDate { get; set; } - public Date PublishDate { get; set; } + public DateOnly PublishDate { get; set; } - public TimeOfDay? ShowTime { get; set; } + public TimeOnly? ShowTime { get; set; } public ProductVersion Version { get; set; } diff --git a/test/Microsoft.OData.ModelBuilder.Tests/ODataModelBuilderTest.cs b/test/Microsoft.OData.ModelBuilder.Tests/ODataModelBuilderTest.cs index b3fea9b..cfbf72a 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/ODataModelBuilderTest.cs +++ b/test/Microsoft.OData.ModelBuilder.Tests/ODataModelBuilderTest.cs @@ -953,7 +953,7 @@ public void CanConfig_PrecisionOfTemporalType() ODataModelBuilder builder = new ODataModelBuilder(); var entity = builder.EntityType().HasKey(p => p.Id); entity.Property(p => p.DurationProperty).Precision = 5; - entity.Property(p => p.TimeOfDayProperty).Precision = 6; + entity.Property(p => p.TimeOnlyProperty).Precision = 6; entity.Property(p => p.DateTimeOffsetProperty).Precision = 7; entity.Property(p => p.OnlyTime).Precision = 8; @@ -962,19 +962,19 @@ public void CanConfig_PrecisionOfTemporalType() IEdmEntityType edmEntityType = model.SchemaElements.OfType().First(p => p.Name == "PrecisionEnitity"); IEdmTemporalTypeReference durationType = (IEdmTemporalTypeReference)edmEntityType.DeclaredProperties.First(p => p.Name.Equals("DurationProperty")).Type; - IEdmTemporalTypeReference timeOfDayType = - (IEdmTemporalTypeReference)edmEntityType.DeclaredProperties.First(p => p.Name.Equals("TimeOfDayProperty")).Type; + IEdmTemporalTypeReference timeOnlyType1 = + (IEdmTemporalTypeReference)edmEntityType.DeclaredProperties.First(p => p.Name.Equals("TimeOnlyProperty")).Type; IEdmTemporalTypeReference dateTimeOffsetType = (IEdmTemporalTypeReference)edmEntityType.DeclaredProperties.First(p => p.Name.Equals("DateTimeOffsetProperty")).Type; // Assert Assert.Equal(5, durationType.Precision.Value); - Assert.Equal(6, timeOfDayType.Precision.Value); + Assert.Equal(6, timeOnlyType1.Precision.Value); Assert.Equal(7, dateTimeOffsetType.Precision.Value); - IEdmTemporalTypeReference timeOnlyType = + IEdmTemporalTypeReference timeOnlyType2 = (IEdmTemporalTypeReference)edmEntityType.DeclaredProperties.First(p => p.Name.Equals("OnlyTime")).Type; - Assert.Equal(8, timeOnlyType.Precision.Value); + Assert.Equal(8, timeOnlyType2.Precision.Value); } [Fact] @@ -1127,7 +1127,7 @@ class PrecisionEnitity public TimeSpan DurationProperty { get; set; } - public TimeOfDay TimeOfDayProperty { get; set; } + public TimeOnly TimeOnlyProperty { get; set; } public DateTimeOffset DateTimeOffsetProperty { get; set; } diff --git a/test/Microsoft.OData.ModelBuilder.Tests/Operations/ActionConfigurationTest.cs b/test/Microsoft.OData.ModelBuilder.Tests/Operations/ActionConfigurationTest.cs index 3f508cb..f69ebee 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/Operations/ActionConfigurationTest.cs +++ b/test/Microsoft.OData.ModelBuilder.Tests/Operations/ActionConfigurationTest.cs @@ -760,11 +760,11 @@ public void GetEdmModel_SetsDateTimeAsParameterType() } [Theory] - [InlineData(typeof(Date), "Edm.Date")] - [InlineData(typeof(Date?), "Edm.Date")] - [InlineData(typeof(TimeOfDay), "Edm.TimeOfDay")] - [InlineData(typeof(TimeOfDay?), "Edm.TimeOfDay")] - public void CanCreateEdmModel_WithDateAndTimeOfDay_AsActionParameter(Type paramType, string expect) + [InlineData(typeof(DateOnly), "Edm.Date")] + [InlineData(typeof(DateOnly?), "Edm.Date")] + [InlineData(typeof(TimeOnly), "Edm.TimeOfDay")] + [InlineData(typeof(TimeOnly?), "Edm.TimeOfDay")] + public void CanCreateEdmModel_WithDateOnlyAndTimeOnly_AsActionParameter(Type paramType, string expect) { // Arrange ODataModelBuilder builder = ODataModelBuilderMocks.GetModelBuilderMock(); diff --git a/test/Microsoft.OData.ModelBuilder.Tests/Operations/FunctionConfigurationTest.cs b/test/Microsoft.OData.ModelBuilder.Tests/Operations/FunctionConfigurationTest.cs index 02bfa8c..b4546a4 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/Operations/FunctionConfigurationTest.cs +++ b/test/Microsoft.OData.ModelBuilder.Tests/Operations/FunctionConfigurationTest.cs @@ -827,11 +827,11 @@ public void GetEdmModel_SetsDateTimeAsParameterType_WorksForDefaultConverter() } [Theory] - [InlineData(typeof(Date), "Edm.Date")] - [InlineData(typeof(Date?), "Edm.Date")] - [InlineData(typeof(TimeOfDay), "Edm.TimeOfDay")] - [InlineData(typeof(TimeOfDay?), "Edm.TimeOfDay")] - public void CanCreateEdmModel_WithDateAndTimeOfDay_AsFunctionParameter(Type paramType, string expect) + [InlineData(typeof(DateOnly), "Edm.Date")] + [InlineData(typeof(DateOnly?), "Edm.Date")] + [InlineData(typeof(TimeOnly), "Edm.TimeOfDay")] + [InlineData(typeof(TimeOnly?), "Edm.TimeOfDay")] + public void CanCreateEdmModel_WithDateOnlyAndTimeOnly_AsFunctionParameter(Type paramType, string expect) { // Arrange ODataModelBuilder builder = ODataModelBuilderMocks.GetModelBuilderMock(); diff --git a/test/Microsoft.OData.ModelBuilder.Tests/Property/CollectionPropertyConfigurationTest.cs b/test/Microsoft.OData.ModelBuilder.Tests/Property/CollectionPropertyConfigurationTest.cs index 8455aea..45ed8f7 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/Property/CollectionPropertyConfigurationTest.cs +++ b/test/Microsoft.OData.ModelBuilder.Tests/Property/CollectionPropertyConfigurationTest.cs @@ -43,10 +43,10 @@ public static TheoryDataSet GetValidPropertiesAndElementType { type.GetProperty("RandomRandomComplexType"), typeof(RandomComplexType) }, { type.GetProperty("CollectionDateTimes"), typeof(DateTime) }, { type.GetProperty("CollectionNullableDateTimes"), typeof(DateTime?) }, - { type.GetProperty("CollectionDates"), typeof(Date) }, - { type.GetProperty("CollectionNullableDates"), typeof(Date?) }, - { type.GetProperty("CollectionTimesOfDays"), typeof(TimeOfDay) }, - { type.GetProperty("CollectionNullableTimesOfDays"), typeof(TimeOfDay?) }, + { type.GetProperty("CollectionDates"), typeof(DateOnly) }, + { type.GetProperty("CollectionNullableDates"), typeof(DateOnly?) }, + { type.GetProperty("CollectionTimesOfDays"), typeof(TimeOnly) }, + { type.GetProperty("CollectionNullableTimesOfDays"), typeof(TimeOnly?) }, }; } } @@ -113,10 +113,10 @@ internal class LotsOfCollectionProperties public IEnumerable CollectionDateTimes { get; set; } public IEnumerable CollectionNullableDateTimes { get; set; } - public IEnumerable CollectionDates { get; set; } - public IEnumerable CollectionNullableDates { get; set; } - public IEnumerable CollectionTimesOfDays { get; set; } - public IEnumerable CollectionNullableTimesOfDays { get; set; } + public IEnumerable CollectionDates { get; set; } + public IEnumerable CollectionNullableDates { get; set; } + public IEnumerable CollectionTimesOfDays { get; set; } + public IEnumerable CollectionNullableTimesOfDays { get; set; } } internal class RandomComplexType { } diff --git a/test/Microsoft.OData.ModelBuilder.Tests/PublicApi/Microsoft.OData.ModelBuilder.PublicApi.bsl b/test/Microsoft.OData.ModelBuilder.Tests/PublicApi/Microsoft.OData.ModelBuilder.PublicApi.bsl index 4fd6a35..20622f8 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/PublicApi/Microsoft.OData.ModelBuilder.PublicApi.bsl +++ b/test/Microsoft.OData.ModelBuilder.Tests/PublicApi/Microsoft.OData.ModelBuilder.PublicApi.bsl @@ -300,19 +300,17 @@ public abstract class Microsoft.OData.ModelBuilder.StructuralTypeConfiguration`1 public Microsoft.OData.ModelBuilder.StructuralTypeConfiguration`1 Page () public Microsoft.OData.ModelBuilder.StructuralTypeConfiguration`1 Page (System.Nullable`1[[System.Int32]] maxTopValue, System.Nullable`1[[System.Int32]] pageSizeValue) public Microsoft.OData.ModelBuilder.PrecisionPropertyConfiguration Property (Expression`1 propertyExpression) - public Microsoft.OData.ModelBuilder.LengthPropertyConfiguration Property (Expression`1 propertyExpression) - public Microsoft.OData.ModelBuilder.LengthPropertyConfiguration Property (Expression`1 propertyExpression) public Microsoft.OData.ModelBuilder.PrimitivePropertyConfiguration Property (Expression`1 propertyExpression) public Microsoft.OData.ModelBuilder.DecimalPropertyConfiguration Property (Expression`1 propertyExpression) public Microsoft.OData.ModelBuilder.UntypedPropertyConfiguration Property (Expression`1 propertyExpression) - public Microsoft.OData.ModelBuilder.DecimalPropertyConfiguration Property (Expression`1 propertyExpression) - public Microsoft.OData.ModelBuilder.PrecisionPropertyConfiguration Property (Expression`1 propertyExpression) - public Microsoft.OData.ModelBuilder.PrecisionPropertyConfiguration Property (Expression`1 propertyExpression) + public Microsoft.OData.ModelBuilder.LengthPropertyConfiguration Property (Expression`1 propertyExpression) + public Microsoft.OData.ModelBuilder.LengthPropertyConfiguration Property (Expression`1 propertyExpression) public Microsoft.OData.ModelBuilder.PrecisionPropertyConfiguration Property (Expression`1 propertyExpression) public Microsoft.OData.ModelBuilder.PrecisionPropertyConfiguration Property (Expression`1 propertyExpression) public Microsoft.OData.ModelBuilder.PrecisionPropertyConfiguration Property (Expression`1 propertyExpression) public Microsoft.OData.ModelBuilder.PrecisionPropertyConfiguration Property (Expression`1 propertyExpression) public Microsoft.OData.ModelBuilder.PrecisionPropertyConfiguration Property (Expression`1 propertyExpression) + public Microsoft.OData.ModelBuilder.DecimalPropertyConfiguration Property (Expression`1 propertyExpression) public Microsoft.OData.ModelBuilder.PrimitivePropertyConfiguration Property (Expression`1 propertyExpression) public Microsoft.OData.ModelBuilder.PrimitivePropertyConfiguration Property (Expression`1 propertyExpression) public Microsoft.OData.ModelBuilder.StructuralTypeConfiguration`1 Select () @@ -404,6 +402,11 @@ public sealed class Microsoft.OData.ModelBuilder.PrimitivePropertyConfigurationE ExtensionAttribute(), ] public static Microsoft.OData.ModelBuilder.PrimitivePropertyConfiguration AsTimeOfDay (Microsoft.OData.ModelBuilder.PrimitivePropertyConfiguration property) + + [ + ExtensionAttribute(), + ] + public static Microsoft.OData.ModelBuilder.PrimitivePropertyConfiguration AsTimeOnly (Microsoft.OData.ModelBuilder.PrimitivePropertyConfiguration property) } [ diff --git a/test/Microsoft.OData.ModelBuilder.Tests/Types/ComplexTypeTest.cs b/test/Microsoft.OData.ModelBuilder.Tests/Types/ComplexTypeTest.cs index 8caa621..2bb1682 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/Types/ComplexTypeTest.cs +++ b/test/Microsoft.OData.ModelBuilder.Tests/Types/ComplexTypeTest.cs @@ -104,8 +104,8 @@ public void NullablePropertiesAreOptional() Assert.True(complexType.Property(t => t.NullableLongProperty).NullableProperty); Assert.True(complexType.Property(t => t.NullableShortProperty).NullableProperty); Assert.True(complexType.Property(t => t.NullableTimeSpanProperty).NullableProperty); - Assert.True(complexType.Property(t => t.NullableDateProperty).NullableProperty); - Assert.True(complexType.Property(t => t.NullableTimeOfDayProperty).NullableProperty); + Assert.True(complexType.Property(t => t.NullableDateOnlyProperty).NullableProperty); + Assert.True(complexType.Property(t => t.NullableTimeOnlyProperty).NullableProperty); // Assert.True(complexType.Property(t => t.StreamProperty).OptionalProperty); Assert.True(complexType.Property(t => t.StringProperty).NullableProperty); @@ -130,8 +130,8 @@ public void NonNullablePropertiesAreNotOptional() Assert.False(complexType.Property(t => t.ShortProperty).NullableProperty); Assert.False(complexType.Property(t => t.TimeSpanProperty).NullableProperty); Assert.False(complexType.Property(t => t.DateTimeProperty).NullableProperty); - Assert.False(complexType.Property(t => t.DateProperty).NullableProperty); - Assert.False(complexType.Property(t => t.TimeOfDayProperty).NullableProperty); + Assert.False(complexType.Property(t => t.DateOnlyProperty).NullableProperty); + Assert.False(complexType.Property(t => t.TimeOnlyProperty).NullableProperty); } [Fact] @@ -564,11 +564,11 @@ public class ComplexTypeTestModel public DateTime DateTimeProperty { get; set; } public DateTime? NullableDateTimeProperty { get; set; } - public Date DateProperty { get; set; } - public Date? NullableDateProperty { get; set; } + public DateOnly DateOnlyProperty { get; set; } + public DateOnly? NullableDateOnlyProperty { get; set; } - public TimeOfDay TimeOfDayProperty { get; set; } - public TimeOfDay? NullableTimeOfDayProperty { get; set; } + public TimeOnly TimeOnlyProperty { get; set; } + public TimeOnly? NullableTimeOnlyProperty { get; set; } public string StringProperty { get; set; } public Stream StreamProperty { get; set; } diff --git a/test/Microsoft.OData.ModelBuilder.Tests/Types/EntityTypeTest.cs b/test/Microsoft.OData.ModelBuilder.Tests/Types/EntityTypeTest.cs index 8f70dc5..26aef8a 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/Types/EntityTypeTest.cs +++ b/test/Microsoft.OData.ModelBuilder.Tests/Types/EntityTypeTest.cs @@ -73,23 +73,23 @@ public void CanCreateEntityWithCompoundKey() } [Fact] - public void CanCreateEntityWithCompoundKey_ForDateAndTimeOfDay() + public void CanCreateEntityWithCompoundKey_ForDateOnlyAndTimeOnly() { // Arrange var builder = new ODataModelBuilder(); - var entity = builder.EntityType(); - entity.HasKey(e => new { e.Date, e.TimeOfDay }); + var entity = builder.EntityType(); + entity.HasKey(e => new { e.DateOnly, e.TimeOnly }); // Act var model = builder.GetServiceModel(); // Assert var entityType = - model.SchemaElements.OfType().Single(e => e.Name == "EntityTypeWithDateAndTimeOfDay"); + model.SchemaElements.OfType().Single(e => e.Name == "EntityTypeWithDateOnlyAndTimeOnly"); Assert.Equal(2, entityType.Properties().Count()); Assert.Equal(2, entityType.DeclaredKey.Count()); - Assert.NotNull(entityType.DeclaredKey.SingleOrDefault(k => k.Name == "Date")); - Assert.NotNull(entityType.DeclaredKey.SingleOrDefault(k => k.Name == "TimeOfDay")); + Assert.NotNull(entityType.DeclaredKey.SingleOrDefault(k => k.Name == "DateOnly")); + Assert.NotNull(entityType.DeclaredKey.SingleOrDefault(k => k.Name == "TimeOnly")); } [Fact] @@ -725,10 +725,10 @@ public class SimpleOpenEntityType public IDictionary DynamicProperties { get; set; } } - public class EntityTypeWithDateAndTimeOfDay + public class EntityTypeWithDateOnlyAndTimeOnly { - public Date Date { get; set; } - public TimeOfDay TimeOfDay { get; set; } + public DateOnly DateOnly { get; set; } + public TimeOnly TimeOnly { get; set; } } [Fact] diff --git a/test/Microsoft.OData.ModelBuilder.Tests/Types/PrimitiveTypeTest.cs b/test/Microsoft.OData.ModelBuilder.Tests/Types/PrimitiveTypeTest.cs index 17f10e6..b3cca13 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/Types/PrimitiveTypeTest.cs +++ b/test/Microsoft.OData.ModelBuilder.Tests/Types/PrimitiveTypeTest.cs @@ -121,18 +121,18 @@ public void CreateDatePrimitiveProperty_FromDateTime() } [Fact] - public void CreateTimeOfDayPrimitiveProperty() + public void CreateTimeOnlyPrimitiveProperty() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); EntityTypeConfiguration file = builder.EntityType(); - PrimitivePropertyConfiguration timeOfDay = file.Property(f => f.TimeOfDayProperty); + PrimitivePropertyConfiguration timeOnly = file.Property(f => f.TimeOnlyProperty); // Act IEdmModel model = builder.GetServiceModel(); // Assert - Assert.Equal(PropertyKind.Primitive, timeOfDay.Kind); + Assert.Equal(PropertyKind.Primitive, timeOnly.Kind); IEdmEntityType fileType = Assert.Single(model.SchemaElements.OfType()); @@ -142,13 +142,13 @@ public void CreateTimeOfDayPrimitiveProperty() } [Fact] - public void CreateTimeOfDayPrimitiveProperty_FromTimeSpan() + public void CreateTimeOnlyPrimitiveProperty_FromTimeSpan() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); EntityTypeConfiguration file = builder.EntityType(); - file.Property(f => f.CreatedTime).AsTimeOfDay(); - file.Property(f => f.EndTime).AsTimeOfDay(); + file.Property(f => f.CreatedTime).AsTimeOnly(); + file.Property(f => f.EndTime).AsTimeOnly(); // Act IEdmModel model = builder.GetServiceModel(); @@ -174,9 +174,9 @@ public class PrimitiveFile public Stream StreamData { get; set; } - public Date DateProperty { get; set; } + public DateOnly DateProperty { get; set; } - public TimeOfDay TimeOfDayProperty { get; set; } + public TimeOnly TimeOnlyProperty { get; set; } public DateTime Birthday { get; set; } public DateTime? PublishDay { get; set; } diff --git a/test/Microsoft.OData.ModelBuilder.Tests/Vocabularies/Core/RevisionsConfigurationTests.cs b/test/Microsoft.OData.ModelBuilder.Tests/Vocabularies/Core/RevisionsConfigurationTests.cs index 4a99091..a5b1a8b 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/Vocabularies/Core/RevisionsConfigurationTests.cs +++ b/test/Microsoft.OData.ModelBuilder.Tests/Vocabularies/Core/RevisionsConfigurationTests.cs @@ -27,7 +27,7 @@ public void RevisionsCanBeAddedToEntitySet() var revisionsBuilder = modelBuilder .EntitySet("Customers") - .HasRevisions(a=>a.HasKind(RevisionKind.Deprecated).HasDescription(Description).HasVersion(Version).HasDynamicProperty("Date", Date).HasDynamicProperty("RemovalDate", RemovalDate)); + .HasRevisions(a=>a.HasKind(RevisionKind.Deprecated).HasDescription(Description).HasVersion(Version).HasDynamicProperty("DateOnly", Date).HasDynamicProperty("RemovalDate", RemovalDate)); var model = modelBuilder.GetServiceModel(); var container = model.SchemaElements.OfType().SingleOrDefault(); @@ -120,7 +120,7 @@ public void RevisionsCanBeAddedToProperties() var revisionsBuilder = modelBuilder .ComplexType
() .Property(a => a.HouseNumber) - .HasRevisions(a => a.HasKind(RevisionKind.Deprecated).HasDescription(Description).HasVersion(Version).HasDynamicProperty("Date", Date).HasDynamicProperty("RemovalDate", RemovalDate)); + .HasRevisions(a => a.HasKind(RevisionKind.Deprecated).HasDescription(Description).HasVersion(Version).HasDynamicProperty("DateOnly", Date).HasDynamicProperty("RemovalDate", RemovalDate)); var model = modelBuilder.GetServiceModel(); var property = model.SchemaElements.OfType().Single().DeclaredProperties.OfType().FirstOrDefault(a => a.Name == "HouseNumber"); @@ -131,7 +131,7 @@ public void RevisionsCanBeAddedToProperties() var revisionsProperties = GetAnnotationTermEdmRecordExpression(annotation); - var dateNameValue = GetRecordValue(revisionsProperties, "Date"); + var dateNameValue = GetRecordValue(revisionsProperties, "DateOnly"); Assert.NotNull(dateNameValue); Assert.Equal(Date, dateNameValue.Value); @@ -149,7 +149,7 @@ public void RevisionsCanBeAddedToOperation() var actionConfiguration = modelBuilder.Action("MyAction"); var operationRestrictionsBuilder = actionConfiguration - .HasRevisions(a => a.HasKind(RevisionKind.Deprecated).HasDescription(Description).HasVersion(Version).HasDynamicProperty("Date", Date).HasDynamicProperty("RemovalDate", RemovalDate)); + .HasRevisions(a => a.HasKind(RevisionKind.Deprecated).HasDescription(Description).HasVersion(Version).HasDynamicProperty("DateOnly", Date).HasDynamicProperty("RemovalDate", RemovalDate)); var model = modelBuilder.GetServiceModel(); var action = model.SchemaElements.OfType().Single(); @@ -160,7 +160,7 @@ public void RevisionsCanBeAddedToOperation() var revisionsProperties = GetAnnotationTermEdmRecordExpression(annotation); - var dateNameValue = GetRecordValue(revisionsProperties, "Date"); + var dateNameValue = GetRecordValue(revisionsProperties, "DateOnly"); Assert.NotNull(dateNameValue); Assert.Equal(Date, dateNameValue.Value); From a4e03500812c9f285f8756982ee1d93b2ea8acb0 Mon Sep 17 00:00:00 2001 From: Samuel Wanjohi Date: Sun, 23 Nov 2025 13:30:53 +0300 Subject: [PATCH 2/8] update .net sdk to 10.x --- build/azure-pipelines-nightly.yml | 6 +++--- build/azure-pipelines-rolling.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build/azure-pipelines-nightly.yml b/build/azure-pipelines-nightly.yml index 313a9c1..fe49ed8 100644 --- a/build/azure-pipelines-nightly.yml +++ b/build/azure-pipelines-nightly.yml @@ -70,10 +70,10 @@ extends: versionSpec: '>=5.2.0' - task: UseDotNet@2 - displayName: Use .NET 8.0 + displayName: Use .NET Core SDK 10.x inputs: - packageType: 'sdk' - version: '8.0.x' + version: 10.x + includePreviewVersions: true - task: Powershell@2 displayName: 'Skip Strong Name Validation' diff --git a/build/azure-pipelines-rolling.yml b/build/azure-pipelines-rolling.yml index 61a1c46..a26e297 100644 --- a/build/azure-pipelines-rolling.yml +++ b/build/azure-pipelines-rolling.yml @@ -66,10 +66,10 @@ extends: checkLatest: true - task: UseDotNet@2 - displayName: Use .NET 8.0 + displayName: Use .NET Core SDK 10.x inputs: - packageType: 'sdk' - version: '8.0.x' + version: 10.x + includePreviewVersions: true - task: DotNetCoreCLI@2 displayName: 'Build Microsoft.OData.ModelBuilder.csproj ' From 5ef0fa884eb338f43f7f852866445778c27ac1d4 Mon Sep 17 00:00:00 2001 From: Samuel Wanjohi Date: Sun, 23 Nov 2025 13:45:17 +0300 Subject: [PATCH 3/8] resolve failing test --- build/azure-pipelines-nightly.yml | 8 ++++---- build/azure-pipelines-rolling.yml | 12 ++++++------ .../Microsoft.OData.ModelBuilder.xml | 2 +- .../ColumnAttributeEdmPropertyConventionTest.cs | 2 +- .../Types/PrimitiveTypeTest.cs | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/build/azure-pipelines-nightly.yml b/build/azure-pipelines-nightly.yml index fe49ed8..8ae8fa3 100644 --- a/build/azure-pipelines-nightly.yml +++ b/build/azure-pipelines-nightly.yml @@ -70,7 +70,7 @@ extends: versionSpec: '>=5.2.0' - task: UseDotNet@2 - displayName: Use .NET Core SDK 10.x + displayName: Use .NET Core 10.x inputs: version: 10.x includePreviewVersions: true @@ -99,10 +99,10 @@ extends: arguments: '--configuration $(buildConfiguration) --no-incremental' - task: UseDotNet@2 - displayName: Use .NET 3.x + displayName: Use .NET Core 10.x inputs: - packageType: 'sdk' - version: '3.x' + version: 10.x + includePreviewVersions: true - task: DotNetCoreCLI@2 displayName: 'Unit Tests (Microsoft.OData.ModelBuilder.Tests.csproj) ' diff --git a/build/azure-pipelines-rolling.yml b/build/azure-pipelines-rolling.yml index a26e297..891ee64 100644 --- a/build/azure-pipelines-rolling.yml +++ b/build/azure-pipelines-rolling.yml @@ -6,12 +6,12 @@ trigger: branches: include: - main - - release-1.x + - release-3.x # Pull request (PR) triggers pr: - main -- release-1.x +- release-3.x resources: repositories: @@ -66,7 +66,7 @@ extends: checkLatest: true - task: UseDotNet@2 - displayName: Use .NET Core SDK 10.x + displayName: Use .NET Core 10.x inputs: version: 10.x includePreviewVersions: true @@ -84,10 +84,10 @@ extends: arguments: '--configuration $(buildConfiguration) --no-incremental' - task: UseDotNet@2 - displayName: Use .NET 3.x + displayName: Use .NET Core 10.x inputs: - packageType: 'sdk' - version: '3.x' + version: 10.x + includePreviewVersions: true - task: DotNetCoreCLI@2 displayName: 'Unit Tests (Microsoft.OData.ModelBuilder.Tests.csproj) ' diff --git a/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.xml b/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.xml index 81ec44c..53b3ea9 100644 --- a/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.xml +++ b/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.xml @@ -691,7 +691,7 @@ Determine if a type is a TimeOnly.
The type to test. - True if the type is a TimeSpan; false otherwise. + True if the type is a TimeOnly; false otherwise.
diff --git a/test/Microsoft.OData.ModelBuilder.Tests/Conventions/Attributes/ColumnAttributeEdmPropertyConventionTest.cs b/test/Microsoft.OData.ModelBuilder.Tests/Conventions/Attributes/ColumnAttributeEdmPropertyConventionTest.cs index a937896..d61a2d7 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/Conventions/Attributes/ColumnAttributeEdmPropertyConventionTest.cs +++ b/test/Microsoft.OData.ModelBuilder.Tests/Conventions/Attributes/ColumnAttributeEdmPropertyConventionTest.cs @@ -60,7 +60,7 @@ public void Apply_SetsDateTimeProperty_AsEdmDate(string typeName, bool expect) [InlineData("time", true)] [InlineData("tIme", true)] [InlineData("edm.timeofday", false)] - [InlineData("Edm.TimeOfDay", false)] + [InlineData("eDm.TimeOfDay", false)] [InlineData("any", false)] public void Apply_SetsTimeSpanProperty_AsEdmTimeOnly(string typeName, bool expect) { diff --git a/test/Microsoft.OData.ModelBuilder.Tests/Types/PrimitiveTypeTest.cs b/test/Microsoft.OData.ModelBuilder.Tests/Types/PrimitiveTypeTest.cs index b3cca13..defddb1 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/Types/PrimitiveTypeTest.cs +++ b/test/Microsoft.OData.ModelBuilder.Tests/Types/PrimitiveTypeTest.cs @@ -136,7 +136,7 @@ public void CreateTimeOnlyPrimitiveProperty() IEdmEntityType fileType = Assert.Single(model.SchemaElements.OfType()); - IEdmProperty property = Assert.Single(fileType.DeclaredProperties.Where(p => p.Name == "TimeOfDayProperty")); + IEdmProperty property = Assert.Single(fileType.DeclaredProperties.Where(p => p.Name == "TimeOnlyProperty")); Assert.NotNull(property); Assert.Equal("Edm.TimeOfDay", property.Type.FullName()); } From 722db7f019ef85eb0b3bb2a145fc176b21e0a341 Mon Sep 17 00:00:00 2001 From: Samuel Wanjohi Date: Sun, 23 Nov 2025 14:11:36 +0300 Subject: [PATCH 4/8] refactor and doing some nit --- .../ColumnAttributeEdmPropertyConvention.cs | 2 +- .../Microsoft.OData.ModelBuilder.xml | 18 +++++++--- ...rimitivePropertyConfigurationExtensions.cs | 35 +++++++++++++++---- .../Types/PrimitiveTypeTest.cs | 4 +-- 4 files changed, 45 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.OData.ModelBuilder/Conventions/Attributes/ColumnAttributeEdmPropertyConvention.cs b/src/Microsoft.OData.ModelBuilder/Conventions/Attributes/ColumnAttributeEdmPropertyConvention.cs index 1705493..7912303 100644 --- a/src/Microsoft.OData.ModelBuilder/Conventions/Attributes/ColumnAttributeEdmPropertyConvention.cs +++ b/src/Microsoft.OData.ModelBuilder/Conventions/Attributes/ColumnAttributeEdmPropertyConvention.cs @@ -57,7 +57,7 @@ public override void Apply(PropertyConfiguration edmProperty, StructuralTypeConf string typeName = columnAttribute.TypeName; if (String.Compare(typeName, "date", StringComparison.OrdinalIgnoreCase) == 0) { - primitiveProperty.AsDate(); + primitiveProperty.AsDateOnly(); } else if (String.Compare(typeName, "time", StringComparison.OrdinalIgnoreCase) == 0) { diff --git a/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.xml b/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.xml index 53b3ea9..0d7485b 100644 --- a/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.xml +++ b/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.xml @@ -3645,8 +3645,16 @@ - If this primitive property is , this method will make the target - Edm type kind as + If this primitive property is or , this method will make the target + Edm type kind as + + Reference to the calling primitive property configuration. + Returns itself so that multiple calls can be chained. + + + + If this primitive property is or , this method will make the target + Edm type kind as Reference to the calling primitive property configuration. Returns itself so that multiple calls can be chained. @@ -3654,15 +3662,15 @@ If this primitive property is , this method will make the target - Edm type kind as + Edm type kind as Reference to the calling primitive property configuration. Returns itself so that multiple calls can be chained. - If this primitive property is , this method will make the target - Edm type kind as + If this primitive property is or , this method will make the target + Edm type kind as Reference to the calling primitive property configuration. Returns itself so that multiple calls can be chained. diff --git a/src/Microsoft.OData.ModelBuilder/Property/PrimitivePropertyConfigurationExtensions.cs b/src/Microsoft.OData.ModelBuilder/Property/PrimitivePropertyConfigurationExtensions.cs index bafd230..0fd7c18 100644 --- a/src/Microsoft.OData.ModelBuilder/Property/PrimitivePropertyConfigurationExtensions.cs +++ b/src/Microsoft.OData.ModelBuilder/Property/PrimitivePropertyConfigurationExtensions.cs @@ -11,8 +11,8 @@ namespace Microsoft.OData.ModelBuilder public static class PrimitivePropertyConfigurationExtensions { /// - /// If this primitive property is , this method will make the target - /// Edm type kind as + /// If this primitive property is or , this method will make the target + /// Edm type kind as /// /// Reference to the calling primitive property configuration. /// Returns itself so that multiple calls can be chained. @@ -33,9 +33,32 @@ public static PrimitivePropertyConfiguration AsDate(this PrimitivePropertyConfig return property; } + /// + /// If this primitive property is or , this method will make the target + /// Edm type kind as + /// + /// Reference to the calling primitive property configuration. + /// Returns itself so that multiple calls can be chained. + public static PrimitivePropertyConfiguration AsDateOnly(this PrimitivePropertyConfiguration property) + { + if (property == null) + { + throw Error.ArgumentNull("property"); + } + + if (!TypeHelper.IsDateTime(property.RelatedClrType) && !TypeHelper.IsDateOnly(property.RelatedClrType)) + { + throw Error.Argument("property", SRResources.MustBeDateTimeProperty, property.PropertyInfo.Name, + property.DeclaringType.FullName); + } + + property.TargetEdmTypeKind = EdmPrimitiveTypeKind.Date; + return property; + } + /// /// If this primitive property is , this method will make the target - /// Edm type kind as + /// Edm type kind as /// /// Reference to the calling primitive property configuration. /// Returns itself so that multiple calls can be chained. @@ -57,8 +80,8 @@ public static PrimitivePropertyConfiguration AsTimeOfDay(this PrimitivePropertyC } /// - /// If this primitive property is , this method will make the target - /// Edm type kind as + /// If this primitive property is or , this method will make the target + /// Edm type kind as /// /// Reference to the calling primitive property configuration. /// Returns itself so that multiple calls can be chained. @@ -69,7 +92,7 @@ public static PrimitivePropertyConfiguration AsTimeOnly(this PrimitivePropertyCo throw Error.ArgumentNull("property"); } - if (!TypeHelper.IsTimeSpan(property.RelatedClrType)) + if (!TypeHelper.IsTimeSpan(property.RelatedClrType) && !TypeHelper.IsTimeOnly(property.RelatedClrType)) { throw Error.Argument("property", SRResources.MustBeTimeSpanProperty, property.PropertyInfo.Name, property.DeclaringType.FullName); diff --git a/test/Microsoft.OData.ModelBuilder.Tests/Types/PrimitiveTypeTest.cs b/test/Microsoft.OData.ModelBuilder.Tests/Types/PrimitiveTypeTest.cs index defddb1..e982f4c 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/Types/PrimitiveTypeTest.cs +++ b/test/Microsoft.OData.ModelBuilder.Tests/Types/PrimitiveTypeTest.cs @@ -100,8 +100,8 @@ public void CreateDatePrimitiveProperty_FromDateTime() // Arrange ODataModelBuilder builder = new ODataModelBuilder(); EntityTypeConfiguration file = builder.EntityType(); - file.Property(f => f.Birthday).AsDate(); - file.Property(f => f.PublishDay).AsDate(); + file.Property(f => f.Birthday).AsDateOnly(); + file.Property(f => f.PublishDay).AsDateOnly(); // Act IEdmModel model = builder.GetServiceModel(); From 617bf11d8765b0e6de8dccdba0b2f56a50689ac8 Mon Sep 17 00:00:00 2001 From: Samuel Wanjohi Date: Sun, 23 Nov 2025 14:14:32 +0300 Subject: [PATCH 5/8] update pipeline --- build/azure-pipelines-rolling.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/azure-pipelines-rolling.yml b/build/azure-pipelines-rolling.yml index 891ee64..cd25108 100644 --- a/build/azure-pipelines-rolling.yml +++ b/build/azure-pipelines-rolling.yml @@ -6,12 +6,12 @@ trigger: branches: include: - main - - release-3.x + - dev-3.x # Pull request (PR) triggers pr: - main -- release-3.x +- dev-3.x resources: repositories: From 7282684488fbe68fbe9ea8c13756af52822d966a Mon Sep 17 00:00:00 2001 From: Samuel Wanjohi Date: Sun, 23 Nov 2025 14:38:09 +0300 Subject: [PATCH 6/8] fix failing test --- .../PublicApi/Microsoft.OData.ModelBuilder.PublicApi.bsl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/Microsoft.OData.ModelBuilder.Tests/PublicApi/Microsoft.OData.ModelBuilder.PublicApi.bsl b/test/Microsoft.OData.ModelBuilder.Tests/PublicApi/Microsoft.OData.ModelBuilder.PublicApi.bsl index 20622f8..62cad5a 100644 --- a/test/Microsoft.OData.ModelBuilder.Tests/PublicApi/Microsoft.OData.ModelBuilder.PublicApi.bsl +++ b/test/Microsoft.OData.ModelBuilder.Tests/PublicApi/Microsoft.OData.ModelBuilder.PublicApi.bsl @@ -398,6 +398,11 @@ public sealed class Microsoft.OData.ModelBuilder.PrimitivePropertyConfigurationE ] public static Microsoft.OData.ModelBuilder.PrimitivePropertyConfiguration AsDate (Microsoft.OData.ModelBuilder.PrimitivePropertyConfiguration property) + [ + ExtensionAttribute(), + ] + public static Microsoft.OData.ModelBuilder.PrimitivePropertyConfiguration AsDateOnly (Microsoft.OData.ModelBuilder.PrimitivePropertyConfiguration property) + [ ExtensionAttribute(), ] From b25d32e03e62169ff87e1fb8d3bea206a182480c Mon Sep 17 00:00:00 2001 From: Samuel Wanjohi Date: Mon, 24 Nov 2025 09:55:56 +0300 Subject: [PATCH 7/8] Make AsTimeOfDay call AsTimeOnly and AsDate call AsDateOnly --- ...rimitivePropertyConfigurationExtensions.cs | 28 ++----------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/src/Microsoft.OData.ModelBuilder/Property/PrimitivePropertyConfigurationExtensions.cs b/src/Microsoft.OData.ModelBuilder/Property/PrimitivePropertyConfigurationExtensions.cs index 0fd7c18..7c5e776 100644 --- a/src/Microsoft.OData.ModelBuilder/Property/PrimitivePropertyConfigurationExtensions.cs +++ b/src/Microsoft.OData.ModelBuilder/Property/PrimitivePropertyConfigurationExtensions.cs @@ -18,19 +18,7 @@ public static class PrimitivePropertyConfigurationExtensions /// Returns itself so that multiple calls can be chained. public static PrimitivePropertyConfiguration AsDate(this PrimitivePropertyConfiguration property) { - if (property == null) - { - throw Error.ArgumentNull("property"); - } - - if (!TypeHelper.IsDateTime(property.RelatedClrType) && !TypeHelper.IsDateOnly(property.RelatedClrType)) - { - throw Error.Argument("property", SRResources.MustBeDateTimeProperty, property.PropertyInfo.Name, - property.DeclaringType.FullName); - } - - property.TargetEdmTypeKind = EdmPrimitiveTypeKind.Date; - return property; + return property.AsDateOnly(); } /// @@ -64,19 +52,7 @@ public static PrimitivePropertyConfiguration AsDateOnly(this PrimitivePropertyCo /// Returns itself so that multiple calls can be chained. public static PrimitivePropertyConfiguration AsTimeOfDay(this PrimitivePropertyConfiguration property) { - if (property == null) - { - throw Error.ArgumentNull("property"); - } - - if (!TypeHelper.IsTimeSpan(property.RelatedClrType) && !TypeHelper.IsTimeOnly(property.RelatedClrType)) - { - throw Error.Argument("property", SRResources.MustBeTimeSpanProperty, property.PropertyInfo.Name, - property.DeclaringType.FullName); - } - - property.TargetEdmTypeKind = EdmPrimitiveTypeKind.TimeOfDay; - return property; + return property.AsTimeOnly(); } /// From 43762ce05631a39b86da168c37318e0baa3e9885 Mon Sep 17 00:00:00 2001 From: Samuel Wanjohi Date: Mon, 24 Nov 2025 11:23:26 +0300 Subject: [PATCH 8/8] update pipelines --- build/azure-pipelines-nightly.yml | 1 + build/azure-pipelines-rolling.yml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/build/azure-pipelines-nightly.yml b/build/azure-pipelines-nightly.yml index 8ae8fa3..7515d90 100644 --- a/build/azure-pipelines-nightly.yml +++ b/build/azure-pipelines-nightly.yml @@ -13,6 +13,7 @@ schedules: branches: include: - main + - dev-3.x resources: repositories: diff --git a/build/azure-pipelines-rolling.yml b/build/azure-pipelines-rolling.yml index cd25108..cf8b8fd 100644 --- a/build/azure-pipelines-rolling.yml +++ b/build/azure-pipelines-rolling.yml @@ -6,11 +6,13 @@ trigger: branches: include: - main + - release-1.x - dev-3.x # Pull request (PR) triggers pr: - main +- release-1.x - dev-3.x resources: