Skip to content

Commit

Permalink
Fix not throwing due to overflow while writing NodaTime's period (#5894)
Browse files Browse the repository at this point in the history
Fixes #5893

(cherry picked from commit e6c166b)
  • Loading branch information
vonzshik committed Oct 21, 2024
1 parent b977012 commit 56688dd
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 20 deletions.
26 changes: 18 additions & 8 deletions src/Npgsql.NodaTime/Internal/PeriodConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,24 @@ protected override void WriteCore(PgWriter writer, Period value)
{
// We have to normalize the value as otherwise we might get a value with 0 everything except for ticks, which we ignore
value = value.Normalize();
// Note that the end result must be long
// see #3438
var microsecondsInDay =
(((value.Hours * NodaConstants.MinutesPerHour + value.Minutes) * NodaConstants.SecondsPerMinute + value.Seconds) * NodaConstants.MillisecondsPerSecond + value.Milliseconds) * 1000 +
value.Nanoseconds / 1000; // Take the microseconds, discard the nanosecond remainder

writer.WriteInt64(microsecondsInDay);
writer.WriteInt32(value.Weeks * 7 + value.Days); // days
writer.WriteInt32(value.Years * 12 + value.Months); // months
try
{
checked
{
// Note that the end result must be long
// see #3438
var microsecondsInDay =
(((value.Hours * NodaConstants.MinutesPerHour + value.Minutes) * NodaConstants.SecondsPerMinute + value.Seconds) * NodaConstants.MillisecondsPerSecond + value.Milliseconds) * 1000 +
value.Nanoseconds / 1000; // Take the microseconds, discard the nanosecond remainder
writer.WriteInt64(microsecondsInDay);
writer.WriteInt32(value.Weeks * 7 + value.Days); // days
writer.WriteInt32(value.Years * 12 + value.Months); // months
}
}
catch (OverflowException ex)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 12, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 12, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 12, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 12, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Debug, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Debug, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Debug, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Debug, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 13, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 13, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 13, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 13, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 14, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 14, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 14, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 14, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 15, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 15, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 15, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 15, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, netcoreapp3.1)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, netcoreapp3.1)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, netcoreapp3.1)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, netcoreapp3.1)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (macos-12, 14, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (macos-12, 14, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (macos-12, 14, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (macos-12, 14, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 12, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 12, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 12, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 12, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 15, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 15, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 15, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 15, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 13, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 13, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 13, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 13, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 16, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 16, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 16, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 16, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 14, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 14, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 14, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 53 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 14, Release, net8.0)

The type or namespace name 'OverflowException' could not be found (are you missing a using directive or an assembly reference?)
{
throw new ArgumentException(NpgsqlNodaTimeStrings.CannotWritePeriodDueToOverflow, ex);

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 12, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 12, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 12, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 12, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 12, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 12, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Debug, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Debug, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Debug, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Debug, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Debug, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Debug, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 13, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 13, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 13, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 13, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 13, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 13, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 14, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 14, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 14, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 14, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 14, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 14, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 15, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 15, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 15, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 15, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 15, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 15, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, netcoreapp3.1)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, netcoreapp3.1)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, netcoreapp3.1)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, netcoreapp3.1)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, netcoreapp3.1)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, netcoreapp3.1)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 16, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (macos-12, 14, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (macos-12, 14, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (macos-12, 14, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (macos-12, 14, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (macos-12, 14, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (macos-12, 14, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 12, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 12, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 12, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 12, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 12, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 12, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 15, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 15, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 15, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 15, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 15, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 15, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 13, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 13, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 13, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 13, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 13, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 13, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 16, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 16, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 16, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 16, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 16, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 16, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 14, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 14, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 14, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 14, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 14, Release, net8.0)

The type or namespace name 'ArgumentException' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in src/Npgsql.NodaTime/Internal/PeriodConverter.cs

View workflow job for this annotation

GitHub Actions / build (windows-2022, 14, Release, net8.0)

The name 'NpgsqlNodaTimeStrings' does not exist in the current context
}
}
}
53 changes: 41 additions & 12 deletions src/Npgsql.NodaTime/Properties/NpgsqlNodaTimeStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Npgsql.NodaTime/Properties/NpgsqlNodaTimeStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@
<data name="CannotReadIntervalWithMonthsAsDuration" xml:space="preserve">
<value>Cannot read PostgreSQL interval with non-zero months to NodaTime Duration. Try reading as a NodaTime Period instead.</value>
</data>
<data name="CannotWritePeriodDueToOverflow" xml:space="preserve">
<value>Cannot write NodaTime's Period because it's out of range for the PG interval type.</value>
</data>
</root>
12 changes: 12 additions & 0 deletions test/Npgsql.PluginTests/NodaTimeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,18 @@ public async Task Normalize_period_on_write()
Assert.That(dbValue, Is.EqualTo(expectedAfterRoundtrip));
}

[Test]
public async Task Period_write_throw_on_overflow()
{
var periodBuilder = new PeriodBuilder
{
Years = int.MaxValue
};
var ex = await AssertTypeUnsupportedWrite<Period, ArgumentException>(periodBuilder.Build(), "interval");
Assert.That(ex.Message, Is.EqualTo(NpgsqlNodaTimeStrings.CannotWritePeriodDueToOverflow));
Assert.That(ex.InnerException, Is.TypeOf<OverflowException>());
}

#endregion Interval

#region Support
Expand Down

0 comments on commit 56688dd

Please sign in to comment.