Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Ical.Net.Tests/Calendars/Journal/JOURNAL3.ics
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//ABC Corporation//NONSGML My Product//EN
BEGIN:VJOURNAL
DTSTAMP:19970324T120000Z
UID:[email protected]
ORGANIZER;SENT-BY=;CN=JohnSmith;DIR="ldap://host.com:6666/
o=3DDC%20Associates,c=3DUS??(cn=3DJohn%20Smith)":MAILTO:[email protected]
STATUS:FINAL
CLASS:PRIVATE
CATEGORY:Project Report, XYZ, Weekly Meeting
DESCRIPTION:Project xyz Review Meeting Minutes\n
Agenda\n1. Review of project version 1.0 requirements.\n2.
Definition of project processes.\n3. Review of project schedule.\n
Participants: John Smith, Jane Doe, Jim Dandy\n-It was
decided that the requirements need to be signed off by
product marketing.\n-Project processes were accepted.\n
-Project schedule needs to account for scheduled holidays
and employee vacation time. Check with HR for specific
dates.\n-New schedule will be distributed by Friday.\n-
Next weeks meeting is cancelled. No meeting until 3/23.
SUMMARY:Project xyz Review Meeting
END:VJOURNAL
END:VCALENDAR
3 changes: 2 additions & 1 deletion Ical.Net.Tests/IcsFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ internal static string ReadStream(string manifestResource)
internal static string HourlyUntil1 => ReadStream("Ical.Net.Tests.Calendars.Recurrence.HourlyUntil1.ics");
internal static string Journal1 => ReadStream("Ical.Net.Tests.Calendars.Journal.JOURNAL1.ics");
internal static string Journal2 => ReadStream("Ical.Net.Tests.Calendars.Journal.JOURNAL2.ics");
internal static string Journal3 => ReadStream("Ical.Net.Tests.Calendars.Journal.JOURNAL3.ics");
internal static string Language1 => ReadStream("Ical.Net.Tests.Calendars.Serialization.Language1.ics");
internal static string Language2 => ReadStream("Ical.Net.Tests.Calendars.Serialization.Language2.ics");
internal static string Language3 => ReadStream("Ical.Net.Tests.Calendars.Serialization.Language3.ics");
Expand Down Expand Up @@ -168,4 +169,4 @@ internal static string ReadStream(string manifestResource)

internal static string LibicalIcalrecurTest => ReadStream("Ical.Net.Tests.contrib.libical.icalrecur_test.out");

}
}
13 changes: 12 additions & 1 deletion Ical.Net.Tests/JournalTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,15 @@ public void Journal2()
Assert.That(j.Start, Is.Null);
});
}
}

[Test, Category("Journal")]
public void Journal3()
{
var iCal = Calendar.Load(IcsFiles.Journal3);
ProgramTest.TestCal(iCal);
Assert.That(iCal.Journals, Has.Count.EqualTo(1));
var j = iCal.Journals.First();

Assert.That(j.Organizer.SentBy, Is.Null, "Expected Organizer's SENT-BY to be null, but it was not.");
}
}
36 changes: 27 additions & 9 deletions Ical.Net/DataTypes/Organizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Licensed under the MIT license.
//

#nullable enable
using System;
using System.Diagnostics;
using System.IO;
Expand All @@ -16,9 +17,17 @@
[DebuggerDisplay("{Value}")]
public class Organizer : EncodableDataType
{
public virtual Uri SentBy
public virtual Uri? SentBy
{
get => new Uri(Parameters.Get("SENT-BY"));
get
{
string sentBy = Parameters.Get("SENT-BY");
if (!string.IsNullOrWhiteSpace(sentBy))
{
return new Uri(sentBy);
}
return null;
}
set
{
if (value != null)
Expand All @@ -27,7 +36,7 @@
}
else
{
Parameters.Set("SENT-BY", (string) null);
Parameters.Remove("SENT-BY");
}
}
}
Expand All @@ -38,9 +47,18 @@
set => Parameters.Set("CN", value);
}

