ical.net icon indicating copy to clipboard operation
ical.net copied to clipboard

Replace public methods / properties using `DateTime` with `CalDateTime`

Open axunonb opened this issue 1 month ago • 2 comments

Here is a list of all public methods, fields, and properties (getters) in the project that use DateTime or DateTime?.

Type: Ical.Net.Calendar, Method: GetOccurrences
Type: Ical.Net.Calendar, Method: GetOccurrences
Type: Ical.Net.Calendar, Method: AddTimeZone
Type: Ical.Net.Calendar, Method: AddTimeZone
Type: Ical.Net.Calendar, Method: AddLocalTimeZone
Type: Ical.Net.CalendarCollection, Method: GetOccurrences
Type: Ical.Net.CalendarCollection, Method: GetOccurrences
Type: Ical.Net.CalendarExtensions, Method: GetIso8601WeekOfYear
Type: Ical.Net.CalendarExtensions, Method: GetIso8601YearOfWeek
Type: Ical.Net.IGetOccurrences, Method: GetOccurrences
Type: Ical.Net.IGetOccurrencesTyped, Method: GetOccurrences
Type: Ical.Net.VTimeZoneInfo, Method: GetOccurrences
Type: Ical.Net.Utility.DateUtil, Method: AsCalDateTime
Type: Ical.Net.Utility.DateUtil, Method: AddWeeks
Type: Ical.Net.Utility.DateUtil, Method: FirstDayOfWeek
Type: Ical.Net.Utility.DateUtil, Method: ToZonedDateTimeLeniently
Type: Ical.Net.Utility.DateUtil, Method: FromTimeZoneToTimeZone
Type: Ical.Net.Utility.DateUtil, Method: FromTimeZoneToTimeZone
Type: Ical.Net.Utility.DateUtil, Method: Truncate
Type: Ical.Net.Utility.DateUtil, Method: WeekOfMonth
Type: Ical.Net.Evaluation.Evaluator, Method: Evaluate
Type: Ical.Net.Evaluation.EventEvaluator, Method: Evaluate
Type: Ical.Net.Evaluation.IEvaluator, Method: Evaluate
Type: Ical.Net.Evaluation.PeriodListEvaluator, Method: Evaluate
Type: Ical.Net.Evaluation.RecurrencePatternEvaluator, Method: Evaluate
Type: Ical.Net.Evaluation.RecurringEvaluator, Method: Evaluate
Type: Ical.Net.Evaluation.TimeZoneInfoEvaluator, Method: Evaluate
Type: Ical.Net.Evaluation.TodoEvaluator, Method: Evaluate
Type: Ical.Net.DataTypes.CalDateTime, Method: op_Implicit
Type: Ical.Net.DataTypes.RecurrencePattern, Method: set_Until
Type: Ical.Net.DataTypes.RecurrencePattern, Property: Until
Type: Ical.Net.DataTypes.UtcOffset, Method: ToUtc
Type: Ical.Net.DataTypes.UtcOffset, Method: ToLocal
Type: Ical.Net.CalendarComponents.CalendarEvent, Method: GetOccurrences
Type: Ical.Net.CalendarComponents.Journal, Method: GetOccurrences
Type: Ical.Net.CalendarComponents.RecurringComponent, Method: GetOccurrences
Type: Ical.Net.CalendarComponents.Todo, Method: GetOccurrences
Type: Ical.Net.CalendarComponents.VTimeZone, Method: FromLocalTimeZone
Type: Ical.Net.CalendarComponents.VTimeZone, Method: FromSystemTimeZone
Type: Ical.Net.CalendarComponents.VTimeZone, Method: FromDateTimeZone
Type: Ical.Net.CalendarCollection+<>c__DisplayClass5_0, Field: startTime
Type: Ical.Net.CalendarCollection+<>c__DisplayClass5_0, Field: endTime
Type: Ical.Net.CalendarCollection+<>c__DisplayClass7_0`1, Field: startTime
Type: Ical.Net.CalendarCollection+<>c__DisplayClass7_0`1, Field: endTime
Type: Ical.Net.Evaluation.RecurrencePatternEvaluator+<>c__DisplayClass11_1, Field: d
Type: Ical.Net.Evaluation.RecurrencePatternEvaluator+<>c__DisplayClass11_2, Field: date
Type: Ical.Net.Evaluation.RecurrencePatternEvaluator+<>c__DisplayClass14_0, Field: date1
Type: Ical.Net.Evaluation.RecurrencePatternEvaluator+<>c__DisplayClass15_0, Field: date
Type: Ical.Net.Evaluation.RecurrencePatternEvaluator+<>c__DisplayClass8_0, Field: originalDate
Type: Ical.Net.Evaluation.RecurrencePatternEvaluator+<EnumerateDates>d__8, Field: <>3__originalDate
Type: Ical.Net.Evaluation.RecurrencePatternEvaluator+<EnumerateDates>d__8, Field: <>3__seedCopy
Type: Ical.Net.Evaluation.RecurrencePatternEvaluator+<EnumerateDates>d__8, Field: <>3__periodStart
Type: Ical.Net.Evaluation.RecurrencePatternEvaluator+<EnumerateDates>d__8, Field: <>3__periodEnd
Type: Ical.Net.Evaluation.RecurringEvaluator+<>c__DisplayClass5_0, Field: periodStart
Type: Ical.Net.Evaluation.RecurringEvaluator+<>c__DisplayClass5_0, Field: periodEnd
Type: Ical.Net.Evaluation.RecurringEvaluator+<>c__DisplayClass7_0, Field: periodStart
Type: Ical.Net.Evaluation.RecurringEvaluator+<>c__DisplayClass7_0, Field: periodEnd
Type: Ical.Net.CalendarComponents.VTimeZone+IntervalRecurrencePattern, Method: set_Until
Type: Ical.Net.CalendarComponents.VTimeZone+IntervalRecurrencePattern, Property: Until

The list is a starting point to decide, where we can leave DateTime, and where to replace it with IDateTime. #406 could be a good starting point

Click to toggle code that produces the list
public void FindDateTime()
{
    var assembly = Assembly.Load("Ical.Net"); // Load your assembly here
    var types = assembly.GetTypes();

    foreach (var type in types)
    {
        // Find methods with DateTime or DateTime? parameters
        var methods = type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static)
            .Where(m => m.GetParameters().Any(p => p.ParameterType == typeof(DateTime) || p.ParameterType == typeof(DateTime?)));

        foreach (var method in methods)
        {
            Console.WriteLine($"Type: {type.FullName}, Method: {method.Name}");
        }

        // Find public fields of type DateTime or DateTime?
        var fields = type.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static)
            .Where(f => f.FieldType == typeof(DateTime) || f.FieldType == typeof(DateTime?));

        foreach (var field in fields)
        {
            Console.WriteLine($"Type: {type.FullName}, Field: {field.Name}");
        }

        // Find public properties of type DateTime or DateTime? that are not getters-only
        var properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static)
            .Where(p => (p.PropertyType == typeof(DateTime) || p.PropertyType == typeof(DateTime?)) && p.CanWrite);

        foreach (var property in properties)
        {
            Console.WriteLine($"Type: {type.FullName}, Property: {property.Name}");
        }
    }
}

axunonb avatar Jan 22 '25 13:01 axunonb