diff --git a/Ical.Net/DataTypes/CalDateTime.cs b/Ical.Net/DataTypes/CalDateTime.cs
index 10a891fd7..7fa81b469 100644
--- a/Ical.Net/DataTypes/CalDateTime.cs
+++ b/Ical.Net/DataTypes/CalDateTime.cs
@@ -228,7 +228,7 @@ private void CopyFrom(CalDateTime calDt)
_tzId = calDt._tzId;
}
- public bool Equals(CalDateTime other) => this == other;
+ public bool Equals(CalDateTime? other) => this == other;
///
public override bool Equals(object? obj)
@@ -598,22 +598,22 @@ public CalDateTime AddDays(int days)
///
/// Returns if the current instance is less than .
///
- public bool LessThan(CalDateTime dt) => this < dt;
+ public bool LessThan(CalDateTime? dt) => this < dt;
///
/// Returns if the current instance is greater than .
///
- public bool GreaterThan(CalDateTime dt) => this > dt;
+ public bool GreaterThan(CalDateTime? dt) => this > dt;
///
/// Returns if the current instance is less than or equal to .
///
- public bool LessThanOrEqual(CalDateTime dt) => this <= dt;
+ public bool LessThanOrEqual(CalDateTime? dt) => this <= dt;
///
/// Returns if the current instance is greater than or equal to .
///
- public bool GreaterThanOrEqual(CalDateTime dt) => this >= dt;
+ public bool GreaterThanOrEqual(CalDateTime? dt) => this >= dt;
///
/// Compares the current instance with another object and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other CalDateTime.
diff --git a/Ical.Net/Evaluation/EvaluationException.cs b/Ical.Net/Evaluation/EvaluationException.cs
index 5d592806a..78eaccdb8 100644
--- a/Ical.Net/Evaluation/EvaluationException.cs
+++ b/Ical.Net/Evaluation/EvaluationException.cs
@@ -3,6 +3,7 @@
// Licensed under the MIT license.
//
+#nullable enable
using System;
namespace Ical.Net.Evaluation;
diff --git a/Ical.Net/Evaluation/EvaluationLimitExceededException.cs b/Ical.Net/Evaluation/EvaluationLimitExceededException.cs
index f86fb1fb9..ceedf29dc 100644
--- a/Ical.Net/Evaluation/EvaluationLimitExceededException.cs
+++ b/Ical.Net/Evaluation/EvaluationLimitExceededException.cs
@@ -3,6 +3,7 @@
// Licensed under the MIT license.
//
+#nullable enable
namespace Ical.Net.Evaluation;
///
diff --git a/Ical.Net/Evaluation/EvaluationOptions.cs b/Ical.Net/Evaluation/EvaluationOptions.cs
index da8bf5bb0..17e7ceb14 100644
--- a/Ical.Net/Evaluation/EvaluationOptions.cs
+++ b/Ical.Net/Evaluation/EvaluationOptions.cs
@@ -3,7 +3,9 @@
// Licensed under the MIT license.
//
+#nullable enable
namespace Ical.Net.Evaluation;
+
public class EvaluationOptions
{
///
@@ -12,7 +14,7 @@ public class EvaluationOptions
///
///
/// This option only applies to the evaluation of RecurrencePatterns.
- ///
+ ///
/// If the specified number of increments is exceeded without finding a recurrence, an
/// exception of type will be thrown.
///
diff --git a/Ical.Net/Evaluation/Evaluator.cs b/Ical.Net/Evaluation/Evaluator.cs
index 9569f3fab..c967bb96b 100644
--- a/Ical.Net/Evaluation/Evaluator.cs
+++ b/Ical.Net/Evaluation/Evaluator.cs
@@ -48,5 +48,5 @@ protected void IncrementDate(ref CalDateTime dt, RecurrencePattern pattern, int
}
}
- public abstract IEnumerable Evaluate(CalDateTime referenceDate, CalDateTime? periodStart, CalDateTime? periodEnd, EvaluationOptions options);
+ public abstract IEnumerable Evaluate(CalDateTime referenceDate, CalDateTime? periodStart, CalDateTime? periodEnd, EvaluationOptions? options);
}
diff --git a/Ical.Net/Evaluation/IEvaluator.cs b/Ical.Net/Evaluation/IEvaluator.cs
index 8232aa70a..92a8e27e1 100644
--- a/Ical.Net/Evaluation/IEvaluator.cs
+++ b/Ical.Net/Evaluation/IEvaluator.cs
@@ -37,5 +37,5 @@ public interface IEvaluator
/// A sequence of objects for
/// each date/time when this item occurs/recurs.
///
- IEnumerable Evaluate(CalDateTime referenceDate, CalDateTime? periodStart, CalDateTime? periodEnd, EvaluationOptions options);
+ IEnumerable Evaluate(CalDateTime referenceDate, CalDateTime? periodStart, CalDateTime? periodEnd, EvaluationOptions? options);
}
diff --git a/Ical.Net/Evaluation/RecurrenceUtil.cs b/Ical.Net/Evaluation/RecurrenceUtil.cs
index 594a8ed4d..78dbf154c 100644
--- a/Ical.Net/Evaluation/RecurrenceUtil.cs
+++ b/Ical.Net/Evaluation/RecurrenceUtil.cs
@@ -3,21 +3,20 @@
// Licensed under the MIT license.
//
-using System;
+#nullable enable
using System.Collections.Generic;
using System.Linq;
using Ical.Net.CalendarComponents;
using Ical.Net.DataTypes;
-using Ical.Net.Utility;
namespace Ical.Net.Evaluation;
internal class RecurrenceUtil
{
- public static IEnumerable GetOccurrences(IRecurrable recurrable, CalDateTime dt, EvaluationOptions options = default) => GetOccurrences(recurrable,
+ public static IEnumerable GetOccurrences(IRecurrable recurrable, CalDateTime dt, EvaluationOptions? options = null) => GetOccurrences(recurrable,
new CalDateTime(dt.Date), new CalDateTime(dt.Date.AddDays(1)), options);
- public static IEnumerable GetOccurrences(IRecurrable recurrable, CalDateTime periodStart, CalDateTime periodEnd, EvaluationOptions options = default)
+ public static IEnumerable GetOccurrences(IRecurrable recurrable, CalDateTime? periodStart, CalDateTime? periodEnd, EvaluationOptions? options = null)
{
var evaluator = recurrable.Evaluator;
if (evaluator == null || recurrable.Start == null)
@@ -43,7 +42,9 @@ from p in periods
let endTime = p.EndTime ?? p.StartTime
where
(((periodStart == null) || endTime.GreaterThan(periodStart)) && ((periodEnd == null) || p.StartTime.LessThan(periodEnd)) ||
- (periodStart.Equals(periodEnd) && p.StartTime.LessThanOrEqual(periodStart) && endTime.GreaterThan(periodEnd))) || //A period that starts at the same time it ends
+ (periodStart != null && periodStart.Equals(periodEnd)
+ && p.StartTime.LessThanOrEqual(periodStart)
+ && endTime.GreaterThan(periodEnd))) || //A period that starts at the same time it ends
(p.StartTime.Equals(endTime) && p.StartTime.Equals(periodStart)) //An event that starts at the same time it ends
select new Occurrence(recurrable, p);
@@ -56,16 +57,16 @@ from p in periods
switch (p.Frequency)
{
case FrequencyType.Minutely:
- return new bool?[] { false, null, false, false, false, false, false, true, false };
+ return [false, null, false, false, false, false, false, true, false];
case FrequencyType.Hourly:
- return new bool?[] { false, null, false, false, false, false, true, true, false };
+ return [false, null, false, false, false, false, true, true, false];
case FrequencyType.Daily:
- return new bool?[] { false, null, null, false, false, true, true, true, false };
+ return [false, null, null, false, false, true, true, true, false];
case FrequencyType.Weekly:
- return new bool?[] { false, null, null, null, true, true, true, true, false };
+ return [false, null, null, null, true, true, true, true, false];
case FrequencyType.Monthly:
{
- var row = new bool?[] { false, null, null, true, true, true, true, true, false };
+ bool?[] row = [false, null, null, true, true, true, true, true, false];
// Limit if BYMONTHDAY is present; otherwise, special expand for MONTHLY.
if (p.ByMonthDay.Count > 0)
@@ -77,7 +78,7 @@ from p in periods
}
case FrequencyType.Yearly:
{
- var row = new bool?[] { true, true, true, true, true, true, true, true, false };
+ bool?[] row = [true, true, true, true, true, true, true, true, false];
// Limit if BYYEARDAY or BYMONTHDAY is present; otherwise,
// special expand for WEEKLY if BYWEEKNO present; otherwise,
@@ -91,7 +92,7 @@ from p in periods
return row;
}
default:
- return new bool?[] { false, null, false, false, false, false, false, false, false };
+ return [false, null, false, false, false, false, false, false, false];
}
}
}
diff --git a/Ical.Net/Evaluation/RecurringEvaluator.cs b/Ical.Net/Evaluation/RecurringEvaluator.cs
index 4f576a12f..d1aa9549a 100644
--- a/Ical.Net/Evaluation/RecurringEvaluator.cs
+++ b/Ical.Net/Evaluation/RecurringEvaluator.cs
@@ -4,7 +4,6 @@
//
#nullable enable
-using System;
using System.Collections.Generic;
using System.Linq;
using Ical.Net.CalendarComponents;