diff --git a/MailKit/MailKit.csproj b/MailKit/MailKit.csproj
index ed1585c33c..b661cccd13 100644
--- a/MailKit/MailKit.csproj
+++ b/MailKit/MailKit.csproj
@@ -47,9 +47,9 @@
$(DefineConstants);SERIALIZABLE
-
+
+
+
diff --git a/MailKit/MailKitLite.csproj b/MailKit/MailKitLite.csproj
index 9d9028fd4b..c9195fb220 100644
--- a/MailKit/MailKitLite.csproj
+++ b/MailKit/MailKitLite.csproj
@@ -48,9 +48,9 @@
$(DefineConstants);SERIALIZABLE
-
+
+
+
diff --git a/MailKit/Net/Imap/ImapEngine.cs b/MailKit/Net/Imap/ImapEngine.cs
index 69848d1787..d7797530f7 100644
--- a/MailKit/Net/Imap/ImapEngine.cs
+++ b/MailKit/Net/Imap/ImapEngine.cs
@@ -805,23 +805,27 @@ public Task ReadLineAsync (CancellationToken cancellationToken)
}
#endif
- internal Task ReadTokenAsync (string specials, bool doAsync, CancellationToken cancellationToken)
+ internal ValueTask ReadTokenAsync (string specials, bool doAsync, CancellationToken cancellationToken)
{
if (doAsync)
return Stream.ReadTokenAsync (specials, cancellationToken);
- return Task.FromResult (Stream.ReadToken (specials, cancellationToken));
+ var token = Stream.ReadToken (specials, cancellationToken);
+
+ return new ValueTask (token);
}
- internal Task ReadTokenAsync (bool doAsync, CancellationToken cancellationToken)
+ internal ValueTask ReadTokenAsync (bool doAsync, CancellationToken cancellationToken)
{
if (doAsync)
return Stream.ReadTokenAsync (ImapStream.DefaultSpecials, cancellationToken);
- return Task.FromResult (Stream.ReadToken (ImapStream.DefaultSpecials, cancellationToken));
+ var token = Stream.ReadToken (ImapStream.DefaultSpecials, cancellationToken);
+
+ return new ValueTask (token);
}
- internal async Task PeekTokenAsync (string specials, bool doAsync, CancellationToken cancellationToken)
+ internal async ValueTask PeekTokenAsync (string specials, bool doAsync, CancellationToken cancellationToken)
{
ImapToken token;
@@ -835,7 +839,7 @@ internal async Task PeekTokenAsync (string specials, bool doAsync, Ca
return token;
}
- internal Task PeekTokenAsync (bool doAsync, CancellationToken cancellationToken)
+ internal ValueTask PeekTokenAsync (bool doAsync, CancellationToken cancellationToken)
{
return PeekTokenAsync (ImapStream.DefaultSpecials, doAsync, cancellationToken);
}
@@ -880,7 +884,7 @@ public ImapToken ReadToken (CancellationToken cancellationToken)
///
/// An IMAP protocol error occurred.
///
- public Task ReadTokenAsync (CancellationToken cancellationToken)
+ public ValueTask ReadTokenAsync (CancellationToken cancellationToken)
{
return Stream.ReadTokenAsync (cancellationToken);
}
@@ -926,7 +930,7 @@ public ImapToken PeekToken (string specials, CancellationToken cancellationToken
///
/// An IMAP protocol error occurred.
///
- public Task PeekTokenAsync (string specials, CancellationToken cancellationToken)
+ public ValueTask PeekTokenAsync (string specials, CancellationToken cancellationToken)
{
return PeekTokenAsync (specials, true, cancellationToken);
}
@@ -970,7 +974,7 @@ public ImapToken PeekToken (CancellationToken cancellationToken)
///
/// An IMAP protocol error occurred.
///
- public Task PeekTokenAsync (CancellationToken cancellationToken)
+ public ValueTask PeekTokenAsync (CancellationToken cancellationToken)
{
return PeekTokenAsync (true, cancellationToken);
}
@@ -1045,7 +1049,7 @@ public Task ReadLiteralAsync (CancellationToken cancellationToken)
}
#endif
- async Task SkipLineAsync (bool doAsync, CancellationToken cancellationToken)
+ async ValueTask SkipLineAsync (bool doAsync, CancellationToken cancellationToken)
{
ImapToken token;
diff --git a/MailKit/Net/Imap/ImapStream.cs b/MailKit/Net/Imap/ImapStream.cs
index cf7582fd0e..c58fb022fa 100644
--- a/MailKit/Net/Imap/ImapStream.cs
+++ b/MailKit/Net/Imap/ImapStream.cs
@@ -320,7 +320,7 @@ int ReadAhead (int atleast, CancellationToken cancellationToken)
return inputEnd - inputIndex;
}
- async Task ReadAheadAsync (int atleast, CancellationToken cancellationToken)
+ async ValueTask ReadAheadAsync (int atleast, CancellationToken cancellationToken)
{
if (!AlignReadAheadBuffer (atleast, out int left, out int start, out int end))
return left;
@@ -591,7 +591,7 @@ ImapToken ReadQuotedStringToken (CancellationToken cancellationToken)
}
}
- async Task ReadQuotedStringTokenAsync (CancellationToken cancellationToken)
+ async ValueTask ReadQuotedStringTokenAsync (CancellationToken cancellationToken)
{
bool escaped = false;
@@ -636,7 +636,7 @@ ImapToken ReadAtomString (ImapTokenType type, string specials, CancellationToken
}
}
- async Task ReadAtomStringAsync (ImapTokenType type, string specials, CancellationToken cancellationToken)
+ async ValueTask ReadAtomStringAsync (ImapTokenType type, string specials, CancellationToken cancellationToken)
{
using (var builder = new ByteArrayBuilder (32)) {
if (type == ImapTokenType.Flag)
@@ -654,7 +654,7 @@ ImapToken ReadAtomToken (string specials, CancellationToken cancellationToken)
return ReadAtomString (ImapTokenType.Atom, specials, cancellationToken);
}
- Task ReadAtomTokenAsync (string specials, CancellationToken cancellationToken)
+ ValueTask ReadAtomTokenAsync (string specials, CancellationToken cancellationToken)
{
return ReadAtomStringAsync (ImapTokenType.Atom, specials, cancellationToken);
}
@@ -666,7 +666,7 @@ ImapToken ReadFlagToken (string specials, CancellationToken cancellationToken)
return ReadAtomString (ImapTokenType.Flag, specials, cancellationToken);
}
- Task ReadFlagTokenAsync (string specials, CancellationToken cancellationToken)
+ ValueTask ReadFlagTokenAsync (string specials, CancellationToken cancellationToken)
{
inputIndex++;
@@ -745,7 +745,7 @@ ImapToken ReadLiteralToken (CancellationToken cancellationToken)
}
}
- async Task ReadLiteralTokenAsync (CancellationToken cancellationToken)
+ async ValueTask ReadLiteralTokenAsync (CancellationToken cancellationToken)
{
using (var builder = new ByteArrayBuilder (16)) {
// skip over the '{'
@@ -861,7 +861,7 @@ public ImapToken ReadToken (string specials, CancellationToken cancellationToken
///
/// An I/O error occurred.
///
- public async Task ReadTokenAsync (string specials, CancellationToken cancellationToken)
+ public async ValueTask ReadTokenAsync (string specials, CancellationToken cancellationToken)
{
CheckDisposed ();
@@ -928,7 +928,7 @@ public ImapToken ReadToken (CancellationToken cancellationToken)
///
/// An I/O error occurred.
///
- public Task ReadTokenAsync (CancellationToken cancellationToken)
+ public ValueTask ReadTokenAsync (CancellationToken cancellationToken)
{
return ReadTokenAsync (DefaultSpecials, cancellationToken);
}
@@ -1025,7 +1025,7 @@ internal bool ReadLine (ByteArrayBuilder builder, CancellationToken cancellation
///
/// An I/O error occurred.
///
- internal async Task ReadLineAsync (ByteArrayBuilder builder, CancellationToken cancellationToken)
+ internal async ValueTask ReadLineAsync (ByteArrayBuilder builder, CancellationToken cancellationToken)
{
CheckDisposed ();
diff --git a/MailKit/Net/Imap/ImapUtils.cs b/MailKit/Net/Imap/ImapUtils.cs
index 058f738168..d245d8fcb0 100644
--- a/MailKit/Net/Imap/ImapUtils.cs
+++ b/MailKit/Net/Imap/ImapUtils.cs
@@ -731,7 +731,7 @@ public static Task ParseMetadataAsync (ImapEngine engine, ImapCommand ic, int in
return ParseMetadataAsync (engine, metadata, doAsync, ic.CancellationToken);
}
- internal static async Task ReadStringTokenAsync (ImapEngine engine, string format, bool doAsync, CancellationToken cancellationToken)
+ internal static async ValueTask ReadStringTokenAsync (ImapEngine engine, string format, bool doAsync, CancellationToken cancellationToken)
{
var token = await engine.ReadTokenAsync (doAsync, cancellationToken).ConfigureAwait (false);
@@ -746,7 +746,7 @@ internal static async Task ReadStringTokenAsync (ImapEngine engine, stri
}
}
- static async Task ReadNStringTokenAsync (ImapEngine engine, string format, bool rfc2047, bool doAsync, CancellationToken cancellationToken)
+ static async ValueTask ReadNStringTokenAsync (ImapEngine engine, string format, bool rfc2047, bool doAsync, CancellationToken cancellationToken)
{
var token = await engine.ReadTokenAsync (doAsync, cancellationToken).ConfigureAwait (false);
string value;
@@ -774,7 +774,7 @@ static async Task ReadNStringTokenAsync (ImapEngine engine, string forma
return value;
}
- static async Task ReadNumberAsync (ImapEngine engine, string format, bool doAsync, CancellationToken cancellationToken)
+ static async ValueTask ReadNumberAsync (ImapEngine engine, string format, bool doAsync, CancellationToken cancellationToken)
{
var token = await engine.ReadTokenAsync (doAsync, cancellationToken).ConfigureAwait (false);
diff --git a/nuget/MailKit.nuspec b/nuget/MailKit.nuspec
index 0870fc82ae..7b596e08b3 100644
--- a/nuget/MailKit.nuspec
+++ b/nuget/MailKit.nuspec
@@ -61,15 +61,19 @@ Features include:
+
+
+
+
@@ -79,6 +83,7 @@ Features include:
+
diff --git a/nuget/MailKitLite.nuspec b/nuget/MailKitLite.nuspec
index 2ba99c3a29..49bfcb5d66 100644
--- a/nuget/MailKitLite.nuspec
+++ b/nuget/MailKitLite.nuspec
@@ -61,15 +61,19 @@ Features include:
+
+
+
+
@@ -79,6 +83,7 @@ Features include:
+