Skip to content

Conversation

@axunonb
Copy link
Collaborator

@axunonb axunonb commented Apr 7, 2025

Now < 100 files left for NRT :) - 30% done

@codecov
Copy link

codecov bot commented Apr 7, 2025

Codecov Report

Attention: Patch coverage is 35.71429% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
Ical.Net/DataTypes/AlarmOccurrence.cs 0% 5 Missing ⚠️
Ical.Net/CalendarComponents/Alarm.cs 0% 4 Missing ⚠️
Ical.Net/DataTypes/Attachment.cs 43% 1 Missing and 3 partials ⚠️
Ical.Net/DataTypes/PeriodList.cs 33% 0 Missing and 2 partials ⚠️
Ical.Net/DataTypes/Attendee.cs 0% 1 Missing ⚠️
Ical.Net/DataTypes/CalendarDataType.cs 67% 1 Missing ⚠️
Ical.Net/DataTypes/Duration.cs 75% 1 Missing ⚠️

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

Impacted file tree graph

@@         Coverage Diff         @@
##           main   #762   +/-   ##
===================================
- Coverage    67%    67%   -0%     
===================================
  Files       104    104           
  Lines      4508   4498   -10     
  Branches   1103   1107    +4     
===================================
- Hits       3012   3001   -11     
- Misses     1065   1068    +3     
+ Partials    431    429    -2     
Files with missing lines Coverage Δ
Ical.Net/DataTypes/Organizer.cs 44% <100%> (ø)
Ical.Net/Evaluation/TodoEvaluator.cs 62% <ø> (ø)
Ical.Net/DataTypes/Attendee.cs 70% <0%> (+2%) ⬆️
Ical.Net/DataTypes/CalendarDataType.cs 49% <67%> (+3%) ⬆️
Ical.Net/DataTypes/Duration.cs 71% <75%> (-6%) ⬇️
Ical.Net/DataTypes/PeriodList.cs 84% <33%> (-4%) ⬇️
Ical.Net/CalendarComponents/Alarm.cs 16% <0%> (-1%) ⬇️
Ical.Net/DataTypes/Attachment.cs 76% <43%> (-1%) ⬇️
Ical.Net/DataTypes/AlarmOccurrence.cs 0% <0%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@axunonb axunonb force-pushed the axunonb/wip/pr/datatypes-nrt branch from d2d1822 to d482732 Compare April 7, 2025 12:00
@axunonb axunonb marked this pull request as ready for review April 7, 2025 12:03
@axunonb axunonb requested review from Copilot and minichma and removed request for Copilot April 7, 2025 12:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

Ical.Net/Evaluation/TimeZoneInfoEvaluator.cs:27

  • The null-check for TimeZoneInfo was removed; consider restoring or adjusting this check to prevent potential NullReferenceExceptions if TimeZoneInfo remains unset.
if (TimeZoneInfo == null)

Ical.Net/DataTypes/PeriodList.cs:131

  • Using the null-conditional operator may silently fail to remove an item if Periods is null; ensure that Periods is initialized or handle the null case explicitly.
public void RemoveAt(int index) => Periods?.RemoveAt(index);

}

public int CompareTo(AlarmOccurrence other) => Period.CompareTo(other.Period);
public int CompareTo(AlarmOccurrence? other)
Copy link

Copilot AI Apr 7, 2025

Choose a reason for hiding this comment

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

[nitpick] In the CompareTo method, returning 1 when other or its Period is null could result in inconsistent ordering; consider defining explicit ordering when both Period properties are null.

Copilot uses AI. Check for mistakes.
@axunonb axunonb changed the title Enable NRT for AlarmOccurrence,Attachment, Attendee, CalendarDataType, Duration Enable NRT for AlarmOccurrence,Attachment, Attendee, CalendarDataType, Duration, ICalendarDataType, ICalendarParameterCollectionContainer Apr 7, 2025
@axunonb axunonb force-pushed the axunonb/wip/pr/datatypes-nrt branch from ff53acc to 78f6218 Compare April 7, 2025 13:28
Copy link
Collaborator

@minichma minichma 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, just a few minor comments.

/// </summary>
/// <exception cref="System.FormatException">Thrown if the value is not a valid duration.</exception>
public static Duration Parse(string value) => (Duration)new DurationSerializer().Deserialize(new StringReader(value));
public static Duration? Parse(string value) =>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unfortunately we are somewhat inconsistent here. According to the XML doc the method should throw if the passed string is not a valid duration. DurationSerializer throws in some cases and returns null in other. I'd generally suggest to throw and return a non-nullable Duration.

foreach (var p in list)
{
Add(p.Copy<Period>());
if (p != null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

By not copying null values the copy will not be equal to the original. Maybe to do something like Add(p?.Copy<Period>())?

EnsureConsistentTimezoneAndPeriodKind(item);
if (Periods.Contains(item)) return;
Periods.Insert(index, item);
Periods?.Insert(index, item);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This ? hast just been removed one commit earlier.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed

&& Members.SequenceEqual(other.Members)
&& DelegatedTo.SequenceEqual(other.DelegatedTo)
&& DelegatedFrom.SequenceEqual(other.DelegatedFrom);
&& (DelegatedTo?.SequenceEqual(other.DelegatedTo ?? Enumerable.Empty<string>()) ?? other.DelegatedTo == null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comparison is not commutative this way. I.e. if one is null and the other is empty, then the comparison is not symmetrical. Not sure though, whether an empty sequence should equal null. Usually they're considered different.

return Data == null
? firstPart
: firstPart && Data.SequenceEqual(other.Data);
: firstPart && other?.Data != null && Data.SequenceEqual(other.Data);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comparison is not correct. If other?.Data == null, then this.Data is ignored, even if it contains data.


var recurringPeriods1 = rpe1.Evaluate(new CalDateTime(start), start, end, default).ToList();
var recurringPeriods2 = rpe2.Evaluate(new CalDateTime(start), start, end, default).ToList();
var recurringPeriods1 = rpe1.Evaluate(new CalDateTime(start), start, end, null).ToList();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, better. I started with default because the options should have been a value type at first.

public int CompareTo(AlarmOccurrence other) => Period.CompareTo(other.Period);
public int CompareTo(AlarmOccurrence? other)
{
if (other == null || other.Period == null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if other.Period == null and this.Period == null?

@axunonb
Copy link
Collaborator Author

axunonb commented Apr 7, 2025

Love your reviews, thanks!

@axunonb axunonb requested a review from minichma April 7, 2025 17:59
minichma
minichma previously approved these changes Apr 7, 2025
Copy link
Collaborator

@minichma minichma 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!

public static Duration? Parse(string value) =>
(Duration?) new DurationSerializer().Deserialize(new StringReader(value));
public static Duration Parse(string value) =>
(Duration) new DurationSerializer().Deserialize(new StringReader(value))!; // throws if null
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually it doesn't throw in all cases as of today (

) although it should.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 7, 2025

@axunonb axunonb merged commit e44021e into main Apr 7, 2025
5 of 7 checks passed
@axunonb axunonb deleted the axunonb/wip/pr/datatypes-nrt branch April 7, 2025 19:12
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.

3 participants