-
Notifications
You must be signed in to change notification settings - Fork 170
Support DateOnly and TimeOnly #450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,6 +90,19 @@ public static bool IsDateTime(Type clrType) | |
return Type.GetTypeCode(underlyingTypeOrSelf) == TypeCode.DateTime; | ||
} | ||
|
||
#if NET6_0 | ||
internal static bool IsDateOnly(Type clrType) | ||
{ | ||
Type underlyingTypeOrSelf = GetUnderlyingTypeOrSelf(clrType); | ||
return underlyingTypeOrSelf == typeof(DateOnly); | ||
} | ||
|
||
internal static bool IsTimeOnly(Type clrType) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the whole There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realize there are already similar methods here (for example,
|
||
{ | ||
Type underlyingTypeOrSelf = GetUnderlyingTypeOrSelf(clrType); | ||
return underlyingTypeOrSelf == typeof(TimeOnly); | ||
} | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You might want to leave an extra blank line after this. #Resolved |
||
/// <summary> | ||
/// Determine if a type is a TimeSpan. | ||
/// </summary> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,13 @@ static DefaultODataTypeMapper() | |
BuildTypeMapping<char>(EdmPrimitiveTypeKind.String, isStandard: false); | ||
BuildTypeMapping<DateTime?>(EdmPrimitiveTypeKind.DateTimeOffset, isStandard: false); | ||
BuildTypeMapping<DateTime>(EdmPrimitiveTypeKind.DateTimeOffset, isStandard: false); | ||
|
||
#if NET6_0 | ||
BuildTypeMapping<DateOnly>(EdmPrimitiveTypeKind.Date, isStandard: false); | ||
BuildTypeMapping<DateOnly?>(EdmPrimitiveTypeKind.Date, isStandard: false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume there is no behavior difference in the order we add these mappings, but I'd still suggest adding the nullable versions prior to the non-nullable ones for consistency: all other types in this method are following that pattern. FAKE EDIT: Actually, scratch that: the order does seem to matter, as per the comment at the top of the method: // Do not change the order for the nullable or non-nullable. Put nullable ahead of non-nullable.
// By design: non-nullable will overwrite the item1. I'd even go as far as to suggest a small method to encapsulate this, something like: public void BuildStructTypeMapping<T>(EdmPrimitiveTypeKind edmPrimitiveTypeKind, bool isStandard)
where T : struct
{
BuildTypeMapping<T?>(edmPrimitiveTypeKind, isStandard);
BuildTypeMapping<T>(edmPrimitiveTypeKind, isStandard);
} Using this for all There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind sharing with me a contribution for this? I'd love to take and merge it for you. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For sure. I'll wait until you merge this and then refactor the whole block so as to avoid you having to rebase it. For now, just make sure the order is as per the comment and we should be good. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, you are right for the order. I forget what i said. OMG |
||
BuildTypeMapping<TimeOnly>(EdmPrimitiveTypeKind.TimeOfDay, isStandard: false); | ||
BuildTypeMapping<TimeOnly?>(EdmPrimitiveTypeKind.TimeOfDay, isStandard: false); | ||
#endif | ||
} | ||
#endregion | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,6 +137,28 @@ public static object ConvertPrimitiveValue(object value, Type type, TimeZoneInfo | |
|
||
throw new ValidationException(Error.Format(SRResources.PropertyMustBeBoolean)); | ||
} | ||
#if NET6_0 | ||
else if (type == typeof(DateOnly)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be nice if this could be simplified using a switch expression instead of all the I understand it is a bit unrelated though, so up to you. #WontFix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the suggestion, i'd like to leave for other PR. |
||
{ | ||
if (value is Date) | ||
{ | ||
Date dt = (Date)value; | ||
return new DateOnly(dt.Year, dt.Month, dt.Day); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would strongly recommend using pattern matching capture instead: if (value is Date date)
{
return new DateOnly(date.Year, date.Month, date.Day);
} Or a variation that includes the exception: return value switch
{
Date date => new DateOnly(date.Year, date.Month, date.Day).
_ => throw new ValidationException(Error.Format(SRResources.PropertyMustBeDateTimeOffsetOrDate)),
} #Resolved |
||
|
||
throw new ValidationException(Error.Format(SRResources.PropertyMustBeDateTimeOffsetOrDate)); | ||
} | ||
else if (type == typeof(TimeOnly)) | ||
{ | ||
if (value is TimeOfDay) | ||
{ | ||
TimeOfDay tod = (TimeOfDay)value; | ||
return new TimeOnly(tod.Hours, tod.Minutes, tod.Seconds, (int)tod.Milliseconds); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, It's ODL problem and now i have to cast it. |
||
} | ||
|
||
throw new ValidationException(Error.Format(SRResources.PropertyMustBeTimeOfDay)); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. #Resolved |
||
#endif | ||
else | ||
{ | ||
if (TypeHelper.TryGetInstance(type, value, out var result)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
@@ -102,6 +104,7 @@ private static ODataInnerError ToODataInnerError(this Dictionary<string, object> | |
|
||
// Convert the model state errors in to a string (for debugging only). | ||
// This should be improved once ODataError allows more details. | ||
[SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume you forgot to write the justification there. Please double check. Also, can you elaborate why we are touching this file as part of this PR? It looks unrelated to me. #Resolved |
||
private static string ConvertModelStateErrors(this IReadOnlyDictionary<string, object> errors) | ||
{ | ||
StringBuilder builder = new StringBuilder(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,6 +144,23 @@ internal static object ConvertPrimitiveValue(object value, IEdmPrimitiveTypeRefe | |
return tod; | ||
} | ||
|
||
#if NET6_0 | ||
// Since ODL doesn't support "DateOnly" and "TimeOnly", we have to use Date and TimeOfDay defined in ODL as a bridge. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the comment is currently sitting on top of an Otherwise this creates a sequential coupling between the blocks that is very hard to see (i.e., if code is added in-between them, it will suddenly stop making sense). #Resolved |
||
if (primitiveType != null && primitiveType.IsDate() && TypeHelper.IsDateOnly(type)) | ||
{ | ||
DateOnly dateOnly = (DateOnly)value; | ||
Date dt = new Date(dateOnly.Year, dateOnly.Month, dateOnly.Day); | ||
return dt; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we just inline the |
||
} | ||
|
||
if (primitiveType != null && primitiveType.IsTimeOfDay() && TypeHelper.IsTimeOnly(type)) | ||
{ | ||
TimeOnly timeOnly = (TimeOnly)value; | ||
TimeOfDay tod = new TimeOfDay(timeOnly.Hour, timeOnly.Minute, timeOnly.Second, timeOnly.Millisecond); | ||
return tod; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above on inlining unnecessary temporary variable. #Resolved |
||
} | ||
#endif | ||
|
||
return ConvertUnsupportedPrimitives(value, timeZoneInfo); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,25 @@ internal class ClrCanonicalFunctions | |
new KeyValuePair<string, PropertyInfo>(MillisecondFunctionName, typeof(TimeOfDay).GetProperty("Milliseconds")), | ||
}.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); | ||
|
||
#if NET6_0 | ||
// DateOnly properties | ||
public static readonly Dictionary<string, PropertyInfo> DateOnlyProperties = new[] | ||
{ | ||
new KeyValuePair<string, PropertyInfo>(YearFunctionName, typeof(DateOnly).GetProperty("Year")), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of using hardcoded strings, can we use For example: |
||
new KeyValuePair<string, PropertyInfo>(MonthFunctionName, typeof(DateOnly).GetProperty("Month")), | ||
new KeyValuePair<string, PropertyInfo>(DayFunctionName, typeof(DateOnly).GetProperty("Day")), | ||
}.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a very convoluted and expensive way to initialize the dictionary. I'd recommend the following instead: public static readonly Dictionary<string, PropertyInfo> DateOnlyProperties = new()
{
[YearFunctionName] = typeof(DateOnly).GetProperty("Year"),
[MonthFunctionName] = typeof(DateOnly).GetProperty("Month"),
[DayFunctionName] = typeof(DateOnly).GetProperty("Day"),
};
``` #Resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed to use {}. |
||
|
||
// TimeOnly | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: would suggest adding the " properties" at the end for consistency #Resolved |
||
public static readonly Dictionary<string, PropertyInfo> TimeOnlyProperties = new[] | ||
{ | ||
new KeyValuePair<string, PropertyInfo>(HourFunctionName, typeof(TimeOnly).GetProperty("Hour")), | ||
new KeyValuePair<string, PropertyInfo>(MinuteFunctionName, typeof(TimeOnly).GetProperty("Minute")), | ||
new KeyValuePair<string, PropertyInfo>(SecondFunctionName, typeof(TimeOnly).GetProperty("Second")), | ||
new KeyValuePair<string, PropertyInfo>(MillisecondFunctionName, typeof(TimeOnly).GetProperty("Millisecond")), | ||
}.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comments as above apply here. #Resolved |
||
#endif | ||
|
||
// TimeSpan properties | ||
public static readonly Dictionary<string, PropertyInfo> TimeSpanProperties = new[] | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,21 @@ public static Expression CreateBinaryExpression(BinaryOperatorKind binaryOperato | |
right = CreateTimeBinaryExpression(right, querySettings); | ||
} | ||
|
||
#if NET6_0 | ||
if ((IsType<DateOnly>(leftUnderlyingType) && IsDate(rightUnderlyingType)) || | ||
(IsDate(leftUnderlyingType) && IsType<DateOnly>(rightUnderlyingType))) | ||
{ | ||
left = CreateDateBinaryExpression(left, querySettings); | ||
right = CreateDateBinaryExpression(right, querySettings); | ||
} | ||
else if((IsType<TimeOnly>(leftUnderlyingType) && IsTimeOfDay(rightUnderlyingType)) || | ||
(IsTimeOfDay(leftUnderlyingType) && IsType<TimeOnly>(rightUnderlyingType))) | ||
{ | ||
left = CreateTimeBinaryExpression(left, querySettings); | ||
right = CreateTimeBinaryExpression(right, querySettings); | ||
} | ||
#endif | ||
|
||
if (left.Type != right.Type) | ||
{ | ||
// one of them must be nullable and the other is not. | ||
|
@@ -381,6 +396,16 @@ private static Expression GetProperty(Expression source, string propertyName, OD | |
{ | ||
return MakePropertyAccess(ClrCanonicalFunctions.TimeSpanProperties[propertyName], source, querySettings); | ||
} | ||
#if NET6_0 | ||
else if (IsType<DateOnly>(source.Type)) | ||
{ | ||
return MakePropertyAccess(ClrCanonicalFunctions.DateOnlyProperties[propertyName], source, querySettings); | ||
} | ||
else if (IsType<TimeOnly>(source.Type)) | ||
{ | ||
return MakePropertyAccess(ClrCanonicalFunctions.TimeOnlyProperties[propertyName], source, querySettings); | ||
} | ||
#endif | ||
|
||
return source; | ||
} | ||
|
@@ -407,15 +432,19 @@ private static Expression CreateTimeBinaryExpression(Expression source, ODataQue | |
{ | ||
source = ConvertToDateTimeRelatedConstExpression(source); | ||
|
||
long ticksPerHour = 36000000000L; | ||
long ticksPerMinute = 600000000L; | ||
long ticksPerSecond = 10000000L; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These values should be Having said that, I'd strongly recommend just using the constants exposed by the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's just what i am looking for. |
||
|
||
// Hour, Minute, Second, Millisecond | ||
Expression hour = GetProperty(source, ClrCanonicalFunctions.HourFunctionName, querySettings); | ||
Expression minute = GetProperty(source, ClrCanonicalFunctions.MinuteFunctionName, querySettings); | ||
Expression second = GetProperty(source, ClrCanonicalFunctions.SecondFunctionName, querySettings); | ||
Expression milliSecond = GetProperty(source, ClrCanonicalFunctions.MillisecondFunctionName, querySettings); | ||
|
||
Expression hourTicks = Expression.Multiply(Expression.Convert(hour, typeof(long)), Expression.Constant(TimeOfDay.TicksPerHour)); | ||
Expression minuteTicks = Expression.Multiply(Expression.Convert(minute, typeof(long)), Expression.Constant(TimeOfDay.TicksPerMinute)); | ||
Expression secondTicks = Expression.Multiply(Expression.Convert(second, typeof(long)), Expression.Constant(TimeOfDay.TicksPerSecond)); | ||
Expression hourTicks = Expression.Multiply(Expression.Convert(hour, typeof(long)), Expression.Constant(ticksPerHour, typeof(long))); | ||
Expression minuteTicks = Expression.Multiply(Expression.Convert(minute, typeof(long)), Expression.Constant(ticksPerMinute, typeof(long))); | ||
Expression secondTicks = Expression.Multiply(Expression.Convert(second, typeof(long)), Expression.Constant(ticksPerSecond, typeof(long))); | ||
|
||
// return (hour * TicksPerHour + minute * TicksPerMinute + second * TicksPerSecond + millisecond) | ||
Expression result = Expression.Add(hourTicks, Expression.Add(minuteTicks, Expression.Add(secondTicks, Expression.Convert(milliSecond, typeof(long))))); | ||
|
@@ -451,6 +480,20 @@ private static Expression ConvertToDateTimeRelatedConstExpression(Expression sou | |
{ | ||
return Expression.Constant(timeOfDay.Value, typeof(TimeOfDay)); | ||
} | ||
|
||
#if NET6_0 | ||
var dateOnly = parameterizedConstantValue as DateOnly?; | ||
if (dateOnly != null) | ||
{ | ||
return Expression.Constant(dateOnly.Value, typeof(DateOnly)); | ||
} | ||
|
||
var timeOnly = parameterizedConstantValue as TimeOnly?; | ||
if (timeOnly != null) | ||
{ | ||
return Expression.Constant(timeOnly.Value, typeof(TimeOnly)); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These checks are fairly convoluted as well. We can use a simple pattern match capture here: if (parameterizedConstantValue is DateOnly dateOnly)
{
return Expression.Constant(dateOnly);
}
if (parameterizedConstantValue is TimeOnly timeOnly)
{
return Expression.Constant(timeOnly);
} The type parameter is then probably not necessary as well since they are directly typed to the non-null type. Again... this entire method should be simplified with a big switch expression return but I understand it might be unrelated here. #Resolved |
||
#endif | ||
} | ||
|
||
return source; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -348,7 +348,11 @@ protected virtual Expression BindDateRelatedProperty(SingleValueFunctionCallNode | |
CheckArgumentNull(node, context); | ||
|
||
Expression[] arguments = BindArguments(node.Parameters, context); | ||
Contract.Assert(arguments.Length == 1 && ExpressionBinderHelper.IsDateRelated(arguments[0].Type)); | ||
Contract.Assert(arguments.Length == 1 && (ExpressionBinderHelper.IsDateRelated(arguments[0].Type) | ||
#if NET6_0 | ||
|| ExpressionBinderHelper.IsType<DateOnly>(arguments[0].Type) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of adding a conditional at this point, I'd strongly suggest adding the same check inside the |
||
#endif | ||
)); | ||
|
||
// We should support DateTime & DateTimeOffset even though DateTime is not part of OData v4 Spec. | ||
Expression parameter = arguments[0]; | ||
|
@@ -359,6 +363,13 @@ protected virtual Expression BindDateRelatedProperty(SingleValueFunctionCallNode | |
Contract.Assert(ClrCanonicalFunctions.DateProperties.ContainsKey(node.Name)); | ||
property = ClrCanonicalFunctions.DateProperties[node.Name]; | ||
} | ||
#if NET6_0 | ||
else if (ExpressionBinderHelper.IsType<DateOnly>(parameter.Type)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you considered adding a I understand they are trivial 1 liners, but it makes the code more consistent when the checks use the same approaches. Otherwise, when reading this code, it immediately raises questions to me like "wait, but why are we not using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :) I have the same concern. |
||
{ | ||
Contract.Assert(ClrCanonicalFunctions.DateOnlyProperties.ContainsKey(node.Name)); | ||
property = ClrCanonicalFunctions.DateOnlyProperties[node.Name]; | ||
} | ||
#endif | ||
else if (ExpressionBinderHelper.IsDateTime(parameter.Type)) | ||
{ | ||
Contract.Assert(ClrCanonicalFunctions.DateTimeProperties.ContainsKey(node.Name)); | ||
|
@@ -384,7 +395,12 @@ protected virtual Expression BindTimeRelatedProperty(SingleValueFunctionCallNode | |
CheckArgumentNull(node, context); | ||
|
||
Expression[] arguments = BindArguments(node.Parameters, context); | ||
Contract.Assert(arguments.Length == 1 && (ExpressionBinderHelper.IsTimeRelated(arguments[0].Type))); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unintended line break? #Resolved |
||
Contract.Assert(arguments.Length == 1 && (ExpressionBinderHelper.IsTimeRelated(arguments[0].Type) | ||
#if NET6_0 | ||
|| ExpressionBinderHelper.IsType<TimeOnly>(arguments[0].Type) | ||
#endif | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. Please move the check to inside the |
||
)); | ||
|
||
// We should support DateTime & DateTimeOffset even though DateTime is not part of OData v4 Spec. | ||
Expression parameter = arguments[0]; | ||
|
@@ -395,6 +411,13 @@ protected virtual Expression BindTimeRelatedProperty(SingleValueFunctionCallNode | |
Contract.Assert(ClrCanonicalFunctions.TimeOfDayProperties.ContainsKey(node.Name)); | ||
property = ClrCanonicalFunctions.TimeOfDayProperties[node.Name]; | ||
} | ||
#if NET6_0 | ||
else if (ExpressionBinderHelper.IsType<TimeOnly>(parameter.Type)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above regarding |
||
{ | ||
Contract.Assert(ClrCanonicalFunctions.TimeOnlyProperties.ContainsKey(node.Name)); | ||
property = ClrCanonicalFunctions.TimeOnlyProperties[node.Name]; | ||
} | ||
#endif | ||
else if (ExpressionBinderHelper.IsDateTime(parameter.Type)) | ||
{ | ||
Contract.Assert(ClrCanonicalFunctions.DateTimeProperties.ContainsKey(node.Name)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Net.Mime; | ||
using System.Text; | ||
|
@@ -163,6 +164,7 @@ internal static bool AcceptsJson(IHeaderDictionary headers) | |
return result; | ||
} | ||
|
||
[SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "<Pending>")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also missing justification (and also apparently unrelated to the changes). #Resolved There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. .NET 6 introduces a new overload for Append and raises a compile waring to use the old overload. So, before .NET 6, it's ok to build without a warning. however, there's a build warning after add .NET 6 target framework. Since I have to add .NET 6 target framework to introduce DateOnly and TimeOnly type, so, a build warning raises. Originally, i use But, i think it's easy to suppress the message since that's only for debugging purposes. Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ah I see, so that's why it is only raised now. Gotcha.
I'd agree. The docs for this rule state:
I LOL'd at the second part ("nah, this doesn't need to be maintainable" 🤣 ) but the first part says that if you are ok with the defaults it is a safe suppression. Just make sure to replace the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Took your suggestion. Thanks. |
||
private static void AppendRoute(StringBuilder builder, EndpointRouteInfo routeInfo) | ||
{ | ||
builder.Append("<tr>"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered moving NET6-specific members into a partial file? That might make it easier to manage in the future. Something like
TypeHelper.Net6.cs
for example. #WontFixThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there's only two new methods added, i'd like to create a new file until we have more .NET 6 specify methods added. Thanks for your suggestion.