diff --git a/MailKit/AccessRight.cs b/MailKit/AccessRight.cs
index 94f01f9c41..be3efbf71e 100644
--- a/MailKit/AccessRight.cs
+++ b/MailKit/AccessRight.cs
@@ -200,7 +200,7 @@ public bool Equals (AccessRight other)
/// The to compare with the current .
/// if the specified is equal to the current ;
/// otherwise, .
- public override bool Equals (object obj)
+ public override bool Equals (object? obj)
{
return obj is AccessRight right && right.Right == Right;
}
diff --git a/MailKit/Annotation.cs b/MailKit/Annotation.cs
index 28bb9c2546..2bc3029eff 100644
--- a/MailKit/Annotation.cs
+++ b/MailKit/Annotation.cs
@@ -50,10 +50,10 @@ public class Annotation
///
public Annotation (AnnotationEntry entry)
{
- if (entry == null)
+ if (entry is null)
throw new ArgumentNullException (nameof (entry));
- Properties = new Dictionary ();
+ Properties = new Dictionary ();
Entry = entry;
}
@@ -75,7 +75,7 @@ public AnnotationEntry Entry {
/// Gets the annotation properties.
///
/// The annotation properties.
- public Dictionary Properties {
+ public Dictionary Properties {
get; private set;
}
}
diff --git a/MailKit/AnnotationAttribute.cs b/MailKit/AnnotationAttribute.cs
index d44630acdc..a2654f243e 100644
--- a/MailKit/AnnotationAttribute.cs
+++ b/MailKit/AnnotationAttribute.cs
@@ -181,7 +181,7 @@ public string Specifier {
/// The to compare with the current .
/// if the specified is equal to the current
/// ; otherwise, .
- public bool Equals (AnnotationAttribute other)
+ public bool Equals (AnnotationAttribute? other)
{
return other?.Specifier == Specifier;
}
@@ -225,7 +225,7 @@ public bool Equals (AnnotationAttribute other)
/// The to compare with the current .
/// if the specified is equal to the current
/// ; otherwise, .
- public override bool Equals (object obj)
+ public override bool Equals (object? obj)
{
return obj is AnnotationAttribute attribute && attribute.Specifier == Specifier;
}
diff --git a/MailKit/AnnotationEntry.cs b/MailKit/AnnotationEntry.cs
index 7ca14d792d..d1f2a14f23 100644
--- a/MailKit/AnnotationEntry.cs
+++ b/MailKit/AnnotationEntry.cs
@@ -172,8 +172,12 @@ static void ValidatePartSpecifier (string partSpecifier)
throw new ArgumentException ("Invalid part-specifier.", nameof (partSpecifier));
}
- AnnotationEntry ()
+ AnnotationEntry (string? partSpecifier, string entry, string path, AnnotationScope scope)
{
+ PartSpecifier = partSpecifier;
+ Entry = entry;
+ Path = path;
+ Scope = scope;
}
///
@@ -199,6 +203,7 @@ public AnnotationEntry (string path, AnnotationScope scope = AnnotationScope.Bot
case AnnotationScope.Shared: Entry = path + ".shared"; break;
default: Entry = path; break;
}
+
PartSpecifier = null;
Path = path;
Scope = scope;
@@ -233,6 +238,7 @@ public AnnotationEntry (string partSpecifier, string path, AnnotationScope scope
case AnnotationScope.Shared: Entry = string.Format ("/{0}{1}.shared", partSpecifier, path); break;
default: Entry = string.Format ("/{0}{1}", partSpecifier, path); break;
}
+
PartSpecifier = partSpecifier;
Path = path;
Scope = scope;
@@ -267,6 +273,7 @@ public AnnotationEntry (BodyPart part, string path, AnnotationScope scope = Anno
case AnnotationScope.Shared: Entry = string.Format ("/{0}{1}.shared", part.PartSpecifier, path); break;
default: Entry = string.Format ("/{0}{1}", part.PartSpecifier, path); break;
}
+
PartSpecifier = part.PartSpecifier;
Path = path;
Scope = scope;
@@ -290,7 +297,7 @@ public string Entry {
/// Gets the part-specifier component of the annotation entry.
///
/// The part-specifier.
- public string PartSpecifier {
+ public string? PartSpecifier {
get; private set;
}
@@ -327,7 +334,7 @@ public AnnotationScope Scope {
/// The to compare with the current .
/// if the specified is equal to the current
/// ; otherwise, .
- public bool Equals (AnnotationEntry other)
+ public bool Equals (AnnotationEntry? other)
{
return other?.Entry == Entry;
}
@@ -371,7 +378,7 @@ public bool Equals (AnnotationEntry other)
/// The to compare with the current .
/// if the specified is equal to the current
/// ; otherwise, .
- public override bool Equals (object obj)
+ public override bool Equals (object? obj)
{
return obj is AnnotationEntry entry && entry.Entry == Entry;
}
@@ -427,7 +434,7 @@ public static AnnotationEntry Parse (string entry)
var scope = AnnotationScope.Both;
int startIndex = 0, endIndex;
- string partSpecifier = null;
+ string? partSpecifier = null;
var component = 0;
var pc = entry[0];
string path;
@@ -497,12 +504,7 @@ public static AnnotationEntry Parse (string entry)
path = entry.Substring (startIndex, endIndex - startIndex);
- return new AnnotationEntry {
- PartSpecifier = partSpecifier,
- Entry = entry,
- Path = path,
- Scope = scope
- };
+ return new AnnotationEntry (partSpecifier, entry, path, scope);
}
internal static AnnotationEntry Create (string entry)
diff --git a/MailKit/AnnotationsChangedEventArgs.cs b/MailKit/AnnotationsChangedEventArgs.cs
index e50deb4d10..25144ad860 100644
--- a/MailKit/AnnotationsChangedEventArgs.cs
+++ b/MailKit/AnnotationsChangedEventArgs.cs
@@ -38,17 +38,6 @@ namespace MailKit {
///
public class AnnotationsChangedEventArgs : MessageEventArgs
{
- ///
- /// Initializes a new instance of the class.
- ///
- ///
- /// Creates a new .
- ///
- /// The message index.
- internal AnnotationsChangedEventArgs (int index) : base (index)
- {
- }
-
///
/// Initializes a new instance of the class.
///
diff --git a/MailKit/AppendRequest.cs b/MailKit/AppendRequest.cs
index a3e6d4916b..af3d9457a4 100644
--- a/MailKit/AppendRequest.cs
+++ b/MailKit/AppendRequest.cs
@@ -165,7 +165,7 @@ public MessageFlags Flags {
/// Gets or sets the keywords that should be set on the message.
///
/// The keywords.
- public ISet Keywords {
+ public ISet? Keywords {
get; set;
}
@@ -192,7 +192,7 @@ public DateTimeOffset? InternalDate {
///
///
/// The list of annotations.
- public IList Annotations {
+ public IList? Annotations {
get; set;
}
@@ -203,7 +203,7 @@ public IList Annotations {
/// Gets or sets the transfer progress reporting mechanism.
///
/// The transfer progress mechanism.
- public ITransferProgress TransferProgress {
+ public ITransferProgress? TransferProgress {
get; set;
}
}
diff --git a/MailKit/BodyPart.cs b/MailKit/BodyPart.cs
index b20236984d..f66785c04b 100644
--- a/MailKit/BodyPart.cs
+++ b/MailKit/BodyPart.cs
@@ -28,6 +28,7 @@
using System.Text;
using System.Globalization;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using MimeKit;
using MimeKit.Utils;
@@ -52,8 +53,36 @@ public abstract class BodyPart
///
/// Creates a new .
///
+ [Obsolete ("Use BodyPart (ContentType, string) instead.")]
protected BodyPart ()
{
+ ContentType = new ContentType ("application", "octet-stream");
+ PartSpecifier = string.Empty;
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ /// Creates a new .
+ ///
+ /// The content type.
+ /// The part specifier.
+ ///
+ /// is .
+ /// -or-
+ /// is .
+ ///
+ protected BodyPart (ContentType contentType, string partSpecifier)
+ {
+ if (contentType == null)
+ throw new ArgumentNullException (nameof (contentType));
+
+ if (partSpecifier == null)
+ throw new ArgumentNullException (nameof (partSpecifier));
+
+ ContentType = contentType;
+ PartSpecifier = partSpecifier;
}
///
@@ -103,7 +132,7 @@ internal static void Encode (StringBuilder builder, uint value)
builder.Append (value.ToString (CultureInfo.InvariantCulture));
}
- internal static void Encode (StringBuilder builder, string value)
+ internal static void Encode (StringBuilder builder, string? value)
{
if (value != null)
MimeUtils.AppendQuoted (builder, value);
@@ -111,7 +140,7 @@ internal static void Encode (StringBuilder builder, string value)
builder.Append ("NIL");
}
- internal static void Encode (StringBuilder builder, Uri location)
+ internal static void Encode (StringBuilder builder, Uri? location)
{
if (location != null)
MimeUtils.AppendQuoted (builder, location.ToString ());
@@ -119,7 +148,7 @@ internal static void Encode (StringBuilder builder, Uri location)
builder.Append ("NIL");
}
- internal static void Encode (StringBuilder builder, string[] values)
+ internal static void Encode (StringBuilder builder, string[]? values)
{
if (values == null || values.Length == 0) {
builder.Append ("NIL");
@@ -159,7 +188,7 @@ internal static void Encode (StringBuilder builder, IList parameters)
builder.Append (')');
}
- internal static void Encode (StringBuilder builder, ContentDisposition disposition)
+ internal static void Encode (StringBuilder builder, ContentDisposition? disposition)
{
if (disposition == null) {
builder.Append ("NIL");
@@ -197,7 +226,7 @@ internal static void Encode (StringBuilder builder, BodyPartCollection parts)
}
}
- internal static void Encode (StringBuilder builder, Envelope envelope)
+ internal static void Encode (StringBuilder builder, Envelope? envelope)
{
if (envelope == null) {
builder.Append ("NIL");
@@ -207,7 +236,7 @@ internal static void Encode (StringBuilder builder, Envelope envelope)
envelope.Encode (builder);
}
- internal static void Encode (StringBuilder builder, BodyPart body)
+ internal static void Encode (StringBuilder builder, BodyPart? body)
{
if (body == null) {
builder.Append ("NIL");
@@ -268,7 +297,7 @@ static bool TryParse (string text, ref int index, out uint value)
return index > startIndex;
}
- static bool TryParse (string text, ref int index, out string nstring)
+ static bool TryParse (string text, ref int index, out string? nstring)
{
nstring = null;
@@ -316,7 +345,7 @@ static bool TryParse (string text, ref int index, out string nstring)
return true;
}
- static bool TryParse (string text, ref int index, out string[] values)
+ static bool TryParse (string text, ref int index, out string[]? values)
{
values = null;
@@ -346,10 +375,11 @@ static bool TryParse (string text, ref int index, out string[] values)
if (text[index] == ')')
break;
- if (!TryParse (text, ref index, out string value))
+ if (!TryParse (text, ref index, out string? value))
return false;
- list.Add (value);
+ if (value != null)
+ list.Add (value);
} while (index < text.Length);
if (index >= text.Length || text[index] != ')')
@@ -361,11 +391,11 @@ static bool TryParse (string text, ref int index, out string[] values)
return true;
}
- static bool TryParse (string text, ref int index, out Uri uri)
+ static bool TryParse (string text, ref int index, out Uri? uri)
{
uri = null;
- if (!TryParse (text, ref index, out string nstring))
+ if (!TryParse (text, ref index, out string? nstring))
return false;
if (!string.IsNullOrEmpty (nstring)) {
@@ -378,7 +408,7 @@ static bool TryParse (string text, ref int index, out Uri uri)
return true;
}
- static bool TryParse (string text, ref int index, out IList parameters)
+ static bool TryParse (string text, ref int index, [NotNullWhen (true)] out IList? parameters)
{
parameters = null;
@@ -409,10 +439,10 @@ static bool TryParse (string text, ref int index, out IList parameter
if (text[index] == ')')
break;
- if (!TryParse (text, ref index, out string name))
+ if (!TryParse (text, ref index, out string? name) || name == null)
return false;
- if (!TryParse (text, ref index, out string value))
+ if (!TryParse (text, ref index, out string? value) || value == null)
return false;
parameters.Add (new Parameter (name, value));
@@ -426,7 +456,7 @@ static bool TryParse (string text, ref int index, out IList parameter
return true;
}
- static bool TryParse (string text, ref int index, out ContentDisposition disposition)
+ static bool TryParse (string text, ref int index, out ContentDisposition? disposition)
{
disposition = null;
@@ -447,10 +477,10 @@ static bool TryParse (string text, ref int index, out ContentDisposition disposi
index++;
- if (!TryParse (text, ref index, out string value))
+ if (!TryParse (text, ref index, out string? value) || value == null)
return false;
- if (!TryParse (text, ref index, out IList parameters))
+ if (!TryParse (text, ref index, out IList? parameters))
return false;
if (index >= text.Length || text[index] != ')')
@@ -466,9 +496,9 @@ static bool TryParse (string text, ref int index, out ContentDisposition disposi
return true;
}
- static bool TryParse (string text, ref int index, bool multipart, out ContentType contentType)
+ static bool TryParse (string text, ref int index, bool multipart, [NotNullWhen (true)] out ContentType? contentType)
{
- string type, subtype;
+ string? type, subtype;
contentType = null;
@@ -488,7 +518,7 @@ static bool TryParse (string text, ref int index, bool multipart, out ContentTyp
if (!TryParse (text, ref index, out subtype))
return false;
- if (!TryParse (text, ref index, out IList parameters))
+ if (!TryParse (text, ref index, out IList? parameters))
return false;
contentType = new ContentType (type ?? "application", subtype ?? "octet-stream");
@@ -499,17 +529,17 @@ static bool TryParse (string text, ref int index, bool multipart, out ContentTyp
return true;
}
- static bool TryParse (string text, ref int index, string prefix, out IList children)
+ static bool TryParse (string text, ref int index, string prefix, [NotNullWhen (true)] out BodyPartCollection? bodyParts)
{
string path;
int id = 1;
- children = null;
+ bodyParts = null;
if (index >= text.Length)
return false;
- children = new List ();
+ bodyParts = new BodyPartCollection ();
do {
if (text[index] != '(')
@@ -517,25 +547,27 @@ static bool TryParse (string text, ref int index, string prefix, out IList 0 ? path + "." : string.Empty;
- var multipart = new BodyPartMultipart ();
+ BodyPartCollection? bodyParts = null;
if (text[index] == '(') {
- if (!TryParse (text, ref index, prefix, out IList children))
+ if (!TryParse (text, ref index, prefix, out bodyParts))
return false;
-
- foreach (var child in children)
- multipart.BodyParts.Add (child);
} else {
index += "NIL".Length;
}
@@ -573,7 +602,7 @@ static bool TryParse (string text, ref int index, string path, out BodyPart part
if (!TryParse (text, ref index, true, out contentType))
return false;
- multipart.ContentType = contentType;
+ var multipart = new BodyPartMultipart (contentType, path, bodyParts ?? new BodyPartCollection ());
if (!TryParse (text, ref index, out disposition))
return false;
@@ -592,22 +621,20 @@ static bool TryParse (string text, ref int index, string path, out BodyPart part
part = multipart;
} else {
- BodyPartMessage message = null;
- BodyPartText txt = null;
- BodyPartBasic basic;
- string nstring;
+ BodyPartMessage? message = null;
+ BodyPartText? txt = null;
+ BodyPartBasic? basic;
+ string? nstring;
if (!TryParse (text, ref index, false, out contentType))
return false;
if (contentType.IsMimeType ("message", "rfc822"))
- basic = message = new BodyPartMessage ();
+ basic = message = new BodyPartMessage (contentType, path);
else if (contentType.IsMimeType ("text", "*"))
- basic = txt = new BodyPartText ();
+ basic = txt = new BodyPartText (contentType, path);
else
- basic = new BodyPartBasic ();
-
- basic.ContentType = contentType;
+ basic = new BodyPartBasic (contentType, path);
if (!TryParse (text, ref index, out nstring))
return false;
@@ -650,12 +677,12 @@ static bool TryParse (string text, ref int index, string path, out BodyPart part
basic.ContentLocation = location;
if (message != null) {
- if (!Envelope.TryParse (text, ref index, out Envelope envelope))
+ if (!Envelope.TryParse (text, ref index, out Envelope? envelope))
return false;
message.Envelope = envelope;
- if (!TryParse (text, ref index, path, out BodyPart body))
+ if (!TryParse (text, ref index, path, out BodyPart? body))
return false;
message.Body = body;
@@ -674,8 +701,6 @@ static bool TryParse (string text, ref int index, string path, out BodyPart part
part = basic;
}
- part.PartSpecifier = path;
-
if (index >= text.Length || text[index] != ')')
return false;
@@ -698,7 +723,7 @@ static bool TryParse (string text, ref int index, string path, out BodyPart part
///
/// is .
///
- public static bool TryParse (string text, out BodyPart part)
+ public static bool TryParse (string text, out BodyPart? part)
{
if (text == null)
throw new ArgumentNullException (nameof (text));
diff --git a/MailKit/BodyPartBasic.cs b/MailKit/BodyPartBasic.cs
index f16cd9b126..50c1ced90a 100644
--- a/MailKit/BodyPartBasic.cs
+++ b/MailKit/BodyPartBasic.cs
@@ -48,7 +48,25 @@ public class BodyPartBasic : BodyPart
///
/// Creates a new .
///
- public BodyPartBasic ()
+ [Obsolete ("Use BodyPartBasic (ContentType, string) instead.")]
+ public BodyPartBasic () : base ()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ /// Creates a new .
+ ///
+ /// The content type.
+ /// The part specifier.
+ ///
+ /// is .
+ /// -or-
+ /// is .
+ ///
+ public BodyPartBasic (ContentType contentType, string partSpecifier) : base (contentType, partSpecifier)
{
}
@@ -59,7 +77,7 @@ public BodyPartBasic ()
/// Gets the Content-Id of the body part, if available.
///
/// The content identifier.
- public string ContentId {
+ public string? ContentId {
get; set;
}
@@ -70,7 +88,7 @@ public string ContentId {
/// Gets the Content-Description of the body part, if available.
///
/// The content description.
- public string ContentDescription {
+ public string? ContentDescription {
get; set;
}
@@ -83,7 +101,7 @@ public string ContentDescription {
/// method to parse this value into a usable .
///
/// The content transfer encoding.
- public string ContentTransferEncoding {
+ public string? ContentTransferEncoding {
get; set;
}
@@ -107,7 +125,7 @@ public uint Octets {
/// Gets the MD5 hash of the content, if available.
///
/// The content md5.
- public string ContentMd5 {
+ public string? ContentMd5 {
get; set;
}
@@ -121,7 +139,7 @@ public string ContentMd5 {
/// summary information from an .
///
/// The content disposition.
- public ContentDisposition ContentDisposition {
+ public ContentDisposition? ContentDisposition {
get; set;
}
@@ -135,7 +153,7 @@ public ContentDisposition ContentDisposition {
/// summary information from an .
///
/// The content language.
- public string[] ContentLanguage {
+ public string[]? ContentLanguage {
get; set;
}
@@ -149,7 +167,7 @@ public string[] ContentLanguage {
/// summary information from an .
///
/// The content location.
- public Uri ContentLocation {
+ public Uri? ContentLocation {
get; set;
}
@@ -179,9 +197,9 @@ public bool IsAttachment {
/// fetching summary information from an .
///
/// The name of the file.
- public string FileName {
+ public string? FileName {
get {
- string filename = null;
+ string? filename = null;
if (ContentDisposition != null)
filename = ContentDisposition.FileName;
diff --git a/MailKit/BodyPartCollection.cs b/MailKit/BodyPartCollection.cs
index 0cc8769ab0..2ac68f6e16 100644
--- a/MailKit/BodyPartCollection.cs
+++ b/MailKit/BodyPartCollection.cs
@@ -219,7 +219,7 @@ public int IndexOf (Uri uri)
if (cid) {
if (!string.IsNullOrEmpty (bodyPart.ContentId)) {
// Note: we might have a Content-Id in the form "", so attempt to decode it
- var id = MimeUtils.EnumerateReferences (bodyPart.ContentId).FirstOrDefault () ?? bodyPart.ContentId;
+ var id = MimeUtils.EnumerateReferences (bodyPart.ContentId!).FirstOrDefault () ?? bodyPart.ContentId;
if (id == uri.AbsolutePath)
return index;
diff --git a/MailKit/BodyPartMessage.cs b/MailKit/BodyPartMessage.cs
index c13d0cd909..3517812b6a 100644
--- a/MailKit/BodyPartMessage.cs
+++ b/MailKit/BodyPartMessage.cs
@@ -27,6 +27,8 @@
using System;
using System.Text;
+using MimeKit;
+
namespace MailKit {
///
/// A message/rfc822 body part.
@@ -42,7 +44,25 @@ public class BodyPartMessage : BodyPartBasic
///
/// Creates a new .
///
- public BodyPartMessage ()
+ [Obsolete ("Use BodyPartMessage (ContentType, string) instead.")]
+ public BodyPartMessage () : this (new ContentType ("message", "rfc822"), string.Empty)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ /// Creates a new .
+ ///
+ /// The content type.
+ /// The part specifier.
+ ///
+ /// is .
+ /// -or-
+ /// is .
+ ///
+ public BodyPartMessage (ContentType contentType, string partSpecifier) : base (contentType, partSpecifier)
{
}
@@ -53,7 +73,7 @@ public BodyPartMessage ()
/// Gets the envelope of the message, if available.
///
/// The envelope.
- public Envelope Envelope {
+ public Envelope? Envelope {
get; set;
}
@@ -64,7 +84,7 @@ public Envelope Envelope {
/// Gets the body structure of the message.
///
/// The body structure.
- public BodyPart Body {
+ public BodyPart? Body {
get; set;
}
diff --git a/MailKit/BodyPartMultipart.cs b/MailKit/BodyPartMultipart.cs
index 427eb1ecfb..7e1a8df9ba 100644
--- a/MailKit/BodyPartMultipart.cs
+++ b/MailKit/BodyPartMultipart.cs
@@ -44,11 +44,53 @@ public class BodyPartMultipart : BodyPart
///
/// Creates a new .
///
- public BodyPartMultipart ()
+ [Obsolete ("Use BodyPartMultipart (ContentType, string) instead.")]
+ public BodyPartMultipart () : this (new ContentType ("multipart", "mixed"), string.Empty)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ /// Creates a new .
+ ///
+ /// The content type.
+ /// The part specifier.
+ ///
+ /// is .
+ /// -or-
+ /// is .
+ ///
+ public BodyPartMultipart (ContentType contentType, string partSpecifier) : base (contentType, partSpecifier)
{
BodyParts = new BodyPartCollection ();
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ /// Creates a new .
+ ///
+ /// The content type.
+ /// The part specifier.
+ /// The child body parts of the multipart.
+ ///
+ /// is .
+ /// -or-
+ /// is .
+ /// -or-
+ /// is .
+ ///
+ public BodyPartMultipart (ContentType contentType, string partSpecifier, BodyPartCollection bodyParts) : base (contentType, partSpecifier)
+ {
+ if (bodyParts is null)
+ throw new ArgumentNullException (nameof (bodyParts));
+
+ BodyParts = bodyParts;
+ }
+
///
/// Gets the child body parts.
///
@@ -67,7 +109,7 @@ public BodyPartCollection BodyParts {
/// Gets the Content-Disposition of the body part, if available.
///
/// The content disposition.
- public ContentDisposition ContentDisposition {
+ public ContentDisposition? ContentDisposition {
get; set;
}
@@ -78,7 +120,7 @@ public ContentDisposition ContentDisposition {
/// Gets the Content-Language of the body part, if available.
///
/// The content language.
- public string[] ContentLanguage {
+ public string[]? ContentLanguage {
get; set;
}
@@ -89,7 +131,7 @@ public string[] ContentLanguage {
/// Gets the Content-Location of the body part, if available.
///
/// The content location.
- public Uri ContentLocation {
+ public Uri? ContentLocation {
get; set;
}
diff --git a/MailKit/BodyPartText.cs b/MailKit/BodyPartText.cs
index c7bdca47f1..1924b94be9 100644
--- a/MailKit/BodyPartText.cs
+++ b/MailKit/BodyPartText.cs
@@ -27,6 +27,8 @@
using System;
using System.Text;
+using MimeKit;
+
namespace MailKit {
///
/// A textual body part.
@@ -45,7 +47,25 @@ public class BodyPartText : BodyPartBasic
///
/// Creates a new .
///
- public BodyPartText ()
+ [Obsolete ("Use BodyPartText (ContentType, string) instead.")]
+ public BodyPartText () : this (new ContentType ("text", "plain"), string.Empty)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ /// Creates a new .
+ ///
+ /// The content type.
+ /// The part specifier.
+ ///
+ /// is .
+ /// -or-
+ /// is .
+ ///
+ public BodyPartText (ContentType contentType, string partSpecifier) : base (contentType, partSpecifier)
{
}
diff --git a/MailKit/BodyPartVisitor.cs b/MailKit/BodyPartVisitor.cs
index b2e6bbec9a..78160968b2 100644
--- a/MailKit/BodyPartVisitor.cs
+++ b/MailKit/BodyPartVisitor.cs
@@ -88,7 +88,7 @@ protected internal virtual void VisitBodyPartBasic (BodyPartBasic entity)
/// The body part representing the message/rfc822 message.
protected virtual void VisitMessage (BodyPart message)
{
- message?.Accept (this);
+ message.Accept (this);
}
///
@@ -101,7 +101,9 @@ protected virtual void VisitMessage (BodyPart message)
protected internal virtual void VisitBodyPartMessage (BodyPartMessage entity)
{
VisitBodyPartBasic (entity);
- VisitMessage (entity.Body);
+
+ if (entity.Body != null)
+ VisitMessage (entity.Body);
}
///
diff --git a/MailKit/ByteArrayBuilder.cs b/MailKit/ByteArrayBuilder.cs
index f6cb842bf2..a22b7a3994 100644
--- a/MailKit/ByteArrayBuilder.cs
+++ b/MailKit/ByteArrayBuilder.cs
@@ -173,9 +173,9 @@ public bool TryParse (int startIndex, int endIndex, out int value)
public void Dispose ()
{
- if (buffer != null) {
+ if (length != -1) {
ArrayPool.Shared.Return (buffer);
- buffer = null;
+ length = -1;
}
}
}
diff --git a/MailKit/Envelope.cs b/MailKit/Envelope.cs
index 18f67045ba..83c51535bf 100644
--- a/MailKit/Envelope.cs
+++ b/MailKit/Envelope.cs
@@ -28,6 +28,7 @@
using System.Text;
using System.Linq;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using MimeKit;
using MimeKit.Utils;
@@ -136,7 +137,7 @@ public InternetAddressList Bcc {
/// The Message-Id that the message is replying to.
///
/// The Message-Id that the message is replying to.
- public string InReplyTo {
+ public string? InReplyTo {
get; set;
}
@@ -158,7 +159,7 @@ public DateTimeOffset? Date {
/// Gets the ID of the message, if available.
///
/// The message identifier.
- public string MessageId {
+ public string? MessageId {
get; set;
}
@@ -169,7 +170,7 @@ public string MessageId {
/// Gets the subject of the message.
///
/// The subject.
- public string Subject {
+ public string? Subject {
get; set;
}
@@ -348,7 +349,7 @@ static bool IsNIL (string text, int index)
return string.Compare (text, index, "NIL", 0, 3, StringComparison.Ordinal) == 0;
}
- static bool TryParse (string text, ref int index, out string nstring)
+ static bool TryParse (string text, ref int index, out string? nstring)
{
nstring = null;
@@ -396,7 +397,7 @@ static bool TryParse (string text, ref int index, out string nstring)
return true;
}
- static bool TryParse (string text, ref int index, out InternetAddress addr)
+ static bool TryParse (string text, ref int index, out InternetAddress? addr)
{
addr = null;
@@ -405,16 +406,16 @@ static bool TryParse (string text, ref int index, out InternetAddress addr)
index++;
- if (!TryParse (text, ref index, out string name))
+ if (!TryParse (text, ref index, out string? name))
return false;
- if (!TryParse (text, ref index, out string route))
+ if (!TryParse (text, ref index, out string? route))
return false;
- if (!TryParse (text, ref index, out string user))
+ if (!TryParse (text, ref index, out string? user))
return false;
- if (!TryParse (text, ref index, out string domain))
+ if (!TryParse (text, ref index, out string? domain))
return false;
while (index < text.Length && text[index] == ' ')
@@ -442,7 +443,7 @@ static bool TryParse (string text, ref int index, out InternetAddress addr)
return true;
}
- static bool TryParse (string text, ref int index, out InternetAddressList list)
+ static bool TryParse (string text, ref int index, [NotNullWhen (true)] out InternetAddressList? list)
{
list = null;
@@ -477,7 +478,7 @@ static bool TryParse (string text, ref int index, out InternetAddressList list)
if (text[index] == ')')
break;
- if (!TryParse (text, ref index, out InternetAddress addr))
+ if (!TryParse (text, ref index, out InternetAddress? addr))
return false;
if (addr != null) {
@@ -507,7 +508,7 @@ static bool TryParse (string text, ref int index, out InternetAddressList list)
return true;
}
- internal static bool TryParse (string text, ref int index, out Envelope envelope)
+ internal static bool TryParse (string text, ref int index, out Envelope? envelope)
{
DateTimeOffset? date = null;
@@ -527,7 +528,7 @@ internal static bool TryParse (string text, ref int index, out Envelope envelope
index++;
- if (!TryParse (text, ref index, out string nstring))
+ if (!TryParse (text, ref index, out string? nstring))
return false;
if (nstring != null) {
@@ -537,31 +538,31 @@ internal static bool TryParse (string text, ref int index, out Envelope envelope
date = value;
}
- if (!TryParse (text, ref index, out string subject))
+ if (!TryParse (text, ref index, out string? subject))
return false;
- if (!TryParse (text, ref index, out InternetAddressList from))
+ if (!TryParse (text, ref index, out InternetAddressList? from))
return false;
- if (!TryParse (text, ref index, out InternetAddressList sender))
+ if (!TryParse (text, ref index, out InternetAddressList? sender))
return false;
- if (!TryParse (text, ref index, out InternetAddressList replyto))
+ if (!TryParse (text, ref index, out InternetAddressList? replyto))
return false;
- if (!TryParse (text, ref index, out InternetAddressList to))
+ if (!TryParse (text, ref index, out InternetAddressList? to))
return false;
- if (!TryParse (text, ref index, out InternetAddressList cc))
+ if (!TryParse (text, ref index, out InternetAddressList? cc))
return false;
- if (!TryParse (text, ref index, out InternetAddressList bcc))
+ if (!TryParse (text, ref index, out InternetAddressList? bcc))
return false;
- if (!TryParse (text, ref index, out string inreplyto))
+ if (!TryParse (text, ref index, out string? inreplyto))
return false;
- if (!TryParse (text, ref index, out string messageid))
+ if (!TryParse (text, ref index, out string? messageid))
return false;
if (index >= text.Length || text[index] != ')')
@@ -599,7 +600,7 @@ internal static bool TryParse (string text, ref int index, out Envelope envelope
///
/// is .
///
- public static bool TryParse (string text, out Envelope envelope)
+ public static bool TryParse (string text, out Envelope? envelope)
{
if (text == null)
throw new ArgumentNullException (nameof (text));
diff --git a/MailKit/FetchRequest.cs b/MailKit/FetchRequest.cs
index 69469c3297..087304ec37 100644
--- a/MailKit/FetchRequest.cs
+++ b/MailKit/FetchRequest.cs
@@ -134,7 +134,7 @@ public FetchRequest (MessageSummaryItems items, IEnumerable headers) : t
/// Gets the set of headers that will be fetched.
///
/// The set of headers to be fetched.
- public HeaderSet Headers { get; set; }
+ public HeaderSet? Headers { get; set; }
#if ENABLE_LAZY_PREVIEW_API
///
diff --git a/MailKit/FolderQuota.cs b/MailKit/FolderQuota.cs
index 8f12d706a3..89883c1d11 100644
--- a/MailKit/FolderQuota.cs
+++ b/MailKit/FolderQuota.cs
@@ -43,7 +43,7 @@ public class FolderQuota
/// Creates a new with the specified root.
///
/// The quota root.
- public FolderQuota (IMailFolder quotaRoot)
+ public FolderQuota (IMailFolder? quotaRoot)
{
QuotaRoot = quotaRoot;
}
@@ -59,7 +59,7 @@ public FolderQuota (IMailFolder quotaRoot)
///
///
/// The quota root.
- public IMailFolder QuotaRoot {
+ public IMailFolder? QuotaRoot {
get; private set;
}
diff --git a/MailKit/IAppendRequest.cs b/MailKit/IAppendRequest.cs
index 8a83176d42..7b83ab0c77 100644
--- a/MailKit/IAppendRequest.cs
+++ b/MailKit/IAppendRequest.cs
@@ -63,7 +63,7 @@ public interface IAppendRequest
/// Gets or sets the keywords that should be set on the message.
///
/// The keywords.
- ISet Keywords { get; set; }
+ ISet? Keywords { get; set; }
///
/// Get or set the timestamp that should be used by folder as the .
@@ -86,7 +86,7 @@ public interface IAppendRequest
///
///
/// The list of annotations.
- IList Annotations { get; set; }
+ IList? Annotations { get; set; }
///
/// Get or set the transfer progress reporting mechanism.
@@ -95,6 +95,6 @@ public interface IAppendRequest
/// Gets or sets the transfer progress reporting mechanism.
///
/// The transfer progress mechanism.
- ITransferProgress TransferProgress { get; set; }
+ ITransferProgress? TransferProgress { get; set; }
}
}
diff --git a/MailKit/IFetchRequest.cs b/MailKit/IFetchRequest.cs
index 8c33010b16..30e984d4f0 100644
--- a/MailKit/IFetchRequest.cs
+++ b/MailKit/IFetchRequest.cs
@@ -69,7 +69,7 @@ public interface IFetchRequest
/// Gets the set of headers that will be fetched.
///
/// The set of headers to be fetched.
- HeaderSet Headers { get; }
+ HeaderSet? Headers { get; }
#if ENABLE_LAZY_PREVIEW_API
///
diff --git a/MailKit/IMailFolder.cs b/MailKit/IMailFolder.cs
index f6bba8b700..ad82962194 100644
--- a/MailKit/IMailFolder.cs
+++ b/MailKit/IMailFolder.cs
@@ -64,7 +64,7 @@ public interface IMailFolder : IEnumerable
/// Root-level folders do not have a parent folder.
///
/// The parent folder.
- IMailFolder ParentFolder { get; }
+ IMailFolder? ParentFolder { get; }
///
/// Get the folder attributes.
@@ -205,7 +205,7 @@ public interface IMailFolder : IEnumerable
/// OBJECTID extension.
///
/// The unique folder identifier.
- string Id { get; }
+ string? Id { get; }
///
/// Get whether or not the folder is subscribed.
@@ -650,7 +650,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- IMailFolder Create (string name, bool isMessageFolder, CancellationToken cancellationToken = default);
+ IMailFolder? Create (string name, bool isMessageFolder, CancellationToken cancellationToken = default);
///
/// Asynchronously create a new subfolder with the given name.
@@ -692,7 +692,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task CreateAsync (string name, bool isMessageFolder, CancellationToken cancellationToken = default);
+ Task CreateAsync (string name, bool isMessageFolder, CancellationToken cancellationToken = default);
///
/// Create a new subfolder with the given name.
@@ -739,7 +739,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- IMailFolder Create (string name, IEnumerable specialUses, CancellationToken cancellationToken = default);
+ IMailFolder? Create (string name, IEnumerable specialUses, CancellationToken cancellationToken = default);
///
/// Asynchronously create a new subfolder with the given name.
@@ -786,7 +786,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task CreateAsync (string name, IEnumerable specialUses, CancellationToken cancellationToken = default);
+ Task CreateAsync (string name, IEnumerable specialUses, CancellationToken cancellationToken = default);
///
/// Create a new subfolder with the given name.
@@ -831,7 +831,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- IMailFolder Create (string name, SpecialFolder specialUse, CancellationToken cancellationToken = default);
+ IMailFolder? Create (string name, SpecialFolder specialUse, CancellationToken cancellationToken = default);
///
/// Asynchronously create a new subfolder with the given name.
@@ -876,7 +876,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task CreateAsync (string name, SpecialFolder specialUse, CancellationToken cancellationToken = default);
+ Task CreateAsync (string name, SpecialFolder specialUse, CancellationToken cancellationToken = default);
///
/// Rename the folder.
@@ -2262,7 +2262,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- string GetMetadata (MetadataTag tag, CancellationToken cancellationToken = default);
+ string? GetMetadata (MetadataTag tag, CancellationToken cancellationToken = default);
///
/// Asynchronously gets the specified metadata.
@@ -2297,7 +2297,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetMetadataAsync (MetadataTag tag, CancellationToken cancellationToken = default);
+ Task GetMetadataAsync (MetadataTag tag, CancellationToken cancellationToken = default);
///
/// Gets the specified metadata.
@@ -4617,7 +4617,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- HeaderList GetHeaders (UniqueId uid, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ HeaderList GetHeaders (UniqueId uid, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get the specified message headers.
@@ -4659,7 +4659,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetHeadersAsync (UniqueId uid, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetHeadersAsync (UniqueId uid, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get the specified body part headers.
@@ -4705,7 +4705,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- HeaderList GetHeaders (UniqueId uid, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ HeaderList GetHeaders (UniqueId uid, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get the specified body part headers.
@@ -4751,7 +4751,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetHeadersAsync (UniqueId uid, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetHeadersAsync (UniqueId uid, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get the specified message headers.
@@ -4793,7 +4793,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- HeaderList GetHeaders (int index, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ HeaderList GetHeaders (int index, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get the specified message headers.
@@ -4835,7 +4835,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetHeadersAsync (int index, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetHeadersAsync (int index, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get the specified body part headers.
@@ -4881,7 +4881,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- HeaderList GetHeaders (int index, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ HeaderList GetHeaders (int index, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get the specified body part headers.
@@ -4927,7 +4927,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetHeadersAsync (int index, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetHeadersAsync (int index, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get the specified message.
@@ -4972,7 +4972,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- MimeMessage GetMessage (UniqueId uid, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ MimeMessage GetMessage (UniqueId uid, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get the specified message.
@@ -5017,7 +5017,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetMessageAsync (UniqueId uid, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetMessageAsync (UniqueId uid, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get the specified message.
@@ -5062,7 +5062,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- MimeMessage GetMessage (int index, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ MimeMessage GetMessage (int index, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get the specified message.
@@ -5107,7 +5107,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetMessageAsync (int index, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetMessageAsync (int index, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get the specified body part.
@@ -5156,7 +5156,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- MimeEntity GetBodyPart (UniqueId uid, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ MimeEntity GetBodyPart (UniqueId uid, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get the specified body part.
@@ -5205,7 +5205,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetBodyPartAsync (UniqueId uid, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetBodyPartAsync (UniqueId uid, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get the specified body part.
@@ -5251,7 +5251,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- MimeEntity GetBodyPart (int index, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ MimeEntity GetBodyPart (int index, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get the specified body part.
@@ -5297,7 +5297,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetBodyPartAsync (int index, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetBodyPartAsync (int index, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get a message stream.
@@ -5342,7 +5342,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Stream GetStream (UniqueId uid, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Stream GetStream (UniqueId uid, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get a message stream.
@@ -5387,7 +5387,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetStreamAsync (UniqueId uid, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetStreamAsync (UniqueId uid, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get a message stream.
@@ -5432,7 +5432,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Stream GetStream (int index, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Stream GetStream (int index, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get a message stream.
@@ -5477,7 +5477,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetStreamAsync (int index, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetStreamAsync (int index, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get a substream of the specified message.
@@ -5529,7 +5529,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Stream GetStream (UniqueId uid, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Stream GetStream (UniqueId uid, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get a substream of the specified message.
@@ -5581,7 +5581,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetStreamAsync (UniqueId uid, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetStreamAsync (UniqueId uid, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get a substream of the specified message.
@@ -5632,7 +5632,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Stream GetStream (int index, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Stream GetStream (int index, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get a substream of the specified message.
@@ -5683,7 +5683,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetStreamAsync (int index, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetStreamAsync (int index, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get a body part as a stream.
@@ -5732,7 +5732,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Stream GetStream (UniqueId uid, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Stream GetStream (UniqueId uid, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get a body part as a stream.
@@ -5781,7 +5781,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetStreamAsync (UniqueId uid, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetStreamAsync (UniqueId uid, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get a body part as a stream.
@@ -5827,7 +5827,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Stream GetStream (int index, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Stream GetStream (int index, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get a body part as a stream.
@@ -5873,7 +5873,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetStreamAsync (int index, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetStreamAsync (int index, BodyPart part, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get a substream of the specified body part.
@@ -5929,7 +5929,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Stream GetStream (UniqueId uid, BodyPart part, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Stream GetStream (UniqueId uid, BodyPart part, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get a substream of the specified body part.
@@ -5985,7 +5985,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetStreamAsync (UniqueId uid, BodyPart part, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetStreamAsync (UniqueId uid, BodyPart part, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get a substream of the specified body part.
@@ -6040,7 +6040,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Stream GetStream (int index, BodyPart part, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Stream GetStream (int index, BodyPart part, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get a substream of the specified body part.
@@ -6095,7 +6095,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetStreamAsync (int index, BodyPart part, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetStreamAsync (int index, BodyPart part, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get a substream of the specified message.
@@ -6146,7 +6146,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Stream GetStream (UniqueId uid, string section, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Stream GetStream (UniqueId uid, string section, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get a substream of the specified message.
@@ -6197,7 +6197,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetStreamAsync (UniqueId uid, string section, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetStreamAsync (UniqueId uid, string section, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get a substream of the specified message.
@@ -6255,7 +6255,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Stream GetStream (UniqueId uid, string section, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Stream GetStream (UniqueId uid, string section, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get a substream of the specified message.
@@ -6313,7 +6313,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetStreamAsync (UniqueId uid, string section, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetStreamAsync (UniqueId uid, string section, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get a substream of the specified message.
@@ -6361,7 +6361,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Stream GetStream (int index, string section, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Stream GetStream (int index, string section, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get a substream of the specified message.
@@ -6409,7 +6409,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetStreamAsync (int index, string section, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetStreamAsync (int index, string section, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Get a substream of the specified message.
@@ -6466,7 +6466,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Stream GetStream (int index, string section, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Stream GetStream (int index, string section, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Asynchronously get a substream of the specified message.
@@ -6523,7 +6523,7 @@ public interface IMailFolder : IEnumerable
///
/// The command failed.
///
- Task GetStreamAsync (int index, string section, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress progress = null);
+ Task GetStreamAsync (int index, string section, int offset, int count, CancellationToken cancellationToken = default, ITransferProgress? progress = null);
///
/// Store message flags and keywords for a message.
diff --git a/MailKit/IMailFolderAppendExtensions.cs b/MailKit/IMailFolderAppendExtensions.cs
index 2d6a949a73..37a648f382 100644
--- a/MailKit/IMailFolderAppendExtensions.cs
+++ b/MailKit/IMailFolderAppendExtensions.cs
@@ -75,7 +75,7 @@ public static partial class IMailFolderExtensions
///
/// The command failed.
///
- public static UniqueId? Append (this IMailFolder folder, MimeMessage message, MessageFlags flags = MessageFlags.None, CancellationToken cancellationToken = default, ITransferProgress progress = null)
+ public static UniqueId? Append (this IMailFolder folder, MimeMessage message, MessageFlags flags = MessageFlags.None, CancellationToken cancellationToken = default, ITransferProgress? progress = null)
{
return Append (folder, FormatOptions.Default, message, flags, cancellationToken, progress);
}
@@ -119,7 +119,7 @@ public static partial class IMailFolderExtensions
///
/// The command failed.
///
- public static Task AppendAsync (this IMailFolder folder, MimeMessage message, MessageFlags flags = MessageFlags.None, CancellationToken cancellationToken = default, ITransferProgress progress = null)
+ public static Task AppendAsync (this IMailFolder folder, MimeMessage message, MessageFlags flags = MessageFlags.None, CancellationToken cancellationToken = default, ITransferProgress? progress = null)
{
return AppendAsync (folder, FormatOptions.Default, message, flags, cancellationToken, progress);
}
@@ -164,7 +164,7 @@ public static partial class IMailFolderExtensions
///
/// The command failed.
///
- public static UniqueId? Append (this IMailFolder folder, MimeMessage message, MessageFlags flags, DateTimeOffset date, CancellationToken cancellationToken = default, ITransferProgress progress = null)
+ public static UniqueId? Append (this IMailFolder folder, MimeMessage message, MessageFlags flags, DateTimeOffset date, CancellationToken cancellationToken = default, ITransferProgress? progress = null)
{
return Append (folder, FormatOptions.Default, message, flags, date, cancellationToken, progress);
}
@@ -209,7 +209,7 @@ public static partial class IMailFolderExtensions
///
/// The command failed.
///
- public static Task AppendAsync (this IMailFolder folder, MimeMessage message, MessageFlags flags, DateTimeOffset date, CancellationToken cancellationToken = default, ITransferProgress progress = null)
+ public static Task AppendAsync (this IMailFolder folder, MimeMessage message, MessageFlags flags, DateTimeOffset date, CancellationToken cancellationToken = default, ITransferProgress? progress = null)
{
return AppendAsync (folder, FormatOptions.Default, message, flags, date, cancellationToken, progress);
}
@@ -258,7 +258,7 @@ public static partial class IMailFolderExtensions
///
/// The command failed.
///
- public static UniqueId? Append (this IMailFolder folder, MimeMessage message, MessageFlags flags, DateTimeOffset? date, IList annotations, CancellationToken cancellationToken = default, ITransferProgress progress = null)
+ public static UniqueId? Append (this IMailFolder folder, MimeMessage message, MessageFlags flags, DateTimeOffset? date, IList annotations, CancellationToken cancellationToken = default, ITransferProgress? progress = null)
{
return Append (folder, FormatOptions.Default, message, flags, date, annotations, cancellationToken, progress);
}
@@ -307,7 +307,7 @@ public static partial class IMailFolderExtensions
///
/// The command failed.
///
- public static Task AppendAsync (this IMailFolder folder, MimeMessage message, MessageFlags flags, DateTimeOffset? date, IList annotations, CancellationToken cancellationToken = default, ITransferProgress progress = null)
+ public static Task AppendAsync (this IMailFolder folder, MimeMessage message, MessageFlags flags, DateTimeOffset? date, IList annotations, CancellationToken cancellationToken = default, ITransferProgress? progress = null)
{
return AppendAsync (folder, FormatOptions.Default, message, flags, date, annotations, cancellationToken, progress);
}
@@ -360,7 +360,7 @@ public static partial class IMailFolderExtensions
///
/// The command failed.
///
- public static UniqueId? Append (this IMailFolder folder, FormatOptions options, MimeMessage message, MessageFlags flags = MessageFlags.None, CancellationToken cancellationToken = default, ITransferProgress progress = null)
+ public static UniqueId? Append (this IMailFolder folder, FormatOptions options, MimeMessage message, MessageFlags flags = MessageFlags.None, CancellationToken cancellationToken = default, ITransferProgress? progress = null)
{
var request = new AppendRequest (message, flags) {
TransferProgress = progress
@@ -417,7 +417,7 @@ public static partial class IMailFolderExtensions
///
/// The command failed.
///
- public static Task AppendAsync (this IMailFolder folder, FormatOptions options, MimeMessage message, MessageFlags flags = MessageFlags.None, CancellationToken cancellationToken = default, ITransferProgress progress = null)
+ public static Task AppendAsync (this IMailFolder folder, FormatOptions options, MimeMessage message, MessageFlags flags = MessageFlags.None, CancellationToken cancellationToken = default, ITransferProgress? progress = null)
{
var request = new AppendRequest (message, flags) {
TransferProgress = progress
@@ -475,7 +475,7 @@ public static partial class IMailFolderExtensions
///
/// The command failed.
///
- public static UniqueId? Append (this IMailFolder folder, FormatOptions options, MimeMessage message, MessageFlags flags, DateTimeOffset date, CancellationToken cancellationToken = default, ITransferProgress progress = null)
+ public static UniqueId? Append (this IMailFolder folder, FormatOptions options, MimeMessage message, MessageFlags flags, DateTimeOffset date, CancellationToken cancellationToken = default, ITransferProgress? progress = null)
{
var request = new AppendRequest (message, flags, date) {
TransferProgress = progress
@@ -533,7 +533,7 @@ public static partial class IMailFolderExtensions
///
/// The command failed.
///
- public static Task AppendAsync (this IMailFolder folder, FormatOptions options, MimeMessage message, MessageFlags flags, DateTimeOffset date, CancellationToken cancellationToken = default, ITransferProgress progress = null)
+ public static Task AppendAsync (this IMailFolder folder, FormatOptions options, MimeMessage message, MessageFlags flags, DateTimeOffset date, CancellationToken cancellationToken = default, ITransferProgress? progress = null)
{
var request = new AppendRequest (message, flags, date) {
TransferProgress = progress
@@ -592,7 +592,7 @@ public static partial class IMailFolderExtensions
///
/// The command failed.
///
- public static UniqueId? Append (this IMailFolder folder, FormatOptions options, MimeMessage message, MessageFlags flags, DateTimeOffset? date, IList annotations, CancellationToken cancellationToken = default, ITransferProgress progress = null)
+ public static UniqueId? Append (this IMailFolder folder, FormatOptions options, MimeMessage message, MessageFlags flags, DateTimeOffset? date, IList annotations, CancellationToken cancellationToken = default, ITransferProgress? progress = null)
{
var request = new AppendRequest (message, flags) {
TransferProgress = progress,
@@ -653,7 +653,7 @@ public static partial class IMailFolderExtensions
///
/// The command failed.
///
- public static Task AppendAsync (this IMailFolder folder, FormatOptions options, MimeMessage message, MessageFlags flags, DateTimeOffset? date, IList annotations, CancellationToken cancellationToken = default, ITransferProgress progress = null)
+ public static Task AppendAsync (this IMailFolder folder, FormatOptions options, MimeMessage message, MessageFlags flags, DateTimeOffset? date, IList annotations, CancellationToken cancellationToken = default, ITransferProgress? progress = null)
{
var request = new AppendRequest (message, flags) {
TransferProgress = progress,
@@ -710,7 +710,7 @@ public static partial class IMailFolderExtensions
///
/// The command failed.
///
- public static IList Append (this IMailFolder folder, IList messages, IList flags, CancellationToken cancellationToken = default, ITransferProgress progress = null)
+ public static IList Append (this IMailFolder folder, IList messages, IList flags, CancellationToken cancellationToken = default, ITransferProgress? progress = null)
{
return Append (folder, FormatOptions.Default, messages, flags, cancellationToken, progress);
}
@@ -761,7 +761,7 @@ public static IList Append (this IMailFolder folder, IList
/// The command failed.
///
- public static Task> AppendAsync (this IMailFolder folder, IList messages, IList flags, CancellationToken cancellationToken = default, ITransferProgress progress = null)
+ public static Task> AppendAsync (this IMailFolder folder, IList messages, IList flags, CancellationToken cancellationToken = default, ITransferProgress? progress = null)
{
return AppendAsync (folder, FormatOptions.Default, messages, flags, cancellationToken, progress);
}
@@ -815,7 +815,7 @@ public static Task> AppendAsync (this IMailFolder folder, IList<
///
/// The command failed.
///
- public static IList Append (this IMailFolder folder, IList messages, IList flags, IList dates, CancellationToken cancellationToken = default, ITransferProgress progress = null)
+ public static IList Append (this IMailFolder folder, IList messages, IList flags, IList dates, CancellationToken cancellationToken = default, ITransferProgress? progress = null)
{
return Append (folder, FormatOptions.Default, messages, flags, dates, cancellationToken, progress);
}
@@ -869,7 +869,7 @@ public static IList Append (this IMailFolder folder, IList
/// The command failed.
///
- public static Task> AppendAsync (this IMailFolder folder, IList messages, IList flags, IList dates, CancellationToken cancellationToken = default, ITransferProgress progress = null)
+ public static Task> AppendAsync (this IMailFolder folder, IList messages, IList flags, IList dates, CancellationToken cancellationToken = default, ITransferProgress? progress = null)
{
return AppendAsync (folder, FormatOptions.Default, messages, flags, dates, cancellationToken, progress);
}
@@ -929,7 +929,7 @@ public static Task> AppendAsync (this IMailFolder folder, IList<
///
/// The command failed.
///
- public static IList Append (this IMailFolder folder, FormatOptions options, IList messages, IList flags, CancellationToken cancellationToken = default, ITransferProgress progress = null)
+ public static IList Append (this IMailFolder folder, FormatOptions options, IList messages, IList flags, CancellationToken cancellationToken = default, ITransferProgress? progress = null)
{
if (options == null)
throw new ArgumentNullException (nameof (options));
@@ -1013,7 +1013,7 @@ public static IList Append (this IMailFolder folder, FormatOptions opt
///
/// The command failed.
///
- public static Task> AppendAsync (this IMailFolder folder, FormatOptions options, IList messages, IList