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

Period in RDate not fully supported in serialization #491

Closed
matzeboe opened this issue Apr 23, 2020 · 1 comment · Fixed by #595
Closed

Period in RDate not fully supported in serialization #491

matzeboe opened this issue Apr 23, 2020 · 1 comment · Fixed by #595

Comments

@matzeboe
Copy link

The serializer does not fully support RDates with periods.
When parsing an RDate with a given period everything is fine but wehn it is serialized only the date is present. Information about duration etc. is lost.

E.g.:
RDATE;VALUE=PERIOD:20170103T020000Z/20170103T021500Z,20170215T010000Z/PT3H
becomes
RDATE;VALUE=PERIOD:20170103T020000Z,20170215T010000Z

This leads to anther problem: If we parse a VCard in order to make changes, serialize it for storage and parse it again when we use it the next time, the information about periods (duration etc.) in rdates is completely lost now.

public void RDatePeriodNotSupported()
        {
            const string ical =
        @"BEGIN:VCALENDAR
PRODID:-//ddaysoftware.com//NONSGML DDay.iCal 1.0//EN
VERSION:2.0
BEGIN:VEVENT
DTSTART:20160829T080000
DTEND:20160829T090000
RDATE;VALUE=PERIOD:20170103T020000Z/20170103T021500Z,20170215T010000Z/PT3H
SEQUENCE:0
SUMMARY:Do your cardio
UID:abab717c-1786-4efc-87dd-6859c2b48eb6
END:VEVENT
END:VCALENDAR";

            var collection = Ical.Net.Calendar.Load(ical);
            //var firstEvent = collection.Events.First();
            var serializer = new Ical.Net.Serialization.CalendarSerializer(new Ical.Net.Serialization.SerializationContext());
            var serialized = serializer.SerializeToString(collection);

            Console.WriteLine(serialized);
            Console.WriteLine("Problem: The serialized calendar does not contain the proper period information from RDate (Only the date is present now)).");
            Console.WriteLine("Due to examples in RFC-5545 this is allowed (https://tools.ietf.org/html/rfc5545#section-3.8.5.2)");

            //The following part shows that information is lost:
            var collection2 = Ical.Net.Calendar.Load(serialized);
            var durationFromFirstParsing = collection.Events.First().RecurrenceDates.First().First().Duration;
            var durationFromSecondParsing = collection2.Events.First().RecurrenceDates.First().First().Duration;
            System.Diagnostics.Debug.Assert(durationFromFirstParsing == durationFromSecondParsing);

            Console.ReadKey();
        }
@s3mic0lin
Copy link
Contributor

Created pull request #528 to fix this issue.

@matzeboe Can you confirm this fixes your issue?

axunonb added a commit that referenced this issue Oct 13, 2024
* Update the repository from fork `laget.se/ical net` 

**Apply the following change after the update:**

* Remove net5.0 as target framework from all lprojects
* Update nuget-specific settings
  * Update icon.png file used in Ical.Net.nuspec
  * Update package metadata
  * Remove net5.0 package target framework
  * Update README.md to reflect the current project state with ical-org
* Fix: Update publish.yml to create deterministic builds for packages,
update action versions
* Update GitHub actions to reflect the changed main branch name
* Update `readme.md`
* Update CI workflows `publish.yml` and `tests.yml`
  - Changed `runs-on` to `ubuntu-latest`.
  - Added `fetch-depth: 0` to `actions/checkout@v4` in both workflows.
  - Added `Get version tag` step in `publish.yml`.
  - Included `-p:nowarn=1591` in `Build` steps to suppress warnings.
  - Changed `Test` verbosity to `quiet` in both workflows.
- Updated `Build and pack for publishing` in `publish.yml` to use
`VERSION`.
- Updated `Store artifacts` step in `publish.yml` for new naming
convention.
- Updated `Push package to NuGet` step in `publish.yml` to use
`VERSION`.
* Update ProdId constant and NodaTime package version
* Add back assembly signing to projects and include strong name key
* Update `Ical.Net.Tests.csproj` and `Ical.Net.csproj` to include
assembly signing by adding `SignAssembly` and
`AssemblyOriginatorKeyFile` properties.
* Replace `InternalsVisibleTo` with `AssemblyAttribute` including a
public key in `Ical.Net.csproj`.
  * Add `IcalNetStrongnameKey.snk` for strong name key.
  * Move InternalsVisibleTo from AssemblyInfo.cs to project file
* Add class `RegexDefaults` and update all Regex with
`RegexDefaults.Timeout` which is set to 200 milliseconds

**This PR closes the following PRs which have previously been merged
into `laget.se/ical net`**
Closes #491
Closes #443
Closes #525
Closes #528
Closes #571 
Closes #579
Closes #584
Closes #595
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 a pull request may close this issue.

2 participants