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

Remove interface IDateTime and replace any use with CalDateTime #705

Merged
merged 6 commits into from
Feb 10, 2025

Conversation

minichma
Copy link
Collaborator

@minichma minichma commented Jan 22, 2025

The changes in this PR are in based on the discussion in #705 (comment), where we discussed whether arithmetics and timezone-related operations on should be moved out of CalDateTime in favor of a more flexible approach where we could even configure different timezone databases in a future iteration. We decided against it for reasons of available resources, so arithmetics are kept as part of CalDateTime. Based on that the PR implements several improvements, most notably:

  • Remove the interface IDateTime in favor of using CalDateTime directly.
  • Simplify the type hierarchy of CalDateTime, i.e. stop it inheriting from EncodableDataType
  • Get rid of CalDateTime.AssociatedObject

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 81.37255% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
Ical.Net/CalendarComponents/Alarm.cs 0% 4 Missing ⚠️
....Net/Serialization/DataTypes/DateTimeSerializer.cs 85% 1 Missing and 2 partials ⚠️
Ical.Net/DataTypes/CalDateTime.cs 89% 1 Missing and 1 partial ⚠️
Ical.Net/DataTypes/CalendarDataType.cs 0% 2 Missing ⚠️
...l.Net/Serialization/DataTypes/TriggerSerializer.cs 0% 2 Missing ⚠️
Ical.Net/VTimeZoneInfo.cs 0% 2 Missing ⚠️
Ical.Net/DataTypes/AlarmOccurrence.cs 0% 1 Missing ⚠️
Ical.Net/DataTypes/Trigger.cs 50% 1 Missing ⚠️
Ical.Net/Evaluation/RecurrenceUtil.cs 0% 1 Missing ⚠️
...cal.Net/Serialization/DataTypeSerializerFactory.cs 0% 0 Missing and 1 partial ⚠️

❌ Your project status has failed because the head coverage (65%) is below the target coverage (80%). You can increase the head coverage or adjust the target coverage.

Impacted file tree graph

@@         Coverage Diff         @@
##           main   #705   +/-   ##
===================================
- Coverage    65%    65%   -0%     
===================================
  Files       103    103           
  Lines      4659   4642   -17     
  Branches   1131   1130    -1     
===================================
- Hits       3028   3004   -24     
- Misses     1197   1200    +3     
- Partials    434    438    +4     
Files with missing lines Coverage Δ
Ical.Net/Calendar.cs 70% <ø> (ø)
Ical.Net/CalendarCollection.cs 57% <ø> (ø)
Ical.Net/CalendarComponents/CalendarEvent.cs 74% <100%> (ø)
Ical.Net/CalendarComponents/FreeBusy.cs 48% <100%> (ø)
Ical.Net/CalendarComponents/RecurringComponent.cs 65% <100%> (ø)
Ical.Net/CalendarComponents/Todo.cs 67% <100%> (ø)
Ical.Net/CalendarComponents/UniqueComponent.cs 56% <100%> (ø)
Ical.Net/DataTypes/ExceptionDates.cs 100% <ø> (ø)
Ical.Net/DataTypes/Period.cs 85% <100%> (ø)
Ical.Net/DataTypes/PeriodList.cs 88% <ø> (ø)
... and 26 more

... and 5 files with indirect coverage changes

@minichma minichma force-pushed the work/minichma/feature/remove_idatetime branch from a85dd77 to a09dcf2 Compare January 23, 2025 19:18
@@ -23,7 +23,7 @@ namespace Ical.Net.DataTypes;
/// This is because RFC 5545, Section 3.3.5, does not allow for fractional seconds.
/// </remarks>
/// </summary>
public sealed class CalDateTime : EncodableDataType, IComparable<CalDateTime>, IFormattable
public sealed class CalDateTime : IComparable<CalDateTime>, IFormattable
Copy link
Collaborator

@axunonb axunonb Jan 23, 2025

Choose a reason for hiding this comment

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

... or even struct? (not in this PR probably)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, struct would certainly be good. But we'd have to deal with all the nullability stuff first, which is not perfectly straight forward. Next step could then be to do all that also for Period, PeriodList and maybe others.

@@ -15,7 +15,7 @@ namespace Ical.Net.Utility;

internal static class DateUtil
{
public static DateTime GetSimpleDateTimeData(IDateTime dt)
public static DateTime GetSimpleDateTimeData(CalDateTime dt)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we remove this method? Using dt.Value is shorter and more clear

@minichma minichma force-pushed the work/minichma/feature/remove_idatetime branch from 1679c9f to 0d1cd25 Compare January 27, 2025 20:36
@axunonb
Copy link
Collaborator

axunonb commented Jan 31, 2025

This is PR is still in progress, right? Just asking because I'm assigned to review.

@minichma
Copy link
Collaborator Author

Yes, it is still work in progress. I'm not quiet convinced, this is the right approach. Will try to comment more this weekend.

@minichma
Copy link
Collaborator Author

minichma commented Feb 2, 2025

@axunonb I apologize for the delay, don't find sufficient time recently. I continued the discussion in #606 (reply in thread), as this is not really specific to this PR. Please let me know what you think!

@minichma
Copy link
Collaborator Author

minichma commented Feb 2, 2025

Based on the discussion in #705 (comment) we decided to proceed, so the PR should be ready for review.

@minichma minichma marked this pull request as ready for review February 2, 2025 19:20
@axunonb axunonb self-requested a review February 2, 2025 22:30
@axunonb
Copy link
Collaborator

axunonb commented Feb 2, 2025

public CalDateTime() { } should be internal or even private - nothing for the public API

@@ -107,7 +107,7 @@ public void Bug2033495()
}

/// <summary>
/// Tests bug #2938007 - involving the HasTime property in IDateTime values.
/// Tests bug #2938007 - involving the HasTime property in CalDateTime values.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Summary could be removed?

@@ -54,9 +54,9 @@ private void SetProperty<T>(string group, T value)
/// will be extrapolated.
/// </note>
/// </summary>
public virtual IDateTime? DtEnd
public virtual CalDateTime? DtEnd
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we now remove the aliases End => DtEnd and Start => DtStart and just use the more intuitive End and Start everywhere?
(The underlying Properties could stay unchanged)

@@ -15,7 +15,7 @@ public interface IUniqueComponent : ICalendarComponent

IList<Attendee> Attendees { get; set; }
IList<string> Comments { get; set; }
IDateTime DtStamp { get; set; }
CalDateTime DtStamp { get; set; }
Copy link
Collaborator

Choose a reason for hiding this comment

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

or just Stamp?

/// <inheritdoc cref="TzId"/>
/// <summary>
/// Gets the timezone name this time is in, if it references a timezone.
/// </summary>
/// <remarks>This is an alias for <see cref="TzId"/></remarks>
public string? TimeZoneName => TzId;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove the alias?

@@ -16,9 +16,6 @@ namespace Ical.Net.Utility;

internal static class DateUtil
{
public static DateTime GetSimpleDateTimeData(IDateTime dt)
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@@ -133,15 +133,15 @@ public virtual IList<string> TimeZoneNames
set => Properties.Set("TZNAME", value);
}

public virtual IDateTime DtStart
public virtual CalDateTime DtStart
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are many of these aliases, so maybe rather address remove the the Dt... properties in a separate PR

Copy link
Collaborator

@axunonb axunonb left a comment

Choose a reason for hiding this comment

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

Very nice. See few minor comments.

@axunonb axunonb merged commit f6f502f into main Feb 10, 2025
7 of 8 checks passed
@axunonb axunonb deleted the work/minichma/feature/remove_idatetime branch February 10, 2025 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants