Skip to content

Commit

Permalink
chg - Corrected daylight parsing
Browse files Browse the repository at this point in the history
---

Type: chg
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Sep 23, 2024
1 parent 420782f commit 082eff8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions VisualCard.Calendar/Parsers/VCalendarParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,15 @@ public Parts.Calendar Parse()
internal void ValidateCalendar(Parts.Calendar calendar)
{
// Track the required root fields
string[] expectedFields = [VCalendarConstants._productIdSpecifier];
string[] expectedFields =
calendar.CalendarVersion.Major == 2 ? [VCalendarConstants._productIdSpecifier] : [];
if (!ValidateComponent(ref expectedFields, out string[] actualFields, calendar))
throw new InvalidDataException($"The following keys [{string.Join(", ", expectedFields)}] are required in the root calendar. Got [{string.Join(", ", actualFields)}].");

// Now, track the individual components starting from events
string[] expectedEventFields =
calendar.CalendarVersion.Major == 2 ?
[VCalendarConstants._uidSpecifier, VCalendarConstants._dateStampSpecifier] :
[VCalendarConstants._uidSpecifier];
[VCalendarConstants._uidSpecifier, VCalendarConstants._dateStampSpecifier] : [];
string[] expectedTodoFields = expectedEventFields;
foreach (var eventInfo in calendar.events)
{
Expand Down
4 changes: 2 additions & 2 deletions VisualCard.Calendar/Parsers/VCalendarParserTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ internal static bool EnumArrayTypeSupported(CalendarPartsArrayEnum partsArrayEnu
CalendarPartsArrayEnum.TimeZoneName => calendarVersion.Major == 2 && TypeMatch(componentType, typeof(CalendarTimeZone)),
CalendarPartsArrayEnum.TimeZoneOffsetFrom => calendarVersion.Major == 2 && TypeMatch(componentType, typeof(CalendarStandard), typeof(CalendarDaylight)),
CalendarPartsArrayEnum.TimeZoneOffsetTo => calendarVersion.Major == 2 && TypeMatch(componentType, typeof(CalendarStandard), typeof(CalendarDaylight)),
CalendarPartsArrayEnum.RecDate => calendarVersion.Major == 2 && TypeMatch(componentType, typeof(Parts.Calendar)),
CalendarPartsArrayEnum.Daylight => calendarVersion.Major == 1 && TypeMatch(componentType, typeof(CalendarEvent), typeof(CalendarTodo), typeof(CalendarJournal), typeof(CalendarStandard), typeof(CalendarDaylight)),
CalendarPartsArrayEnum.RecDate => calendarVersion.Major == 2 && TypeMatch(componentType, typeof(CalendarEvent), typeof(CalendarTodo), typeof(CalendarJournal), typeof(CalendarStandard), typeof(CalendarDaylight)),
CalendarPartsArrayEnum.Daylight => calendarVersion.Major == 1 && TypeMatch(componentType, typeof(Parts.Calendar)),
CalendarPartsArrayEnum.NonstandardNames => true,
_ =>
throw new InvalidOperationException("Invalid parts array enumeration type to get supported value"),
Expand Down

0 comments on commit 082eff8

Please sign in to comment.