Skip to content

Commit

Permalink
fixes for .Net 6
Browse files Browse the repository at this point in the history
  • Loading branch information
olmobrutall committed Nov 8, 2021
1 parent 11f2a0d commit 0669737
Show file tree
Hide file tree
Showing 5 changed files with 483 additions and 517 deletions.
Expand Up @@ -29,7 +29,6 @@ public static void Start(SchemaBuilder sb)
}
}
}
}

// In order to work this module, you should apply below mentioned changes to your index.cshtml file
/*
Expand Down
8 changes: 6 additions & 2 deletions Signum.Engine/Linq/ExpressionVisitor/DbExpressionNominator.cs
Expand Up @@ -837,8 +837,12 @@ protected override Expression VisitBinary(BinaryExpression b)
b.Left is MemberExpression leftSide && leftSide.Member is PropertyInfo piLeft && ReflectionTools.PropertyEquals(piLeft, piDayNumber) &&
b.Right is MemberExpression rightSide && rightSide.Member is PropertyInfo piRight && ReflectionTools.PropertyEquals(piRight, piDayNumber))
{
var diff = TrySqlDifference(SqlEnums.day, b.Type, leftSide.Expression!, rightSide.Expression!);
if (diff == null)
return b;

return TrySqlDifference(SqlEnums.day, b.Type, leftSide.Expression!, rightSide.Expression!) ?? b;

return Add(new SqlCastExpression(typeof(int), diff));
}

b = SmartEqualizer.UnwrapPrimaryKeyBinary(b);
Expand Down Expand Up @@ -1610,7 +1614,7 @@ protected override Expression VisitMethodCall(MethodCallExpression m)
case "DateTimeExtensions.Quarter": return TrySqlFunction(null, GetDatePart(), m.Type, new SqlLiteralExpression(SqlEnums.quarter), m.Arguments.Single());
case "DateTimeExtensions.WeekNumber": return TrySqlFunction(null, GetDatePart(), m.Type, new SqlLiteralExpression(SqlEnums.week), m.Arguments.Single());

case "DateTimeExtensions.ToDate": return TrySqlCast(m.Type, m.GetArgument("dateTime"));
case "DateTimeExtensions.ToDateOnly": return TrySqlCast(m.Type, m.GetArgument("dateTime"));
case "DateTimeExtensions.ToDateTime": return TrySqlCast(m.Type, m.GetArgument("date"));
case "DateOnly.FromDateTime":return TrySqlCast(m.Type, m.GetArgument("dateTime"));

Expand Down

2 comments on commit 0669737

@olmobrutall
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.Net 6 and C# 10

If you were not living under a rock today, VS 2022, .Net 6 and C# 10 has just been released!

Some links:

https://devblogs.microsoft.com/visualstudio/visual-studio-2022-now-available/
https://devblogs.microsoft.com/dotnet/welcome-to-csharp-10/
https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-10
https://www.dotnetconf.net/

I've prepared a battery of Signum Upgrades to update you code to C# 10 / .Net 6

  • Upgrade_20211108_Net6: Updates Nugets, TargetFramework, and replaces Date (removed) by DateOnly.
    Note: Consider replacing TimeSpan to TimeOnly for cases where it doesn't express a duration but an hour in the day.
  • Upgrade_20211109_GlobalUsings: creates an appropriate GlobalUsings.cs file per project and simplifies trivial usings.
  • Upgrade_20211109_RemoveSerializable: Removes [Serializable] attribute from the entities.
  • Upgrade_20211109_SimplifyNamespaces: Uses file-scoped namespaces declarations to recover ident space.

Expect every single .cs file touched by some of this migrations. Your code needs to loose some weight!

image

@MehdyKarimpour
Copy link
Contributor

@MehdyKarimpour MehdyKarimpour commented on 0669737 Nov 9, 2021 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.