Skip to content

Commit ad56fe1

Browse files
authored
Added nullability attributes to the API (#1983)
Fixes issue #1972
1 parent a2766da commit ad56fe1

126 files changed

Lines changed: 2210 additions & 2014 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎MailKit/AccessRight.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public bool Equals (AccessRight other)
200200
/// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="MailKit.AccessRight"/>.</param>
201201
/// <returns><see langword="true" /> if the specified <see cref="System.Object"/> is equal to the current <see cref="MailKit.AccessRight"/>;
202202
/// otherwise, <see langword="false" />.</returns>
203-
public override bool Equals (object obj)
203+
public override bool Equals (object? obj)
204204
{
205205
return obj is AccessRight right && right.Right == Right;
206206
}

‎MailKit/Annotation.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ public class Annotation
5050
/// </exception>
5151
public Annotation (AnnotationEntry entry)
5252
{
53-
if (entry == null)
53+
if (entry is null)
5454
throw new ArgumentNullException (nameof (entry));
5555

56-
Properties = new Dictionary<AnnotationAttribute, string> ();
56+
Properties = new Dictionary<AnnotationAttribute, string?> ();
5757
Entry = entry;
5858
}
5959

@@ -75,7 +75,7 @@ public AnnotationEntry Entry {
7575
/// Gets the annotation properties.
7676
/// </remarks>
7777
/// <value>The annotation properties.</value>
78-
public Dictionary<AnnotationAttribute, string> Properties {
78+
public Dictionary<AnnotationAttribute, string?> Properties {
7979
get; private set;
8080
}
8181
}

‎MailKit/AnnotationAttribute.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public string Specifier {
181181
/// <param name="other">The <see cref="MailKit.AnnotationAttribute"/> to compare with the current <see cref="MailKit.AnnotationAttribute"/>.</param>
182182
/// <returns><see langword="true" /> if the specified <see cref="MailKit.AnnotationAttribute"/> is equal to the current
183183
/// <see cref="MailKit.AnnotationAttribute"/>; otherwise, <see langword="false" />.</returns>
184-
public bool Equals (AnnotationAttribute other)
184+
public bool Equals (AnnotationAttribute? other)
185185
{
186186
return other?.Specifier == Specifier;
187187
}
@@ -225,7 +225,7 @@ public bool Equals (AnnotationAttribute other)
225225
/// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="MailKit.AnnotationAttribute"/>.</param>
226226
/// <returns><see langword="true" /> if the specified <see cref="System.Object"/> is equal to the current
227227
/// <see cref="MailKit.AnnotationAttribute"/>; otherwise, <see langword="false" />.</returns>
228-
public override bool Equals (object obj)
228+
public override bool Equals (object? obj)
229229
{
230230
return obj is AnnotationAttribute attribute && attribute.Specifier == Specifier;
231231
}

‎MailKit/AnnotationEntry.cs‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,12 @@ static void ValidatePartSpecifier (string partSpecifier)
172172
throw new ArgumentException ("Invalid part-specifier.", nameof (partSpecifier));
173173
}
174174

175-
AnnotationEntry ()
175+
AnnotationEntry (string? partSpecifier, string entry, string path, AnnotationScope scope)
176176
{
177+
PartSpecifier = partSpecifier;
178+
Entry = entry;
179+
Path = path;
180+
Scope = scope;
177181
}
178182

179183
/// <summary>
@@ -199,6 +203,7 @@ public AnnotationEntry (string path, AnnotationScope scope = AnnotationScope.Bot
199203
case AnnotationScope.Shared: Entry = path + ".shared"; break;
200204
default: Entry = path; break;
201205
}
206+
202207
PartSpecifier = null;
203208
Path = path;
204209
Scope = scope;
@@ -233,6 +238,7 @@ public AnnotationEntry (string partSpecifier, string path, AnnotationScope scope
233238
case AnnotationScope.Shared: Entry = string.Format ("/{0}{1}.shared", partSpecifier, path); break;
234239
default: Entry = string.Format ("/{0}{1}", partSpecifier, path); break;
235240
}
241+
236242
PartSpecifier = partSpecifier;
237243
Path = path;
238244
Scope = scope;
@@ -267,6 +273,7 @@ public AnnotationEntry (BodyPart part, string path, AnnotationScope scope = Anno
267273
case AnnotationScope.Shared: Entry = string.Format ("/{0}{1}.shared", part.PartSpecifier, path); break;
268274
default: Entry = string.Format ("/{0}{1}", part.PartSpecifier, path); break;
269275
}
276+
270277
PartSpecifier = part.PartSpecifier;
271278
Path = path;
272279
Scope = scope;
@@ -290,7 +297,7 @@ public string Entry {
290297
/// Gets the part-specifier component of the annotation entry.
291298
/// </remarks>
292299
/// <value>The part-specifier.</value>
293-
public string PartSpecifier {
300+
public string? PartSpecifier {
294301
get; private set;
295302
}
296303

@@ -327,7 +334,7 @@ public AnnotationScope Scope {
327334
/// <param name="other">The <see cref="MailKit.AnnotationEntry"/> to compare with the current <see cref="MailKit.AnnotationEntry"/>.</param>
328335
/// <returns><see langword="true" /> if the specified <see cref="MailKit.AnnotationEntry"/> is equal to the current
329336
/// <see cref="MailKit.AnnotationEntry"/>; otherwise, <see langword="false" />.</returns>
330-
public bool Equals (AnnotationEntry other)
337+
public bool Equals (AnnotationEntry? other)
331338
{
332339
return other?.Entry == Entry;
333340
}
@@ -371,7 +378,7 @@ public bool Equals (AnnotationEntry other)
371378
/// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="MailKit.AnnotationEntry"/>.</param>
372379
/// <returns><see langword="true" /> if the specified <see cref="System.Object"/> is equal to the current
373380
/// <see cref="MailKit.AnnotationEntry"/>; otherwise, <see langword="false" />.</returns>
374-
public override bool Equals (object obj)
381+
public override bool Equals (object? obj)
375382
{
376383
return obj is AnnotationEntry entry && entry.Entry == Entry;
377384
}
@@ -427,7 +434,7 @@ public static AnnotationEntry Parse (string entry)
427434

428435
var scope = AnnotationScope.Both;
429436
int startIndex = 0, endIndex;
430-
string partSpecifier = null;
437+
string? partSpecifier = null;
431438
var component = 0;
432439
var pc = entry[0];
433440
string path;
@@ -497,12 +504,7 @@ public static AnnotationEntry Parse (string entry)
497504

498505
path = entry.Substring (startIndex, endIndex - startIndex);
499506

500-
return new AnnotationEntry {
501-
PartSpecifier = partSpecifier,
502-
Entry = entry,
503-
Path = path,
504-
Scope = scope
505-
};
507+
return new AnnotationEntry (partSpecifier, entry, path, scope);
506508
}
507509

508510
internal static AnnotationEntry Create (string entry)

‎MailKit/AnnotationsChangedEventArgs.cs‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,6 @@ namespace MailKit {
3838
/// </remarks>
3939
public class AnnotationsChangedEventArgs : MessageEventArgs
4040
{
41-
/// <summary>
42-
/// Initializes a new instance of the <see cref="MailKit.AnnotationsChangedEventArgs"/> class.
43-
/// </summary>
44-
/// <remarks>
45-
/// Creates a new <see cref="AnnotationsChangedEventArgs"/>.
46-
/// </remarks>
47-
/// <param name="index">The message index.</param>
48-
internal AnnotationsChangedEventArgs (int index) : base (index)
49-
{
50-
}
51-
5241
/// <summary>
5342
/// Initializes a new instance of the <see cref="T:MailKit.AnnotationsChangedEventArgs"/> class.
5443
/// </summary>

‎MailKit/AppendRequest.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public MessageFlags Flags {
165165
/// Gets or sets the keywords that should be set on the message.
166166
/// </remarks>
167167
/// <value>The keywords.</value>
168-
public ISet<string> Keywords {
168+
public ISet<string>? Keywords {
169169
get; set;
170170
}
171171

@@ -192,7 +192,7 @@ public DateTimeOffset? InternalDate {
192192
/// </note>
193193
/// </remarks>
194194
/// <value>The list of annotations.</value>
195-
public IList<Annotation> Annotations {
195+
public IList<Annotation>? Annotations {
196196
get; set;
197197
}
198198

@@ -203,7 +203,7 @@ public IList<Annotation> Annotations {
203203
/// Gets or sets the transfer progress reporting mechanism.
204204
/// </remarks>
205205
/// <value>The transfer progress mechanism.</value>
206-
public ITransferProgress TransferProgress {
206+
public ITransferProgress? TransferProgress {
207207
get; set;
208208
}
209209
}

0 commit comments

Comments
 (0)