-
Notifications
You must be signed in to change notification settings - Fork 248
Enable NRT for AlarmOccurrence,Attachment, Attendee, CalendarDataType, Duration, ICalendarDataType, ICalendarParameterCollectionContainer
#762
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
Changes from 8 commits
7735978
c659a72
5592cc9
d10d886
d482732
639b47f
78f6218
80c8287
4e0333c
030f32f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| // Licensed under the MIT license. | ||
| // | ||
|
|
||
| #nullable enable | ||
| using System; | ||
| using Ical.Net.CalendarComponents; | ||
|
|
||
|
|
@@ -18,16 +19,16 @@ | |
| /// </remarks> | ||
| public class AlarmOccurrence : IComparable<AlarmOccurrence> | ||
| { | ||
| public Period Period { get; set; } | ||
| public Period? Period { get; set; } | ||
|
|
||
| public IRecurringComponent Component { get; set; } | ||
| public IRecurringComponent? Component { get; set; } | ||
|
|
||
| public Alarm Alarm { get; set; } | ||
| public Alarm? Alarm { get; set; } | ||
|
|
||
| public CalDateTime DateTime | ||
| public CalDateTime? DateTime | ||
| { | ||
| get => Period.StartTime; | ||
| set => Period = new Period(value); | ||
| get => Period?.StartTime; | ||
| set => Period = value != null ? new Period(value) : null; | ||
| } | ||
|
|
||
| public AlarmOccurrence(AlarmOccurrence ao) | ||
|
|
@@ -44,14 +45,21 @@ | |
| Component = rc; | ||
| } | ||
|
|
||
| public int CompareTo(AlarmOccurrence other) => Period.CompareTo(other.Period); | ||
| public int CompareTo(AlarmOccurrence? other) | ||
|
||
| { | ||
| if (other == null || other.Period == null) | ||
|
||
| { | ||
| return 1; | ||
| } | ||
| return Period?.CompareTo(other.Period) ?? 1; | ||
| } | ||
|
|
||
| protected bool Equals(AlarmOccurrence other) | ||
| => Equals(Period, other.Period) | ||
| && Equals(Component, other.Component) | ||
| && Equals(Alarm, other.Alarm); | ||
|
|
||
| public override bool Equals(object obj) | ||
| public override bool Equals(object? obj) | ||
| { | ||
| if (ReferenceEquals(null, obj)) return false; | ||
| if (ReferenceEquals(this, obj)) return true; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| // Licensed under the MIT license. | ||
| // | ||
|
|
||
| #nullable enable | ||
| using System; | ||
| using System.Linq; | ||
| using System.Text; | ||
|
|
@@ -18,8 +19,8 @@ namespace Ical.Net.DataTypes; | |
| /// </summary> | ||
| public class Attachment : EncodableDataType | ||
| { | ||
| public virtual Uri Uri { get; set; } | ||
| public virtual byte[] Data { get; private set; } // private set for CopyFrom | ||
| public virtual Uri? Uri { get; set; } | ||
| public virtual byte[]? Data { get; private set; } // private set for CopyFrom | ||
|
|
||
| private Encoding _valueEncoding = System.Text.Encoding.UTF8; | ||
| public virtual Encoding ValueEncoding | ||
|
|
@@ -43,7 +44,7 @@ public virtual string FormatType | |
|
|
||
| public Attachment() { } | ||
|
|
||
| public Attachment(byte[] value) : this() | ||
| public Attachment(byte[]? value) : this() | ||
| { | ||
| if (value != null) | ||
| { | ||
|
|
@@ -93,15 +94,15 @@ public override void CopyFrom(ICopyable obj) | |
| FormatType = att.FormatType; | ||
| } | ||
|
|
||
| protected bool Equals(Attachment other) | ||
| protected bool Equals(Attachment? other) | ||
| { | ||
| var firstPart = Equals(Uri, other.Uri) && ValueEncoding.Equals(other.ValueEncoding); | ||
| var firstPart = Equals(Uri, other?.Uri) && ValueEncoding.Equals(other?.ValueEncoding); | ||
| return Data == null | ||
| ? firstPart | ||
| : firstPart && Data.SequenceEqual(other.Data); | ||
| : firstPart && other?.Data != null && Data.SequenceEqual(other.Data); | ||
|
||
| } | ||
|
|
||
| public override bool Equals(object obj) | ||
| public override bool Equals(object? obj) | ||
| { | ||
| if (ReferenceEquals(null, obj)) return false; | ||
| if (ReferenceEquals(this, obj)) return true; | ||
|
|
@@ -118,4 +119,4 @@ public override int GetHashCode() | |
| return hashCode; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| // Licensed under the MIT license. | ||
| // | ||
|
|
||
| #nullable enable | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
|
|
@@ -12,9 +13,9 @@ | |
|
|
||
| public class Attendee : EncodableDataType | ||
| { | ||
| private Uri _sentBy; | ||
| private Uri? _sentBy; | ||
| /// <summary> SENT-BY, to indicate who is acting on behalf of the ATTENDEE </summary> | ||
| public virtual Uri SentBy | ||
| public virtual Uri? SentBy | ||
| { | ||
| get | ||
| { | ||
|
|
@@ -38,7 +39,7 @@ | |
| } | ||
| } | ||
|
|
||
| private string _commonName; | ||
| private string? _commonName; | ||
| /// <summary> CN: to show the common or displayable name associated with the calendar address </summary> | ||
| public virtual string CommonName | ||
| { | ||
|
|
@@ -48,7 +49,7 @@ | |
| { | ||
| _commonName = Parameters.Get("CN"); | ||
| } | ||
| return _commonName; | ||
|
Check warning on line 52 in Ical.Net/DataTypes/Attendee.cs
|
||
| } | ||
| set | ||
| { | ||
|
|
@@ -61,9 +62,9 @@ | |
| } | ||
| } | ||
|
|
||
| private Uri _directoryEntry; | ||
| private Uri? _directoryEntry; | ||
| /// <summary> DIR, to indicate the URI that points to the directory information corresponding to the attendee </summary> | ||
| public virtual Uri DirectoryEntry | ||
| public virtual Uri? DirectoryEntry | ||
| { | ||
| get | ||
| { | ||
|
|
@@ -87,7 +88,7 @@ | |
| } | ||
| } | ||
|
|
||
| private string _type; | ||
| private string? _type; | ||
| /// <summary> CUTYPE: the type of calendar user </summary> | ||
| public virtual string Type | ||
| { | ||
|
|
@@ -97,7 +98,7 @@ | |
| { | ||
| _type = Parameters.Get("CUTYPE"); | ||
| } | ||
| return _type; | ||
|
Check warning on line 101 in Ical.Net/DataTypes/Attendee.cs
|
||
| } | ||
| set | ||
| { | ||
|
|
@@ -111,7 +112,7 @@ | |
| } | ||
| } | ||
|
|
||
| private List<string> _members; | ||
| private List<string>? _members; | ||
| /// <summary> MEMBER: the groups the user belongs to </summary> | ||
| public virtual IList<string> Members | ||
| { | ||
|
|
@@ -123,7 +124,7 @@ | |
| } | ||
| } | ||
|
|
||
| private string _role; | ||
| private string? _role; | ||
| /// <summary> ROLE: the intended role the attendee will have </summary> | ||
| public virtual string Role | ||
| { | ||
|
|
@@ -133,7 +134,7 @@ | |
| { | ||
| _role = Parameters.Get("ROLE"); | ||
| } | ||
| return _role; | ||
|
Check warning on line 137 in Ical.Net/DataTypes/Attendee.cs
|
||
| } | ||
| set | ||
| { | ||
|
|
@@ -146,7 +147,7 @@ | |
| } | ||
| } | ||
|
|
||
| private string _participationStatus; | ||
| private string? _participationStatus; | ||
| public virtual string ParticipationStatus | ||
| { | ||
| get | ||
|
|
@@ -155,7 +156,7 @@ | |
| { | ||
| _participationStatus = Parameters.Get(EventParticipationStatus.Key); | ||
| } | ||
| return _participationStatus; | ||
|
Check warning on line 159 in Ical.Net/DataTypes/Attendee.cs
|
||
| } | ||
| set | ||
| { | ||
|
|
@@ -179,9 +180,8 @@ | |
| return _rsvp.Value; | ||
| } | ||
|
|
||
| bool val; | ||
| var rsvp = Parameters.Get("RSVP"); | ||
| if (rsvp != null && bool.TryParse(rsvp, out val)) | ||
| if (rsvp != null && bool.TryParse(rsvp, out var val)) | ||
| { | ||
| _rsvp = val; | ||
| return _rsvp.Value; | ||
|
|
@@ -196,9 +196,9 @@ | |
| } | ||
| } | ||
|
|
||
| private List<string> _delegatedTo; | ||
| private List<string>? _delegatedTo; | ||
| /// <summary> DELEGATED-TO, to indicate the calendar users that the original request was delegated to </summary> | ||
| public virtual IList<string> DelegatedTo | ||
| public virtual IList<string>? DelegatedTo | ||
| { | ||
| get => _delegatedTo ?? (_delegatedTo = new List<string>(Parameters.GetMany("DELEGATED-TO"))); | ||
| set | ||
|
|
@@ -212,7 +212,7 @@ | |
| } | ||
| } | ||
|
|
||
| private List<string> _delegatedFrom; | ||
| private List<string>? _delegatedFrom; | ||
| /// <summary> DELEGATED-FROM, to indicate whom the request was delegated from </summary> | ||
| public virtual IList<string> DelegatedFrom | ||
| { | ||
|
|
@@ -229,7 +229,7 @@ | |
| } | ||
|
|
||
| /// <summary> Uri associated with the attendee, typically an email address </summary> | ||
| public virtual Uri Value { get; set; } | ||
| public virtual Uri? Value { get; set; } | ||
|
|
||
| public Attendee() { } | ||
|
|
||
|
|
@@ -276,10 +276,10 @@ | |
| && Rsvp == other.Rsvp | ||
| && Equals(Value, other.Value) | ||
| && Members.SequenceEqual(other.Members) | ||
| && DelegatedTo.SequenceEqual(other.DelegatedTo) | ||
| && DelegatedFrom.SequenceEqual(other.DelegatedFrom); | ||
| && (DelegatedTo?.SequenceEqual(other.DelegatedTo ?? Enumerable.Empty<string>()) ?? other.DelegatedTo == null) | ||
|
||
| && (DelegatedFrom?.SequenceEqual(other.DelegatedFrom ?? Enumerable.Empty<string>()) ?? other.DelegatedFrom == null); | ||
|
|
||
| public override bool Equals(object obj) | ||
| public override bool Equals(object? obj) | ||
| { | ||
| if (ReferenceEquals(null, obj)) return false; | ||
| if (ReferenceEquals(this, obj)) return true; | ||
|
|
@@ -305,4 +305,4 @@ | |
| return hashCode; | ||
| } | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
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
defaultbecause the options should have been a value type at first.