public virtual Uri DirectoryEntry
public virtual Uri? DirectoryEntry
{
get => new Uri(Parameters.Get("DIR"));
get
{
string dir = Parameters.Get("DIR");
if (!string.IsNullOrWhiteSpace(dir))
{
return new Uri(dir);
}

return null;
}
set
{
if (value != null)
Expand All @@ -49,12 +67,12 @@
}
else
{
Parameters.Set("DIR", (string) null);
Parameters.Remove("DIR");
}
}
}

public virtual Uri Value { get; set; }
public virtual Uri? Value { get; set; }

public Organizer() { }

Expand All @@ -66,12 +84,12 @@
}

var serializer = new OrganizerSerializer();
CopyFrom(serializer.Deserialize(new StringReader(value)) as ICopyable);

Check warning on line 87 in Ical.Net/DataTypes/Organizer.cs

View workflow job for this annotation

GitHub Actions / coverage

Possible null reference argument for parameter 'obj' in 'void Organizer.CopyFrom(ICopyable obj)'.

Check warning on line 87 in Ical.Net/DataTypes/Organizer.cs

View workflow job for this annotation

GitHub Actions / coverage

Possible null reference argument for parameter 'obj' in 'void Organizer.CopyFrom(ICopyable obj)'.

Check warning on line 87 in Ical.Net/DataTypes/Organizer.cs

View workflow job for this annotation

GitHub Actions / coverage

Possible null reference argument for parameter 'obj' in 'void Organizer.CopyFrom(ICopyable obj)'.

Check warning on line 87 in Ical.Net/DataTypes/Organizer.cs

View workflow job for this annotation

GitHub Actions / coverage

Possible null reference argument for parameter 'obj' in 'void Organizer.CopyFrom(ICopyable obj)'.

Check warning on line 87 in Ical.Net/DataTypes/Organizer.cs

View workflow job for this annotation

GitHub Actions / coverage

Possible null reference argument for parameter 'obj' in 'void Organizer.CopyFrom(ICopyable obj)'.

Check warning on line 87 in Ical.Net/DataTypes/Organizer.cs

View workflow job for this annotation

GitHub Actions / coverage

Possible null reference argument for parameter 'obj' in 'void Organizer.CopyFrom(ICopyable obj)'.

Check warning on line 87 in Ical.Net/DataTypes/Organizer.cs

View workflow job for this annotation

GitHub Actions / tests

Possible null reference argument for parameter 'obj' in 'void Organizer.CopyFrom(ICopyable obj)'.

Check warning on line 87 in Ical.Net/DataTypes/Organizer.cs

View workflow job for this annotation

GitHub Actions / tests

Possible null reference argument for parameter 'obj' in 'void Organizer.CopyFrom(ICopyable obj)'.

Check warning on line 87 in Ical.Net/DataTypes/Organizer.cs

View workflow job for this annotation

GitHub Actions / tests

Possible null reference argument for parameter 'obj' in 'void Organizer.CopyFrom(ICopyable obj)'.

Check warning on line 87 in Ical.Net/DataTypes/Organizer.cs

View workflow job for this annotation

GitHub Actions / tests

Possible null reference argument for parameter 'obj' in 'void Organizer.CopyFrom(ICopyable obj)'.

Check warning on line 87 in Ical.Net/DataTypes/Organizer.cs

View workflow job for this annotation

GitHub Actions / tests

Possible null reference argument for parameter 'obj' in 'void Organizer.CopyFrom(ICopyable obj)'.

Check warning on line 87 in Ical.Net/DataTypes/Organizer.cs

View workflow job for this annotation

GitHub Actions / tests

Possible null reference argument for parameter 'obj' in 'void Organizer.CopyFrom(ICopyable obj)'.
}

protected bool Equals(Organizer other) => Equals(Value, other.Value);

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj))
{
Expand Down Expand Up @@ -100,4 +118,4 @@
Value = o.Value;
}
}
}
}
Loading