Skip to content
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

Replace public methods / properties using DateTime with CalDateTime #703

Open
axunonb opened this issue Jan 22, 2025 · 2 comments
Open

Replace public methods / properties using DateTime with CalDateTime #703

axunonb opened this issue Jan 22, 2025 · 2 comments

Comments

@axunonb
Copy link
Collaborator

axunonb commented Jan 22, 2025

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}");
        }
    }
}
@minichma
Copy link
Collaborator

minichma commented Jan 22, 2025

@axunonb I started some effort in this direction end of last year. See #704 and #705

@axunonb axunonb changed the title Replace public methods / properties using DateTime with IDateTime Replace public methods / properties using DateTime with CalDateTime Jan 22, 2025
@axunonb
Copy link
Collaborator Author

axunonb commented Jan 23, 2025

#704 and #705 are significant, and I'm happy to see #406 gets closed. Excellent job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants